From e5323ecaf854924cdc6226a5db716d35ae347e9b Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Sat, 28 May 2016 16:42:32 +0200 Subject: Fix numerous time-travel issues in front and API Fixes #69 #11 #5 Introduces nmsTime which unifies the time travel code a bit. It still needs some work, but this is much better. All conversion is now done by native JavaScript methods, freeing us from the hell that is parsing it ourself. One thing should be added: The backend should discard any now=values that are not 5-minute intervals. We don't want to kill the cache and the database by extension. Still need to re-implement the "replay event" shorthand, but that ties in to #54 --- web/js/nms-map.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'web/js/nms-map.js') diff --git a/web/js/nms-map.js b/web/js/nms-map.js index ef86102..26782f8 100644 --- a/web/js/nms-map.js +++ b/web/js/nms-map.js @@ -180,6 +180,19 @@ nmsMap._resizeEvent = function() { nmsMap.drawNow = function () { var now = nmsData.now; + var ctx = nmsMap._c.top.ctx; + if (nmsTime.isRealTime()) { + if (!nmsMap._nowCleared) { + ctx.save(); + ctx.scale(this.scale, this.scale); + ctx.clearRect(0,0,800,100); + ctx.restore(); + nmsMap._nowCleared = true; + nmsMap._lastNow = undefined; + } + return true; + } + nmsMap._nowCleared = false; if(String(now).indexOf('T') == -1) { //If now does not contain 'T' we assume its in epoch format now = new Date(nmsData.now * 1000); } else { @@ -192,7 +205,6 @@ nmsMap.drawNow = function () } nmsMap.stats.nows++; - var ctx = nmsMap._c.top.ctx; ctx.save(); ctx.scale(this.scale, this.scale); ctx.font = (2 * this._settings.fontSize) + "px " + this._settings.fontFace; -- cgit v1.2.3