$data['showingMain'] = var_export(!empty($_POST['main']), true);
$data['showingAll'] = var_export(!empty($_POST['all']), true);
$data['showingExtra'] = var_export(!empty($_POST['extra']), true);
- $data['showingTimer'] = var_export(!empty($_POST['timer']), true);
+ $data['showingTimer1'] = var_export(!empty($_POST['timer1']), true);
+ $data['showingTimer2'] = var_export(!empty($_POST['timer2']), true);
+ $data['showingTimer3'] = var_export(!empty($_POST['timer3']), true);
$data['showingBanner'] = var_export(!empty($_POST['banner']), true);
$data['showingSigil'] = [
var_export(!empty($_POST['sigilNE']), true),
$clock['movementSpeed'] = (int)$_POST['movementSpeed'];
$clock['currentPosition'] = (int)$_POST["doomsday"];
- $data['timerOffset'] = (int)$_POST['timerOffset'];
+ $data['timer1Offset'] = (int)$_POST['timer1Offset'];
+ $data['timer2Offset'] = (int)$_POST['timer2Offset'];
+ $data['timer3Offset'] = (int)$_POST['timer3Offset'];
$data['priceChange'] = (int)$_POST['priceChange'];
$data['discount'] = (int)$_POST['discount'];
$data['itemId'] = (int)$_POST['item'];
$data['bannerText'] = $text['bannerText'][(int)$_POST['bannerText']];
- if (!empty($_POST['addTime'])) {
- $minutes = (int)substr($_POST['addTime'], 0, 2);
- $seconds = (int)substr($_POST['addTime'], 2, 4) + ($minutes * 60);
- $data['timerEnd'] = time() + $seconds;
+ if (!empty($_POST['addTime1'])) {
+ $minutes = (int)substr($_POST['addTime1'], 0, 2);
+ $seconds = (int)substr($_POST['addTime1'], 2, 4) + ($minutes * 60);
+ $data['timer1End'] = time() + $seconds;
+ }
+ if (!empty($_POST['addTime2'])) {
+ $minutes = (int)substr($_POST['addTime2'], 0, 2);
+ $seconds = (int)substr($_POST['addTime2'], 2, 4) + ($minutes * 60);
+ $data['timer2End'] = time() + $seconds;
+ }
+ if (!empty($_POST['addTime3'])) {
+ $minutes = (int)substr($_POST['addTime3'], 0, 2);
+ $seconds = (int)substr($_POST['addTime3'], 2, 4) + ($minutes * 60);
+ $data['timer3End'] = time() + $seconds;
}
$json = json_encode($data);
margin: 10px;
vertical-align: top;
}
+.third {
+ display: inline-block;
+ width: calc((100% / 3) - 20px);
+ margin: 10px;
+ vertical-align: top;
+}
.entry {
width: 50%;
margin: 0;
</fieldset>
<fieldset>
<legend>Timer</legend>
- <div class="split entry"><input type='radio' id='0000' value='0000' name='addTime'>
- <label for='0000'> Reset</label></div>
- <div class="split entry"><input type='radio' id='0030' value='0030' name='addTime'>
- <label for='0030'> +00:30</label></div>
- <div class="split entry"><input type='radio' id='0100' value='0100' name='addTime'>
- <label for='0100'> +01:00</label></div>
- <div class="split entry"><input type='radio' id='0200' value='0200' name='addTime'>
- <label for='0200'> +02:00</label></div>
- <div class="split entry"><input type='radio' id='0500' value='0500' name='addTime'>
- <label for='0500'> +05:00</label></div>
- <div class="split entry"><input type='radio' id='1000' value='1000' name='addTime'>
- <label for='1000'> +10:00</label></div>
<?php
-$checked = "";
-if ($data['showingTimer'] == "true") {
- $checked = " checked='checked' ";
-}
-$timerOffset = $data["timerOffset"];
-echo "<input type='number' id='timerOffset' name='timerOffset' min='-5000' max='5000' step='1' value='$timerOffset'>";
-echo "<label for='timerOffset'> Timer offset (ms)</label>";
-echo "<br><input type='checkbox' id='timer' name='timer' value='true'$checked>";
-echo "<label for='timer'> Showing timer</label>";
-echo "</fieldset>";
+$timer1Checked = "";
+if ($data['showingTimer1'] == "true") {
+ $timer1Checked = " checked='checked' ";
+}
+$timer1Offset = $data["timer1Offset"];
+$timer2Checked = "";
+if ($data['showingTimer2'] == "true") {
+ $timer2Checked = " checked='checked' ";
+}
+$timer2Offset = $data["timer2Offset"];
+$timer3Checked = "";
+if ($data['showingTimer3'] == "true") {
+ $timer3Checked = " checked='checked' ";
+}
+$timer3Offset = $data["timer3Offset"];
?>
+ <div class="third">
+ <input type='radio' id='0000' value='0000' name='addTime1'>
+ <label for='0000'> Reset</label><br>
+ <input type='radio' id='0030' value='0030' name='addTime1'>
+ <label for='0030'> +00:30</label><br>
+ <input type='radio' id='0100' value='0100' name='addTime1'>
+ <label for='0100'> +01:00</label><br>
+ <input type='radio' id='0200' value='0200' name='addTime1'>
+ <label for='0200'> +02:00</label><br>
+ <input type='radio' id='0500' value='0500' name='addTime1'>
+ <label for='0500'> +05:00</label><br>
+ <input type='radio' id='1000' value='1000' name='addTime1'>
+ <label for='1000'> +10:00</label><br>
+ <input type='number' id='timer1Offset' name='timer1Offset' min='-5000' max='5000' step='1' value='<?php echo $timer1Offset; ?>'>
+ <label for='timer1Offset'> Timer 1 offset (ms)</label>
+ <br><input type='checkbox' id='timer1' name='timer1' value='true'<?php echo $timer1Checked; ?>>
+ <label for='timer1'> Showing timer</label>
+ </div><div class="third">
+ <input type='radio' id='0000' value='0000' name='addTime2'>
+ <label for='0000'> Reset</label><br>
+ <input type='radio' id='0030' value='0030' name='addTime2'>
+ <label for='0030'> +00:30</label><br>
+ <input type='radio' id='0100' value='0100' name='addTime2'>
+ <label for='0100'> +01:00</label><br>
+ <input type='radio' id='0200' value='0200' name='addTime2'>
+ <label for='0200'> +02:00</label><br>
+ <input type='radio' id='0500' value='0500' name='addTime2'>
+ <label for='0500'> +05:00</label><br>
+ <input type='radio' id='1000' value='1000' name='addTime2'>
+ <label for='1000'> +10:00</label><br>
+ <input type='number' id='timer2Offset' name='timer2Offset' min='-5000' max='5000' step='1' value='<?php echo $timer2Offset; ?>'>
+ <label for='timer2Offset'> Timer 2 offset (ms)</label>
+ <br><input type='checkbox' id='timer2' name='timer2' value='true'<?php echo $timer2Checked; ?>>
+ <label for='timer2'> Showing timer</label>
+ </div><div class="third">
+ <input type='radio' id='0000' value='0000' name='addTime3'>
+ <label for='0000'> Reset</label><br>
+ <input type='radio' id='0030' value='0030' name='addTime3'>
+ <label for='0030'> +00:30</label><br>
+ <input type='radio' id='0100' value='0100' name='addTime3'>
+ <label for='0100'> +01:00</label><br>
+ <input type='radio' id='0200' value='0200' name='addTime3'>
+ <label for='0200'> +02:00</label><br>
+ <input type='radio' id='0500' value='0500' name='addTime3'>
+ <label for='0500'> +05:00</label><br>
+ <input type='radio' id='1000' value='1000' name='addTime3'>
+ <label for='1000'> +10:00</label><br>
+ <input type='number' id='timer3Offset' name='timer3Offset' min='-5000' max='5000' step='1' value='<?php echo $timer3Offset; ?>'>
+ <label for='timer3Offset'> Timer 3 offset (ms)</label>
+ <br><input type='checkbox' id='timer3' name='timer3' value='true'<?php echo $timer3Checked; ?>>
+ <label for='timer3'> Showing timer</label>
+ </div>
+ </fieldset>
</div><div class="split">
<?php
echo "<fieldset><legend>Doomsday clock <em>(Incr. $clockIncrement deg)</em></legend>";
}
#notes {
margin: 40px;
+}
+#timer {
+ position: absolute;
+ bottom: 0;
+ left: 0;
}
</style>
<script>
var itemId = 0;
+function makeTime(t, o) {
+ let current = Math.round((Date.now() + o) / 1000);
+ var time = t - current;
+ if (Math.sign(time) == -1) {time = 0;}
+ var minutes = Math.floor(time / 60);
+ var seconds = (time - (minutes * 60));
+
+ var minutesString = minutes.toString();
+ var secondsString = seconds.toString();
+ minutesString = minutesString.padStart(2, "0");
+ secondsString = secondsString.padStart(2, "0");
+
+ return `${minutesString}:${secondsString}`;
+}
+
function frame() {
var slider = document.getElementById("slider");
var notes = document.getElementById("notes");
+ var timers = document.getElementById("timer");
- notes.style.fontSize = `${slider.value}px`
+ notes.style.fontSize = `${slider.value}px`;
+ timers.style.fontSize = `${slider.value}px`;
}
function update() {
.then(data => data.json())
.then(data => {
itemId = data.itemId;
+ var timers = document.getElementsByClassName("time");
+ timers[0].innerHTML = makeTime(data.timer1End, data.timer1Offset);
+ timers[1].innerHTML = makeTime(data.timer2End, data.timer2Offset);
+ timers[2].innerHTML = makeTime(data.timer3End, data.timer3Offset);
})
fetch("../items.json", {cache: "no-store"})
.then(data => data.json())
<body>
<input type="range" min="30" max="100" value="45" id="slider">
<div style="font-size: 50px;" id="notes">some test text!</div>
+ <div id="timer">
+ T1: <span style="background-color: red;" class="time"></span> -
+ T2: <span style="background-color: green;" class="time"></span> -
+ T3: <span style="background-color: blue;" class="time"></span>
+ </div>
</body>
</html>