# HG changeset patch # User Atul Varma # Date 1272260640 25200 # Node ID e3de1fe32f40578ac36c1863df23c53ff842e829 # Parent 677df912e92de7cb59814259afc80aea6895d18a made cache module require 'storage' instead of 'window' diff -r 677df912e92d -r e3de1fe32f40 js/modules/app.js --- a/js/modules/app.js Sun Apr 25 22:26:14 2010 -0700 +++ b/js/modules/app.js Sun Apr 25 22:44:00 2010 -0700 @@ -3,6 +3,7 @@ var bugzilla = require("app/bugzilla-auth").create(options.Bugzilla); moduleExports.bugzilla = bugzilla; moduleExports.window = options.window; + moduleExports.storage = options.window.localStorage; moduleExports.jQuery = options.jQuery; require("app/ui").init(options.window.document); diff -r 677df912e92d -r e3de1fe32f40 js/modules/cache.js --- a/js/modules/cache.js Sun Apr 25 22:26:14 2010 -0700 +++ b/js/modules/cache.js Sun Apr 25 22:44:00 2010 -0700 @@ -1,8 +1,8 @@ Require.modules["cache"] = function(exports, require) { const CACHE_NAME = "cache"; - var window = require("window"); - var cache = window.localStorage.getItem(CACHE_NAME); + var storage = require("storage"); + var cache = storage.getItem(CACHE_NAME); if (cache) cache = JSON.parse(cache); @@ -14,12 +14,12 @@ // Remove the key first, to get around a strange iPad // issue: http://stackoverflow.com/questions/2603682/is-anyone-else-receiving-a-quota-exceeded-err-on-their-ipad-when-accessing-locals - window.localStorage.removeItem(CACHE_NAME); + storage.removeItem(CACHE_NAME); // TODO: We should really catch QUOTA_EXCEEDED_ERR here, // which could be thrown if the user is in private // browsing mode. - window.localStorage.setItem(CACHE_NAME, JSON.stringify(cache)); + storage.setItem(CACHE_NAME, JSON.stringify(cache)); }; exports.get = function get(key) { @@ -27,7 +27,7 @@ }; exports.clear = function clear() { - window.localStorage.removeItem(CACHE_NAME); + storage.removeItem(CACHE_NAME); cache = {}; }; };