-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
76 lines (69 loc) · 2.54 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p>IGT timer:</p>
<h1 style="font-family: monospace" id="timer-2"></h1>
<p>RTA timer (as if it started from the given IGT):</p>
<h1 style="font-family: monospace" id="timer-3"></h1>
<br>
<button id="start-button" onclick="startButton()">Start</button>
<button id="stop-button" onclick="stopButton()">Stop</button>
<br>
<label for="igt-on-start">IGT on start: </label><input id="igt-on-start" type="text" oninput="updateButton()">
<button id="update-button" onclick="updateButton()">Update</button>
<br>
<label for="fps-input">FPS: </label><input type="text" name="fps-input" id="fps-input" value="59.824">
<script>
let ivar;
let start_real_time_millis;
let start_igt = 0;
const fpsInput = document.querySelector("#fps-input");
function fps() {
return parseFloat(fpsInput.value);
}
function startButton() {
let d = new Date();
start_real_time_millis = d.getTime();
// let timer_element = $("#timer").get()[0];
const timer2_element = document.getElementById("timer-2");
const timer3_element = document.getElementById("timer-3");
if (ivar !== undefined && ivar !== null) {
window.clearInterval(ivar);
}
ivar = window.setInterval(function () {
d = new Date();
let t = ((d.getTime() - start_real_time_millis) * (fps() / 60) + (start_igt * 1000)) / 1000;
let s = `${Math.floor(t / 3600)}:${("00" + Math.floor((t / 60) % 60)).slice(-2)}:${("00" + Math.floor(t % 60)).slice(-2)}`;
timer2_element.innerText = t.toFixed(3) + " " + s;
t = ((d.getTime() - start_real_time_millis) + (start_igt * 1000)) / 1000;
s = `${Math.floor(t / 3600)}:${("00" + Math.floor((t / 60) % 60)).slice(-2)}:${("00" + Math.floor(t % 60)).slice(-2)}`;
timer3_element.innerText = t.toFixed(3) + " " + s;
}, 10);
}
function stopButton() {
if (ivar !== undefined && ivar !== null) {
window.clearInterval(ivar);
}
}
function updateButton() {
start_igt = 0;
let val = document.getElementById("igt-on-start").value;
if (val.length === 0) {
return;
}
let arr = val.split(/[:\. ]/);
console.log(arr)
for (let x = 0; x < arr.length; x++) {
start_igt *= 60;
if (arr[x].length !== 0) {
start_igt += parseInt(arr[x]);
}
}
}
</script>
</body>
</html>