-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
54 lines (40 loc) · 1.46 KB
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
document.addEventListener('DOMContentLoaded', setup_popup);
function setup_popup() {
var username = localStorage["username"];
$("#username").append(username);
var quarter = localStorage["quarter"];
$("#quarter").append(quarter_text(quarter));
var timestamp = new Date(localStorage["year"], localStorage["month"], localStorage["date"], localStorage["hour"], localStorage["min"], 0, 0);
$("#pass").append(timestamp.toLocaleDateString() + " " + timestamp.toLocaleTimeString());
//Add all the classes
var classes = JSON.parse(localStorage["classes"]);
var count = localStorage["count"];
for(i=0; i< count; i++) {
var html = "<tr><td>"
html += classes[i][0] + "</td><td>" + classes[i][1] + "</td>";
html += "<td>" + added_text(classes[i][2]) + "</td></tr>";
$('#classes').append(html);
}
$(".options_link").click(function() {
chrome.tabs.create({
url: chrome.extension.getURL("options.html")
});
});
}
//Text for the added state of a class
// 0 = NOT TRIED
// 1 = TRIED AND FULL
// -1 = TRIED AND NEED ADD CODE
// 2 = ADDED
function added_text(num) {
if(num == 0) { return "Not Tried"; }
else if(num == 1) { return "Tried and Failed"; }
else if(num == 2) { return "Class Successfully Added"; }
else { return "Unknown Error"; }
}
function quarter_text(quarter) {
var arr = ["Winter", "Spring", "Summer", "Fall"]
var qtr = quarter.substr(quarter.length-1);
var year = quarter.substr(0, quarter.length-1);
return arr[qtr-1] + " " + year;
}