Changeset 606 in tmcsimulator for branches


Ignore:
Timestamp:
03/29/2020 01:38:01 PM (6 years ago)
Author:
jdalbey
Message:

realtimeVDS fix code smells in vdsLayer.js

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/realtime_VDS/cptms/js/vdsLayer.js

    r588 r606  
    162162//initialize live indicator icon 
    163163function initLiveIcon(success) { 
    164     //create new img tags for live and not-live indicators 
    165     var live = document.createElement('img'); 
    166     var notLive = document.createElement('img'); 
    167     live.src ="images/live.svg"; 
    168     live.width = 50 ; 
    169     live.height= 40 ; 
    170     notLive.src ="images/offline.jpg"; 
    171164    // if fetch is a success, display live img 
    172     if (success) { 
    173         //console.log(live); 
    174         if (map.controls[google.maps.ControlPosition.TOP_RIGHT].getLength() > 0) 
     165    var indicator = document.createElement('img'); 
     166    if (success)  
     167    { 
     168        //create new img tags for live and not-live indicators 
     169        indicator.src ="images/live.svg"; 
     170        indicator.width = 50 ; 
     171        indicator.height= 40 ; 
     172    } 
     173    else 
     174    { 
     175        indicator.src ="images/offline.jpg"; 
     176    } 
     177    if (map.controls[google.maps.ControlPosition.TOP_RIGHT].getLength() > 0) 
    175178            map.controls[google.maps.ControlPosition.TOP_RIGHT].pop(); 
    176         map.controls[google.maps.ControlPosition.TOP_RIGHT].push(live); 
    177     } 
    178     // if error, display sad smiley image 
    179     else { 
    180         //console.log(notLive); 
    181         if (map.controls[google.maps.ControlPosition.TOP_RIGHT].getLength() > 0) 
    182             map.controls[google.maps.ControlPosition.TOP_RIGHT].pop(); 
    183         map.controls[google.maps.ControlPosition.TOP_RIGHT].push(notLive); 
    184     } 
     179    map.controls[google.maps.ControlPosition.TOP_RIGHT].push(indicator); 
    185180} 
    186181 
     
    202197                var now = new Date(); 
    203198                // calculate time difference 
     199                var timeDiff = new Date(now - lastFetch); 
    204200                var msec = now - lastFetch; 
    205201                var days = Math.floor(msec / 1000 / 60 / (60 * 24)); 
     
    216212                else  
    217213                    initLiveIcon(0) 
    218                 //console.log(days + " Days "+ hh + " Hours " + mm + " Minutes " + ss + " Seconds"); 
     214                //console.log(days + " Days "+ hh + " Hours " + mm + " Minutes " + ss + " Seconds "); 
    219215            } 
    220216        } 
Note: See TracChangeset for help on using the changeset viewer.