Changeset 468 in tmcsimulator for trunk/webapps/einotebook/scripts


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.

Location:
trunk/webapps/einotebook/scripts
Files:
4 edited

Legend:

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

    r418 r468  
    324324} 
    325325 
    326  
    327326/** 
    328327 * Finds the Event that was last executed by based on given time. 
  • trunk/webapps/einotebook/scripts/Incident.js

    r359 r468  
    1717        //========== public methods ==========// 
    1818        this.html = html; 
    19         this.expandAction = expandAction; 
     19    this.setSummary = setSummary; 
    2020         
    2121        //========== private methods ==========// 
    2222        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    /** 
    2631        /** 
    2732         * @return The html representation of this incident; 
     
    3540                           "<tr>" +  
    3641                           "<td class='incidentSummary' id='summary" + this.number + "'>" +  
    37                              (this.expanded ? this.summary : "") + "</td>" + 
     42                             this.summary + "</td>" + 
    3843                           "</tr>" +  
    3944                           "</table>"; 
     
    5055                return "<table class='incidentHeader'>" + 
    5156                                "<tr class='incidentHeader'>" + 
    52                                 "<td class='incidentExpandOption'>" + this.expandOption() + "</td>" + 
     57                                "<td class='incidentExpandOption'></td>" + 
    5358                                "<td class='incidentTime'>Time: " + this.time.format() + "</td>" + 
    5459                                "<td class='incidentNumber'>" + this.number + "</td>" + 
     
    5863        } 
    5964         
    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         } 
    7065         
    71         /** 
    72          * Returns the symbol for the expand option. 
    73          * @return Either "+" or "-" depending on whether this incidents is collapsed or  
    74          *         expanded. 
    75          */ 
    76         function expandOptionSymbol() 
    77         { 
    78                 return this.expanded == true ? "&ndash;" : "+"; 
    79         } 
    80          
    81         /** 
    82          * Performs the action of clicking on the + or - symbol that expands or collapses  
    83          * 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                 else 
    93                 { 
    94                         incidents.doc.getElementById("summary" + this.number).innerHTML =  
    95                                 this.summary; 
    96                         incidents.doc.getElementById("expandOption" + this.number).innerHTML =  
    97                                 "&ndash;"; 
    98                 } 
    99                  
    100                 this.expanded = !this.expanded; 
    101                  
    102         } 
    10366} 
  • trunk/webapps/einotebook/scripts/Incidents.js

    r359 r468  
    1010//========== public methods ==========// 
    1111incidents.get = incidents_get; 
    12 incidents.collapseAll = incidents_collapseAll; 
    13 incidents.expandAll = incidents_expandAll; 
    1412incidents.add = incidents_add; 
    1513 
     
    3836 
    3937/** 
    40  * Collapses each Incident. 
    41  */ 
    42 function incidents_collapseAll() 
    43 { 
    44         // FOR each incident 
    45         for (var i = 0; i < this.length; i++) 
    46         { 
    47                 // IF the incident is expanded THEN 
    48                 if (this[i].expanded) 
    49                 { 
    50                         // collapse incident 
    51                         this[i].expandAction(); 
    52                 } 
    53         } 
    54 } 
    55  
    56 /** 
    57  * Expands each incident. 
    58  */ 
    59 function incidents_expandAll() 
    60 { 
    61         // FOR each incident 
    62         for (var i = 0; i < this.length; i++) 
    63         { 
    64                 // IF incident is collapsed THEN 
    65                 if (!this[i].expanded) 
    66                 { 
    67                         // expand incident 
    68                         this[i].expandAction(); 
    69                 } 
    70         } 
    71 } 
    72  
    73 /** 
    7438 * Adds an Incident. 
    7539 * @param incident {Incident} The Incident to be added. 
  • 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.