-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrain.js
158 lines (141 loc) · 4.72 KB
/
brain.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
window.onscroll = function() {
list()
};
var lft = document.getElementById("mylist");
var sticky = lft.parentElement.offsetTop;
function list() {
if (window.pageYOffset > sticky) {
lft.classList.add("sticky");
} else {
lft.classList.remove("sticky");
}
}
function show_msg() {
alert("We won't try to steal your data.")
}
function GetCookie(name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal(j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie(name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape(value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie(name) {
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval = GetCookie(name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays * 24 * 60 * 60 * 1000));
function amt() {
var count = GetCookie('count')
if (count == null) {
SetCookie('count', '1')
return 1
} else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count', newcount, exp)
return count
}
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf(";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
var vis = "Number of visits today: <b>" + amt() + "</b>";
document.getElementById('visit').innerHTML = vis;
var dat = new Date();
var weekd = dat.getDay();
var day = dat.getDate();
var month = dat.getMonth() + 1;
var year = dat.getFullYear();
function setbgnday() {
function findDay() {
var dname;
switch (weekd) { //change this to see all the bg images
case 0:
dname = "Sun, ";
document.body.style.backgroundImage = "url('assets/sunbg.jpg')";
break;
case 1:
dname = "Mon, ";
document.body.style.backgroundImage = "url('assets/monbg.jpg')";
break;
case 2:
dname = "Tue, ";
document.body.style.backgroundImage = "url('assets/tuebg.png')";
break;
case 3:
dname = "Wed, ";
document.body.style.backgroundImage = "url('assets/wedbg.jpg')";
var wed = document.getElementById("wedclr");
wed.style.color = "purple";
wed.onmouseover = function() {
wed.style.color = "black";
}
wed.onmouseout = function() {
wed.style.color = "purple";
}
break;
case 4:
dname = "Thur, ";
document.body.style.backgroundImage = "url('assets/thurbg.png')";
break;
case 5:
dname = "Fri, ";
document.body.style.backgroundImage = "url('assets/fribg.jfif')";
break;
default:
dname = "Sat, ";
break;
}
return dname
}
var todat = findDay() + day + "/" + month + "/" + year;
return todat;
}
document.getElementById("todate").innerHTML = setbgnday();
// get the language object from the json file
var language;
function getLanguage() {
localStorage.getItem("language") == null ? setLanguage("EN") : false;
var request = new XMLHttpRequest();
request.open('GET', 'assets/textContent/content_' + localStorage.getItem("language") + '.json', false);
request.send(null);
if (request.status === 200) {
language = JSON.parse(request.responseText);
// console.log(language);
return language;
}
}
// set the language
function setLanguage(lang) {
localStorage.setItem("language", lang);
window.location.reload();
console.log(getLanguage());
}