Changeset 415 in tmcsimulator for trunk/webapps/einotebook


Ignore:
Timestamp:
06/18/2019 10:44:53 AM (7 years ago)
Author:
jdalbey
Message:

einotebook fix to #131

Location:
trunk/webapps/einotebook
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/webapps/einotebook/cad/cad.js

    r359 r415  
    1515 
    1616/** 
    17  * Updates the CAD screen. 
     17 * Updates the current event tab. 
    1818 */ 
    1919function updateCad() 
     
    2121    // Set timer to do this again in one second 
    2222        setTimeout("updateCad()", 1000); 
    23  
    24         var currentEvent = events.getLastExecutedEvent(readCookie("time")); 
     23     
     24    var currentEvent = events.getLastExecutedEvent(readCookie("time")); 
     25    //console.log("length " + currentEvent.length); 
    2526    // Show current event to Current Event Window 
    2627    var currDiv = document.getElementById("cadpadcontent"); 
    27         currDiv.innerHTML = currentEvent.html(); 
     28    // empty holder for display current events  
     29    var display = ""; 
     30    var evt; 
     31     
     32    // get all the current events  
     33    for (evt=0; evt<currentEvent.length; evt++) { 
     34        display += currentEvent[evt].html(); 
     35    } 
    2836 
     37    currDiv.innerHTML = display; 
    2938} 
  • trunk/webapps/einotebook/notebook.js

    r373 r415  
    7373    if (updateStatus.lastEvent != latestEvent) 
    7474    { 
    75                 // IF the new event has evaluations THEN 
    76         if (latestEvent.evaluations.evaluations.length == 0) 
    77         { 
    78 //              document.getElementById('updateStatus').innerHTML = "New Event"; 
    79         } 
    80         else 
    81         { 
    82 //              document.getElementById('updateStatus').innerHTML = "New Evaluation"; 
    83         } 
     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                 
    8488         
    8589                // fades the text 
  • trunk/webapps/einotebook/script/script.js

    r401 r415  
    1313function jumpToLastExecutedEvent() 
    1414{        
    15         var lastEvent = Script.events.getLastExecutedEvent(readCookie("time")); 
    16          
     15        var lastEventArray = Script.events.getLastExecutedEvent(readCookie("time")); 
     16 
    1717        // IF a current event exists THEN 
    18         if (lastEvent != null) 
    19         { 
    20                 lastEvent.focus(); 
     18        if (lastEventArray != null) 
     19        { 
     20        // Move window focus to first event of the current ones 
     21        var last = lastEventArray.length - 1; 
     22            lastEventArray[last].focus(); 
    2123        } 
    2224        else 
     
    3335function highlightLatestEvent()  
    3436{ 
    35         var currentEvent = Script.events.getLastExecutedEvent(readCookie("time")); 
     37        var currentEventArray = Script.events.getLastExecutedEvent(readCookie("time")); 
    3638 
    3739        // IF the old event is has not been set THEN 
    38         if (typeof highlightLatestEvent.oldEvent == 'undefined') 
    39         { 
    40                 highlightLatestEvent.oldEvent = new Object(); 
    41                 highlightLatestEvent.oldEvent.id = Event.invalidID; 
    42         } 
    43          
     40        if (typeof highlightLatestEvent.oldEventArray == 'undefined') 
     41        { 
     42                highlightLatestEvent.oldEventArray = []; /* set up array of old events */ 
     43                var currentEvent = new Object();  
     44                highlightLatestEvent.oldEventArray.push(currentEvent); 
     45                highlightLatestEvent.oldEventArray[0].id = Event.invalidID; 
     46        } 
     47 
    4448        // IF a current event exists THEN 
    45         if (currentEvent != null) 
    46         { 
    47                 // IF there is a new current event THEN 
    48                 if (highlightLatestEvent.oldEvent.id != currentEvent.id) 
    49                 { 
    50                         currentEvent.highlight(); 
    51                          
    52                         // IF there was previously a current event THEN 
    53                         if (highlightLatestEvent.oldEvent.id != Event.invalidID && currentEvent.id != 0) 
    54                         { 
    55                                 highlightLatestEvent.oldEvent.unhighlight(); 
     49        if (currentEventArray !== null) 
     50        { 
     51                var found = false; /* check if a current event is found in the old event array */ 
     52 
     53                /* traverse the array of current event to check  
     54                if there is event already in the old event array */ 
     55                // IF there is a new current event THEN  
     56                for (j=0; j<highlightLatestEvent.oldEventArray.length; j++) { 
     57                        var oldEvent = highlightLatestEvent.oldEventArray[j]; 
     58                        found = false; 
     59                        for (i=0; i<currentEventArray.length; i++) { 
     60                                var currentEvent = currentEventArray[i]; 
     61                                if (oldEvent.id === currentEvent.id) 
     62                                { 
     63                                        found = true;    
     64                                        break;           
     65                                }  
    5666                        } 
    57                          
    58                         highlightLatestEvent.oldEvent = currentEvent;                    
     67                        /* unhighlight all the events that are no longer current */ 
     68                        if (!found && oldEvent.id !== Event.invalidID) { 
     69                                oldEvent.unhighlight(); 
     70                        }                
    5971                } 
     72 
     73                /* highlight the current event in the array */ 
     74                for (i=0; i<currentEventArray.length; i++) { 
     75                        currentEventArray[i].highlight(); 
     76                } 
     77 
     78                /* update the old events array with current event array */ 
     79                highlightLatestEvent.oldEventArray = currentEventArray; 
    6080        } 
    6181 
    6282    // Set timer to do this again in one second 
    6383        setTimeout("highlightLatestEvent()", 1000); 
    64 } 
    65  
    66  
    67 /** Change color of text of expired events so they appear disabled. 
    68   * @param events The list of events 
    69   * @param currEvent The current event 
    70   */ 
    71 function greyOldEvents(events, currEvent) 
    72 { 
    73           // Examine all events 
    74    for (var evtNum = 0; evtNum < events.length; evtNum++) 
    75    { 
    76                 // Change color of those before current time and Event 
    77       if (events[evtNum].time.compareTo(currEvent.time) < 0 && currEvent.id != events[evtNum].id)  
    78       { 
    79                         events[evtNum].unhighlight(); 
    80       } 
    81         } 
    8284} 
    8385 
     
    101103                // add the Event's html 
    102104                html += Script.events[i].html(); 
    103         } 
    104         
     105        //console.log(Script.events[i].html()); 
     106        } 
    105107         
    106108        // display events in iframe 
     
    115117        Script.events.win.scrollTo(0, readCookie('scriptScrollY')); 
    116118         
    117         greyOldEvents(Script.events, Script.events.getLastExecutedEvent(readCookie("time"))); 
    118119        highlightLatestEvent(); 
    119120 
  • trunk/webapps/einotebook/scripts/Events.js

    r363 r415  
    304304 * Finds the Event that was last executed by based on given time. 
    305305 * @param time The time in seconds. 
    306  * @return The last execute event if at least one event has executed; otherwise, null. 
     306 * @return The array of last execute event if at least one event has executed; otherwise, null. 
    307307 */ 
    308308function events_getLastExecutedEvent(time) 
    309309{ 
    310         var event = null; 
     310        // var event = null; 
     311        var event_arr = []; 
    311312        if (this.length == 0) 
    312313    { 
     
    317318        if (this.length == 1 && this[0].time.getSeconds() <= time) 
    318319        { 
    319                 event = this[0]; 
     320                event.push(this[0]); 
    320321        } 
    321322        else 
     
    323324                //NOTE: remember that the events are maintained in ascending order by time 
    324325                 
    325                 // FOR each Event 
     326                // FOR each Event  
    326327                for (var i = 0; i < this.length - 1; i++) 
    327328                { 
     
    330331                            this[i + 1].time.getSeconds() > time) 
    331332                        { 
    332                                 event = this[i]; 
     333                                event_arr.push(this[i]); 
     334                                /* traverse backward to check if there is an event happen at the same time  
     335                                with the current event */ 
     336                                var k = i - 1; 
     337                                while ( k>=0 && (this[k].time.getSeconds() == this[i].time.getSeconds())) { 
     338                                        event_arr.push(this[k]); 
     339                                        k--; 
     340                                } 
    333341                        } 
    334342                } 
     
    337345                if (this[this.length - 1].time.getSeconds() <= time) 
    338346                { 
    339                         event = this[this.length - 1]; 
     347                        event_arr.push(this[this.length - 1]); 
    340348                }        
    341349        } 
    342350         
    343         return event; 
    344 } 
    345  
     351        // return an array of event  
     352        return event_arr; 
     353} 
     354 
Note: See TracChangeset for help on using the changeset viewer.