polishing

This commit is contained in:
Sriram Hariharan
2019-01-09 21:14:18 -06:00
parent 74aed3e64b
commit 5258455db4
4 changed files with 88 additions and 64 deletions

View File

@@ -118,18 +118,20 @@ $(function () {
} }
}); });
$("#export").click(function(){ $("#export").click(function () {
var cal = ics(); var cal = ics();
var calendarEvents = $('#calendar').fullCalendar('clientEvents'); var calendarEvents = $('#calendar').fullCalendar('clientEvents');
for(i in calendarEvents){ for (i in calendarEvents) {
let event = calendarEvents[i]; let event = calendarEvents[i];
var title = event.title; var title = event.title;
var classname = title.substring(0, title.indexOf('with')); var classname = title.substring(0, title.indexOf('with'));
var description = title.substring(title.indexOf('with')); var description = title.substring(title.indexOf('with'));
var time = event.start._d.toUTCString(); var time = event.start._d.toUTCString();
cal.addEvent(classname, description, event.building, event.start._i, event.end._i, {rrule: `RRULE:FREQ=WEEKLY;BYDAY=${time.substring(0, time.indexOf(",")-1).toUpperCase()};INTERVAL=1`}); cal.addEvent(classname, description, event.building, event.start._i, event.end._i, {
rrule: `RRULE:FREQ=WEEKLY;BYDAY=${time.substring(0, time.indexOf(",")-1).toUpperCase()};INTERVAL=1`
});
} }
cal.download("My_Calendar"); cal.download("My_Course_Calendar");
}); });
/* convert from the dtarr and maek the time lines*/ /* convert from the dtarr and maek the time lines*/

View File

@@ -7,7 +7,6 @@ setCourseList();
// $("#html").prepend(modhtml); // $("#html").prepend(modhtml);
getSemesters(); getSemesters();
function setCourseList() { function setCourseList() {
$("#courseList").empty() $("#courseList").empty()
chrome.storage.sync.get('savedCourses', function (data) { chrome.storage.sync.get('savedCourses', function (data) {
@@ -37,7 +36,24 @@ function setCourseList() {
if (profname == "") { if (profname == "") {
profname = "Undecided Professor"; profname = "Undecided Professor";
} }
var listhtml = "<li id='" + i + "'style='padding: 0px 5px 5px 5px; overflow-y: auto;max-height:400px;'><div class='card'><div class='container' style='background:" + color + "''><h4 class='truncate' style='color:white;margin:5px; display:inline-block;font-size:large;'><b>" + department + " " + course_nbr + "<span style='font-size:medium'>" + " with </span><span style='font-size:medium'>" + profname + " (" + courses[i].unique + ")" + "</span></b></h4><p id='arrow' style='float:right;font-size:small;display:inline-block;margin-top:10px;color:white;'>&#9658;</p></div></div><div id='moreInfo' style='display: none;'><p style='font-weight:bold;padding:10px;margin:0px 5px 0px 15px;font-size:small;background-color:#FFCDD2;'>" + makeLine(i) + "</p><div id='infoButtons' style='border-radius:0px;'><button class='matbut' id='listRemove'style='float:right;background:#F44336; margin:5px;'>Remove</button><button class='matbut' id='register' style='float:right;background:#4CAF50; margin:5px;'>Register</button><button class='matbut' id='listMoreInfo' style='float:right;background:#2196F3; margin:5px;'>More Info</button></div></div></li>"; var listhtml = `<li id='${i}'style='padding: 0px 5px 5px 5px; overflow-y: auto;max-height:400px;'>
<div class='card'>
<div class='container' style='background:${color}'>
<h4 class='truncate' style='color:white;margin:5px; display:inline-block;font-size:large;'>
<b>${department} ${course_nbr} <span style='font-size:medium'> with </span><span style='font-size:medium'>${profname} (${courses[i].unique})</span></b>
</h4>
<p id='arrow' style='float:right;font-size:small;display:inline-block;margin-top:10px;color:white;'>&#9658;</p>
</div>
</div>
<div id='moreInfo' style='display: none;'>
<p style='font-weight:bold;padding:10px;margin:0px 5px 0px 15px;font-size:small;background-color:#FFCDD2;'>${makeLine(i)}</p>
<div id='infoButtons' style='border-radius:0px;'>
<button class='matbut' id='listRemove'style='float:right;background:#F44336; margin:5px;'>Remove</button>
<button class='matbut' id='register' style='float:right;background:#4CAF50; margin:5px;'>Register</button>
<button class='matbut' id='listMoreInfo' style='float:right;background:#2196F3; margin:5px;'>More Info</button>
</div>
</div>
</li>`;
$("#courseList").append(listhtml); $("#courseList").append(listhtml);
} }
}); });
@@ -193,14 +209,17 @@ $(document).ready(function () {
}); });
$('#export').click(function () { $('#export').click(function () {
chrome.storage.sync.get('savedCourses', function (data) { chrome.storage.sync.get('savedCourses', function (data) {
var exportArray = JSON.stringify(data.savedCourses, null, 4); if (data.savedCourses.length > 0) {
var exportlink = document.createElement('a'); var exportlink = document.createElement('a');
var url = window.URL.createObjectURL(new Blob([exportArray], { var url = window.URL.createObjectURL(new Blob([JSON.stringify(data.savedCourses, null, 4)], {
type: "octet/stream" type: "octet/stream"
})); }));
exportlink.setAttribute('href', url); exportlink.setAttribute('href', url);
exportlink.setAttribute('download', 'my_courses.json'); exportlink.setAttribute('download', 'my_courses.json');
exportlink.click(); exportlink.click();
} else {
alert('You have no Saved Courses to export.');
}
}); });
}); });
$("#class_id").on("keyup", function (e) { $("#class_id").on("keyup", function (e) {
@@ -251,7 +270,7 @@ $("#importOrig").change(function (e) {
} catch (err) { } catch (err) {
} }
importOrig.value = ''; //make sure to clear input value after every import importOrig.value = '';
} }
reader.readAsText(files[0]); reader.readAsText(files[0]);
}); });
@@ -402,21 +421,26 @@ function getInfo(sem, unique) {
if (response) { if (response) {
var output = ""; var output = "";
var object = $('<div/>').html(response).contents(); var object = $('<div/>').html(response).contents();
var c = getCourseObject(object, link); console.log(object.find('.error').text());
console.log(c); if (object.find('.error').text().trim() == 'No class was found for your input.') {
if (c.coursename) { alert(`Could not find a course with unique number: ${unique}`);
chrome.runtime.sendMessage({
command: "courseStorage",
course: c,
action: "add"
}, function () {
chrome.runtime.sendMessage({
command: "updateCourseList"
});
setCourseList();
});
} else { } else {
alert("There Was An Error.") var c = getCourseObject(object, link);
console.log(c);
if (c.coursename) {
chrome.runtime.sendMessage({
command: "courseStorage",
course: c,
action: "add"
}, function () {
chrome.runtime.sendMessage({
command: "updateCourseList"
});
setCourseList();
});
} else {
alert("There Was An Error. Please check if you are logged into the UT Course Schedule.")
}
} }
} }
} }

