Changeset 468 in tmcsimulator for trunk/webapps/einotebook/scripts/LoadEvents.js
- Timestamp:
- 07/28/2019 05:27:26 AM (7 years ago)
- File:
-
- 1 edited
-
trunk/webapps/einotebook/scripts/LoadEvents.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/webapps/einotebook/scripts/LoadEvents.js
r434 r468 9 9 var xmlDoc = parser.parseFromString(response,"text/xml"); 10 10 var eventTags = xmlDoc.getElementsByTagName("SCRIPT_EVENT"); 11 console.log("parsing incident xml file ");11 console.log("parsing incident xml file containing "+eventTags.length+" event tags."); 12 12 // Process each SCRIPT_EVENT tag 13 13 for (var i = 0; i < eventTags.length; i++) … … 33 33 break; 34 34 case "INCIDENT": 35 incidentNum = Number(currEvt.childNodes[child].attributes["LogNum"].value);36 incidentTitle = currEvt.childNodes[child].textContent;37 break;38 case "GENERAL_INFO":39 35 /* This tag identifies a new incident. As long as it appears before any 40 36 other tags, we can use it to create a new incident. (The alternative is to … … 42 38 we load events.) Creating an event (below) requires that the incident has already 43 39 been created. */ 40 incidentNum = Number(currEvt.childNodes[child].attributes["LogNum"].value); 41 // If this incident number doesn't exist 42 if (incidents.get(incidentNum) == undefined) 43 { 44 incidentTitle = currEvt.childNodes[child].textContent; 45 // Construct the incident 46 var theIncident = new Incident(evtTime, incidentNum, incidentTitle, ""); 47 // Add the incident to the list of incidents 48 incidents.add(theIncident); 49 } 50 break; 51 case "GENERAL_INFO": 52 // Add the summary description to the incident 44 53 var desc = currEvt.childNodes[child].getElementsByTagName("TEXT")[0].textContent; 45 var theIncident = new Incident(evtTime, incidentNum, incidentTitle, desc);46 incident s.add(theIncident);47 // Create an entry showing the Incident start description. Fixes ticket #16454 incidentToUpdate = incidents.get(incidentNum); 55 incidentToUpdate.setSummary(desc); 56 // Create an entry showing the Incident start description. Fixes ticket #164 48 57 var result = new Array(); 49 58 result.push("Description:"); 50 result.push(desc);59 result.push(desc); 51 60 proparray.push(new Property("Incident Start",result)); 52 61 break; … … 101 110 } 102 111 } 103 } 104 // console.log(evtTime.format(), incidentNum, proparray.length, evalarray.length);112 }//end one event 113 // console.log(evtTime.format(), incidentNum, proparray.length, evalarray.length); 105 114 // Ignore Media Log incident and empty nodes 106 115 if (incidentNum != undefined && incidentNum != 100) … … 111 120 new Evaluations(evalarray)) ); 112 121 } 113 } 122 }// end all events 123 console.log("Done parsing xml, " + events.length + " events and " +incidents.length + " incidents saved."); 124 125 // NOW THAT WE HAVE THE EVENT LIST WE CAN PERFORM SETUP 126 setupNotebook(); 114 127 } 115 128 … … 208 221 return result; 209 222 } 210 // MAIN 211 //console.log("starting LoadEvents"); 212 try { 213 // the script must be located where accessible by the web server 214 var scriptFilename = "../dynamicdata/incident_script.xml"; 215 console.log("Attempting to load ", scriptFilename); 216 // Now load the Incident Script and go parse it 217 loadJSON(scriptFilename, parseXml) 218 219 } catch(e) { 220 console.log("Error attempt to parse incident script "+response) 221 } 222 223 223 // MAIN ENTRY POINT for this application 224 function init() 225 { 226 try { 227 // the script must be located where accessible by the web server 228 var scriptFilename = "../dynamicdata/incident_script.xml"; 229 console.log("LoadEvents.js main Attempting to load ", scriptFilename); 230 // Now load the Incident Script and go parse it 231 // NB: This is an async function, so all other notebook setup must be in the callback. 232 loadJSON(scriptFilename, parseXml) 233 234 } catch(e) { 235 console.log("Error attempting to parse incident script "+response) 236 } 237 } 238
Note: See TracChangeset
for help on using the changeset viewer.
