Skip to content

Commit

Permalink
add support for chrome apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeus Gómez Marmolejo committed Sep 30, 2014
1 parent f39956a commit e9c730a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ exports.save = save;
exports.load = load;
exports.useColors = useColors;

/**
* Use chrome.storage.local if we are in an app
*/

var storage;

if (chrome.storage.local !== undefined)
storage = chrome.storage.local;
else
storage = window.localStorage;

/**
* Colors.
*/
Expand Down Expand Up @@ -118,9 +129,9 @@ function log() {
function save(namespaces) {
try {
if (null == namespaces) {
localStorage.removeItem('debug');
storage.removeItem('debug');
} else {
localStorage.debug = namespaces;
storage.debug = namespaces;
}
} catch(e) {}
}
Expand All @@ -135,7 +146,7 @@ function save(namespaces) {
function load() {
var r;
try {
r = localStorage.debug;
r = storage.debug;
} catch(e) {}
return r;
}
Expand Down

0 comments on commit e9c730a

Please sign in to comment.