From 36ba81c8b4ce3bced4898d45853d2b736ef9b2b4 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Sat, 14 May 2016 14:15:10 +0200 Subject: Add tabs for admin/map The admin-tab is currently empty. That is besides the point. Closes #18 --- web/js/nms-ui.js | 23 +++++++++++++++++++++++ web/js/nms.js | 19 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 web/js/nms-ui.js (limited to 'web/js') diff --git a/web/js/nms-ui.js b/web/js/nms-ui.js new file mode 100644 index 0000000..411ed2f --- /dev/null +++ b/web/js/nms-ui.js @@ -0,0 +1,23 @@ +"use strict"; + + +/* + * The idea is to gradually move pure UI stuff into nmsUi. + */ +var nmsUi = nmsUi || { + _active: "map" +}; + +nmsUi.setActive = function(pane) { + var old = document.getElementById(nmsUi._active); + var newp = document.getElementById(pane); + old.style.display = "none"; + newp.style.display = "block"; + + var oldlink = document.getElementById(nmsUi._active + "-link"); + var newlink = document.getElementById(pane + "-link"); + oldlink.classList.remove("active"); + newlink.classList.add("active"); + + nmsUi._active = pane; +} diff --git a/web/js/nms.js b/web/js/nms.js index cd60633..1f7398b 100644 --- a/web/js/nms.js +++ b/web/js/nms.js @@ -1,4 +1,21 @@ "use strict"; + +/* + * This is the original nms.js and it's a bit of a mess as much has been + * moved into separate js-files and cleaned up. + * + * Gradual refactoring has begun. + * + * On the TODO list: + * + * - Move all pure UI stuff into nmsUi: nightMode, vertical mode, + * menushowing, + * - Get rid of "tvmode". As in: complete the merge + * - Move all time-travel related code out into a separate entity. + * - Remove nms.now: it belongs in nmsData. + * - nms.timers probably also deserves to die. It used to do a lot more, + * now it's just leftovers. + */ var nms = { stats:{}, // Various internal stats get nightMode() { return this._nightMode; }, @@ -495,6 +512,8 @@ function isIn(box, x, y) /* * Return the name of the switch found at coordinates (x,y), or 'undefined' * if none is found. + * + * FIXME: this belongs in nmsMap. */ function findSwitch(x,y) { x = parseInt(parseInt(x) / nmsMap.scale); -- cgit v1.2.3