Browse code

improve readibility

Gandolf authored on 06/20/2021 00:49:50
Showing 2 changed files
... ...
@@ -7,7 +7,6 @@
7 7
 <title>Node Power</title>
8 8
 <meta charset="UTF-8">
9 9
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
10
-<link rel="shortcut icon" href="/favicon.png" type="image/x-icon" />
11 10
 <style>
12 11
 body {
13 12
     background-image: url("static/chalk.jpg");
... ...
@@ -387,7 +386,7 @@ function displayData(dataItem) {
387 386
     battemp_t.innerHTML = battemp.toFixed(2).toString();
388 387
     ambtemp_t.innerHTML = ambtemp.toFixed(2).toString();
389 388
 
390
-    period_t.innerHTML = dataItem.period / 60;
389
+    period_t.innerHTML = dataItem.chartUpdateInterval / 60;
391 390
     status_t.innerHTML = "online";
392 391
     status_t.style.color = "green";
393 392
 }
... ...
@@ -55,6 +55,9 @@ img.chart {
55 55
 
56 56
 # Define global constants
57 57
 
58
+# debug mode
59
+define("_DEBUG", false);
60
+
58 61
 # round robin database file
59 62
 define("_RRD_FILE", str_replace("public_html/power/power.php",
60 63
                                 "database/powerData.rrd",
... ...
@@ -67,8 +70,6 @@ define("_CHART_DIRECTORY", str_replace("power.php",
67 70
 define("_CHART_WIDTH", 600);
68 71
 # standard chart height in pixels
69 72
 define("_CHART_HEIGHT", 150);
70
-# debug mode
71
-define("_DEBUG", false);
72 73
 
73 74
 # Set error handling modes.
74 75
 error_reporting(E_ALL);
... ...
@@ -101,6 +102,30 @@ if ($beginDateEp > $endDateEp) {
101 102
           date('m / d / Y', $firstDP) . " and " . 
102 103
           date('m / d / Y', $lastDP) . ".</p>";
103 104
 } else {
105
+    generateCharts($beginDateEp, $endDateEp);
106
+    sendChartsToClient();
107
+}
108
+
109
+function sendChartsToClient() {
110
+    # Send html commands to client browser.
111
+    echo "<div class=\"chartContainer\">" .
112
+         "<img class=\"chart\" src=\"dynamic/custom_current.png\">" .
113
+         "</div>";
114
+    echo "<div class=\"chartContainer\">" .
115
+         "<img class=\"chart\" src=\"dynamic/custom_voltage.png\">" .
116
+         "</div>";
117
+    echo "<div class=\"chartContainer\">" .
118
+         "<img class=\"chart\" src=\"dynamic/custom_power.png\">" .
119
+         "</div>";
120
+    echo "<div class=\"chartContainer\">" .
121
+         "<img class=\"chart\" src=\"dynamic/custom_battemp.png\">" .
122
+         "</div>";
123
+    echo "<div class=\"chartContainer\">" .
124
+         "<img class=\"chart\" src=\"dynamic/custom_ambtemp.png\">" .
125
+         "</div>";
126
+}
127
+
128
+function generateCharts($beginDateEp, $endDateEp) {
104 129
     # Generate charts from validated user supplied dates.
105 130
     if (_DEBUG) {
106 131
         echo "<p>Date range: " . $beginDateEp . " thru " .
... ...
@@ -111,32 +136,16 @@ if ($beginDateEp > $endDateEp) {
111 136
                  0, 0, 2, false);
112 137
     createChart('custom_voltage', 'VOLT', 'Volts', 
113 138
                 'Voltage', $beginDateEp, $endDateEp,
114
-                 0, 0, 2, false);
139
+                 0, 0, 0, false);
115 140
     createChart('custom_power', 'PWR', 'Watts', 
116 141
                 'Power', $beginDateEp, $endDateEp,
117 142
                  0, 0, 2, false);
118 143
     createChart('custom_battemp', 'BTMP', 'deg\ F', 
119 144
                 'Battery\ Temperature', $beginDateEp, $endDateEp,
120
-                 0, 0, 2, false);
145
+                 0, 0, 0, false);
121 146
     createChart('custom_ambtemp', 'ATMP', 'deg\ F', 
122 147
                 'Ambient\ Temperature', $beginDateEp, $endDateEp,
123
-                 0, 0, 2, false);
124
-    # Send html commands to client browser.
125
-    echo "<div class=\"chartContainer\">" .
126
-         "<img class=\"chart\" src=\"dynamic/custom_current.png\">" .
127
-         "</div>";
128
-    echo "<div class=\"chartContainer\">" .
129
-         "<img class=\"chart\" src=\"dynamic/custom_voltage.png\">" .
130
-         "</div>";
131
-    echo "<div class=\"chartContainer\">" .
132
-         "<img class=\"chart\" src=\"dynamic/custom_power.png\">" .
133
-         "</div>";
134
-    echo "<div class=\"chartContainer\">" .
135
-         "<img class=\"chart\" src=\"dynamic/custom_battemp.png\">" .
136
-         "</div>";
137
-    echo "<div class=\"chartContainer\">" .
138
-         "<img class=\"chart\" src=\"dynamic/custom_ambtemp.png\">" .
139
-         "</div>";
148
+                 0, 0, 0, false);
140 149
 }
141 150
 
142 151
 function createChart($chartFile, $dataItem, $label, $title, $begin,