Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
65
gaia/apps/costcontrol/js/desktop-only/async_storage.js
Executable file
65
gaia/apps/costcontrol/js/desktop-only/async_storage.js
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
(function(exports) {
|
||||
'use strict';
|
||||
|
||||
const store = new Map();
|
||||
|
||||
function isParentAsyncStorageAvailable() {
|
||||
return !!(window.parent &&
|
||||
window.parent !== window &&
|
||||
window.parent.asyncStorage);
|
||||
}
|
||||
|
||||
function callCallback(value, callback) {
|
||||
if (typeof callback === 'function') {
|
||||
setTimeout(callback.bind(null, value));
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(exports, 'asyncStorage', {
|
||||
value: {
|
||||
getItem: function asm_getItem(key, callback) {
|
||||
if (isParentAsyncStorageAvailable()) {
|
||||
window.parent.asyncStorage.getItem(key, callback);
|
||||
return;
|
||||
}
|
||||
|
||||
callCallback(store.get(key) || null, callback);
|
||||
},
|
||||
setItem: function asm_setItem(key, value, callback) {
|
||||
if (isParentAsyncStorageAvailable()) {
|
||||
window.parent.asyncStorage.setItem(key, value, callback);
|
||||
return;
|
||||
}
|
||||
|
||||
callCallback(store.set(key, value), callback);
|
||||
},
|
||||
removeItem: function asm_removeItem(key, callback) {
|
||||
if (isParentAsyncStorageAvailable()) {
|
||||
window.parent.asyncStorage.removeItem(key, callback);
|
||||
return;
|
||||
}
|
||||
|
||||
callCallback(store.delete(key), callback);
|
||||
},
|
||||
clear: function asm_clear(callback) {
|
||||
if (isParentAsyncStorageAvailable()) {
|
||||
window.parent.asyncStorage.clear(callback);
|
||||
return;
|
||||
}
|
||||
|
||||
callCallback(store.clear(), callback);
|
||||
},
|
||||
length: function(callback) {
|
||||
if (isParentAsyncStorageAvailable()) {
|
||||
window.parent.asyncStorage.length(callback);
|
||||
return;
|
||||
}
|
||||
|
||||
callCallback(store.size, callback);
|
||||
},
|
||||
key: function() {
|
||||
throw new Error('Not Implemented');
|
||||
}
|
||||
}
|
||||
});
|
||||
})(window);
|
||||
Loading…
Reference in a new issue