Changeset 418 in tmcsimulator for trunk/webapps


Ignore:
Timestamp:
06/20/2019 03:46:03 PM (7 years ago)
Author:
jdalbey
Message:

Fix #124

Location:
trunk/webapps/einotebook
Files:
3 edited

Legend:

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

    r415 r418  
    3535function highlightLatestEvent()  
    3636{ 
    37         var currentEventArray = Script.events.getLastExecutedEvent(readCookie("time")); 
     37    Script.events.setEmphasis();  // Set text colors on all events 
    3838 
    39         // IF the old event is has not been set THEN 
    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  
    48         // IF a current event exists THEN 
    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                                 }  
    66                         } 
    67                         /* unhighlight all the events that are no longer current */ 
    68                         if (!found && oldEvent.id !== Event.invalidID) { 
    69                                 oldEvent.unhighlight(); 
    70                         }                
    71                 } 
    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; 
     39    var currentEventArray = Script.events.getLastExecutedEvent(readCookie("time")); 
     40        /* highlight the items in the current event array */ 
     41    for (i=0; i<currentEventArray.length; i++)  
     42    { 
     43                currentEventArray[i].highlight(); 
    8044        } 
    8145 
  • trunk/webapps/einotebook/scripts/Event.js

    r364 r418  
    3333        this.highlight = highlight; 
    3434        this.unhighlight = unhighlight; 
     35    this.normalize = normalize; 
    3536        this.focus = focus; 
    3637         
     
    184185                events.doc.getElementById(this.eventHeaderID).style.borderColor = "blue"; 
    185186                events.doc.getElementById(this.eventHeaderID).style.backgroundColor = "yellow"; 
     187                events.doc.getElementById(this.eventHeaderID).style.color = "black"; 
     188                events.doc.getElementById(this.dataID).style.color = "black"; 
     189        events.doc.getElementById(this.dataID).style.backgroundColor = incidentColor[this.incident.number]; 
    186190                 
    187191                // IF this event is expanded THEN 
     
    194198                        events.doc.getElementById(this.dataID).style.border = "none"; 
    195199                } 
    196                  
     200         
    197201        } 
    198202         
     
    211215                events.doc.getElementById(this.dataID).style.color = "gray"; 
    212216        } 
     217        /** 
     218         * Normalize this Event: provide normal background and text colors. 
     219         */ 
     220        function normalize() 
     221        { 
     222        var myColor = incidentColor[this.incident.number]; 
     223                events.doc.getElementById(this.eventHeaderID).style.backgroundColor = "white"; 
     224                events.doc.getElementById(this.eventHeaderID).style.borderColor = "black"; 
     225                events.doc.getElementById(this.eventHeaderID).style.color = "black"; 
     226                events.doc.getElementById(this.dataID).style.color = "black"; 
     227        events.doc.getElementById(this.dataID).style.backgroundColor = myColor; 
     228                events.doc.getElementById(this.eventHeaderID).style.backgroundColor = myColor; 
     229    }            
     230 
    213231         
    214232        /** 
  • trunk/webapps/einotebook/scripts/Events.js

    r415 r418  
    2525events.expandAllProperties = events_expandAllProperties; 
    2626events.expandAllEvaluations = events_expandAllEvaluations; 
     27events.setEmphasis = events_setEmphasis; 
    2728events.expandAll = events_expandAll; 
    2829events.collapseAll = events_collapseAll; 
     
    300301        events.expandAllEvents();        
    301302} 
     303 
     304/** Set emphasis for all events.   
     305    Change color of text of expired events so they appear disabled, and future  
     306    events appear normal. 
     307  */ 
     308function events_setEmphasis() 
     309{ 
     310    var currentTime = readCookie("time"); 
     311    // FOR each Event  
     312    for (var i = 0; i < this.length - 1; i++) 
     313    { 
     314          // Change color of those before current time  
     315      if (this[i].time.getSeconds() <= currentTime)  
     316      { 
     317              this[i].unhighlight(); 
     318      } 
     319      else 
     320      { 
     321              this[i].normalize(); // normal colors for everything else 
     322      }           
     323   } 
     324} 
     325 
    302326 
    303327/** 
Note: See TracChangeset for help on using the changeset viewer.