ios fix
parent
c3b30dd59f
commit
94c7078134
52
izberi.html
52
izberi.html
|
@ -96,6 +96,8 @@
|
|||
<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");
|
||||
|
@ -103,26 +105,36 @@
|
|||
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;
|
||||
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";
|
||||
tv.src = '/nepovednik' + resp;
|
||||
tv.play();
|
||||
loading = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
xhttp.send();
|
||||
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;
|
||||
|
@ -138,13 +150,13 @@
|
|||
loader.style.display = "block";
|
||||
tv.pause();
|
||||
pridobiPosnetek();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function klik(e) {
|
||||
if (e.keyCode == 13) {
|
||||
proziPosnetek();
|
||||
}
|
||||
if (e.keyCode == 13) {
|
||||
proziPosnetek();
|
||||
}
|
||||
}
|
||||
|
||||
stel.onkeypress = klik;
|
||||
|
|
12
server.js
12
server.js
|
@ -7,6 +7,18 @@ app.get('/nepovednik', function(req, res) {
|
|||
res.sendFile(__dirname + '/izberi.html');
|
||||
});
|
||||
|
||||
app.get('/nepovednik/apple/nepovid/:id', function (req, res) {
|
||||
let st = parseInt(req.params.id);
|
||||
if (st < 1 || st > 1000) {
|
||||
res.status(404);
|
||||
}
|
||||
|
||||
let nejm = 'nepovedi/' + st + '.mp4';
|
||||
if (fs.existsSync(nejm)) {
|
||||
res.sendFile(__dirname + '/' + nejm);
|
||||
}
|
||||
});
|
||||
|
||||
app.get('/nepovednik/nepovid/:id', function (req, res) {
|
||||
let st = parseInt(req.params.id);
|
||||
if (st < 1 || st > 1000) {
|
||||
|
|
Loading…
Reference in New Issue