| 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 | |
|---|
| 26 | /** |
|---|
| 27 | * Sets the selected tab to the summary tab and loads the summary page. |
|---|
| 28 | */ |
|---|
| 29 | |
|---|
| 30 | function setupNotebook() |
|---|
| 31 | { |
|---|
| 32 | changeTab('summaryTab'); |
|---|
| 33 | showContent('summaryPageContent') |
|---|
| 34 | loadSummary(); |
|---|
| 35 | setCookie("time", "0"); |
|---|
| 36 | setCookie("scriptScrollY", 0); |
|---|
| 37 | setCookie("summaryScrollY", 0); |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | /** |
|---|
| 41 | * Runs the script. |
|---|
| 42 | */ |
|---|
| 43 | function run() |
|---|
| 44 | { |
|---|
| 45 | run.initialDelay = 1000; |
|---|
| 46 | |
|---|
| 47 | setTimeout("run.run()", run.initialDelay); |
|---|
| 48 | |
|---|
| 49 | run.run = function() |
|---|
| 50 | { |
|---|
| 51 | // document.getElementById("simulationStatus").innerHTML = "RUNNING"; |
|---|
| 52 | setTime(); |
|---|
| 53 | updateStatus(); |
|---|
| 54 | }; |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | /** |
|---|
| 58 | * Displays fading text alerts in the status box (left-top corner). |
|---|
| 59 | */ |
|---|
| 60 | function updateStatus() |
|---|
| 61 | { |
|---|
| 62 | // IF last event if it has not been set before THEN |
|---|
| 63 | if (typeof updateStatus.lastEvent == 'undefined') |
|---|
| 64 | { |
|---|
| 65 | updateStatus.lastEvent = null; |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | var latestEvent = events.getLastExecutedEvent(readCookie("time")); |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | // IF a new event executed THEN |
|---|
| 72 | if (updateStatus.lastEvent != latestEvent) |
|---|
| 73 | { |
|---|
| 74 | // IF the new event has evaluations THEN |
|---|
| 75 | if (latestEvent.evaluations.evaluations.length == 0) |
|---|
| 76 | { |
|---|
| 77 | // document.getElementById('updateStatus').innerHTML = "New Event"; |
|---|
| 78 | } |
|---|
| 79 | else |
|---|
| 80 | { |
|---|
| 81 | // document.getElementById('updateStatus').innerHTML = "New Evaluation"; |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | // fades the text |
|---|
| 85 | updateStatus.fade = function fade() |
|---|
| 86 | { |
|---|
| 87 | // IF the fade color is not black yet THEN |
|---|
| 88 | if (fade.hex < 255) |
|---|
| 89 | { |
|---|
| 90 | fade.hex += 5; |
|---|
| 91 | // document.getElementById('updateStatus').style.color = |
|---|
| 92 | "rgb(" + fade.hex + ", " + fade.hex + ", " + fade.hex + ")"; |
|---|
| 93 | setTimeout("updateStatus.fade()", 100); |
|---|
| 94 | } |
|---|
| 95 | else |
|---|
| 96 | { |
|---|
| 97 | // document.getElementById('updateStatus').style.color = "white"; |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | }; |
|---|
| 101 | |
|---|
| 102 | updateStatus.fade.hex = 0; |
|---|
| 103 | updateStatus.fade(); |
|---|
| 104 | updateStatus.lastEvent = latestEvent; |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | setTimeout("updateStatus();", 1000); |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | /** |
|---|
| 111 | * Sets 'simulationTime' to the current simulation time in seconds. |
|---|
| 112 | * This method runs itself every second to keep the time current. |
|---|
| 113 | * Sets the cookie 'time' to the value of 'simulationTime'. |
|---|
| 114 | * @return |
|---|
| 115 | */ |
|---|
| 116 | function setTime() |
|---|
| 117 | { |
|---|
| 118 | // increment time by one second (or initialize it if it has not been set before) |
|---|
| 119 | setTime.time = (typeof setTime.time == 'undefined') ? 0 : ++setTime.time; |
|---|
| 120 | |
|---|
| 121 | setCookie("time", "" + setTime.time); |
|---|
| 122 | |
|---|
| 123 | // display the latest simulation time |
|---|
| 124 | document.getElementById("simulationTime").innerHTML = |
|---|
| 125 | Time.formatTime(setTime.time); |
|---|
| 126 | |
|---|
| 127 | setTimeout("setTime()", 1000); |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | /** |
|---|
| 131 | * Selects a new tab to be viewed. |
|---|
| 132 | * @param id The id for the tab to be selected |
|---|
| 133 | */ |
|---|
| 134 | function changeTab(id) |
|---|
| 135 | { |
|---|
| 136 | /* Set all tabs to not being active */ |
|---|
| 137 | document.getElementById("summaryTab").className = "notActive"; |
|---|
| 138 | document.getElementById("scriptTab").className = "notActive"; |
|---|
| 139 | document.getElementById("CADTab").className = "notActive"; |
|---|
| 140 | document.getElementById("mapsTab").className = "notActive"; |
|---|
| 141 | |
|---|
| 142 | /* Set the selected tab to being active */ |
|---|
| 143 | document.getElementById(id).className = "activeTab"; |
|---|
| 144 | } |
|---|
| 145 | |
|---|
| 146 | /** |
|---|
| 147 | * Loads the script tab page; |
|---|
| 148 | */ |
|---|
| 149 | function loadScript() |
|---|
| 150 | { |
|---|
| 151 | } |
|---|
| 152 | |
|---|
| 153 | /** |
|---|
| 154 | * Loads the summary tab page; |
|---|
| 155 | */ |
|---|
| 156 | function loadSummary() |
|---|
| 157 | { |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | /** |
|---|
| 161 | * @param id The id of the frame element. |
|---|
| 162 | * @return The document of the frame element. |
|---|
| 163 | */ |
|---|
| 164 | function getDocumentFromFrame(id) |
|---|
| 165 | { |
|---|
| 166 | var frame=document.getElementById(id); |
|---|
| 167 | var doc=(frame.contentWindow || frame.contentDocument); |
|---|
| 168 | |
|---|
| 169 | if (doc.document)doc=doc.document; |
|---|
| 170 | |
|---|
| 171 | return doc; |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | /** |
|---|
| 175 | * Hides a tab page |
|---|
| 176 | * @param d The div of the page to hide. |
|---|
| 177 | */ |
|---|
| 178 | function hideContent(d) |
|---|
| 179 | { |
|---|
| 180 | document.getElementById(d).style.display = "none"; |
|---|
| 181 | } |
|---|
| 182 | |
|---|
| 183 | /** |
|---|
| 184 | * Switches the tab page. |
|---|
| 185 | * @param d The div of the page to show. |
|---|
| 186 | */ |
|---|
| 187 | function showContent(d) |
|---|
| 188 | { |
|---|
| 189 | hideContent('summaryPageContent'); |
|---|
| 190 | hideContent('scriptPageContent'); |
|---|
| 191 | hideContent('cadPageContent'); |
|---|
| 192 | hideContent('mapsPageContent'); |
|---|
| 193 | document.getElementById(d).style.display = "block"; |
|---|
| 194 | } |
|---|