Part of MKWS-64.
[mkws-moved-to-github.git] / src / mkws-team.js
index cfbe165..00e1f24 100644 (file)
@@ -76,7 +76,6 @@ mkws.makeTeam = function($, teamName) {
   that.urlFragment = function(overrides) {
     var s;
 
-    that.warn("making urlFragment with overrides " + mkws.$.toJSON(overrides));
     // Expand the filterSet into a set of key=value properties 
     var state = $.extend(true, {}, m_state, overrides ? overrides : {});
     var tmp = state.filters;
@@ -102,6 +101,39 @@ mkws.makeTeam = function($, teamName) {
     return s;
   }
 
+  // ### what quoting do we need to undo? Complement of previous function
+  that.parseFragment = function(s) {
+    var x = {};
+
+    var list = s.split('@');
+    for (var i in list) {
+      var a = list[i].split('=');
+      x[a[0]] = a[1];
+    }
+
+    return x;
+  }
+
+  that.handleChanges = function(oldState, newState) {
+    for (var key in newState) {
+      var val = newState[key];
+      if (newState.hasOwnProperty(key) &&
+          (!oldState || val != oldState[key])) {
+        that.warn("changed property " + key + ": " + 
+                  (oldState ? ("'" + oldState[key] + "'") : "undefined") +
+                  " -> '" + val + "'");
+        if (key === 'page') {
+          that.showPage(parseInt(val));
+        } else if (key === 'sort') {
+          that.set_sortOrder(val);
+          if (that.submitted()) {
+            that.reShow();
+          }
+        }
+      }
+    }
+  };
+
 
   // The following PubSub code is modified from the jQuery manual:
   // http://api.jquery.com/jQuery.Callbacks/