-
Notifications
You must be signed in to change notification settings - Fork 0
/
sc.js
86 lines (71 loc) · 2.51 KB
/
sc.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
let totaljson = 25;
const getRandomInt = (min, max) => ~~(Math.random() * (max - min + 1) + min);
function getParameterByName(a, e) { return e || (e = window.location.href), new URL(e).searchParams.get(a) };
window.rand = getParameterByName('collection');
function reset() {
window.rand = getRandomInt(1, totaljson)
fetch('../collectiondata/' + rand + '.json')
.then(response => response.json())
.then(data => { window.videojson = data; init(rand); });
console.log("Reset " + rand);
}
let video = document.querySelector('#video');
let title = document.querySelector('#title');
window.currentvideo = 0;
video.onloadeddata = function () {
document.querySelector('#loader').style.display = "none";
}
//Functions
//Functions
function init() {
video.src = "https://i.imgur.com/" + videojson.videos[0].imgurid + ".mp4";
video.poster = "https://i.imgur.com/" + videojson.videos[0].imgurid + ".png";
title.innerHTML = videojson.videos[0].title;
}
function next() {
video.poster = "";
document.querySelector('#loader').style.display = "block";
video.onloadeddata = setTimeout(function () {
document.querySelector('#loader').style.display = "none";
}, 1000)
if (currentvideo == 9) back();
let id = videojson.videos[currentvideo + 1];
video.src = "https://i.imgur.com/" + id.imgurid + ".mp4";
title.innerHTML = id.title;
currentvideo = currentvideo + 1;
fill();
}
function prev() {
video.poster = "";
if (currentvideo == 0) back();
let id = videojson.videos[currentvideo - 1];
video.src = "https://i.imgur.com/" + id.imgurid + ".mp4";
title.innerHTML = id.title;
currentvideo = currentvideo - 1;
fill();
}
function playpause() {
if (video.paused) {
video.play();
} else {
video.pause();
}
}
function fill() {
console.log(rand + " fill #" + currentvideo);
let x = (currentvideo + 1) / 10 * 100;
let fill = document.querySelector('#completed').style.width = "" + x + "%";
document.location.hash = rand + "." + (currentvideo + 1);
document.getElementById('colx').innerHTML = window.rand + "." + (currentvideo + 1);
// check();
}
function back() {
reset();
currentvideo = 0;
fill(); init();
currentvideo = -1;
}
function share() {
let id = videojson.videos[currentvideo + 1].imgurid;
location.href = "https://api.whatsapp.com/send?text=Watch%20this%20Video%20on%20CreateevMinutes%20-%20Creative%20Short%20Videos%20Here%20%20%F0%9F%92%96%0A%0AVideo%20Link%20Here%20%3A-%20https://createevminutes.sh20raj.repl.co/play/?collection=" + rand + "#" + (currentvideo + 1);
}