forked from RobertBlackhart/cs1520_site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_side_script.js
63 lines (56 loc) · 1.43 KB
/
client_side_script.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
55
56
57
58
59
60
61
62
63
var items = [
"announcements",
"schedule",
"assignments",
"policies",
"other"
];
/*
When I was working on projects going over the examples, it was annoying when I would go back and it would
close all the tabs and I had to open and scroll down again. Just added trackers to keep them open in local storage.
Also messed around with colors.
*/
function toggleItem(itemName)
{
var item = document.getElementById(itemName);
var itemtoggle = document.getElementById(itemName.concat("toggle"));
if(item.style.display == "none")
{
item.style.display = "";
itemtoggle.innerHTML = "−";
if(typeof(Storage) !== "undefined"){
localStorage[itemName] = '1'; //set it to open so it will remember
}
}
else
{
item.style.display = "none";
itemtoggle.innerHTML = "+";
if(typeof(Storage) !== "undefined"){
localStorage[itemName] = '0' ; //remember if it's closed
}
}
}
function loadContent()
{
for(var i in items)
{
if(items.hasOwnProperty(i))
{
var item = document.getElementById(items[i]);
var itemtoggle = document.getElementById(items[i].concat("toggle"));
//item.style.display = "none";
if(typeof(Storage) !== "undefined"){
if(localStorage[items[i]] == '1'){
item.style.display = "";
itemtoggle.innerHTML = "−";
}else if(localStorage[items[i]] == '0'){
item.style.display = "none";
itemtoggle.innerHTML = "+";
}
}else{
item.style.display = "none" ;
}
}
}
}