Changeset 468 in tmcsimulator for trunk


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
Files:
12 added
9 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/webapps/einotebook/index.html

    r401 r468  
    2121    <script type="text/javascript" src="scripts/Incident.js"></script> 
    2222    <script type="text/javascript" src="scripts/Incidents.js"></script> 
    23     <script type="text/javascript" src="scripts/LoadEvents.js"></script>  
    24     <!--script type="text/javascript" src="scripts/PopulateIncidents.js"></script--> 
    25     <!--script type="text/javascript" src="scripts/PopulateEvents.js"></script--> 
    2623    <script type="text/javascript" src="summary/summary.js"></script>  
    2724    <script type="text/javascript" src="notebook.js"></script>  
     25    <!-- LoadEvents contains init() function, the main entry point --> 
     26    <script type="text/javascript" src="scripts/LoadEvents.js"></script>  
    2827  </head> 
    29   <body onLoad="showRevision(); setupNotebook(); run();"> 
     28  <body onLoad="showRevision(); init()"> 
    3029     
    3130    <table class="notebook"> 
    32      <!-- The header which contains the number of evaluations, simulation status,  
    33                and time  
    34       <tr style="height: 20px"> 
    35         <td> 
    36           <table class="header">      
    37             <tr> 
    38              
    39               <td class="updateStatusBox"> 
    40                 <table> 
    41                   <tr> 
    42                     <td class="updateStatus" id="updateStatus">New Event</td> 
    43                   </tr> 
    44                 </table> 
    45               </td> 
    46          
    47               <td class="statusBox"> 
    48                 <center><table> 
    49                   <tr> 
    50                     <td class="simulationStatus" id="simulationStatus">NOT STARTED</td> 
    51                   </tr> 
    52                 </table></center> 
    53               </td>  
    54  
    55               <td class="simulationTime" id="simulationTime"> 
    56                 0:00:00 
    57               </td> 
    58  
    59             </tr> 
    60           </table> 
    61         </td> 
    62       </tr> 
    63 --> 
    6431      <tr style="height: 80px"> 
    6532        <td colspan='3' class="tabMenu"> 
     
    7744              Simulation Script 
    7845            </li> 
    79             <li class="notActive" id="CADTab"  
    80                 onClick="changeTab(this.id); showContent('cadPageContent')"> 
     46            <li class="notActive" id="currentTab"  
     47                onClick="changeTab(this.id); showContent('currentEventPageContent')"> 
    8148              Current Event 
    8249            </li> 
     
    9461      <tr> 
    9562            <td class='tabPageContent' id='summaryPageContent' style="display:inline"> 
    96             <iframe id='summaryTabPage' src='summary/summary.html' frameborder='0' scrolling='yes' 
    97                     height='100%' width='100%' 
    98                     onLoad='incidents.doc = getDocumentFromFrame(&quot;summaryTabPage&quot;); 
    99                     window.frames[0].loadSummary(incidents);'></iframe> 
     63            <iframe id='summaryTabPage' src='summary/index.html' frameborder='0' scrolling='yes' 
     64                    height='100%' width='100%'> 
     65            </iframe> 
    10066                  </td> 
    10167          <td class='tabPageContent' id='scriptPageContent' style="display:none;"> 
    102             <iframe id='tabPage' src='script/script.html' frameborder='0'  
    103             scrolling='yes' height='100%' width='100%' 
    104             onLoad='window.frames[1].loadScript(events, incidents);' 
    105             > 
     68            <iframe id='tabPage' src='script/index.html' frameborder='0'  
     69            scrolling='yes' height='100%' width='100%'> 
    10670                    </iframe> 
    10771                  </td> 
    108                   <td class='tabPageContent' id='cadPageContent' style="display:none;"> 
    109                     <iframe src='cad/index.html' frameborder='0'  
    110              scrolling='yes' height='100%' width='100%'  
    111             onLoad='window.frames[2].loadScript(events, incidents);'> 
     72                  <td class='tabPageContent' id='currentEventPageContent' style="display:none;"> 
     73                    <iframe id='currentEventPage' src='currentEvent/index.html' frameborder='0'  
     74             scrolling='yes' height='100%' width='100%'>  
    11275                    </iframe> 
    11376                  </td> 
    11477          <td class='tabPageContent' id='mapsPageContent' style="display:none;"> 
    11578            <iframe src='maps/index.html' frameborder='0'  
    116                              scrolling='no' height='100%' width='100%' > 
     79            scrolling='no' height='100%' width='100%' > 
    11780                    </iframe> 
    11881          </td> 
  • trunk/webapps/einotebook/notebook.js

    r415 r468  
    1 /* 
    2 function loadXMLDoc() 
    3 { 
    4   if (window.XMLHttpRequest) 
    5   { 
    6     xmlhttp = new XMLHttpRequest(); 
    7   } 
    8   else 
    9   { 
    10     xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
    11   } 
    12  
    13   xmlhttp.onreadystatechange=function() 
    14   { 
    15     if (xmlhttp.readyState==4 && xmlhttp.status==200) 
    16     { 
    17       document.getElementById("myDiv").innerHTML = xmlhttp.responseText; 
    18     } 
    19   } 
    20    
    21   xmlhttp.open("GET", "ajax_info.txt", true); 
    22   xmlhttp.send(""); 
    23 } 
    24 */ 
    25  
    261/** 
    272 * Sets the selected tab to the summary tab and loads the summary page. 
     
    316{ 
    327   console.log("setupNotebook() starting"); 
    33    changeTab('summaryTab'); 
     8   changeTab('summaryTab');  // Initially show Summary tab 
    349   showContent('summaryPageContent') 
    35    loadSummary(); 
     10   loadSummaryPage(); 
     11   loadPages(); 
    3612   setCookie("time", "0"); 
    3713   setCookie("scriptScrollY", 0); 
    3814   setCookie("summaryScrollY", 0); 
     15   run();  // start the script scrolling 
    3916} 
    4017 
    4118/** 
    42  * Runs the script. 
     19 * Loads the summary tab page; 
     20 */ 
     21function loadSummaryPage() 
     22{           
     23    incidents.doc = getDocumentFromFrame('summaryTabPage'); 
     24    window.frames[0].loadSummary(incidents);  
     25} 
     26 
     27/** 
     28 * Loads content of the pages for Simulation Script and Current Event 
     29 */ 
     30function loadPages() 
     31{ 
     32   window.frames[1].loadScript(events, incidents); 
     33   window.frames[2].loadScript(events, incidents); 
     34} 
     35 
     36/** 
     37 * Start scrolling the script in an infinite loop. 
    4338 */ 
    4439function run() 
    4540{ 
    4641        run.initialDelay = 1000; 
    47          
    4842        setTimeout("run.run()", run.initialDelay); 
    4943         
    5044        run.run = function() 
    5145        { 
    52 //          document.getElementById("simulationStatus").innerHTML = "RUNNING";                  
    5346                setTime(); 
    54                 updateStatus(); 
    5547        }; 
    56 } 
    57  
    58 /** 
    59  * Displays fading text alerts in the status box (left-top corner). 
    60  */ 
    61 function updateStatus() 
    62 { 
    63         // IF last event if it has not been set before THEN 
    64     if (typeof updateStatus.lastEvent == 'undefined') 
    65     { 
    66         updateStatus.lastEvent = null; 
    67     } 
    68     
    69     var latestEvent = events.getLastExecutedEvent(readCookie("time")); 
    70      
    71      
    72     // IF a new event executed THEN 
    73     if (updateStatus.lastEvent != latestEvent) 
    74     { 
    75       var i; 
    76       for (i=0; i<latestEvent.length; i++) { 
    77           // IF the new event has evaluations THEN 
    78         if (latestEvent[i].evaluations.evaluations.length == 0) 
    79         { 
    80   //                    document.getElementById('updateStatus').innerHTML = "New Event"; 
    81         } 
    82         else 
    83         { 
    84   //                    document.getElementById('updateStatus').innerHTML = "New Evaluation"; 
    85         } 
    86       } 
    87                  
    88          
    89                 // fades the text 
    90                 updateStatus.fade = function fade() 
    91                 { 
    92                         // IF the fade color is not black yet THEN 
    93                 if (fade.hex < 255) 
    94                 { 
    95                         fade.hex += 5; 
    96 //                      document.getElementById('updateStatus').style.color =  
    97                                 "rgb(" + fade.hex + ", " + fade.hex + ", " + fade.hex + ")";   
    98                         setTimeout("updateStatus.fade()", 100);  
    99                 } 
    100                 else 
    101                 { 
    102 //                      document.getElementById('updateStatus').style.color = "white"; 
    103                 } 
    104  
    105                 }; 
    106          
    107                 updateStatus.fade.hex = 0; 
    108                 updateStatus.fade(); 
    109         updateStatus.lastEvent = latestEvent; 
    110     } 
    111      
    112     setTimeout("updateStatus();", 1000); 
    11348} 
    11449 
     
    12964            setTime.time = seconds; 
    13065                // increment time by one second (or initialize it if it has not been set before) 
    131     //      setTime.time = (typeof setTime.time == 'undefined') ? 0 : ++setTime.time; 
     66            //      setTime.time = (typeof setTime.time == 'undefined') ? 0 : ++setTime.time; 
    13267 
    13368            setCookie("time", "" + setTime.time); 
     
    15287    document.getElementById("summaryTab").className = "notActive"; 
    15388    document.getElementById("scriptTab").className = "notActive"; 
    154     document.getElementById("CADTab").className = "notActive"; 
     89    document.getElementById("currentTab").className = "notActive"; 
    15590    document.getElementById("mapsTab").className = "notActive"; 
    15691 
    15792    /* Set the selected tab to being active */ 
    15893    document.getElementById(id).className = "activeTab"; 
    159 } 
    160  
    161 /** 
    162  * Loads the script tab page; 
    163  */ 
    164 function loadScript() 
    165 { 
    166 } 
    167  
    168 /** 
    169  * Loads the summary tab page; 
    170  */ 
    171 function loadSummary() 
    172 {           
    17394} 
    17495 
     
    204125    hideContent('summaryPageContent'); 
    205126    hideContent('scriptPageContent'); 
    206     hideContent('cadPageContent'); 
     127    hideContent('currentEventPageContent'); 
    207128    hideContent('mapsPageContent');     
    208129    document.getElementById(d).style.display = "block";  
  • 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 
  • trunk/webapps/einotebook/summary/summary.js

    r359 r468  
     1/** functions for Incident Summary page */ 
    12var incidents; 
    23 
Note: See TracChangeset for help on using the changeset viewer.