-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
135 lines (114 loc) · 3.57 KB
/
index.html
File metadata and controls
135 lines (114 loc) · 3.57 KB
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
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="video"><video preload="auto" autoplay="true" loop="true" muted="muted">
<source src="video2.mp4" type="video/mp4; codecs="avc1.42E01E, mp4a.40.2"">
Тег video не поддерживается вашим браузером.
</video></div>
<div style="
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
">
<div id="dashboard-stats" style="
width: 63%;
height: 100%;
padding-left: 8vh;
padding-top: 4vh;
box-sizing: border-box;
">
</div>
<div class="right-text" >Отправь СМС с номером<br>любимой команды на номер<div class="phone">8 968 642 69 81</div></div></div>
<script src="jquery-3.4.1.min.js"></script>
<script type="text/javascript">
let options = [
"1",
"2",
"3",
"4",
"5",
"6",
"7"
];
let names = [
"HR-монтери",
"Маркетиане",
"ДИТарианцы",
"Коммерцианты",
"желтые СТМиксы",
"Операционные стражи",
"Чар-Чары"
];
let revote = true;
let perSecond = 6;
$.each( options, function( key_o, option ){
$( "#dashboard-stats" ).append( "<div class=\"vote-row vot-"+option.replace(/\s/,"_")+"\"><div class=\"progress-bar\"><span class=\"percantage per\">0%</span><div class=\"progress-filler\" data-value=\"0\" style=\"width: 0%;\"><span class=\"percantage2 per\">0%</span></div></div><div class=\"team-title\"><div class=\"big-num\">"+option+"</div> - "+names[option-1]+"</div></div>" );
});
let api_key = '3914aa34ffe15ea0289e67de567e44d1'
let url = 'https://onlinesim.ru/api/rent/getRentState.php?lang=ru&apikey='+api_key;
let voted = {};
let result = {};
function generateBarGraph(wrapper) {
var sum_value = 0;
$(wrapper + ' .progress-filler').each(function(index, el) {
sum_value += $(this).data('value')
});
$(wrapper + ' .progress-filler').each(function(index, el) {
var bar = $(this),
value = bar.data('value'),
percent = Math.ceil((value / sum_value) * 100);
bar.width(percent + '%');
bar.addClass('in');
});
}
setInterval(()=>{
voted = {};
result = {};
jQuery.post(url, (res)=>{
$.each( res.list, function( key_n, number ){
if(number.number === '9686426981'){
$.each( number.messages.data, function( key_p, page ){
$.each( page, function( key_m, message ){
$.each( options, function( key_o, option ){
if(message.text.match(new RegExp(option.replace(/(\r\n|\n|\r)/gm, ""),'gi')) !== null && ( !revote || voted[message.service] === undefined)){
voted[message.service] = option;
}
});
});
});
}
})
result = {};
$.each( voted, function( key_v, vote ){
$.each( options, function( key_o, option ){
if(vote === option){
if(result[option] === undefined){
result[option] = 1;
}else{
result[option] += 1;
}
}
});
});
$.each( options, function( key_o, option ){
if(result[option] !== undefined){
let sum = Object.values(result).reduce((a, b) => a + b, 0);
let percent = parseFloat(((result[option] / sum) * 100).toFixed(1));
$(".vot-"+option.replace(/\s/,"_")+" .per").text(percent+"%");
$(".vot-"+option.replace(/\s/,"_")+" .progress-filler").data('value', result[option])
generateBarGraph('#dashboard-stats');
}
});
});
}, perSecond*1000);
console.log(result);
</script>
</script>
</body>
</html>