More refactoring

This commit is contained in:
Berkeley Martinez
2015-11-17 21:25:16 -08:00
parent 748f7ab93f
commit 29f90505b7
30 changed files with 1043 additions and 1569 deletions

View File

@@ -0,0 +1,37 @@
// depends on: codeUri
window.common = (function(global) {
const {
localStorage,
common = { init: [] }
} = global;
var codeStorage = {
getStoredValue(key) {
return '' + localStorage.getItem(key + 'Val');
},
isAlive: function() {
var val = this.getStoredValue();
return val !== 'null' &&
val !== 'undefined' &&
(val && val.length > 0);
},
updateStorage(key, code) {
if (
!localStorage ||
typeof localStorage !== 'function' ||
!key ||
typeof key !== 'string'
) {
console.log('unable to save to storage');
return code;
}
localStorage.setItem(key + 'Val', code);
}
};
common.codeStorage = codeStorage;
return common;
}(window, window.common));