Browse code

revisions

Jeff Owrey authored on 02/15/2016 21:18:36
Showing 1 changed files
... ...
@@ -159,6 +159,19 @@ var radmonDataUrl = "dynamic/radmonData.js";
159 159
 var httpRequest = new XMLHttpRequest();
160 160
 var graphPeriod;
161 161
 
162
+/* Chart elements */
163
+var cpmChart_g = document.getElementById("cpmChart");
164
+var uSvChart_g = document.getElementById("uSvChart");
165
+
166
+/* Text elements */
167
+var date_e = document.getElementById("date");    
168
+var time_e = document.getElementById("time"); 
169
+var cpm_e = document.getElementById("cpm");    
170
+var cps_e = document.getElementById("cps");    
171
+var uSvPerHr_e = document.getElementById("uSvPerHr");    
172
+var mode_e = document.getElementById("mode");    
173
+var status_e = document.getElementById("status");    
174
+
162 175
 function main() {
163 176
     getRadmonData();
164 177
     show_charts(1);
... ...
@@ -184,30 +197,26 @@ function show_charts(n) {
184 197
 
185 198
 function getRadmonGraphs() {
186 199
     var d = new Date;
200
+
187 201
     switch(graphPeriod) {
188 202
         case 1:
189
-            document.getElementById("cpmChart").src =
190
-                "dynamic/radGraph1.png?ver=" + d.getTime();
191
-            document.getElementById("uSvChart").src = 
192
-                "dynamic/radGraph2.png?ver=" + d.getTime();
203
+            cpmChart_g.src = "dynamic/radGraph1.png?ver=" + d.getTime();
204
+            uSvChart_g.src = "dynamic/radGraph2.png?ver=" + d.getTime();
193 205
             break;
194 206
         case 2:
195
-            document.getElementById("cpmChart").src = 
196
-                "dynamic/radGraph3.png?ver=" + d.getTime();
197
-            document.getElementById("uSvChart").src = 
198
-                "dynamic/radGraph4.png?ver=" + d.getTime();
207
+            cpmChart_g.src = "dynamic/radGraph3.png?ver=" + d.getTime();
208
+            uSvChart_g.src = "dynamic/radGraph4.png?ver=" + d.getTime();
199 209
             break;
200 210
        case 3:
201
-            document.getElementById("cpmChart").src = 
202
-                "dynamic/radGraph5.png?ver=" + d.getTime();
203
-            document.getElementById("uSvChart").src = 
204
-                "dynamic/radGraph6.png?ver=" + d.getTime();
211
+            cpmChart_g.src = "dynamic/radGraph5.png?ver=" + d.getTime();
212
+            uSvChart_g.src = "dynamic/radGraph6.png?ver=" + d.getTime();
205 213
             break;
206 214
     }
207 215
 }
208 216
 
209 217
 function displayData(dataItem) {
210
-    var timeStamp, date, time, hourminute, status;
218
+    var timeStamp, date, time, hourminute;
219
+    var localDateObj,localTimeZone;
211 220
 
212 221
     timeStamp = dataItem.date;
213 222
     date = timeStamp.split(" ")[0];
... ...
@@ -216,20 +225,18 @@ function displayData(dataItem) {
216 225
     localDateObj = new Date();
217 226
     localTimeZone = localDateObj.getTimezoneOffset() / 60;
218 227
     
219
-    document.getElementById("date").innerHTML = date;    
220
-    document.getElementById("time").innerHTML =  
221
-        hourminute + "  <small>(GMT+" + localTimeZone + ")</small>";    
222
-    document.getElementById("cpm").innerHTML =  dataItem.CPM;    
223
-    document.getElementById("cps").innerHTML =  dataItem.CPS;    
224
-    document.getElementById("uSvPerHr").innerHTML =  dataItem.uSvPerHr;    
225
-    document.getElementById("mode").innerHTML =  dataItem.Mode;    
226
-
227
-    status = dataItem.status;
228
-    document.getElementById("status").innerHTML = status;    
229
-    if (status == "online") {
230
-       document.getElementById("status").style.color = "green";
228
+    date_e.innerHTML = date;    
229
+    time_e.innerHTML = hourminute + "  <small>(GMT+" + localTimeZone + ")</small>";    
230
+    cpm_e.innerHTML = dataItem.CPM;    
231
+    cps_e.innerHTML = dataItem.CPS;    
232
+    uSvPerHr_e.innerHTML = dataItem.uSvPerHr;    
233
+    mode_e.innerHTML = dataItem.Mode;    
234
+
235
+    status_e.innerHTML = dataItem.status;    
236
+    if (dataItem.status == "online") {
237
+       status_e.style.color = "green";
231 238
     } else {
232
-       document.getElementById("status").style.color = "red";
239
+       status_e.style.color = "red";
233 240
     }
234 241
 }
235 242