diff options
author | Kristian Lyngstol <kristian@bohemians.org> | 2016-05-31 22:54:00 +0200 |
---|---|---|
committer | Kristian Lyngstol <kristian@bohemians.org> | 2016-05-31 22:54:00 +0200 |
commit | 5222b78af21f90e230d50c075174fc84f45d4172 (patch) | |
tree | 3eff96fb82d8031d97250a0cef6300050e04ff13 /web/js/nms-data.js | |
parent | 0dd07a2523fe3a440f4e2a9a0edbdfe57bb70913 (diff) |
front: Introduce a tiny heart that pulses....
The HTML/detail should probably be tweaked, but I think we need a way to
show that Gondul is still alive now that we are hiding the time stamp by
default.
Feel free to throw the HTML/CSS away in favor of some other subtle but
noticeable "animation".
Diffstat (limited to 'web/js/nms-data.js')
-rw-r--r-- | web/js/nms-data.js | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/web/js/nms-data.js b/web/js/nms-data.js index 5a219e8..37cc11c 100644 --- a/web/js/nms-data.js +++ b/web/js/nms-data.js @@ -36,6 +36,7 @@ var nmsData = nmsData || { newSource:0, oldSource:0 }, + _pulseBeat: 0, /* * The last time stamp of any data received, regardless of source. * @@ -119,11 +120,39 @@ nmsData.registerSource = function(name, target) { } else { this.stats.oldSource++; } - this.stats.pollSets++; }; /* + * Show sign-of-life to the user. + * + * Now that we don't show the date field constantly it is nice to indicate + * to the user that things are still running in some discreet manner. + * + * The actual html might not be the best choice, but I think the general + * idea of some sort of heartbeat is needed. + */ +nmsData._pulse = function() { + if (nmsData._pulseElement == undefined) { + try { + nmsData._pulseElement = document.getElementById("heartbeat"); + } catch(e) { + nmsData._pulseElement = null; + } + } + if (nmsData._pulseElement == null) + return; + if (nmsData._pulseBeat > 20) { + if (nmsData._pulseElement.classList.contains("pulse-on")) { + nmsData._pulseElement.classList.remove("pulse-on"); + } else { + nmsData._pulseElement.classList.add("pulse-on"); + } + nmsData._pulseBeat = 0; + } + nmsData._pulseBeat++; +} +/* * Add a handler (callback) for a source, using an id. * * This is idempotent: if the id is the same, it will just overwrite the @@ -271,6 +300,7 @@ nmsData._genericUpdater = function(name, cacheok) { } nmsData.stats.identicalFetches++; } + nmsData._pulse(); }, complete: function(jqXHR, textStatus) { nmsData.stats.outstandingAjaxRequests--; |