Skip to content

Commit a97dde1

Browse files
committed
add time_played
1 parent f09a4d1 commit a97dde1

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

index.html

+16-3
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,16 @@
285285
</script>
286286
<script src="/socket.io/socket.io.js"></script>
287287
<script>
288-
var socket = io(), room_name;
288+
var socket = io(), room_name, time_played;
289289

290290
function join() {
291291
if(room_name) socket.emit('join', room_name);
292292
}
293+
function show_time_played() {
294+
var seconds = time_played % 60;
295+
var minutes = (time_played - seconds) / 60;
296+
document.getElementById('time_played').innerHTML = (minutes < 10 ? '0' : '') + minutes + (seconds < 10 ? ':0' : ':') + seconds;
297+
}
293298
function join_and_run(file) {
294299
room_name = prompt("Room name:");
295300
run(file);
@@ -300,7 +305,11 @@
300305
// console.log(event);
301306
gba.keypad.keyboardHandler(event);
302307
});
303-
}
308+
309+
time_played = 0;
310+
setInterval(function(){ time_played++; show_time_played(); }, 1000);
311+
}
312+
304313
if(navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(android)|(webOS)/i) && confirm("Go to controller side?"))
305314
document.location = "controller/index.html"
306315
</script>
@@ -329,7 +338,11 @@
329338
<p>Sound</p>
330339
<input type="range" min="0" max="1" value="1" step="any" onchange="setVolume(this.value)" oninput="setVolume(this.value)">
331340
</div>
332-
<p id="room_name"></p>
341+
<p>
342+
<span id="room_name"></span>
343+
344+
<span id="time_played"></span>
345+
</p>
333346
<p id="openDebug" onclick="enableDebug()">Debugger</p>
334347
</div>
335348
</section>

0 commit comments

Comments
 (0)