TMC is an independent, primarily volunteer organization that relies on ad revenue to cover its operating costs. Please consider whitelisting TMC on your ad blocker or making a Paypal contribution here: paypal.me/SupportTMC

Tesla Roadsters reach 10,000,000 miles

Discussion in 'News' started by vfx, Mar 28, 2011.

  1. vfx

    vfx Well-Known Member

    Joined:
    Aug 18, 2006
    Messages:
    14,792
    Location:
    CA CA
    #1 vfx, Mar 28, 2011
    Last edited: Mar 28, 2011
  2. qwk

    qwk Model S P2681

    Joined:
    Dec 19, 2008
    Messages:
    2,817
    Very cool, I never knew the counter was updated in what looks like real time.
     
  3. suxxer

    suxxer ElektroVolt

    Joined:
    Dec 15, 2010
    Messages:
    294
    Location:
    Zurich, Switzerland
    Showing the counter on tmc should not be a great deal. It's a rather simple Javascript (red code) that counts up the miles and triggers the images over their id (blue code).

    Looks like TM can adjust the current milage over the "var startMileage =10075986;" variable. Accordint to "var milesPerSecond=0.25;" the roadsters drive one mile every four seconds ;)

    <script>

    var startMileage =10075986;
    var milesPerSecond=0.25;
    var baseImageDir = "/sites/all/themes/tesla/images/stats/roadstermiles/H45";



    function dotime() {
    var updateRate = 500; //milliseconds
    var dailySeconds = 0;
    var currentMileage = 0;
    var mileageIndex=0;
    var displaySize = 10;
    var color = ''; //'W' for white, '' for black

    theTime=setTimeout('dotime()',updateRate);

    var d = new Date();
    hr = d.getHours();
    mn = d.getMinutes();
    se = d.getSeconds();
    msec = d.getMilliseconds()

    dailySeconds = hr*3600+ mn*60 + se;
    currentMileage = startMileage + dailySeconds * milesPerSecond;
    currentMileage += '';
    tot=parseInt(currentMileage);
    tot=tot.toString()
    mileageIndex = tot.length;
    for(i=displaySize;i>0;i--) {

    if(mileageIndex==0) {
    src_img = 'Empty.png'
    } else if((displaySize - i + 1) % 4 == 0) {
    // comma
    src_img = 'C' + color + '.png';
    } else{
    src_img = tot.substring(mileageIndex - 1,mileageIndex) + color + '.png';
    mileageIndex--;
    }
    digit = document.getElementById('image' + i);
    if (digit) {
    digit.src = baseImageDir + '/' + src_img;
    }

    }
    }


    </script>


    <div id="counter">
    <img src="/sites/all/themes/tesla/images/stats/roadstermiles/H45/1.png" name="image1" id="image1"/>
    <img src="/sites/all/themes/tesla/images/stats/roadstermiles/H45/0.png" name="image2" id="image2"/>
    <img src="/sites/all/themes/tesla/images/stats/roadstermiles/H45/C.png" name="image3" id="image3"/>
    <img src="/sites/all/themes/tesla/images/stats/roadstermiles/H45/0.png" name="image4" id="image4"/>
    <img src="/sites/all/themes/tesla/images/stats/roadstermiles/H45/8.png" name="image5" id="image5"/>
    <img src="/sites/all/themes/tesla/images/stats/roadstermiles/H45/4.png" name="image6" id="image6"/>
    <img src="/sites/all/themes/tesla/images/stats/roadstermiles/H45/C.png" name="image7" id="image7"/>
    <img src="/sites/all/themes/tesla/images/stats/roadstermiles/H45/8.png" name="image8" id="image8"/>
    <img src="/sites/all/themes/tesla/images/stats/roadstermiles/H45/8.png" name="image9" id="image9"/>
    <img src="/sites/all/themes/tesla/images/stats/roadstermiles/H45/5.png" name="image10" id="image10"/>
    <img src="/sites/all/themes/tesla/images/stats/roadstermiles/H45/Miles.png" name="miles"/>
    </div>
     
  4. mpt

    mpt Electrics are back

    Joined:
    Oct 15, 2008
    Messages:
    1,629
    Location:
    Warren, New Jersey, United States
    #4 mpt, Mar 29, 2011
    Last edited: Mar 29, 2011
    I'll ask...

    update: I asked, I await a response.
     
  5. mpt

    mpt Electrics are back

    Joined:
    Oct 15, 2008
    Messages:
    1,629
    Location:
    Warren, New Jersey, United States
    I heard back; the web team is busy at the moment dealing with Santana Row support. But, they have no objection to our using it. I'll discuss with the TMC team and see if we can implement it in a way to ensure that it remains close to Tesla's number.
     
  6. vfx

    vfx Well-Known Member

    Joined:
    Aug 18, 2006
    Messages:
    14,792
    Location:
    CA CA
    What about a countdown timer? ;)
     

Share This Page