Changeset 415 in tmcsimulator for trunk/webapps/einotebook
- Timestamp:
- 06/18/2019 10:44:53 AM (7 years ago)
- Location:
- trunk/webapps/einotebook
- Files:
-
- 4 edited
-
cad/cad.js (modified) (2 diffs)
-
notebook.js (modified) (1 diff)
-
script/script.js (modified) (4 diffs)
-
scripts/Events.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/webapps/einotebook/cad/cad.js
r359 r415 15 15 16 16 /** 17 * Updates the CAD screen.17 * Updates the current event tab. 18 18 */ 19 19 function updateCad() … … 21 21 // Set timer to do this again in one second 22 22 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); 25 26 // Show current event to Current Event Window 26 27 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 } 28 36 37 currDiv.innerHTML = display; 29 38 } -
trunk/webapps/einotebook/notebook.js
r373 r415 73 73 if (updateStatus.lastEvent != latestEvent) 74 74 { 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 84 88 85 89 // fades the text -
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 -
trunk/webapps/einotebook/scripts/Events.js
r363 r415 304 304 * Finds the Event that was last executed by based on given time. 305 305 * @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. 307 307 */ 308 308 function events_getLastExecutedEvent(time) 309 309 { 310 var event = null; 310 // var event = null; 311 var event_arr = []; 311 312 if (this.length == 0) 312 313 { … … 317 318 if (this.length == 1 && this[0].time.getSeconds() <= time) 318 319 { 319 event = this[0];320 event.push(this[0]); 320 321 } 321 322 else … … 323 324 //NOTE: remember that the events are maintained in ascending order by time 324 325 325 // FOR each Event 326 // FOR each Event 326 327 for (var i = 0; i < this.length - 1; i++) 327 328 { … … 330 331 this[i + 1].time.getSeconds() > time) 331 332 { 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 } 333 341 } 334 342 } … … 337 345 if (this[this.length - 1].time.getSeconds() <= time) 338 346 { 339 event = this[this.length - 1];347 event_arr.push(this[this.length - 1]); 340 348 } 341 349 } 342 350 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.
