Advertisement
Guest User

Untitled

a guest
May 6th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. var countdownTimer, countdownCurrent;
  2. $(document).ready(function () {
  3. countdownCurrent = $('#ctl00_MainContent_example2submit').val() * 100;
  4. countdownTimer = $.timer(function () {
  5. var min = parseInt(countdownCurrent / 6000);
  6. var sec = parseInt(countdownCurrent / 100) - (min * 60);
  7. var micro = pad(countdownCurrent - (sec * 100) - (min * 6000), 2);
  8. var output = "00"; if (min > 0) { output = pad(min, 2); }
  9. $('.countdowntime').html(output + ":" + pad(sec, 2) + ":" + micro);
  10. if (countdownCurrent == 0) {
  11. $('#ctl00_MainContent_btnNext').click();
  12.  
  13. } else {
  14. countdownCurrent -= 7;
  15. if (countdownCurrent < 0) { countdownCurrent = 0; }
  16. }
  17. }, 70, true);
  18.  
  19.  
  20. $('#example2submit').bind('keyup', function (e) { if (e.keyCode == 13) { countdownReset(); } });
  21.  
  22. });
  23.  
  24. function CheckIfOptionSelected() {
  25.  
  26. var vFlag = true;
  27. var radioButton1 = document.forms[0].elements['ctl00_MainContent_rdBtnListOptions_0'];
  28. var radioButton2 = document.forms[0].elements['ctl00_MainContent_rdBtnListOptions_1'];
  29. var radioButton3 = document.forms[0].elements['ctl00_MainContent_rdBtnListOptions_2'];
  30. var radioButton4 = document.forms[0].elements['ctl00_MainContent_rdBtnListOptions_3'];
  31.  
  32. if (radioButton1.checked == false && radioButton2.checked == false && radioButton3.checked == false && radioButton4.checked == false && countdownCurrent > 0) {
  33. vFlag = false;
  34. }
  35.  
  36. else {
  37. countdownReset();
  38. vFlag = true;
  39. }
  40. return vFlag;
  41. }
  42.  
  43. function countdownReset() {
  44. var newCount = parseInt($('#ctl00_MainContent_example2submit').val()) * 100;
  45. if (newCount > 0) { countdownCurrent = newCount; }
  46. countdownTimer.stop().once();
  47. }
  48.  
  49. // Padding function
  50. function pad(number, length) {
  51. var str = '' + number;
  52. while (str.length < length) { str = '0' + str; }
  53. return str;
  54. }
  55.  
  56. if(typeof func == 'object') {
  57. var paramList = ['autostart', 'time'];
  58. for(var arg in paramList) {if(func[paramList[arg]] != undefined) {eval(paramList[arg] + " = func[paramList[arg]]");}};
  59. func = func.action;
  60. }
  61.  
  62. if(typeof func == 'object') {
  63. var paramList = ['autostart', 'time'];
  64. // Never use for..in to iterate over an array
  65. for(var arg in paramList) {
  66. if(func[paramList[arg]] != undefined) {
  67. // What does this eval code do and why?
  68. eval(paramList[arg] + " = func[paramList[arg]]");
  69. }
  70. };
  71. func = func.action;
  72. }
  73.  
  74. <!DOCTYPE html>
  75.  
  76. <html>
  77. <head>
  78. <title>Time Test</title>
  79. </head>
  80. <body>
  81.  
  82. <code>
  83. This page has been open for
  84. <span id="timeOpen">0</span>
  85. seconds
  86. </code>
  87.  
  88. <script>
  89. var timeStart = +new Date;
  90. setInterval( function() {
  91. var timeNow = +new Date;
  92. var secondsOpen = ( timeNow - timeStart ) / 1000;
  93. document.getElementById('timeOpen').innerHTML =
  94. Math.floor( secondsOpen );
  95. }, 250 );
  96. </script>
  97.  
  98. </body>
  99. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement