diff options
-rwxr-xr-x | web/nms.gathering.org/api/read/comments (renamed from web/nms.gathering.org/api/private/comments) | 0 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/read/snmp (renamed from web/nms.gathering.org/api/private/snmp) | 0 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/read/switches-management (renamed from web/nms.gathering.org/api/private/switches-management) | 0 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/read/which-switch-am-i-on (renamed from web/nms.gathering.org/api/private/which-switch-am-i-on) | 0 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/write/comment-add (renamed from web/nms.gathering.org/api/private/comment-add) | 0 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/write/comment-change (renamed from web/nms.gathering.org/api/private/comment-change) | 0 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/write/switch-add (renamed from web/nms.gathering.org/api/private/switch-add) | 0 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/write/switch-update (renamed from web/nms.gathering.org/api/private/switch-update) | 0 | ||||
-rw-r--r-- | web/nms.gathering.org/js/nms-color-util.js | 3 | ||||
-rw-r--r-- | web/nms.gathering.org/js/nms-data.js | 30 | ||||
-rw-r--r-- | web/nms.gathering.org/js/nms-info-box.js | 43 | ||||
-rw-r--r-- | web/nms.gathering.org/js/nms-map-handlers.js | 15 | ||||
-rw-r--r-- | web/nms.gathering.org/js/nms-map.js | 107 | ||||
-rw-r--r-- | web/nms.gathering.org/js/nms.js | 62 |
14 files changed, 129 insertions, 131 deletions
diff --git a/web/nms.gathering.org/api/private/comments b/web/nms.gathering.org/api/read/comments index 4adfb2b..4adfb2b 100755 --- a/web/nms.gathering.org/api/private/comments +++ b/web/nms.gathering.org/api/read/comments diff --git a/web/nms.gathering.org/api/private/snmp b/web/nms.gathering.org/api/read/snmp index f69ca62..f69ca62 100755 --- a/web/nms.gathering.org/api/private/snmp +++ b/web/nms.gathering.org/api/read/snmp diff --git a/web/nms.gathering.org/api/private/switches-management b/web/nms.gathering.org/api/read/switches-management index 6b5fdcd..6b5fdcd 100755 --- a/web/nms.gathering.org/api/private/switches-management +++ b/web/nms.gathering.org/api/read/switches-management diff --git a/web/nms.gathering.org/api/private/which-switch-am-i-on b/web/nms.gathering.org/api/read/which-switch-am-i-on index 0d3f2b4..0d3f2b4 100755 --- a/web/nms.gathering.org/api/private/which-switch-am-i-on +++ b/web/nms.gathering.org/api/read/which-switch-am-i-on diff --git a/web/nms.gathering.org/api/private/comment-add b/web/nms.gathering.org/api/write/comment-add index 26ff734..26ff734 100755 --- a/web/nms.gathering.org/api/private/comment-add +++ b/web/nms.gathering.org/api/write/comment-add diff --git a/web/nms.gathering.org/api/private/comment-change b/web/nms.gathering.org/api/write/comment-change index fb7da54..fb7da54 100755 --- a/web/nms.gathering.org/api/private/comment-change +++ b/web/nms.gathering.org/api/write/comment-change diff --git a/web/nms.gathering.org/api/private/switch-add b/web/nms.gathering.org/api/write/switch-add index 48f62fc..48f62fc 100755 --- a/web/nms.gathering.org/api/private/switch-add +++ b/web/nms.gathering.org/api/write/switch-add diff --git a/web/nms.gathering.org/api/private/switch-update b/web/nms.gathering.org/api/write/switch-update index 6507d2b..6507d2b 100755 --- a/web/nms.gathering.org/api/private/switch-update +++ b/web/nms.gathering.org/api/write/switch-update diff --git a/web/nms.gathering.org/js/nms-color-util.js b/web/nms.gathering.org/js/nms-color-util.js index f50ee04..6b5a4b5 100644 --- a/web/nms.gathering.org/js/nms-color-util.js +++ b/web/nms.gathering.org/js/nms-color-util.js @@ -89,6 +89,5 @@ function getColor(x,y) { var data = imageData.data; if (data.length < 4) return false; - var ret = 'rgb(' + data[0] + ',' + data[1] + ',' + data[2] + ')'; - return ret; + return 'rgb(' + data[0] + ',' + data[1] + ',' + data[2] + ')'; } diff --git a/web/nms.gathering.org/js/nms-data.js b/web/nms.gathering.org/js/nms-data.js index 155b5a8..14e5fed 100644 --- a/web/nms.gathering.org/js/nms-data.js +++ b/web/nms.gathering.org/js/nms-data.js @@ -82,7 +82,7 @@ var nmsData = nmsData || { nmsData._dropData = function (name) { delete this[name]; delete this.old[name]; -} +}; nmsData.removeSource = function (name) { if (this._sources[name] == undefined) { @@ -94,7 +94,7 @@ nmsData.removeSource = function (name) { clearInterval(this._sources[name]['handle']); } delete this._sources[name]; -} +}; /* * Register a source. @@ -121,7 +121,7 @@ nmsData.registerSource = function(name, target) { } this.stats.pollSets++; -} +}; /* * Add a handler (callback) for a source, using an id. @@ -142,7 +142,7 @@ nmsData.addHandler = function(name, id, cb, cbdata) { } this._sources[name].cbs[id] = cbob; this.updateSource(name); -} +}; /* * Unregister all handlers with the "id" for all sources. @@ -154,11 +154,11 @@ nmsData.unregisterHandlerWildcard = function(id) { for (var v in nmsData._sources) { this.unregisterHandler(v, id); } -} +}; nmsData.unregisterHandler = function(name, id) { delete this._sources[name].cbs[id]; -} +}; /* * Updates a source. @@ -181,11 +181,11 @@ nmsData.updateSource = function(name) { return; } this._genericUpdater(name, true); -} +}; nmsData.invalidate = function(name) { this._genericUpdater(name, false); -} +}; /* * Reset a source, deleting all data, including old. * @@ -195,7 +195,7 @@ nmsData.resetSource = function(name) { this[name] = {}; this.old[name] = {}; this.updateSource(name); -} +}; /* * Updates nmsData[name] and nmsData.old[name], issuing any callbacks where @@ -236,16 +236,16 @@ nmsData._genericUpdater = function(name, cacheok) { nmsData[name] = data; nmsMap.drawNow(); for (var i in nmsData._sources[name].cbs) { - var tmp = nmsData._sources[name].cbs[i]; - if (tmp.cb != undefined) { - tmp.cb(tmp.cbdata); + var tmp2 = nmsData._sources[name].cbs[i]; + if (tmp2.cb != undefined) { + tmp2.cb(tmp2.cbdata); } } } else { - for (var i in nmsData._sources[name].cbs) { - var tmp = nmsData._sources[name].cbs[i]; + for (var j in nmsData._sources[name].cbs) { + var tmp = nmsData._sources[name].cbs[j]; if (tmp.cb != undefined && tmp.fresh) { - nmsData._sources[name].cbs[i].fresh = false; + nmsData._sources[name].cbs[j].fresh = false; tmp.cb(tmp.cbdata); } } diff --git a/web/nms.gathering.org/js/nms-info-box.js b/web/nms.gathering.org/js/nms-info-box.js index e3956d8..b6b9d7e 100644 --- a/web/nms.gathering.org/js/nms-info-box.js +++ b/web/nms.gathering.org/js/nms-info-box.js @@ -15,8 +15,8 @@ var nmsInfoBox = nmsInfoBox || { stats: {}, _container: false, //Container window _window: false, //Active window (reference to _windowTypes object or false) - _windowTypes: [], //List of all avaliable window types -} + _windowTypes: [] //List of all avaliable window types +}; /* * Shows a window from the _windowTypes list @@ -34,7 +34,7 @@ nmsInfoBox.showWindow = function (windowName,argument) { return; } } -} +}; /* * Refresh the active window @@ -44,7 +44,7 @@ nmsInfoBox.showWindow = function (windowName,argument) { */ nmsInfoBox.refresh = function() { nmsInfoBox._show(); -} +}; /* * Internal function to show the active _window and pass along any arguments @@ -84,7 +84,7 @@ nmsInfoBox._show = function(argument) { } this._container.appendChild(panel); this._container.style.display = "block"; -} +}; /* * Hide the active window and tell it to unload @@ -99,7 +99,7 @@ nmsInfoBox.hide = function() { nmsData.unregisterHandler("switches","switchshower"); nmsData.unregisterHandler("smanagement","switchshower"); nmsData.unregisterHandler("snmp","switchshower"); -} +}; /* * Window type: Add Switch @@ -134,7 +134,7 @@ nmsInfoBox._windowTypes.addSwitch = { data:myData, success: function (data, textStatus, jqXHR) { var result = JSON.parse(data); - if(result.switches_addded.length > 0) { + if(result.switches_addded.length > 0) { // FIXME unresolved variable switches_addded nmsInfoBox.hide(); } nmsData.invalidate("switches"); @@ -230,9 +230,10 @@ nmsInfoBox._windowTypes.switchInfo = { var template = {}; nmsInfoBox._editValues = {}; + var place; for (var v in this.swi) { if (v == "placement") { - var place = JSON.stringify(this.swi[v]); + place = JSON.stringify(this.swi[v]); template[v] = place; continue; } @@ -320,7 +321,7 @@ nmsInfoBox.click = function(sw) { this.showWindow("switchInfo",sw); this._windowTypes.switchInfo.showComments(); -} +}; /* * General-purpose table-maker? @@ -350,7 +351,7 @@ nmsInfoBox._makeTable = function(content, caption) { td2.innerHTML = content[v][1]; } return table; -} +}; /* * Create and return a table for comments. @@ -393,7 +394,7 @@ nmsInfoBox._makeCommentTable = function(content) { td2.innerHTML = comment["comment"]; } return table; -} +}; nmsInfoBox._searchSmart = function(id, sw) { try { @@ -438,7 +439,7 @@ nmsInfoBox._searchSmart = function(id, sw) { return false; } return false; -} +}; /* * FIXME: Not sure this belongs here, it's really part of the "Core" ui, @@ -474,7 +475,7 @@ nmsInfoBox._search = function() { document.getElementById("searchbox-submit").classList.remove("btn-primary"); document.getElementById("searchbox").dataset.match = ''; } -} +}; nmsInfoBox._searchKeyListener = function(e) { switch (e.keyCode) { @@ -492,14 +493,14 @@ nmsInfoBox._searchKeyListener = function(e) { nmsInfoBox.hide(); break; } -} +}; nmsInfoBox._nullBlank = function(x) { if (x == null || x == false || x == undefined) return ""; return x; -} +}; nmsInfoBox._editChange = function(sw, v) { @@ -520,13 +521,9 @@ nmsInfoBox._editChange = function(sw, v) { var myData = nmsInfoBox._editStringify(sw); var out = document.getElementById("edit-output"); out.value = myData; -} +}; nmsInfoBox._editStringify = function(sw) { - for (var key in nmsInfoBox._editValues) { - var val = nmsInfoBox._editValues[key]; - } - nmsInfoBox._editValues['sysname'] = sw; - var myData = JSON.stringify([nmsInfoBox._editValues]); - return myData; -} + nmsInfoBox._editValues['sysname'] = sw; + return JSON.stringify([nmsInfoBox._editValues]); +}; diff --git a/web/nms.gathering.org/js/nms-map-handlers.js b/web/nms.gathering.org/js/nms-map-handlers.js index d3becde..04aabd2 100644 --- a/web/nms.gathering.org/js/nms-map-handlers.js +++ b/web/nms.gathering.org/js/nms-map-handlers.js @@ -84,7 +84,7 @@ function uplinkUpdater() return; if (!nmsData.switchstate.switches) return; - for (sw in nmsData.switches.switches) { + for (var sw in nmsData.switches.switches) { var uplinks=0; if (nmsData.switchstate.switches[sw] == undefined || nmsData.switchstate.switches[sw].uplinks == undefined) { uplinks=0; @@ -139,9 +139,9 @@ function trafficUpdater() { if (!nms.switches_now["switches"]) return; - for (sw in nms.switches_now["switches"]) { + for (var sw in nms.switches_now["switches"]) { var speed = 0; - for (port in nms.switches_now["switches"][sw]["ports"]) { + for (var port in nms.switches_now["switches"][sw]["ports"]) { if (/ge-0\/0\/44$/.exec(port) || /ge-0\/0\/45$/.exec(port) || /ge-0\/0\/46$/.exec(port) || @@ -177,9 +177,9 @@ function trafficTotUpdater() { if (!nms.switches_now["switches"]) return; - for (sw in nms.switches_now["switches"]) { + for (var sw in nms.switches_now["switches"]) { var speed = 0; - for (port in nms.switches_now["switches"][sw]["ports"]) { + for (var port in nms.switches_now["switches"][sw]["ports"]) { if (!nms.switches_then["switches"][sw] || !nms.switches_then["switches"][sw]["ports"] || !nms.switches_then["switches"][sw]["ports"][port]) @@ -220,14 +220,14 @@ function tempUpdater() if(!nmsData.switches) return; - for (sw in nmsData.switches["switches"]) { + for ( var sw in nmsData.switches["switches"]) { var t = "white"; var temp = ""; if(!nmsData.snmp || !nmsData.snmp.snmp || ! nmsData.snmp.snmp[sw] || !nmsData.snmp.snmp[sw]["misc"] || !nmsData.snmp.snmp[sw]["misc"]["enterprises.2636.3.1.13.1.7.7.1.0.0"]) continue; - tempObj = nmsData.snmp.snmp[sw]["misc"]["enterprises.2636.3.1.13.1.7.7.1.0.0"]; + var tempObj = nmsData.snmp.snmp[sw]["misc"]["enterprises.2636.3.1.13.1.7.7.1.0.0"]; Object.keys(tempObj).forEach(function (key) { if(key == "") { temp = tempObj[key] + "°C"; @@ -259,6 +259,7 @@ function pingUpdater() } for (var sw in nmsData.switches.switches) { try { + var c; if (nmsData.ping.switches[sw].age > 0) { c = red; } else { diff --git a/web/nms.gathering.org/js/nms-map.js b/web/nms.gathering.org/js/nms-map.js index 11ee142..ffedcbf 100644 --- a/web/nms.gathering.org/js/nms-map.js +++ b/web/nms.gathering.org/js/nms-map.js @@ -50,19 +50,20 @@ var nmsMap = nmsMap || { _highlight: { }, _highlightActive: false, _c: {} -} +}; nmsMap._loadEvent = function(e) { nmsMap._init = false; nmsMap._drawAllSwitches(); -} +}; + nmsMap.init = function() { this._initContexts(); this._init = true; nmsData.addHandler("switches","nmsMap",function(){nmsMap._resizeEvent();}); window.addEventListener('resize',nmsMap._resizeEvent,true); window.addEventListener('load',nmsMap._loadEvent,true); -} +}; nmsMap.setSwitchColor = function(sw, color) { if (this._color[sw] != color) { @@ -72,26 +73,30 @@ nmsMap.setSwitchColor = function(sw, color) { } else { this.stats.colorSame++; } -} +}; + nmsMap.setSwitchHighlight = function(sw, highlight) { - if(highlight) - highlight == true; - if (this._highlight[sw] != highlight) { - this.stats.highlightChange++; - this._highlight[sw] = highlight; - } - this._drawSwitch(sw); -} + if( highlight ) + highlight = true; + if ( this._highlight[sw] != highlight ) { + this.stats.highlightChange++; + this._highlight[sw] = highlight; + } + this._drawSwitch(sw); +}; + nmsMap.enableHighlights = function() { - this._highlightActive = true; -} + this._highlightActive = true; +}; + nmsMap.disableHighlights = function() { - this._highlightActive = false; - this._drawAllSwitches(); -} + this._highlightActive = false; + this._drawAllSwitches(); +}; + nmsMap.reset = function() { for (var sw in this._color) { @@ -100,7 +105,7 @@ nmsMap.reset = function() { for (var sw in this._info) { nmsMap.setSwitchInfo(sw, undefined); } -} +}; nmsMap.setSwitchInfo = function(sw,info) { if (this._info[sw] != info) { @@ -110,19 +115,19 @@ nmsMap.setSwitchInfo = function(sw,info) { } else { this.stats.switchInfoSame++; } -} +}; nmsMap._initContext = function(name) { this._c[name] = {}; this._c[name].c = document.getElementById(name + "Canvas"); this._c[name].ctx = this._c[name].c.getContext('2d'); -} +}; nmsMap._initContexts = function() { for (var context in this.contexts) { this._initContext(this.contexts[context]); } -} +}; nmsMap._resizeEvent = function() { var width = window.innerWidth - nmsMap._c.bg.c.offsetLeft; @@ -155,7 +160,7 @@ nmsMap._resizeEvent = function() { nmsMap.drawNow(); nmsMap.stats.resizeEvents++; } -} +}; /* * Draw current time-window @@ -183,10 +188,10 @@ nmsMap.drawNow = function () ctx.fillStyle = "white"; ctx.strokeStyle = "black"; ctx.lineWidth = nms.fontLineFactor; - ctx.strokeText(now, 0 + this._settings.textMargin, 25); - ctx.fillText(now, 0 + this._settings.textMargin, 25); + ctx.strokeText(now, this._settings.textMargin, 25); + ctx.fillText(now, this._settings.textMargin, 25); ctx.restore(); -} +}; nmsMap.setNightMode = function(toggle) { if (this._nightmode == toggle) @@ -202,14 +207,14 @@ nmsMap.setNightMode = function(toggle) { this._c.blur.c.style.display = ""; } nmsMap._drawBG(); -} +}; nmsMap._drawBG = function() { var imageObj = document.getElementById('source'); this._c.bg.ctx.drawImage(imageObj, 0, 0, nmsMap._canvas.width, nmsMap._canvas.height); if(this._nightmode) nmsMap._invertBG(); -} +}; nmsMap._invertBG = function() { var imageData = this._c.bg.ctx.getImageData(0, 0, nmsMap._canvas.width, nmsMap._canvas.height); @@ -221,7 +226,7 @@ nmsMap._invertBG = function() { data[i + 2] = 255 - data[i + 2]; } this._c.bg.ctx.putImageData(imageData, 0, 0); -} +}; nmsMap._getBox = function(sw) { var box = nmsData.switches.switches[sw]['placement']; @@ -230,7 +235,7 @@ nmsMap._getBox = function(sw) { box.width = parseInt(box.width); box.height = parseInt(box.height); return box; -} +}; nmsMap._drawSwitchBlur = function(sw) { @@ -241,10 +246,11 @@ nmsMap._drawSwitchBlur = function(sw) this._c.blur.ctx.fillStyle = "red"; this._c.blur.ctx.shadowBlur = 30; this._c.blur.ctx.shadowColor = "white"; - this._c.blur.ctx.scale(this.scale, this.scale); // FIXME + this._c.blur.ctx.scale(this.scale, this.scale); // FIXME <- fix what?! this._c.blur.ctx.fillRect(box['x'],box['y'],box['width'],box['height']); this._c.blur.ctx.restore(); -} +}; + nmsMap._drawSwitch = function(sw) { // XXX: If a handler sets a color before switches are loaded... The @@ -267,7 +273,7 @@ nmsMap._drawSwitch = function(sw) this._drawBox(this._c.switch.ctx, box['x'],box['y'],box['width'],box['height']); this._c.switch.ctx.shadowBlur = 0; this._drawText(this._c.text.ctx, sw,box); -} +}; nmsMap._drawSwitchInfo = function(sw) { var box = this._getBox(sw); @@ -276,14 +282,14 @@ nmsMap._drawSwitchInfo = function(sw) { } else { this._drawText(this._c.textInfo.ctx, this._info[sw], box, "right"); } -} +}; nmsMap._clearBox = function(ctx,box) { ctx.save(); ctx.scale(this.scale,this.scale); ctx.clearRect(box['x'], box['y'], box['width'], box['height']); ctx.restore(); -} +}; nmsMap._drawText = function(ctx, text, box, align) { var rotate = false; @@ -319,7 +325,7 @@ nmsMap._drawText = function(ctx, text, box, align) { ctx.strokeText(text, 0, 0); ctx.fillText(text, 0, 0); ctx.restore(); -} +}; nmsMap._drawAllSwitches = function() { if (nmsData.switches == undefined) { @@ -331,7 +337,7 @@ nmsMap._drawAllSwitches = function() { } if (this._nightmode) this._drawAllBlur(); -} +}; nmsMap._drawAllBlur = function() { if (nmsMap._blurDrawn == true) @@ -340,22 +346,22 @@ nmsMap._drawAllBlur = function() { for (var sw in nmsData.switches.switches) { nmsMap._drawSwitchBlur(sw); } -} +}; nmsMap._drawBox = function(ctx, x, y, boxw, boxh) { ctx.save(); - ctx.scale(this.scale, this.scale); // FIXME + ctx.scale(this.scale, this.scale); // FIXME <- what?! ctx.fillRect(x,y, boxw, boxh); ctx.lineWidth = 1; ctx.strokeStyle = "#000000"; ctx.strokeRect(x,y, boxw, boxh); ctx.restore(); -} +}; nmsMap._connectSwitches = function(sw1, sw2, color1, color2) { nmsMap._connectBoxes(this._getBox(sw1), this._getBox(sw2), color1, color2); -} +}; /* * Draw a line between two boxes, with a gradient going from color1 to @@ -382,13 +388,13 @@ nmsMap._connectBoxes = function(box1, box2,color1, color2) { ctx.lineWidth = 5; ctx.stroke(); ctx.restore(); -} +}; nmsMap.moveSet = function(toggle) { nmsMap._moveInProgress = toggle; if (!toggle) nmsMap._moveStopListen(); -} +}; /* * onclick handler for the canvas. @@ -405,7 +411,7 @@ nmsMap.canvasClick = function(e) nmsInfoBox.click(sw); } } -} +}; nmsMap._clearOld = function(box) { if (box) { @@ -415,7 +421,7 @@ nmsMap._clearOld = function(box) { nmsMap._c.top.ctx.clearRect(box['x'] - 5, box['y'] - 5, box['width'] + 10, box['height'] + 10); nmsMap._c.top.ctx.restore(); } -} +}; nmsMap._moveMove = function(e) { nmsMap._moveX = (e.pageX - e.target.offsetLeft) / nmsMap.scale; @@ -433,13 +439,13 @@ nmsMap._moveMove = function(e) { nmsMap._c.top.ctx.fillStyle = "red"; nmsMap._drawBox(nmsMap._c.top.ctx, box['x'], box['y'], box['width'], box['height']); nmsMap._c.top.ctx.restore(); -} +}; nmsMap._moveSubmit = function() { var data = { sysname: nmsMap._moving, placement: nmsMap._moveOldBox - } + }; var myData = JSON.stringify([data]); $.ajax({ type: "POST", @@ -450,11 +456,12 @@ nmsMap._moveSubmit = function() { nmsData.invalidate("switches"); } }); -} +}; + nmsMap._moveStopListen = function() { nmsMap._c.input.c.removeEventListener('mousemove',nmsMap._moveMove, true); nmsMap._c.input.c.removeEventListener('mouseup',nmsMap._moveDone, true); -} +}; nmsMap._moveDone = function(e) { nmsMap._moveStopListen(); @@ -463,7 +470,7 @@ nmsMap._moveDone = function(e) { } nmsMap._moveSubmit(); nmsMap._clearOld(nmsMap._moveOldBox); -} +}; nmsMap._moveStart = function(sw, e) { @@ -474,7 +481,7 @@ nmsMap._moveStart = function(sw, e) nmsMap._moveBox = nmsData.switches.switches[sw].placement; nmsMap._c.input.c.addEventListener('mousemove',nmsMap._moveMove,true); nmsMap._c.input.c.addEventListener('mouseup',nmsMap._moveDone,true); -} +}; /* diff --git a/web/nms.gathering.org/js/nms.js b/web/nms.gathering.org/js/nms.js index 411fd1c..8d28028 100644 --- a/web/nms.gathering.org/js/nms.js +++ b/web/nms.gathering.org/js/nms.js @@ -16,8 +16,8 @@ var nms = { * FIXME: Should just stop using these. */ timers: { - playback:false, - }, + playback:false + }, menuShowing:true, /* @@ -84,7 +84,7 @@ function nmsTimer(handler, interval, name, description) { }; this.setInterval = function(interval) { - var started = this.handle == false ? false : true; + var started = this.handle != false; this.stop(); this.interval = parseInt(interval); if (started) @@ -162,27 +162,27 @@ function stringToEpoch(t) function epochToString(t) { // Adjust for timezone when converting from epoch (UTC) to string (local) - var d = new Date(parseInt(t) * parseInt(1000)); - var timezoneOffset = d.getTimezoneOffset() * -60; + var date = new Date(parseInt(t) * parseInt(1000)); + var timezoneOffset = date.getTimezoneOffset() * -60; t = t - timezoneOffset; - var d = new Date(parseInt(t) * parseInt(1000)); - var str = d.getFullYear() + "-"; - if (parseInt(d.getMonth()) < 9) + date = new Date(parseInt(t) * parseInt(1000)); + var str = date.getFullYear() + "-"; + if (parseInt(date.getMonth()) < 9) str += "0"; - str += (parseInt(d.getMonth())+1) + "-"; - if (d.getDate() < 10) + str += (parseInt(date.getMonth())+1) + "-"; + if (date.getDate() < 10) str += "0"; - str += d.getDate() + "T"; - if (d.getHours() < 10) + str += date.getDate() + "T"; + if (date.getHours() < 10) str += "0"; - str += d.getHours() + ":"; - if (d.getMinutes() < 10) + str += date.getHours() + ":"; + if (date.getMinutes() < 10) str += "0"; - str += d.getMinutes() + ":"; - if (d.getSeconds() < 10) + str += date.getMinutes() + ":"; + if (date.getSeconds() < 10) str += "0"; - str += d.getSeconds(); + str += date.getSeconds(); return str; } @@ -207,7 +207,7 @@ nms.playback.startReplay = function(startTime,stopTime) { nms.playback.stopTime = stringToEpoch(stopTime); nms.now = epochToString(nms.playback.startTime); nms.playback.play(); -} +}; /* * Pause playback @@ -215,7 +215,7 @@ nms.playback.startReplay = function(startTime,stopTime) { nms.playback.pause = function() { nms.timers.playback.stop(); nms.playback.playing = false; -} +}; /* * Start playback @@ -224,7 +224,7 @@ nms.playback.play = function() { nms.playback.tick(); nms.timers.playback.start(); nms.playback.playing = true; -} +}; /* * Toggle playback @@ -235,19 +235,18 @@ nms.playback.toggle = function() { } else { nms.playback.play(); } -} +}; /* * Jump to place in time */ nms.playback.setNow = function(now) { - var now = parseNow(now); - nms.now = now; + nms.now = parseNow(now); nms.playback.stopTime = false; nms.playback.startTime = false; nms.playback.tick(); -} +}; /* * Step forwards or backwards in timer @@ -260,7 +259,7 @@ nms.playback.stepTime = function(n) if(!nms.playback.playing) nms.playback.tick(); -} +}; /* * Ticker to trigger updates, and advance time if replaying @@ -288,7 +287,7 @@ nms.playback.tick = function() if(nms.now !== false && nms.playback.playing) { nms.playback.stepTime(nms.playback.replayIncrement); } -} +}; /* * Helper function for safely getting a valid now-epoch @@ -412,11 +411,7 @@ function addComment(sw,comment) */ function isIn(box, x, y) { - if ((x >= box.x) && (x <= (box.x + box.width)) && (y >= box.y) && (y <= (box.y + box.height))) { - return true; - } - return false; - + return ((x >= box.x) && (x <= (box.x + box.width)) && (y >= box.y) && (y <= (box.y + box.height))); } /* @@ -490,7 +485,6 @@ function initNMS() { } function detectHandler() { - var url = document.URL; for (var i in handlers) { if (('#' + handlers[i].tag) == document.location.hash) { setUpdater(handlers[i]); @@ -638,8 +632,8 @@ function getCookie(cname) { function saveSettings() { var foo={}; - for (var v in nms.settingsList) { - foo[nms.settingsList[v]] = nms[nms.settingsList[v]]; + for ( var v in nms.settingsList ) { + foo[ nms.settingsList[v] ] = nms[ nms.settingsList[v] ]; } document.cookie = 'nms='+btoa(JSON.stringify(foo)); } |