Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html><head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>Timer</title>
- </head>
- <body style="font-family:Consolas, Lucida Console, Verdana; background: #033; color: cyan">
- <p id="1" style="margin:0px 0px 12px 0px">Press Start! to start</p>
- <div style="background: cyan; margin: 0px 0px 8px 0px; padding:4px"><div id="2" style="height: 72px;"></div></div>
- <button onclick="e = true;f = performance.now() / 1000" style="background: green; color: white; border: none; padding: 8px; margin: 0px 0px 8px 0px; font-family: Consolas, Lucida Console, Verdana">Start! (Restart)</button>
- <p style="margin:0px 0px 4px 0px">Timer length:</p>
- <textarea id="3" style="resize: none" rows="1">?</textarea>
- <br>
- <select id="4" style="font-family:Consolas, Lucida Console, Verdana">
- <option value="1">seconds</option>
- <option value="60">minutes</option>
- <option value="3600">hours (3600 seconds.)</option>
- <option value="86400">days (That's a little overboard don't you think?)</option>
- <option value="604800">weeks (Wha- why?!)</option>
- <option value="2592000">months (stop.)</option>
- <option value="31557600">years (Huh. Time capsules.)</option>
- </select>
- <p id="5">Waiting for response...</p>
- <p id="6"></p>
- <button onclick="a0 -= 1;">Previous station</button><button onclick="a0 += 1;">Next station</button>
- <br>
- <button onclick="if (rail == 1) {rail = 2} else {rail = 1}">Switch rail</button>
- <script>
- function floor3digits(number) {return Math.floor(number * 1000) / 1000}
- a = document.getElementById("3").value
- b = a0 = 0
- rail = 1
- stations = ['Center','Lake','Snowdin Town','Hotland','Station','Blossom Street','Flower Pier','Space','Sleepwalk Station']
- rail1 = [0, 1, 2, 3, 4, 5, 6]
- rail2 = [0, 7, 8]
- function x() {
- a = parseFloat(document.getElementById("3").value) * parseFloat(document.getElementById("4").value)
- // Used to represent the text-area's value.
- b = performance.now() / 1000 - f
- // The seconds since you've pressed the Start! button.
- c = floor3digits((b * -1) + a)
- // The overall countdown in seconds.
- document.getElementById("1").innerText = c + " seconds\n" + floor3digits(c / 60) + " minutes\n" + floor3digits(c / 3600) + " hours\n" + floor3digits(((b / (a * -0.01)) + 100)) + "% until end"
- document.getElementById("2").style.width = c > 0 ? ((((b / (a * -0.01))) + 100) + "%").toString() : ((((b / (a * 0.01))) - 100) + "%").toString()
- document.getElementById("2").style.background = c > 0 ? "#222 url(\"lefttile.png\")" : "#333c"
- document.getElementById("2").style.backgroundSize = "72px"
- qwe = document.getElementById("5")
- asd = document.getElementById("6")
- qwe.innerHTML = stations[rail == 1 ? rail1[a0] : rail2[a0]]
- asd.innerHTML = a0.toString() + " station\n" + rail.toString() + " rail"
- if (! qwe.innerHTML in stations) {while (! qwe.innerHTML in stations) {qwe.innerHTML = parseInt(qwe.innerHTML) + 1}}
- if (a0 < 0) {a0 = [6,2][rail - 1]}
- if (a0 > [6,2][rail - 1]) {a0 = 0}
- }
- var c
- // Defined as undefined for preventing error.
- d = new Audio("8bit-0.mp3")
- // Played in y(): Alarm sound.
- function y() {
- if (c < 0) {
- d.play()
- }}
- setInterval(y, 1000)
- e = false
- // If you have pressed the Start! button yet.
- f = undefined
- // The distance between the last Start! press and the start of the document.
- function z() {
- if (e == true) {setInterval(x, 20)}
- else {setTimeout(z, 20)}
- }
- z()
- </script>
- <style>button{font-family:Consolas, Lucida Console, Verdana;width:100px}</style>
- </body></html>
Add Comment
Please, Sign In to add comment