forked from kyle8998/Vynchronize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
436 lines (344 loc) · 17.9 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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Movies">
<meta name="author" content="NinkyNonk">
<meta name="theme-color" content="#E7C6FF">
<title>The Ninky Nonk Company</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<!-- Socket.io -->
<script src="/socket.io/socket.io.js"></script>
<!-- Font awesome -->
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
<!-- Custom styles for this template -->
<link href="css/small-business.css" rel="stylesheet">
<link rel="manifest" href="site.webmanifest">
<link href="css/style.css" rel="stylesheet">
<link href="css/mobile-style.css" rel="stylesheet">
<link href="css/stylesheet.css" rel="stylesheet" >
<link href="css/html5player.css" rel="stylesheet">
<link rel="icon" type="image/png" sizes="32x32" href="img/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="img/favicon-16x16.png">
</head>
<!-- Div for lights off! -->
<div id='persoff'></div>
<body class="charlie-gray" id="Home">
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark fixed-top bg-dark-back">
<div class="container">
<a class="navbar-brand js-scroll-trigger" href="#Home"><img src="img/logo.svg" alt="Logo" height="40" width="40"> The Ninky Nonk Company</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" onclick="" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a target="_blank" rel="noopener noreferrer" class="nav-link js-scroll-trigger" href="https://github.com/NinkyNonkers/NinkyMovies">
<i class="fab fa-github"></i>
</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<!-- Loading page -->
<!-- User Form (First Page) -->
<div id="userFormArea" class="row">
<div class="col-md-12">
<h2>Welcome to Ninky Movies</h2>
<p class="lead">Next Film: <span class="font-weight-bold">In the Night Garden</span> and <span class="font-weight-bold">The Curse of the Ware Rabbit</span></p>
<p>Showing at <span class="font-weight-bold"> 19:45</span></p>
<p><em>The synchronization may not be perfect! It's a work in progress, blame archie if anything breaks </em></p>
<hr style="height:20pt; visibility:hidden;" />
<h2> Join a Room! </h2>
<form id="userForm">
<div class="form-group">
<p style="color:red; margin-bottom: 0" id="missinginfo"></p>
<label>Enter Name</label>
<input class="form-control" id="username" />
<br />
<p style="color:red; margin-bottom: 0" id="missinginfo2"></p>
<label>Enter Room ID (Default 1)</label>
<button type="button" style="margin-top: 2px; margin-bottom: 2px" onClick="getMainRoom()" class="btn btn-primary btn-dark-new">Find current room</button>
<br/>
<input class="form-control" id="roomnum" />
<br/>
<input style="margin-top: 10px;" type="submit" class="btn btn-primary btn-dark-new" value="Enter" />
<img src="img/ninky.svg" alt="">
<hr style="height:65pt; visibility:hidden;" />
</div>
<hr style="height:65pt; visibility:hidden;" />
</form>
</div>
</div>
<div id="roomArea">
<!-- Heading Row -->
<div class="row my-4" style="margin-top: 0 !important;">
<div class="col-lg-7">
<div class="nonmobile-hide"><b>Note: </b>Only the host can control the video using the native video player controls </div>
<div class="mobile-hide"><b>Mobile User</b>, please play the video once manually to give the browser permission to control the video player. </div>
<div style="margin: 10px 2px 10px 10px;" class="dropdown">
<button style="background-color: #E7C6FF" class="btn btn-info dropdown-toggle" type="button" onclick="dropDownAClicked()" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-video"></i> Player
</button>
<div class="form-control dropdown-menu scrollable-menu" aria-labelledby="dropdownMenuButton" id="ddmenuA">
<a class="dropdown-item" onclick="dropdownButtonAClicked(roomNum, 0, changePlayer)"><i class="fab fa-youtube"></i> YouTube</a>
<a class="dropdown-item" onclick="dropdownButtonAClicked(roomNum, 3, changePlayer)"><i class="fas fa-file-video"></i> HTML5 Player (.mp4/.webm)</a>
</div>
</div>
<h2><span id="hostlabel" class="label label-default"><i class="fas fa-user"></i> Current Host: Kyle </span></h2>
<!----------------------------------- PLAYER AREA ----------------------------------->
<div id='playerArea'>
<div class="video" id="player"></div>
</div>
<div id='HTML5Area'>
<div class="html5player">
<video src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" width="640" height="360" class="video html5video" id="html5src" controls>
</video>
</div>
</div>
<div>
<button id="playButton" onclick="playVideo(roomNum)" style="margin-top:.5rem" class="btn btn-primary btn-dark-new"><i class="fa fa-play"></i> Play / <i class="fa fa-pause"></i> Pause</button>
<button id="syncbutton" onclick="syncVideo(roomNum)" style="margin-top:.5rem" class="btn btn-primary btn-dark-new"><i class="fa fa-sync"></i> Sync</button>
<button id="loveButton" onclick="loveLive(roomNum)" style="margin-top:.5rem" class="btn btn-primary btn-dark-new"><i class="far fa-heart"></i> Random K-pop</button>
<!--<button id="hostbutton" onclick="changeHost(roomNum)" style="margin-top:.5rem" class="btn btn-primary btn-dark-new"><i class="fas fa-users"></i> Make me the host!</button>-->
<button id="lightButton" style="margin-top:.5rem" class="btn btn-primary btn-dark-new switch"><i style="pointer-events:none;" class="fas fa-lightbulb"></i></button>
<div style="margin: 10px 2px 10px 10px; display: none;" class="dropdown" id="switchmode">
<button style="background-color: #E7C6FF" class="btn btn-info dropdown-toggle" type="button" onclick="dropDownBClicked()" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-video"></i> Bitrate Mode
</button>
<div class="form-control dropdown-menu scrollable-menu" aria-labelledby="dropdownMenuButton" id="ddmenuB">
<a id="mdd1" class="dropdown-item" onclick="dropDownBClicked(1, changeModeIndex)"></a>
<a id="mdd2" class="dropdown-item" onclick="dropDownBClicked(2, changeModeIndex)"></a>
<a id="mdd3" class="dropdown-item" onclick="dropDownBClicked(3, changeModeIndex)"></a>
<a id="mdd4" class="dropdown-item" onclick="dropDownBClicked(4, changeModeIndex)"></a>
</div>
</div>
<p class="sidenote">Change the mode for a different bitrate and less stuttering</p>
<!-- Turn off the lights -->
</div>
<div class="topbotmargins">
<input type="Video" style="max-width: 400px; margin-right: .5rem; margin-bottom: .5rem; float: left;" class="form-control" id="inputVideoId" placeholder="Video ID / URL">
</div>
<div>
<button id="changeButton" onclick="changeVideoParse(roomNum)" class="btn btn-primary btn-dark-new"><i class="fas fa-exchange-alt"></i> Change Video</button>
<br/>
</div>
</div>
<div class="col-lg-5">
<h5 class="right-header">Online Users</h5>
<hr style="height:0; visibility:hidden;" />
<div class="col-md-13">
<div class="well online-users noscrollbar">
<ul class="list-group" id="users"></ul>
</div>
</div>
</div>
</div>
</div>
<hr style="height:20pt; visibility:hidden;" />
</div>
<!-- Footer -->
<footer id="footer" class="py-5 bg-dark-back footer footer-down">
<div class="container">
<p class="m-0 text-center text-white">Copyright 2020 © NinkyNonk, under exclusive license to In the Night Garden, a division of Rosen. </p>
<p class="m-0 text-center text-white">Visit our <a href="https://ninknonk.co.uk"> main website</a> for more</p>
</div>
</footer>
<script>
const socket = io.connect();
let roomNum = 1
let id = "M7lc1UVf-VE"
let userName = ""
// Don't allow trailing or leading whitespace!
const nosymbols = new RegExp("^(([a-zA-Z0-9_-][a-zA-Z0-9 _-]*[a-zA-Z0-9_-])|([a-zA-Z0-9_-]*))$");
function mobileNavbarClicked(){
}
(function() {
const roomArea = document.getElementById("roomArea");
const userFormArea = document.getElementById("userFormArea");
const userForm = document.getElementById("userForm");
const users = document.getElementById("users");
const username = document.getElementById("username");
const roomnum = document.getElementById("roomnum");
const persoff = document.getElementById("persoff");
//Lights off
let per = 0;
persoff.style.height = document.body.style.height;
persoff.style.display = "none";
document.onclick = function(e) {
if (!e.target.classList.contains('switch') && per === 1) {
toggle(persoff);
per = 0;
}
};
const lightToggle = document.getElementById(".switch");
if (lightToggle !== null) {
lightToggle.onclick = function () {
toggle(persoff);
per += 1;
if (per === 2) {
per = 0;
}
};
}
socket.on('new message', function(data) {
console.log("Chat has been deprecated in the latest version of NinkyMovies")
});
if (userForm != null) {
// Submit user form
userForm.onsubmit = function (e) {
e.preventDefault();
// New User
// Get rid of trailing/leading whitespace
// If name not entered
const usernameValue = username.value;
let noname;
if (usernameValue === "") {
console.log("ENTER A NAME")
noname = document.getElementById('missinginfo')
noname.innerHTML = "Surely you have a name right? Enter it below!"
}
// If name is too long
else if (usernameValue.length > 30) {
console.log("NAME IS TOO LONG")
noname = document.getElementById('missinginfo')
noname.innerHTML = "Your name can't possibly be over 30 characters!"
}
// If roomnate
else if (roomnum.value.length > 50) {
console.log("ROOM NAME IS TOO LONG")
noname = document.getElementById('missinginfo')
noname.innerHTML = "How are you going to remember a room code that has more than 50 characters?"
}
// If Room contains symbols
// Can only be reached if the user decided to be sneaky and paste them!
else if (!nosymbols.test(roomnum.value)) {
console.log("ENTER A PROPER ROOMNUMBER")
noname = document.getElementById('missinginfo')
noname.innerHTML = ""
const noname2 = document.getElementById('missinginfo2')
noname2.innerHTML = "Please enter a room ID without symbols or leading/trailing whitespace!"
} else {
socket.emit('new user', username.value, function (data) {
if (data) {
userFormArea.style.display = 'none'
roomArea.style.display = 'block';
// This sets the room number on the client
if (roomnum.value !== "") {
roomNum = roomnum.value;
}
// Sets the invite link (roomnum)
history.pushState('', 'Vynchronize', roomNum);
}
});
// Join room
socket.emit('new room', roomnum.value, function (data) {
// This should only call back if the client is the host
if (data) {
console.log("Host is syncing the new socket!")
syncVideo(roomnum)
}
});
username.value = '';
}
};
}
socket.on('get users', function(data) {
if (users == null)
return;
let html = '';
for (i = 0; i < data.length; i++) {
html += '<li style="padding-right: 10em;" class="list-group-item chat-users">' + data[i] + '</li>';
}
users.innerHTML += html;
});
const nosymbols = new RegExp("^[a-zA-Z0-9\s]+$");
if (roomnum != null) {
// Prevent special characters from being typed
roomnum.onkeypress = function (event) {
const key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
console.log(key)
console.log(event.keyCode)
// Allow enters and spaces to be used still
if (roomnum.value.length > 50 || !nosymbols.test(key) && event.keyCode != 13 && event.keyCode != 32 && event.keyCode != 45 && event.keyCode != 95) {
event.preventDefault();
return false;
}
};
}
if (username != null) {
// Prevent special characters from being typed
username.onkeypress = function (event) {
const key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
// Allow enters and spaces to be used still
if (username.value.length > 30 || !nosymbols.test(key) && event.keyCode != 13 && event.keyCode != 32 && event.keyCode != 45 && event.keyCode != 95) {
event.preventDefault();
return false;
}
};
}
//Here on its just checking url parameters to see if the room can be joined automatically
const urlParams = new URLSearchParams(window.location.search);
const roomId = urlParams.get("room");
if (roomId === null || roomId === "" || roomId === undefined)
return;
let userName = urlParams.get("username");
if (userName === undefined || userName === "" || userName == null)
userName = "random discord user!";
socket.emit('new user', userName, function(data) {
if (data) {
userFormArea.style.display = 'none'
roomArea.style.display = 'block'
setupModeDropdown();
applyRoom(roomnum.value)
// This sets the room number on the client
if (roomnum.value !== "") {
roomNum = roomnum.value
}
history.pushState('', 'Vynchronize', roomNum);
}
});
// Join room
socket.emit('new room', roomnum.value, function(data) {
// This should only call back if the client is the host
if (data) {
console.log("Host is syncing the new socket!")
syncVideo(roomnum)
}
});
})();
// set id
socket.on('set id', function(data) {
// Ensure no valid id too
if (data.id !== "" && nosymbols.test(data.id)) {
document.getElementById('roomnum').value = data.id
// Probably should not force it to be readonly
// document.getElementById('roomnum').readOnly = true
console.log("You are joining room: " + data.id)
}
// Reset url for next person
// Workaround
socket.emit('reset url')
});
function getMainRoom() {
document.getElementById('roomnum').value = "main"
}
</script>
<!-- Core frontbackend JS files -->
<script src="js/sync.js"></script>
<script src="js/player.js"></script>
<script src="js/host.js"></script>
<script src="js/events.js"></script>
<script src="js/styling.js"></script>
<!-- Youtube -->
<script src="js/yt.js"></script>
<!-- HTML5 Player -->
<script src="js/html5.js"></script>
</body>
</html>