Changeset 579 in tmcsimulator for trunk/webapps


Ignore:
Timestamp:
02/02/2020 08:09:33 AM (6 years ago)
Author:
jdalbey
Message:

Add timebox to GTEC.

Location:
trunk/webapps/GTEC
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/webapps/GTEC/css/styles.css

    r569 r579  
    5555          border:1px red solid; 
    5656        } 
    57       #time { 
     57      #timebox { 
    5858        background: #E6E6FA; 
    5959        font-family: Roboto; 
  • trunk/webapps/GTEC/index.html

    r572 r579  
    2626    <button id="greenButton">Green</button> 
    2727    <button id="yellowButton">Yellow</button> 
     28    <input type = "text" 
     29                 id = "timebox" 
     30                 value = "00:00:00" 
     31                 autocomplete=off 
     32                 onchange = "saveTime()"/> 
    2833    <!-- <button id="harButton" class="unstyled-button"><img id="harBtnImg" src="images/btnReady_HAR.png"></button> 
    2934    <button id="cctvButton" class="unstyled-button"><img id="cctvBtnImg" src="images/btnReady_CCTV.png"></button> 
  • trunk/webapps/GTEC/js/vdsLayer.js

    r570 r579  
     1/** Logic for traffic events creator. 
     2    Based on vdsLayer from CPTMS.  
     3    @author T. Kumar, J. Dalbey   Feb 2020 
     4    See wiki for user documentation. 
     5*/ 
    16var postmileList = [];  // the list of postmiles saved from the json file. 
    27var chosenColor = "yellow"; // stores color that user picks, initial default yellow 
     8var currentTime; // the current event time 
    39 
    410// function to find differences between two arrays 
     
    2733            anchor: new google.maps.Point(6, 6) 
    2834        }; 
     35    } 
     36 
     37    function saveTime()  
     38    { 
     39        var timeOverride = document.getElementById("timebox").value;  
     40        var d = new Date(); // creates a Date Object using the clients current time 
     41 
     42        let [hours,minutes,seconds] = timeOverride.split(':'); // using ES6 destructuring 
     43 
     44        d.setHours(+hours); // set the hours, using implicit type coercion 
     45        d.setMinutes(minutes); // you can pass Number or String, it doesn't really matter 
     46        d.setSeconds(seconds); 
     47        currentTime = d;  // save as new current time 
     48    } 
     49 
     50    // Refresh the time display 
     51    function updateTime(time) 
     52    { 
     53        document.getElementById("timebox").value = time;    
    2954    } 
    3055 
     
    5681        var first = []; // stores first dot 
    5782        var asc = false; //ascending 
    58         //var color_arr = [];  
    5983        var white_arr = []; //stores all white dots 
    6084        // Initialize the current time to zero 
    61         var currentTime = new Date(0); 
     85        currentTime = new Date(0); 
    6286        currentTime.setHours(0); 
    6387        currentTime.setMinutes(0); 
     
    76100                // checks highway direction to determine if postmiles are ascending or descending  
    77101                if (parseFloat(event_arr[2]) < parseFloat(first[2])) 
    78                 { 
     102                {  
    79103                    asc = false; 
    80104                } 
     
    106130                    } 
    107131                }); 
    108                 //color_arr.push(clicked_dots); 
    109                 //console.log(clicked_dots); 
    110                 //console.log(range); 
    111132                // extracts ids for all the white dots 
    112133                var white_arr_ids = white_arr.map(function (marker) { 
     
    136157                    }); 
    137158                } 
    138                 // Increment the time by one-half minute (30 seconds) 
    139                 var millisecs = currentTime.getTime(); 
    140                 millisecs += 30000;   
    141                 currentTime = new Date(millisecs); 
    142159 
    143160                // Create a printable string for the time (HH:MM:SS) 
     
    148165                first[1] + "\t" + first[2] + "\t" + range.toFixed(3) + "\t"  
    149166                + getColorAbbr(chosenColor); 
    150                 console.log(lineOut); 
    151167 
    152168                // Using Ajax POST to send the data  
     
    156172                // send the collected data  
    157173                xhr.send("msg="+lineOut + "\n") 
     174 
     175                // Increment the time by one-half minute (30 seconds) 
     176                var millisecs = currentTime.getTime(); 
     177                millisecs += 30000;   
     178                currentTime = new Date(millisecs); 
     179                // Refresh the time display 
     180                updateTime(currentTime.toLocaleTimeString('it-IT')); 
     181 
    158182            } 
    159183            // if user has not yet clicked on a dot 
     
    317341    var greenColor = document.getElementById('greenButton'); 
    318342    var yellowColor = document.getElementById('yellowButton'); 
     343    var time = document.getElementById('timebox'); 
     344    map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(time); 
    319345    map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(redColor); 
    320346    map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(greenColor); 
Note: See TracChangeset for help on using the changeset viewer.