-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloader.js
68 lines (51 loc) · 1.84 KB
/
loader.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
///////////////////////////////
// CONFIG
// Constants defining the configuration.
// The path to the page's CSS file.
// TODO: Dynamically create the URL, relative to this JS file.
var PATH_CSSFile = "https://appydog.github.io/TelehackProfile/happydog.css";
///////////////////////////////
// LOAD STYLESHEET
var objLinkElement = document.createElement("link");
objLinkElement.setAttribute("rel", "stylesheet");
objLinkElement.setAttribute("type", "text/css");
objLinkElement.setAttribute("href", PATH_CSSFile);
document.getElementsByTagName("head")[0].appendChild(objLinkElement);
///////////////////////////////
// FUNCTIONAL CODE
var MIN_Contrast = 1;
var MAX_Contrast = 12;
var Contrast = 1;
function ContrastDown() {
AdjustContrast(-1);
return false;
}
function ContrastUp() {
AdjustContrast(1);
return false;
}
function AdjustContrast(Amount) {
Contrast = Contrast + Amount;
if (Contrast < MIN_Contrast)
Contrast = MIN_Contrast;
if (Contrast > MAX_Contrast)
Contrast = MAX_Contrast;
var Body = document.getElementsByTagName("body")[0];
if (Body.className.indexOf("Contrast") != -1) {
Body.className = Body.className.replace(/ Contrast\d+/, "");
}
Body.className += " Contrast" + Contrast;
console.log(Contrast, Body.className);
}
var objElement;
objElement = document.createElement('div');
objElement.id = "ScreenShine";
document.getElementsByTagName("body")[0].appendChild(objElement);
objElement = document.createElement('div');
objElement.id = "ContrastDown";
objElement.onclick = ContrastDown;
document.getElementsByTagName("body")[0].appendChild(objElement);
objElement = document.createElement('div');
objElement.id = "ContrastUp";
objElement.onclick = ContrastUp;
document.getElementsByTagName("body")[0].appendChild(objElement);