From 71b05bdf64e7d4be87f0b5b1e9ea72bbeadf0051 Mon Sep 17 00:00:00 2001 From: jgyates Date: Fri, 2 Mar 2018 20:39:04 -0500 Subject: [PATCH] Added new files for register display Added new files for register display Minor format update to web UI --- static/genmon.js | 23 ++++++- static/index.html | 4 +- static/internal.css | 86 ++++++++++++++++++++++++++ static/internal.html | 22 +++++++ static/internal.js | 140 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 272 insertions(+), 3 deletions(-) create mode 100644 static/internal.css create mode 100644 static/internal.html create mode 100644 static/internal.js diff --git a/static/genmon.js b/static/genmon.js index 89b34b2a..c9a5f55b 100644 --- a/static/genmon.js +++ b/static/genmon.js @@ -253,6 +253,27 @@ function CreateSelectLists(){ option.onclick = SetTransferClick; myDiv.appendChild(option); document.getElementById("remotetransfer").innerHTML = "Start Generator and Transfer"; + + // Create Footer Links + var myFooter = document.getElementById("footer"); + var a = document.createElement('a'); + a.href = "https://github.com/jgyates/genmon"; + a.innerHTML = "GenMon Project on GitHub"; + myFooter.appendChild(a); + + var option = document.createElement("p"); + option.id = "linksep"; + myFooter.appendChild(option); + document.getElementById("linksep").innerHTML = " "; + + + var myFooter = document.getElementById("footer"); + var a = document.createElement('a'); + var PathName = window.location.href; + a.href = PathName.concat("internal"); + a.innerHTML = "Generator Registers"; + myFooter.appendChild(a); + } //***************************************************************************** @@ -521,7 +542,7 @@ function DisplaySettings(){ var url = baseurl.concat("settings"); $.getJSON(url,function(result){ - var outstr = "Settings:

"; + var outstr = "
Settings:

"; // var outstr = JSON.stringify(result, null, 4); // outstr = replaceAll(outstr,'\n','
') // outstr = replaceAll(outstr,' ',' ') diff --git a/static/index.html b/static/index.html index 610101f7..39bdb7c3 100644 --- a/static/index.html +++ b/static/index.html @@ -7,7 +7,7 @@
- + @@ -20,6 +20,6 @@ - +
diff --git a/static/internal.css b/static/internal.css new file mode 100644 index 00000000..94b81745 --- /dev/null +++ b/static/internal.css @@ -0,0 +1,86 @@ +/* BEGIN RESET*/ +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} +input { + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* END RESET*/ +body { + font-size: 18px; + font-weight: bold; + font-family: Arial; + background-color: white; + margin: 0; +} +header, +footer { + background-color: #f1f1f1; + clear: left; + text-align: center; + font-size: 20px +} +a { + font-style: italic; +} +h1 { + font-style: italic; + font-size: 20px +} +p { + font-size: 18px; +} +/* */ + + + +/* Hack for firefox*/ +:-moz-tree-row(hover),#days, #hours, #minutes, #quietmode, #daysep, #timesep, #modesep { + padding: 0px; +} + + + + diff --git a/static/internal.html b/static/internal.html new file mode 100644 index 00000000..46a3737d --- /dev/null +++ b/static/internal.html @@ -0,0 +1,22 @@ + + + + + Generator Registers + +
+ + + + + + + + +

+ + +
+ + \ No newline at end of file diff --git a/static/internal.js b/static/internal.js new file mode 100644 index 00000000..7d4194d6 --- /dev/null +++ b/static/internal.js @@ -0,0 +1,140 @@ +// internal.js - javascrip source for generator internals +// Define header +document.getElementById("myheader").innerHTML = + '
Generator Registers
'; + +window.onload = init; +var baseurl = "" +var GlobalBaseRegisters; +var InitOK = false; + +var BLACK = ''; +var RED = ''; +var ORANGE = ''; +var ColorInfo = []; + + + +//***************************************************************************** +// called on window.onload +// sets up listener events (click menu) and inits the default page +//***************************************************************************** +function init(){ + // the code to be called when the dom has loaded + + baseurl = window.location.protocol + "//" + window.location.host + "/" + "cmd/"; + setInterval(GetDisplayValues, 1000); // Called every 1 sec + setInterval(AgeEntries, (2000)); // Called every 2 sec + document.getElementById("mydisplay").innerHTML = GetDisplayValues(); + + // Create Footer Links + var myFooter = document.getElementById("footer"); + var a = document.createElement('a'); + a.href = "https://github.com/jgyates/genmon"; + a.innerHTML = "GenMon Project on GitHub"; + myFooter.appendChild(a); + + var option = document.createElement("p"); + option.id = "linksep"; + myFooter.appendChild(option); + document.getElementById("linksep").innerHTML = " "; + + + var myFooter = document.getElementById("footer"); + var a = document.createElement('a'); + a.href = window.location.protocol + "//" + window.location.host + a.innerHTML = "Generator Monitor"; + myFooter.appendChild(a); + +} + +//***************************************************************************** +// GetDisplayValues - updates display based on command sent to server +//***************************************************************************** +function GetDisplayValues() +{ + var url = baseurl.concat("registers_json"); + $.getJSON(url,function(result){ + + var RegData = result; + + var textOut = "
    "; + for (var i = 0; i < RegData.Registers["Base Registers"].length; i++) { + + if ((i % 4) == 0){ + textOut += "
  • "; + } + + var Str1 = JSON.stringify(RegData.Registers["Base Registers"][i]); + if (InitOK == true) { + var Str2 = JSON.stringify(GlobalBaseRegisters.Registers["Base Registers"][i]); + //console.log("Checking %s and %s", Str1, Str2); + if (Str1 != Str2) { + Str1 = RED + Str1 + ''; + ColorInfo[i].Time = new Date(); + ColorInfo[i].Color = RED + } + else { + + Str1 = ColorInfo[i].Color + Str1 + ''; + } + } + textOut += Str1 + ' ' + ' ' + ' ' + ' '; + + if ((i % 4) == 3){ + textOut += "
  • "; + } + else if (i == (RegData.Registers["Base Registers"].length - 1)) { + textOut += "
  • "; + } + } + textOut += "
"; + + var jsonStr = JSON.stringify(RegData.Registers["Base Registers"], null, 4); + //var jsonStr = JSON.stringify(RegData, null, 4); + //var RegData = JSON.parse(result); + document.getElementById("mydisplay").innerHTML = textOut; + + GlobalBaseRegisters = RegData; + if (InitOK == false) { + InitOK = true; + for (var i = 0; i < GlobalBaseRegisters.Registers["Base Registers"].length; i++) { + ColorInfo[i] = new Object; + ColorInfo[i].Time = new Date(); + ColorInfo[i].Color = BLACK; + } + } + }); +} +//***************************************************************************** +// AgeEntries - updates colors of output based on time elapsed +//***************************************************************************** +function AgeEntries() +{ + if (InitOK == false) { + return + } + + var CurrentTime = new Date(); + + for (var i = 0; i < GlobalBaseRegisters.Registers["Base Registers"].length; i++) { + + var difference = CurrentTime.getTime() - ColorInfo[i].Time.getTime(); + var secondsDifference = Math.floor(difference/1000); + + if (ColorInfo[i].Color == ORANGE) { + if (secondsDifference > 10) { + ColorInfo[i].Color = BLACK; + } + } + if (ColorInfo[i].Color == RED) { + if (secondsDifference > 5) { + ColorInfo[i].Color = ORANGE; + } + } + + + } + +} +