How to keep timer like this

by sreddy
3 replies
  • WEB DESIGN
  • |
Hi,

I wish to keep timer in my website like this website : Speed Reading Test Online

I am starting a website in wordpress platform.

The purpose is to calculate the number of minutes the reader spent on reading the text and calculate reading speed.

Thank you
#timer
  • Profile picture of the author Brandon Tanner
    That's done with Javascript. This is the code they are using for the timer on that particular page...

    Code:
    <SCRIPT LANGUAGE="javascript">
    <!--
    function strt(){if(document.forms[0].bStrt.value=="   Start   "){d1=new Date;t1=d1.getTime();document.forms[2].tx.value="";document.forms[0].bStrt.value="reading ...";document.forms[1].bStp.value="   Stop   ";}else{document.forms[0].bStrt.value="   Start   "; } }
    function stp(){if(document.forms[0].bStrt.value=="reading ..."){d2=new Date;document.forms[2].tx.value=Math.round((60000/(d2.getTime()-t1))*597);document.forms[1].bStp.value="  Done  ";document.forms[0].bStrt.value="   Start   "; } }
    //-->
    </SCRIPT>
    And the HTML part...

    HTML Code:
    <FORM ACTION=""><INPUT TYPE="button" NAME="bStrt" onClick="strt()" value="   Start   "></FORM>
    
    <p>(Text to go in between the start and stop buttons...)</p>
    
    FORM ACTION=""><INPUT TYPE="button" NAME="bStp" onClick="stp()" VALUE="   Stop   "></FORM>
    ^ Both the Javascript and HTML on that page are a bit on the sloppy side, but I reckon it gets the job done. I would probably use a jQuery timer for that instead... maybe something like this ... and then modify it to figure out the WPM.
    Signature

    {{ DiscussionBoard.errors[8190802].message }}
  • Profile picture of the author sreddy
    Thank you for the code. I will catch some with java knowledge to build it completely.
    {{ DiscussionBoard.errors[8193187].message }}

Trending Topics