diff cache.js @ 17:4a698ea4be60

Added a really simple bug filing page w/ autocomplete for product/component.
author Atul Varma <varmaa@toolness.com>
date Wed, 10 Mar 2010 12:39:14 -0800
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cache.js	Wed Mar 10 12:39:14 2010 -0800
@@ -0,0 +1,18 @@
+// Really simple JSON cache that uses a form field as
+// a back-end.
+function buildCache(selector) {
+  var data = {};
+  var json = $(selector).val();
+  if (json.length)
+    data = JSON.parse(json);
+
+  return {
+    set: function set(key, value) {
+      data[key] = value;
+      $(selector).val(JSON.stringify(data));
+    },
+    get: function get(key) {
+      return data[key];
+    }
+  };
+}