Recognise all state-changes from fragments.
authorMike Taylor <mike@indexdata.com>
Sat, 2 May 2015 17:26:26 +0000 (18:26 +0100)
committerMike Taylor <mike@indexdata.com>
Sat, 2 May 2015 17:26:26 +0000 (18:26 +0100)
Handle the first of these: switching to a different page.

src/mkws-team.js

index 73dd2f9..ad6bdd3 100644 (file)
@@ -116,9 +116,15 @@ mkws.makeTeam = function($, teamName) {
 
   that.handleChanges = function(oldState, newState) {
     for (var key in newState) {
+      var val = newState[key];
       if (newState.hasOwnProperty(key) &&
-          (!oldState || newState[key] != oldState[key])) {
-        that.warn("changed property " + key + ": '" + oldState[key] + "' -> '" + newState[key] + "'");
+          (!oldState || val != oldState[key])) {
+        that.warn("changed property " + key + ": " + 
+                  (oldState ? ("'" + oldState[key] + "'") : "undefined") +
+                  " -> '" + val + "'");
+        if (key === 'page') {
+          that.showPage(parseInt(val));
+        }
       }
     }
   };