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

Revision 348, 2.6 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 display that scrolls to the current time -->
13<div id="timediv">0:00</div>
14<div> <button onclick="scrollToCurrent()">Goto Current Item</button></div>
15<div id="main" class="pic-container"></div>
16<div id="two">Footer</div>
17<script   src="poem.js"></script>
18<script  src="js/common.js"></script>
19<script>
20var timeDiv = document.getElementById("timediv");
21/** Load the sim clock file and extract the clock string */
22function gettime()
23{
24    loadJSON("sim_clock.json", function(response)
25    {
26        simclockjson = JSON.parse(response);
27        clockstring = simclockjson.clock;
28        timeDiv.innerHTML = clockstring;  // Display current time
29        // Extract the seconds digits
30        digits = clockstring.substring(clockstring.length-2)
31        if (digits.charAt(0) == "0")
32        {
33            digits = digits.charAt(1);
34        }
35        // go adjust the scrolling box
36        adjust(digits);
37    });
38}
39// Highlight the current line and scroll to it.
40function adjust(currLine)
41{
42    if (currElement != null)
43    {
44        // Find the element with the id = seconds digits
45        target = document.getElementById(currLine)
46        if (target != null)
47        {
48            // restore the previous element's background color
49            currElement.style.background = "GhostWhite";
50            currElement = target;
51            currElement.style.background = "Gainsboro"; // set background color
52            //currElement.scrollTop = 0;
53            currElement.scrollIntoView();  // scroll to it
54        }
55    }
56}
57
58function scrollToCurrent()
59{
60    currTime = timediv.innerHTML;
61    target = document.getElementById(currTime)
62    target.scrollIntoView();  // scroll to it
63    target.style.background = "Gainsboro"; // set background color
64}
65// Split a poem into lines
66var fields = poem.split('\n');
67// Place each line in its own DIV with a sequential ID
68for (item in fields)
69{
70    var div = document.createElement("div");
71    var measuredTime = new Date(null);
72    measuredTime.setSeconds(item*5); // specify value of SECONDS
73    var MHSTime = measuredTime.toISOString().substr(12, 7);
74    div.id=MHSTime
75    div.style.color = "black";
76    div.style.background = "GhostWhite";
77    div.innerHTML = fields[item]; // place poem line as content
78    // Append it to the parent div
79    document.getElementById("main").appendChild(div);
80}
81
82var currLine = 1;
83var currElement = document.getElementById("10");
84// Go get the current sim time every second
85var myinterval = setInterval(gettime,1000);
86//clearTimeout(myVar);
87 
88</script>
89</body>
90
91</html>
Note: See TracBrowser for help on using the repository browser.