Changeset 468 in tmcsimulator for trunk/webapps/einotebook/scripts/LoadEvents.js


Ignore:
Timestamp:
07/28/2019 05:27:26 AM (7 years ago)
Author:
jdalbey
Message:

einotebook - multifile commit. Redesign to fix timing problem on some machines as well as improve file naming. Fixed #176.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/webapps/einotebook/scripts/LoadEvents.js

    r434 r468  
    99    var xmlDoc = parser.parseFromString(response,"text/xml"); 
    1010    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."); 
    1212    // Process each SCRIPT_EVENT tag 
    1313    for (var i = 0; i < eventTags.length; i++) 
     
    3333                        break; 
    3434                    case "INCIDENT": 
    35                         incidentNum = Number(currEvt.childNodes[child].attributes["LogNum"].value); 
    36                         incidentTitle =  currEvt.childNodes[child].textContent; 
    37                         break; 
    38                     case "GENERAL_INFO":   
    3935                        /* This tag identifies a new incident.  As long as it appears before any 
    4036                        other tags, we can use it to create a new incident. (The alternative is to 
     
    4238                        we load events.)  Creating an event (below) requires that the incident has already 
    4339                        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 
    4453                        var desc = currEvt.childNodes[child].getElementsByTagName("TEXT")[0].textContent; 
    45                         var theIncident = new Incident(evtTime, incidentNum, incidentTitle, desc); 
    46                         incidents.add(theIncident); 
    47                         // Create an entry showing the Incident start description. Fixes ticket #164 
     54                        incidentToUpdate = incidents.get(incidentNum); 
     55                        incidentToUpdate.setSummary(desc);                         
     56                        // Create an entry showing the Incident start description. Fixes ticket #164 
    4857                        var result = new Array();    
    4958                        result.push("Description:"); 
    50                         result.push(desc); 
     59                        result.push(desc); 
    5160                        proparray.push(new Property("Incident Start",result)); 
    5261                        break; 
     
    101110                } 
    102111            } 
    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); 
    105114        // Ignore Media Log incident and empty nodes 
    106115        if (incidentNum != undefined && incidentNum != 100) 
     
    111120                new Evaluations(evalarray)) ); 
    112121        } 
    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(); 
    114127} 
    115128 
     
    208221    return result; 
    209222} 
    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 
     224function 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.