Alexander Dahl avatar Alexander Dahl committed 9b42631 Draft

chapter 08 final

Comments (0)

Files changed (2)

     </div>
 
     <h4>Congratulations to all our finishers!</h4>
+    <button id="btnStart">Start Page Updates</button>
+    <button id="btnStop">Stop Page Updates</button>
     <p id="freq"></p>
     <p>Last Updated: <em id="updatedTime"></em></p>
 

scripts/page295.js

 var FREQ = 10000;
+var repeat = true;
 
 function getTime(){
     var a_p = "";
 }
 
 function startAJAXcalls() {
-    setTimeout( function() {
-            getXMLRacers();
-            startAJAXcalls();
-        },
-        FREQ
-    );
+    if ( repeat ) {
+        setTimeout( function() {
+                getXMLRacers();
+                startAJAXcalls();
+            },
+            FREQ
+        );
+    }
 }
 
 jQuery(document).ready(function(){
+    $('#btnStart').click(function(){
+        repeat = true;
+        startAJAXcalls();
+        showFrequency();
+    });
+
+    $('#btnStop').click(function(){
+        repeat = false;
+        $('#freq').html( "Updates paused." );
+    });
+
     showFrequency();
     getXMLRacers();
     startAJAXcalls();
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.