-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
152 lines (110 loc) · 3.13 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
document.ready = function( callback ) {
if( document.readyState != 'loading' ) {
callback();
}
else {
document.addEventListener( 'DOMContentLoaded', callback );
}
};
(function() {
document.ready( function() {
let progressbar = document.getElementById( "progressbar" );
if( progressbar ) {
let body = document.getElementsByTagName( "body" )[0];
let window_height = body.offsetHeight;
let client_height = document.documentElement.clientHeight;
let last_known_scroll_position = 0;
let ticking = false;
var vid = document.getElementById("video");
var notion;
var notiplayon = false;
var notiplayoff = true;
var notiup = 0;
var percentageold = 0;
setInterval(myFunction, 500);
function myFunction() {
rdm = Math.random() * 10;
$.get(
"prozent.txt?"+rdm,
function(data) {
var data2 = data.toString();
console.log(data2);
pog(data2)
},
"text"
);
}
function pog(data2){
last_known_scroll_position = data2;
if( !ticking ) {
window.requestAnimationFrame( function() {
nowScrolling( last_known_scroll_position );
ticking = false;
});
ticking = true;
}
}
window.addEventListener( "resize", refactorScreenHeight );
var mutationObserver = new MutationObserver( refactorScreenHeight );
mutationObserver.observe(document.documentElement, {
attributes: true,
characterData: true,
childList: true,
subtree: true,
attributeOldValue: true,
characterDataOldValue: true
});
function refactorScreenHeight() {
client_height = document.documentElement.clientHeight;
window_height = body.offsetHeight;
}
function nowScrolling( last_known_scroll_position ) {
percentage = last_known_scroll_position;
progressbar.style.right = "calc( 100% - " + Math.round( percentage ) + "% )";
if(percentage > 99){
function randomInRange(min, max) {
return Math.random() * (max - min) + min;
}
confetti({
angle: randomInRange(-200, -90),
spread: randomInRange(50, 70),
particleCount: randomInRange(50, 100),
origin: { y: 0, x: 1 }
})
}
notiup = percentage - percentageold;
percentageold = percentage;
console.log("===============");
console.log("Notion = " + notion);
console.log("Notiplayon = " + notiplayon);
console.log("Notiplayoff = " + notiplayoff);
console.log("Notiup = " + notiup);
if((((percentage >= 5 && percentage <= 15) || (percentage >= 85 && percentage <= 100)) && notiup > 0) || percentage >= 98){
notion = true
}
else if (notiup < 0){
notion = false
}
if(notion === true && notiplayon === false){
notiplayon = true;
vid.loop = false;
vid.play();
setTimeout(() => {
vid.pause();
}, 1000);
setTimeout(() => {
notiplayoff = false
}, 5000);
}
else if (notion === false && notiplayoff === false){
notiplayoff = true;
vid.loop = false;
vid.play();
setTimeout(() => {
notiplayon = false
}, 2000);
}
}
}
});
})();