Changeset 415 in tmcsimulator for trunk/webapps/einotebook/script/script.js
- Timestamp:
- 06/18/2019 10:44:53 AM (7 years ago)
- File:
-
- 1 edited
-
trunk/webapps/einotebook/script/script.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/webapps/einotebook/script/script.js
r401 r415 13 13 function jumpToLastExecutedEvent() 14 14 { 15 var lastEvent = Script.events.getLastExecutedEvent(readCookie("time"));16 15 var lastEventArray = Script.events.getLastExecutedEvent(readCookie("time")); 16 17 17 // 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(); 21 23 } 22 24 else … … 33 35 function highlightLatestEvent() 34 36 { 35 var currentEvent = Script.events.getLastExecutedEvent(readCookie("time"));37 var currentEventArray = Script.events.getLastExecutedEvent(readCookie("time")); 36 38 37 39 // 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 44 48 // 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 } 56 66 } 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 } 59 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; 60 80 } 61 81 62 82 // Set timer to do this again in one second 63 83 setTimeout("highlightLatestEvent()", 1000); 64 }65 66 67 /** Change color of text of expired events so they appear disabled.68 * @param events The list of events69 * @param currEvent The current event70 */71 function greyOldEvents(events, currEvent)72 {73 // Examine all events74 for (var evtNum = 0; evtNum < events.length; evtNum++)75 {76 // Change color of those before current time and Event77 if (events[evtNum].time.compareTo(currEvent.time) < 0 && currEvent.id != events[evtNum].id)78 {79 events[evtNum].unhighlight();80 }81 }82 84 } 83 85 … … 101 103 // add the Event's html 102 104 html += Script.events[i].html(); 103 } 104 105 //console.log(Script.events[i].html()); 106 } 105 107 106 108 // display events in iframe … … 115 117 Script.events.win.scrollTo(0, readCookie('scriptScrollY')); 116 118 117 greyOldEvents(Script.events, Script.events.getLastExecutedEvent(readCookie("time")));118 119 highlightLatestEvent(); 119 120
Note: See TracChangeset
for help on using the changeset viewer.
