view js/cache.js @ 65:8294f3d1efee

Startup dialog gains focus on open
author Atul Varma <avarma@mozilla.com>
date Sun, 25 Apr 2010 08:52:28 -0700
parents b2e0ea0178fb
children
line wrap: on
line source

// 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];
    }
  };
}