This repository has been archived by the owner on Jun 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
128 lines (115 loc) · 3.78 KB
/
index.html
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
<html>
<head>
<script type="text/javascript">
function getBodyHeight() {
var height, scrollHeight, offsetHeight;
if (document.height) {
height = document.height;
} else if (document.body) {
if (document.body.scrollHeight) {
height = scrollHeight = document.body.scrollHeight;
}
if (document.body.offsetHeight) {
height = offsetHeight = document.body.offsetHeight;
}
if (scrollHeight && offsetHeight) {
height = Math.max(scrollHeight, offsetHeight);
}
}
return height;
}
window.addEventListener("message", function(event) {
var origin = event.origin || event.originalEvent.origin;
if (origin.indexOf("dzzzr.ru")) {
if (event.data == "getSize") {
var width = 700;
var height = getBodyHeight()+20;
event.source.postMessage({width: width, height: height, type: "Size"}, origin);
} else if (event.data.type == "setCodes") {
var codesHTML = event.data.zad.split('<strong>Коды сложности</strong>')[1];
var codesHTMLBonus = codesHTML.split("бонусные коды: ")[1].split('<br>')[0];
var codesHTMLBonusArray = codesHTMLBonus.split(", ");
if(document.location.href.indexOf('?msg=') < 0) {
document.location.href = '?msg=' + encodeURIComponent(JSON.stringify(codesHTMLBonusArray));
}
}
}
});
var loadJSONP = (function(){
var unique = 0;
return function(url, callback, error, context) {
// INIT
var name = "_jsonp_" + unique++;
if (url.match(/\?/)) url += "&callback="+name;
else url += "?callback="+name;
// Create script
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
script.onerror = error;
// Setup handler
window[name] = function(data){
callback.call((context || window), data);
document.getElementsByTagName('head')[0].removeChild(script);
script = null;
delete window[name];
};
// Load JSON
document.getElementsByTagName('head')[0].appendChild(script);
};
})();
var currentPings = 0;
var maxPings = 300;
var pingURL = 'localhost:3000';
function pingJSONP () {
loadJSONP('http://' + pingURL + '/?ping=' + currentPings, function(data) {
//console.log(data);
if(data.test == 1) {
if(currentPings >= maxPings){
loadJSONP('http://' + pingURL + '/?final=' + currentPings, function(data) {
document.getElementsByTagName('body')[0].innerHTML = '<b>Код закрытия задания: ' + data.code + '</b>';
}, function() {
currentPings = 0;
document.getElementsByTagName('body')[0].innerHTML = 'Нет подключения к Wi-Fi';
setTimeout(function (){ pingJSONP(); }, 1000);
});
} else {
var percent = parseInt(((100 * currentPings)/maxPings).toFixed());
document.getElementsByTagName('body')[0].innerHTML = '<div id="progressbar"><div style="width:' + percent + '%"></div><span><b>' + percent + '%</b></span></div>';
currentPings += 1;
setTimeout(function (){ pingJSONP(); }, 1000);
}
}
}, function() {
currentPings = 0;
document.getElementsByTagName('body')[0].innerHTML = 'Нет подключения к Wi-Fi';
setTimeout(function (){ pingJSONP(); }, 1000);
});
}
function onLoad() {
pingJSONP();
}
</script>
<style>body,table {background-color:black;color:white;font-size:14px;font-family:Tahoma,Arial,Verdana;}a{color:#ffa500;}
#progressbar {
background-color: black;
border-radius: 13px; /* (height of inner div) / 2 + padding */
padding: 3px;
border: 1px solid white;
}
#progressbar > div {
background-color: orange;
height: 20px;
border-radius: 10px;
}
#progressbar > span {
position: absolute;
display: inline-block;
left: 50%;
top: 15px;
}
</style>
</head>
<body onload="onLoad();">
</body>
</html>