-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscript.js
174 lines (151 loc) · 4.63 KB
/
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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
var opacity = 0.1;
var caliShow = false;
var volume = 1.0;
document.addEventListener('keydown', function(event)
{
if(event.keyCode == 67)
{
toggleCalibrator();
}
});
function gotoPage(url, dir)
{
url = "/Eye-Tracking-OS" + url; //for testing on github
var client = new XMLHttpRequest();
client.open('GET', url);
var oldColor = window.getComputedStyle(document.getElementById("border-" + dir), null).getPropertyValue("background-color");
document.getElementById("border-" + dir).classList.add("transition");
document.getElementById("content").className = "transition-" + dir;
client.onload = function()
{
var page = client.responseText;
var content = page.substring(page.indexOf('<div id="content">') + 18, page.indexOf('</div> <!-- end of content -->'));
var title = page.substring(page.indexOf('<title>') + 7, page.indexOf('</title>'));
document.body.style.backgroundColor = oldColor;
setTimeout(function ()
{
document.getElementById("content").innerHTML = content;
window.history.pushState({}, title, url);
document.title = title;
document.getElementById("content").classList.add("in");
document.body.style.backgroundColor = "var(--background)";
setTimeout(function ()
{
document.getElementById("content").className = " ";
}, 805);
}, 550);
}
client.send();
}
function getUrlParam(parameter, defaultvalue)
{
var urlparameter = defaultvalue;
if(window.location.href.indexOf(parameter) > -1)
{
urlparameter = getUrlVars()[parameter];
}
return urlparameter;
}
function increaseBrightness()
{
if(opacity >= 0.1)
{
opacity = opacity - 0.1;
document.getElementById("brightness").style.opacity = opacity;
}
}
function decreaseBrightness()
{
if(opacity < 0.7)
{
opacity = opacity + 0.1;
document.getElementById("brightness").style.opacity = opacity;
}
}
function playPause()
{
var vid = document.getElementById("video");
var icon = document.getElementById("play-icon");
if((vid.currentTime < 0.1) || vid.paused || vid.ended || (vid.readyState < 3))
{
vid.play();
icon.className = "";
}
else
{
vid.pause();
icon.className = "show";
}
}
function skipForward()
{
var vid = document.getElementById("video");
vid.currentTime += 5;
}
function skipBack()
{
var vid = document.getElementById("video");
vid.currentTime -= 7;
}
function playMovie(url, film)
{
url = "/Eye-Tracking-OS" + url; //for testing on github
var client = new XMLHttpRequest();
client.open('GET', url);
document.getElementById(film).style = "top: -50px; left: -50px; overflow: visible; transition: all 1s ease; z-index: 2000;";
document.getElementById(film + "-img").style = "filter: brightness(0%); width: 100vw; height: 100vh; top: 0; left: 0; transition: width 1s ease, height 0.5s ease";
client.onload = function()
{
var page = client.responseText;
var content = page.substring(page.indexOf('<div id="content">') + 18, page.indexOf('</div> <!-- end of content -->'));
var title = page.substring(page.indexOf('<title>') + 7, page.indexOf('</title>'));
setTimeout(function ()
{
document.getElementById("content").innerHTML = content;
window.history.pushState({}, title, url);
document.title = title;
}, 1000);
}
client.send();
}
function volUp()
{
volume += 0.1;
if(volume > 1)
{
volume = 1;
}
}
function volDown()
{
volume -= 0.1;
if(volume < 0)
{
volume = 0;
}
}
function getVol()
{
return volume;
}
function toggleCalibrator()
{
if(caliShow)
{
document.getElementById("calibrator").className = " ";
//document.getElementById("webgazerVideoFeed").className = " ";
//document.getElementById("webgazerFaceOverlay").className = " ";
//document.getElementById("webgazerFaceFeedbackBox").className = " ";
//uncomment and turn off mouse events here
caliShow = false;
}
else
{
document.getElementById("calibrator").className = "show";
//document.getElementById("webgazerVideoFeed").className = "show";
//document.getElementById("webgazerFaceOverlay").className = "show";
//document.getElementById("webgazerFaceFeedbackBox").className = "show";
//uncomment and turn on mouse events here
caliShow = true;
}
}