- Timestamp:
- 04/11/2019 10:35:31 AM (7 years ago)
- Location:
- trunk/webapps/EInotebook
- Files:
-
- 6 edited
-
index.html (modified) (3 diffs)
-
notebook.js (modified) (2 diffs)
-
scripts/Event.js (modified) (1 diff)
-
scripts/Events.js (modified) (1 diff)
-
scripts/LoadEvents.js (modified) (5 diffs)
-
scripts/PopulateIncidents.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/webapps/EInotebook/index.html
r359 r363 1 1 <html> 2 2 <head> 3 <title>Electronic Instructor Notebook v0. 1</title>3 <title>Electronic Instructor Notebook v0.2</title> 4 4 <meta name="apple-mobile-web-app-capable" content="yes"> 5 5 <meta name="viewport" content="width=device-width; initial-scale=1.0; user-scalable=0;"> … … 8 8 <link rel="stylesheet" type="text/css" href="notebook.css"> 9 9 <link rel="stylesheet" type="text/css" href="ipadapp.css"> 10 <script type="text/javascript" src="../js/common.js"></script> 10 11 <script type="text/javascript" src="scripts/cookies.js"></script> 11 12 <script type="text/javascript" src="scripts/Events.js"></script> … … 18 19 <script type="text/javascript" src="scripts/Incident.js"></script> 19 20 <script type="text/javascript" src="scripts/Incidents.js"></script> 21 <script type="text/javascript" src="scripts/LoadEvents.js"></script> 20 22 <script type="text/javascript" src="scripts/PopulateIncidents.js"></script> 21 23 <!--script type="text/javascript" src="scripts/PopulateEvents.js"></script--> 22 24 <script type="text/javascript" src="summary/summary.js"></script> 23 25 <script type="text/javascript" src="notebook.js"></script> 24 <script type="text/javascript" src="scripts/LoadEvents.js"></script>25 26 </head> 26 27 <body onLoad="setupNotebook(); run();"> -
trunk/webapps/EInotebook/notebook.js
r359 r363 30 30 function setupNotebook() 31 31 { 32 console.log("setupNotebook() starting"); 32 33 changeTab('summaryTab'); 33 34 showContent('summaryPageContent') … … 138 139 }); 139 140 } 140 // Load the dynamic json file for highways, etc.141 function loadJSON(inFile, callback)142 {143 var xobj = new XMLHttpRequest();144 // Assume XML unless filename ends with .json145 if (inFile.endsWith(".json"))146 {147 xobj.overrideMimeType("application/json");148 }149 xobj.open('GET', inFile, true);150 xobj.onreadystatechange = function()151 {152 if (xobj.readyState == 4 && xobj.status == "200")153 {154 callback(xobj.responseText);155 }156 };157 // We want ajax to ignore any cached responses158 xobj.setRequestHeader('If-Modified-Since', 'Sat, 01 Jan 2000 01:01:01 GMT')159 xobj.send(null);160 }161 141 /** 162 142 * Selects a new tab to be viewed. -
trunk/webapps/EInotebook/scripts/Event.js
r359 r363 50 50 189: "#ffe680", // CornSilk 51 51 190: "MistyRose", 52 191: "Moccasin" } 52 191: "Moccasin", 53 181: "PowderBlue" } 53 54 54 55 -
trunk/webapps/EInotebook/scripts/Events.js
r359 r363 309 309 { 310 310 var event = null; 311 311 if (this.length == 0) 312 { 313 console.log("Error: event list is empty in getLastExecutedEvent"); 314 return; 315 } 312 316 // IF there is only one event and it has been executed THEN 313 317 if (this.length == 1 && this[0].time.getSeconds() <= time) -
trunk/webapps/EInotebook/scripts/LoadEvents.js
r361 r363 1 var xmlDoc; 2 function loadJSON(inFile, callback) 3 { 4 var xobj = new XMLHttpRequest(); 5 // Assume XML unless filename ends with .json 6 if (inFile.endsWith(".json")) 7 { 8 xobj.overrideMimeType("application/json"); 9 } 10 xobj.open('GET', inFile, true); 11 xobj.onreadystatechange = function() 12 { 13 if (xobj.readyState == 4 && xobj.status == "200") 14 { 15 callback(xobj.responseText); 16 } 17 }; 18 // We want ajax to ignore any cached responses 19 xobj.setRequestHeader('If-Modified-Since', 'Sat, 01 Jan 2000 01:01:01 GMT') 20 xobj.send(null); 21 } 1 22 2 23 3 // Parse the entire Incident XML Script file … … 27 7 // Create a parser and grab the high level tag we're interested in 28 8 var parser = new DOMParser(); 29 xmlDoc = parser.parseFromString(response,"text/xml");9 var xmlDoc = parser.parseFromString(response,"text/xml"); 30 10 var eventTags = xmlDoc.getElementsByTagName("SCRIPT_EVENT"); 31 11 console.log("parsing incident xml file"); 32 12 // Process each SCRIPT_EVENT tag 33 13 for (var i = 0; i < eventTags.length; i++) … … 54 34 incidentNum = Number(currEvt.childNodes[child].attributes["LogNum"].value); 55 35 break; 56 case "GENERAL_INFO": break; 36 case "GENERAL_INFO": 37 /* This tag identifies a new incident. As long as it appears before any 38 other tags, we can use it to create a new incident. (The alternative is to 39 have a separate function that parses xml to extract incidents before 40 we load events.) Creating an event (below) requires that the incident has already 41 been created. */ 42 break; 57 43 case "CAD_DATA": 58 44 var caddata = parseCAD(currEvt.childNodes[child]); … … 84 70 } 85 71 //console.log(evtTime.format(), incidentNum, proparray.length, evalarray.length); 86 if (incidentNum != undefined) 72 // Ignore Media Log incident and empty nodes 73 if (incidentNum != undefined && incidentNum != 100) 87 74 { 88 events.add(new Event(evtTime, incidents.get(incidentNum), new Properties(proparray), 75 // Create new event with fields obtained from xml file 76 events.add(new Event(evtTime, incidents.get(incidentNum), 77 new Properties(proparray), 89 78 new Evaluations(evalarray)) ); 90 79 } 91 80 } 81 } 92 82 93 }94 83 function parseCAD(element) 95 84 { … … 148 137 149 138 // MAIN 150 loadJSON("full_script.xml", parseXml) 151 // Note: the script has the Media Log event removed 139 console.log("starting LoadEvents"); 140 /** Load the sim script name file and extract the filename of the Incident Script */ 141 loadJSON("../sim_scriptname.json", function(response) 142 { 143 console.log("scriptname file loaded"); 144 try { 145 var scriptnamejson = JSON.parse(response); 146 // For now the script must be located in the EInotebook folder. 147 // It would be better to use the file located in trunk/scripts folder. 148 var scriptFilename = scriptnamejson.filename; 149 console.log("Attempting to load", scriptFilename); 150 // Now load the Incident Script and go parse it 151 loadJSON(scriptFilename, parseXml) 152 152 153 } catch(e) { 154 console.log("Error attempt to parse sim_scriptname.json: "+response) 155 } 156 }); 157 -
trunk/webapps/EInotebook/scripts/PopulateIncidents.js
r359 r363 5 5 incidents.add(new Incident(new Time(1, 51, 0), 190, "Tanker Truck vs. Car/Spill", "Incident Description - This is a collision involving a tanker truck and a car that block the #3 and 4 lanes on NB I-5 just north of Main Street. There are 2 minor injured and 1 major injured. Liquid is leaking out of the tanker truck which is identified as milk. The leak is plugged and the fire department sprays the milk down the drain. The fire department, ambulance, additional units, TMT, a big rig tow, and a rotational tow are sent to the scene.")); 6 6 incidents.add(new Incident(new Time(2, 17, 0), 191, "RV Fire", "This is an RV fire on the shoulder southbound 73 just north of Bear/Baker Street. There are two injured victims who were pulled from the RV by passers-by. The #3 is closed to fight the fire. The fire department, paramedics, an extra unit, sign truck/s, and ambulance are sent to the scene.")); 7 // Practice Incident 8 incidents.add(new Incident(new Time(0,0,0), 181, "Overturned Hay Truck", "This is a three-vehicle collision involving a hay truck and two cars blocking the #1, 2, and 3 lanes on NB 405 just south of MacArthur Boulevard. The truck spills hay over the #2 and 3 lanes. There is one 11-44 and two minor injured. Ambulance, fire, paramedics, additional units, Maintenance, and coroner are requested on this incident."));
Note: See TracChangeset
for help on using the changeset viewer.