View File

@@ -20,8 +20,6 @@
Off</button> Off</button>
</div> </div>
<p style="padding:0px 5px 5px 0px; float: right">(v<span id="version"></span>), Sriram Hariharan, 2018<p> <p style="padding:0px 5px 5px 0px; float: right">(v<span id="version"></span>), Sriram Hariharan, 2018<p>
<script src="js/jquery-3.3.1.min.js"></script> <script src="js/jquery-3.3.1.min.js"></script>
<script src="js/options.js"></script> <script src="js/options.js"></script>

View File

@@ -19,47 +19,47 @@
<ul id="courseList" style="list-style-type: none;padding: 5px;"></ul> <ul id="courseList" style="list-style-type: none;padding: 5px;"></ul>
<h2 id="empty" style="font-weight: normal;font-size: large;margin: 60px 30px 40px 30px ;text-align: center"> <h2 id="empty" style="font-weight: normal;font-size: large;margin: 60px 30px 40px 30px ;text-align: center">
<div id="main" style="margin-bottom: 5px;">Doesn't Look Like <div id="main" style="margin-bottom: 5px;">Doesn't Look Like
Anything Anything
To Me. To Me.
</div> </div>
<span style="font-size: small;display:table;margin:0 auto;font-weight: bold">(No Courses Saved)</span> <span style="font-size: small;display:table;margin:0 auto;font-weight: bold">(No Courses Saved)</span>
</h2> </h2>
<div style=" margin-bottom: 0px; display:inline-block"></div> <div style=" margin-bottom: 0px; display:inline-block"></div>
<input type="file" id="importOrig" accept=".json" style="display:none"/> <input type="file" id="importOrig" accept=".json" style="display:none" />
<div class="settings"> <div class="settings">
<div id='semcon' class="select-style"> <div id='semcon' class="select-style">
<select id="semesters" style="display: none;margin-right: 5px; border-color: #ff691a; margin-top: 3px;"> <select id="semesters" style="display: none;margin-right: 5px; border-color: #ff691a; margin-top: 3px;">
</select> </select>
</div> </div>
<input type="text" id="class_id" name="class_id" maxlength="5" <input type="text" id="class_id" name="class_id" maxlength="5" style="display:none;text-indent: 10px;border-style: solid; border-color:#ff691a;"
style="display:none;text-indent: 10px;border-style: solid; border-color:#ff691a;" placeholder="Unique #?"></input> placeholder="Unique #?"></input>
<button title='Search' style="background-color:white;" class="settingsbut" id='search'> <button title='Search' style="background-color:white;" class="settingsbut" id='search'>
<i style='color:#FF9800' class="material-icons"> <i style='color:#FF9800' class="material-icons">
search search
</i> </i>
</button> </button>
<button title='Export' style="background-color:white; display:none;" class="settingsbut" id='export'>
<i style='color:#ff691a' class="material-icons">
arrow_downward
</i>
</button>
<button title='Import' style="background-color:white; display:none;" class="settingsbut" id='import'>
<i style='color:#ff691a' ; class="material-icons">
arrow_upward
</i>
</button>
<button title='Import' style="background-color:white; display:none;" class="settingsbut" id='import'> <button title='Import/Export' style="background-color:white;" class="settingsbut" id='impexp'>
<i style='color:#ff691a'; class="material-icons"> <i style='color:#FF9800' class="material-icons">
arrow_upward import_export
</i> </i>
</button> </button>
<button title='Export' style="background-color:white; display:none;" class="settingsbut"id='export'>
<i style='color:#ff691a' class="material-icons">
arrow_downward
</i>
</button>
<button title='Import/Export' style="background-color:white;" class="settingsbut" id='impexp'>
<i style='color:#FF9800' class="material-icons">
import_export
</i>
</button>
<button title='Options' style="background-color:white; margin-right: 0px;" class="settingsbut" id='open'> <button title='Options' style="background-color:white; margin-right: 0px;" class="settingsbut" id='open'>
<i style='color:#FF9800' class="material-icons"> <i style='color:#FF9800' class="material-icons">
settings settings
</i></button> </i></button>
</div> </div>