diff options
author | Nicolai Tellefsen <niccofyren@gmail.com> | 2016-03-04 21:56:46 +0100 |
---|---|---|
committer | Nicolai Tellefsen <niccofyren@gmail.com> | 2016-03-04 21:56:46 +0100 |
commit | 7227a97b6a6a867b0b370657fe164c3151cccdeb (patch) | |
tree | c34d3a50eefdd4418b8f21bdc28f275c44a27058 /web/nms.gathering.org/js/nms.js | |
parent | f3b5042fddf1ceedd89f72527685b191df6bc6fa (diff) | |
parent | 82128b9b97fdc5df611b42b1ebd119e1650d36aa (diff) |
Merge branch 'timetravel-gui'
Diffstat (limited to 'web/nms.gathering.org/js/nms.js')
-rw-r--r-- | web/nms.gathering.org/js/nms.js | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/web/nms.gathering.org/js/nms.js b/web/nms.gathering.org/js/nms.js index ace6e31..0aba266 100644 --- a/web/nms.gathering.org/js/nms.js +++ b/web/nms.gathering.org/js/nms.js @@ -249,12 +249,12 @@ function toggleNightMode() * * Should probably just use stringToEpoch() instead, but alas, not yet. */ -function checkNow(now) +function parseNow(now) { if (Date.parse(now)) { var d = new Date(Date.parse(now)); - var str = d.getFullYear() + "-" + (parseInt(d.getMonth())+1) + "-" + d.getDate() + "T"; - str += d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds(); + var str = d.getFullYear() + "-" + ("00" + (parseInt(d.getMonth())+1)).slice(-2) + "-" + ("00" + d.getDate()).slice(-2) + "T"; + str += ("00" + d.getHours()).slice(-2) + ":" + ("00" + d.getMinutes()).slice(-2) + ":" + ("00" + d.getSeconds()).slice(-2); return str; } @@ -348,22 +348,29 @@ function startReplay() { } /* - * Used to move to a specific time, but not replay. + * Used to move to a specific time */ -function changeNow() { - var newnow = checkNow(document.getElementById("nowPicker").value); - if (!newnow) { - alert('Bad date-field in time travel field'); - return; - } +function changeNow(newnow,playing) { if (newnow == "") newnow = false; + if (playing == "") + playing = false; + + if(newnow) + newnow = parseNow(newnow); + nms.timers.replay.stop(); nms.now = newnow; - if (newnow) { - nms.timers.ping.stop();; - nms.timers.ports.stop();; - } + resetColors(); + + if (!playing) { + nms.timers.ping.stop(); + nms.timers.ports.stop(); + } else { + nms.timers.ping.start(); + nms.timers.ports.start(); + } + updatePorts(); updatePing(); var boxHide = document.getElementById("nowPickerBox"); @@ -1752,3 +1759,27 @@ function forgetSettings() { document.cookie = 'nms=' + btoa('{}'); } + +/* + * Time travel gui + */ +function startNowPicker(now) { + $('#nowPicker').datetimepicker('destroy'); + $('#nowPicker').datetimepicker({ + value: now, + mask:false, + inline:true, + todayButton: false, + validateOnBlur:false, + maxDate:'+1970/01/01', + onSelectDate: function(ct,$i){ + document.getElementById('nowPicker').dataset.iso = parseNow(ct); + }, + onSelectTime: function(ct,$i){ + document.getElementById('nowPicker').dataset.iso = parseNow(ct); + }, + onGenerate: function(ct,$i){ + document.getElementById('nowPicker').dataset.iso = parseNow(ct); + } + }); +} |