Changeset 468 in tmcsimulator for trunk/webapps/einotebook/notebook.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/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";  
Note: See TracChangeset for help on using the changeset viewer.