changeset 24:d2ba5eae2ca2

refactorings
author Atul Varma <avarma@mozilla.com>
date Fri, 25 Jun 2010 17:04:38 -0700
parents 2451de0b2e88
children 1e7315233967
files static-files/index.js
diffstat 1 files changed, 29 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/static-files/index.js	Fri Jun 25 16:47:52 2010 -0700
+++ b/static-files/index.js	Fri Jun 25 17:04:38 2010 -0700
@@ -1,38 +1,38 @@
-var Config = {
-  get value() {
-    var val = localStorage.getItem("SUMMIT_CFG");
-    if (val)
-      return JSON.parse(val);
-    return {};
-  },
-  get lastChanged() {
-    var ts = localStorage.getItem("SUMMIT_CFG_TIMESTAMP");
-    if (ts)
-      return new Date(ts);
-    return new Date(0);
-  },
-  setValue: function Config_setValue(val) {
-    localStorage.setItem("SUMMIT_CFG", JSON.stringify(val));
-    localStorage.setItem("SUMMIT_CFG_TIMESTAMP",
-                         (new Date()).toString());
-    this.observers.forEach(function(cb) { cb(); });
-  },
-  wipe: function Config_wipe() {
-    localStorage.removeItem("SUMMIT_CFG");
-    localStorage.removeItem("SUMMIT_CFG_TIMESTAMP");
-    this.observers.forEach(function(cb) { cb(); });
-  },
-  observers: []
-};
-
 (
   // Config initialization code.
   function(window) {
+    var Config = window.Config = {
+      get value() {
+        var val = localStorage.getItem("SUMMIT_CFG");
+        if (val)
+          return JSON.parse(val);
+        return {};
+      },
+      get lastChanged() {
+        var ts = localStorage.getItem("SUMMIT_CFG_TIMESTAMP");
+        if (ts)
+          return new Date(ts);
+        return new Date(0);
+      },
+      setValue: function Config_setValue(val) {
+        localStorage.setItem("SUMMIT_CFG", JSON.stringify(val));
+        localStorage.setItem("SUMMIT_CFG_TIMESTAMP",
+                             (new Date()).toString());
+        this.observers.forEach(function(cb) { cb(); });
+      },
+      wipe: function Config_wipe() {
+        localStorage.removeItem("SUMMIT_CFG");
+        localStorage.removeItem("SUMMIT_CFG_TIMESTAMP");
+        this.observers.forEach(function(cb) { cb(); });
+      },
+      observers: []
+    };
+
     function ensureStateIsValid() {
       if (!('state' in Config.value))
         Config.setValue({state: "login"});
     }
-
+    
     Config.observers.push(ensureStateIsValid);
 
     $(window).ready(ensureStateIsValid);
@@ -44,7 +44,7 @@
   function(window) {
     var req;
 
-    var Attendees = {
+    var Attendees = window.Attendees = {
       refresh: function refresh() {
         if (req)
           return;
@@ -76,8 +76,6 @@
 
     Config.observers.push(refreshAttendees);
     $(window).ready(refreshAttendees);
-
-    window.Attendees = Attendees;
   }
 )(window);