source: tmcsimulator/trunk/webapps/cptms/timescroller.html @ 348

Revision 348, 2.2 KB checked in by jdalbey, 7 years ago (diff)

Added gotoxmltime.html and other prototypes for ei notebook. They can be removed when no longer needed.

Line 
1<html>
2<head>
3<style>
4.pic-container {
5    width: 500px;
6    height: 400px;
7    overflow-y: scroll;
8    overflow-x:hidden;
9}
10</style>
11<body>
12<!-- Prototype for a scrolling display that advances to a timer -->
13<div id="timediv">0:00</div>
14<div id="main" class="pic-container"></div>
15<div id="two">Footer</div>
16<script   src="poem.js"></script>
17<script  src="js/common.js"></script>
18<script>
19var timeDiv = document.getElementById("timediv");
20/** Load the sim clock file and extract the clock string */
21function gettime()
22{
23    loadJSON("sim_clock.json", function(response)
24    {
25        simclockjson = JSON.parse(response);
26        clockstring = simclockjson.clock;
27        timeDiv.innerHTML = clockstring;  // Display current time
28        // Extract the seconds digits
29        digits = clockstring.substring(clockstring.length-2)
30        if (digits.charAt(0) == "0")
31        {
32            digits = digits.charAt(1);
33        }
34        // go adjust the scrolling box
35        adjust(digits);
36    });
37}
38// Highlight the current line and scroll to it.
39function adjust(currLine)
40{
41    if (currElement != null)
42    {
43        // Find the element with the id = seconds digits
44        target = document.getElementById(currLine)
45        if (target != null)
46        {
47            // restore the previous element's background color
48            currElement.style.background = "GhostWhite";
49            currElement = target;
50            currElement.style.background = "Gainsboro"; // set background color
51            //currElement.scrollTop = 0;
52            currElement.scrollIntoView();  // scroll to it
53        }
54    }
55}
56
57// Split a poem into lins
58var fields = poem.split('\n');
59// Place each line in its own DIV with a sequential ID
60for (item in fields)
61{
62    var div = document.createElement("div");
63    div.id=item*5
64    div.style.color = "black";
65    div.style.background = "GhostWhite";
66    div.innerHTML = fields[item]; // place poem line as content
67    // Append it to the parent div
68    document.getElementById("main").appendChild(div);
69}
70
71var currLine = 1;
72var currElement = document.getElementById("5");
73// Go get the current sim time every second
74var myinterval = setInterval(gettime,1000);
75//clearTimeout(myVar);
76 
77</script>
78</body>
79
80</html>
Note: See TracBrowser for help on using the repository browser.