Warning: Can't use blame annotator:
svn blame failed on trunk/webapps/einotebook/notebook.js: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator/trunk/webapps/einotebook/notebook.js @ 415

Revision 415, 4.9 KB checked in by jdalbey, 7 years ago (diff)

einotebook fix to #131

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