Skip to content

Commit

Permalink
Added new files for register display
Browse files Browse the repository at this point in the history
Added new files for register display
Minor format update to web UI
  • Loading branch information
jgyates authored Mar 3, 2018
1 parent 6abda39 commit 71b05bd
Show file tree
Hide file tree
Showing 5 changed files with 272 additions and 3 deletions.
23 changes: 22 additions & 1 deletion static/genmon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

//*****************************************************************************
Expand Down Expand Up @@ -521,7 +542,7 @@ function DisplaySettings(){
var url = baseurl.concat("settings");
$.getJSON(url,function(result){

var outstr = "Settings:<br><br><form id=\"formSettings\"><table border=\"0\">";
var outstr = "<br>Settings:<br><br><form id=\"formSettings\"><table border=\"0\">";
// var outstr = JSON.stringify(result, null, 4);
// outstr = replaceAll(outstr,'\n','<br/>')
// outstr = replaceAll(outstr,' ','&nbsp')
Expand Down
4 changes: 2 additions & 2 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- Menu -->
<header id="myheader"></header>
<nav id="navMenu"></nav>
<script type="text/javascript" src="genmon.js?version=2.103"></script>
<script type="text/javascript" src="genmon.js?version=2.110"></script>
<!-- <script src="http://code.jquery.com/jquery-1.12.4.min.js"></script> -->
<script src="jquery-1.12.4.min.js"></script>
<link rel="stylesheet" type="text/css" href="genmon.css?version=1.445">
Expand All @@ -20,6 +20,6 @@
</div>
</body>

<footer id="footer"><a href="https://github.com/jgyates/genmon">Genmon project on Github</a></footer>
<footer id="footer"></footer>

</html>
86 changes: 86 additions & 0 deletions static/internal.css
Original file line number Diff line number Diff line change
@@ -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;
}




22 changes: 22 additions & 0 deletions static/internal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<title>Generator Registers</title>
<!-- Menu -->
<header id="myheader"></header>
<script type="text/javascript" src="internal.js?version=1.051"></script>
<!-- <script src="http://code.jquery.com/jquery-1.12.4.min.js"></script> -->
<script src="jquery-1.12.4.min.js"></script>
<link rel="stylesheet" type="text/css" href="internal.css?version=1.003">
<link rel="icon" href="favicon.ico">
</head>

<body>
<p id="mydisplay"></p>
</body>

<footer id="footer"></footer>

</html>
140 changes: 140 additions & 0 deletions static/internal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
// internal.js - javascrip source for generator internals
// Define header
document.getElementById("myheader").innerHTML =
'<header>Generator Registers</header>';

window.onload = init;
var baseurl = ""
var GlobalBaseRegisters;
var InitOK = false;

var BLACK = '<font color="black">';
var RED = '<font color="red">';
var ORANGE = '<font color="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 = "<ul>";
for (var i = 0; i < RegData.Registers["Base Registers"].length; i++) {

if ((i % 4) == 0){
textOut += "<li>";
}

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 + '</font>';
ColorInfo[i].Time = new Date();
ColorInfo[i].Color = RED
}
else {

Str1 = ColorInfo[i].Color + Str1 + '</font>';
}
}
textOut += Str1 + '&nbsp' + '&nbsp' + '&nbsp' + '&nbsp';

if ((i % 4) == 3){
textOut += "<li>";
}
else if (i == (RegData.Registers["Base Registers"].length - 1)) {
textOut += "<li>";
}
}
textOut += "</ul>";

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;
}
}


}

}

0 comments on commit 71b05bd

Please sign in to comment.