Changeset 468 in tmcsimulator for trunk/webapps/einotebook/scripts
- Timestamp:
- 07/28/2019 05:27:26 AM (7 years ago)
- Location:
- trunk/webapps/einotebook/scripts
- Files:
-
- 4 edited
-
Events.js (modified) (1 diff)
-
Incident.js (modified) (4 diffs)
-
Incidents.js (modified) (2 diffs)
-
LoadEvents.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/webapps/einotebook/scripts/Events.js
r418 r468 324 324 } 325 325 326 327 326 /** 328 327 * Finds the Event that was last executed by based on given time. -
trunk/webapps/einotebook/scripts/Incident.js
r359 r468 17 17 //========== public methods ==========// 18 18 this.html = html; 19 this.expandAction = expandAction;19 this.setSummary = setSummary; 20 20 21 21 //========== private methods ==========// 22 22 this.formatHeader = formatHeader; 23 this.expandOption = expandOption; 24 this.expandOptionSymbol = expandOptionSymbol; 25 23 24 /** Setter for summary field */ 25 function setSummary(description) 26 { 27 this.summary = description; 28 } 29 30 /** 26 31 /** 27 32 * @return The html representation of this incident; … … 35 40 "<tr>" + 36 41 "<td class='incidentSummary' id='summary" + this.number + "'>" + 37 (this.expanded ? this.summary : "")+ "</td>" +42 this.summary + "</td>" + 38 43 "</tr>" + 39 44 "</table>"; … … 50 55 return "<table class='incidentHeader'>" + 51 56 "<tr class='incidentHeader'>" + 52 "<td class='incidentExpandOption'> " + this.expandOption() + "</td>" +57 "<td class='incidentExpandOption'></td>" + 53 58 "<td class='incidentTime'>Time: " + this.time.format() + "</td>" + 54 59 "<td class='incidentNumber'>" + this.number + "</td>" + … … 58 63 } 59 64 60 /**61 * @return The html that for the + or - symbol that expands or collapses the incident.62 */63 function expandOption()64 {65 return "<button class='incidentExpandButton' " +66 "id='expandOption" + this.number + "' onclick='incidents.get(" +67 this.number + ").expandAction()'>" + this.expandOptionSymbol() +68 "</button>";69 }70 65 71 /**72 * Returns the symbol for the expand option.73 * @return Either "+" or "-" depending on whether this incidents is collapsed or74 * expanded.75 */76 function expandOptionSymbol()77 {78 return this.expanded == true ? "–" : "+";79 }80 81 /**82 * Performs the action of clicking on the + or - symbol that expands or collapses83 * the incident.84 */85 function expandAction()86 {87 if (this.expanded)88 {89 incidents.doc.getElementById("summary" + this.number).innerHTML = "";90 incidents.doc.getElementById("expandOption" + this.number).innerHTML = "+";91 }92 else93 {94 incidents.doc.getElementById("summary" + this.number).innerHTML =95 this.summary;96 incidents.doc.getElementById("expandOption" + this.number).innerHTML =97 "–";98 }99 100 this.expanded = !this.expanded;101 102 }103 66 } -
trunk/webapps/einotebook/scripts/Incidents.js
r359 r468 10 10 //========== public methods ==========// 11 11 incidents.get = incidents_get; 12 incidents.collapseAll = incidents_collapseAll;13 incidents.expandAll = incidents_expandAll;14 12 incidents.add = incidents_add; 15 13 … … 38 36 39 37 /** 40 * Collapses each Incident.41 */42 function incidents_collapseAll()43 {44 // FOR each incident45 for (var i = 0; i < this.length; i++)46 {47 // IF the incident is expanded THEN48 if (this[i].expanded)49 {50 // collapse incident51 this[i].expandAction();52 }53 }54 }55 56 /**57 * Expands each incident.58 */59 function incidents_expandAll()60 {61 // FOR each incident62 for (var i = 0; i < this.length; i++)63 {64 // IF incident is collapsed THEN65 if (!this[i].expanded)66 {67 // expand incident68 this[i].expandAction();69 }70 }71 }72 73 /**74 38 * Adds an Incident. 75 39 * @param incident {Incident} The Incident to be added. -
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.
