-
Notifications
You must be signed in to change notification settings - Fork 0
/
izberi.html
172 lines (153 loc) · 5.94 KB
/
izberi.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
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
<html style="padding-left:15%;padding-right:15%;background:black;color:white;">
<head>
<title>nepovednik</title>
<style type="text/css">
@-webkit-keyframes rotate-forever {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@-moz-keyframes rotate-forever {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes rotate-forever {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
.loading-spinner {
-webkit-animation-duration: 0.75s;
-moz-animation-duration: 0.75s;
animation-duration: 0.75s;
-webkit-animation-iteration-count: infinite;
-moz-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-name: rotate-forever;
-moz-animation-name: rotate-forever;
animation-name: rotate-forever;
-webkit-animation-timing-function: linear;
-moz-animation-timing-function: linear;
animation-timing-function: linear;
height: 30px;
width: 30px;
border: 8px solid white;
border-right-color: transparent;
border-radius: 50%;
display: inline-block;
}
.loading-spinner {
position: absolute;
top: 50%;
right: 0;
bottom: 0;
left: 50%;
margin: -15px 0 -15px;
}
</style>
</head>
<body>
<div style="font-size: 1.2rem">
Izberi trejler (1 do 1000):
<input id="stevilo" type="text" style="font-size: 1.2rem;background:black;color:white;border-radius:2px;" />
<button id="gumb" style="font-size: 1.2rem;color:white;background:black;border:1px solid white;border-radius:2px;">klik</button>
</div>
<div style="position: relative;">
<video style="width: 100%; margin-top: .5rem;" id="televizija" controls>
Žal gostujoč kos tehnike ni adekvaten.
</video>
<div class="loading-spinner" style="display: none;" id="loader"></div>
</div>
<a id="dlGumb" href="" style="font-size: 1.2rem; color: white; float: right;" target="_blank" download>Vzemi</a>
<script type="text/javascript">
var gumb = document.getElementById("gumb");
var stel = document.getElementById("stevilo");
var tv = document.getElementById("televizija");
var loader = document.getElementById("loader");
var st = 0;
// je iOS naprava?
var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
var loading = null;
function pridobiPosnetek() {
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "/nepovednik/nepoved/" + st, true);
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var resp = this.responseText;
if (resp === "zacetek" || resp === "cakaj") {
loading = setTimeout(pridobiPosnetek, 3000);
} else {
loader.style.display = "none";
if (iOS) {
resp = "/apple" + resp;
}
document.getElementById("dlGumb").href = '/nepovednik' + resp;
tv.src = '/nepovednik' + resp;
tv.play();
loading = null;
}
}
};
xhttp.send();
}
gumb.onclick = proziPosnetek;
function proziPosnetek() {
st = parseInt(stel.value);
if (isNaN(st) || st < 0 || st > 1000) {
stel.style.backgroundColor = "darksalmon";
} else {
if (loading) return;
stel.style.backgroundColor = "transparent";
loader.style.display = "block";
tv.pause();
pridobiPosnetek();
}
}
function klik(e) {
if (e.keyCode == 13) {
proziPosnetek();
}
}
stel.onkeypress = klik;
// Prvi posnetek je random
var initNum = Math.ceil(Math.random() * 1000);
st = initNum;
stel.value = initNum;
pridobiPosnetek();
</script>
</body>
</html>