Skip to:
Content
Pages
Categories
Search
Top
Bottom

Timer on click

  • @eversatile

    Participant

    Hello,
    I have been trying to implement a function to my bbpress forums but am not sure how to do so. I believe I have the correct script though I do not know how to implement it.
    My goal is to start a timer on the topic once a new topic is created.
    The script that I was informed should work is
    <html>
    <head>
    <title>Untitled Document</title>
    <script language=”javascript” type=”text/javascript”>
    var timerID = null;
    var timerRunning = false;
    var now = new Date();
    var hours = 0;
    var minutes =0;
    var seconds =0
    function stopclock ()
    {
    if(timerRunning)
    clearTimeout(timerID);
    timerRunning = false;
    }
    function showtime ()
    {
    if(seconds>=59)
    {
    seconds=0;
    minutes=minutes+1;
    }
    else
    {
    seconds=1+seconds;
    }
    if(minutes>=59)
    {
    minutes=0;
    hours=hours+1;
    }
    var timeValue =zeroPad(hours,2)+”:”+zeroPad(minutes,2)+”:”+zeroPad(seconds,2);
    document.getElementById(“timeDisplay”).innerHTML=timeValue;
    timerID = setTimeout(“showtime()”,1000);
    timerRunning = true;
    }
    function startclock()
    {
    stopclock();
    showtime();
    }
    // End –>
    function zeroPad(num,count)
    {
    var numZeropad = num + ”;
    while(numZeropad.length < count) {
    numZeropad = “0” + numZeropad;
    }
    return numZeropad;
    }
    </script>
    </head>
    <body onload=”startclock();”>
    <h2 style=”color: #000000; margin: left;”>
    Processing Time :: <span id=”timeDisplay”></span>
    </body>
    </html>

  • You must be logged in to reply to this topic.
Skip to toolbar