| 1 | <!DOCTYPE html> |
|---|
| 2 | <html> |
|---|
| 3 | <head> |
|---|
| 4 | <!-- Launch with python -m CGIHTTPServer 80 --> |
|---|
| 5 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> |
|---|
| 6 | <title>CMS Monitor v0.1</title> |
|---|
| 7 | <style> |
|---|
| 8 | html, body { |
|---|
| 9 | height: 100%; |
|---|
| 10 | margin: 0; |
|---|
| 11 | padding: 0; |
|---|
| 12 | background-color: darkgray; |
|---|
| 13 | } |
|---|
| 14 | </style> |
|---|
| 15 | </head> |
|---|
| 16 | <body> |
|---|
| 17 | Active CMS Messages |
|---|
| 18 | <div id="msgs"></div> |
|---|
| 19 | <script src="js/common.js"></script> |
|---|
| 20 | <script> |
|---|
| 21 | var cmsLocations = {}; |
|---|
| 22 | // Load the CMS locations from the geojson file |
|---|
| 23 | function loadCMSlocations() |
|---|
| 24 | { |
|---|
| 25 | loadJSON("data_layers/cms_locations_D12.gjson", function(response) |
|---|
| 26 | { |
|---|
| 27 | // Parse JSON string into object |
|---|
| 28 | var cmsjson = JSON.parse(response); |
|---|
| 29 | for (var i = 0; i < cmsjson.features.length; i++) |
|---|
| 30 | { |
|---|
| 31 | var item = cmsjson.features[i]; |
|---|
| 32 | // Add each item to a lookup dictionary |
|---|
| 33 | cmsLocations[item.id] = item; |
|---|
| 34 | } |
|---|
| 35 | }); |
|---|
| 36 | } |
|---|
| 37 | // Load the file of CMS messages |
|---|
| 38 | function loadAllcmsMessages() |
|---|
| 39 | { |
|---|
| 40 | var display = document.getElementById("msgs"); |
|---|
| 41 | display.innerHTML = "" |
|---|
| 42 | loadJSON("cms_messages.json", function(response) |
|---|
| 43 | { |
|---|
| 44 | // Parse JSON string into object |
|---|
| 45 | messagejson = JSON.parse(response); |
|---|
| 46 | // Consider each message |
|---|
| 47 | for (var i = 0; i < messagejson.data.length; i++) |
|---|
| 48 | { |
|---|
| 49 | var item = messagejson.data[i]; |
|---|
| 50 | // Find the location for this message |
|---|
| 51 | var cmsLoc = cmsLocations[item.cms.index]; |
|---|
| 52 | // Build the message display |
|---|
| 53 | var current = (item.cms.message.phase1.Line1 + ":" + |
|---|
| 54 | item.cms.message.phase1.Line2 + ":" + |
|---|
| 55 | item.cms.message.phase1.Line3 + ":" + |
|---|
| 56 | item.cms.message.phase2.Line1 + ":" + |
|---|
| 57 | item.cms.message.phase2.Line2 + ":" + |
|---|
| 58 | item.cms.message.phase2.Line3) |
|---|
| 59 | // If the message isn't blank, append it to the div |
|---|
| 60 | if (current != ":::::") |
|---|
| 61 | { |
|---|
| 62 | display.innerHTML += "<br>" + item.cms.index + ": " + |
|---|
| 63 | cmsLoc.properties.location + " " + cmsLoc.properties.street; |
|---|
| 64 | display.innerHTML += "<br>" + current; |
|---|
| 65 | } |
|---|
| 66 | } |
|---|
| 67 | }); |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | // Start |
|---|
| 71 | loadCMSlocations(); |
|---|
| 72 | loadAllcmsMessages(); |
|---|
| 73 | // start an interval timer to refresh the cms icons every 10 seconds |
|---|
| 74 | var cmsTimer = setInterval(loadAllcmsMessages, 10000); |
|---|
| 75 | |
|---|
| 76 | </script> |
|---|
| 77 | </body> |
|---|
| 78 | </html> |
|---|