Skip to content

Commit

Permalink
Merge pull request #143 from marmolejo/master
Browse files Browse the repository at this point in the history
add support for chrome apps
  • Loading branch information
TooTallNate committed Dec 29, 2014
2 parents 85bd499 + 3f97ec6 commit a98c283
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 (typeof chrome !== 'undefined' && typeof chrome.storage !== '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 a98c283

Please sign in to comment.