add LocalStorage plugin

This commit is contained in:
Matias Alejo Garcia 2014-09-01 23:44:35 -03:00
commit b9881c1147
10 changed files with 101 additions and 16 deletions

42
plugins/LocalStorage.js Normal file
View file

@ -0,0 +1,42 @@
'use strict';
function LocalStorage() {
this.type = 'STORAGE';
};
LocalStorage.prototype.init = function() {
console.log(' init LocalStorage'); //TODO
};
LocalStorage.prototype.getItem = function(k) {
return localStorage.getItem(k);
};
LocalStorage.prototype.setItem = function(k,v) {
localStorage.setItem(k,v);
};
LocalStorage.prototype.removeItem = function(k) {
localStorage.removeItem(k);
};
LocalStorage.prototype.clear = function() {
localStorage.clear();
};
delete LocalStorage.prototype.length;
Object.defineProperty(LocalStorage.prototype, 'length', {
get: function() {
return localStorage.length;
}
});
LocalStorage.prototype.key = function(k) {
var v = localStorage.key(k);
return v;
};
module.exports = LocalStorage;

View file

@ -5,7 +5,38 @@ function GoogleDrive() {
};
GoogleDrive.prototype.init = function() {
console.log('[googleDrive.js.3] init'); //TODO
console.log('[googleDrive.js.3] init GoogleDrive'); //TODO
};
GoogleDrive.prototype.getItem = function(k) {
return localStorage.getItem(k);
};
GoogleDrive.prototype.setItem = function(k,v) {
localStorage.setItem(k,v);
};
GoogleDrive.prototype.removeItem = function(k) {
localStorage.removeItem(k);
};
GoogleDrive.prototype.clear = function() {
localStorage.clear();
};
delete GoogleDrive.prototype.length;
Object.defineProperty(GoogleDrive.prototype, 'length', {
get: function() {
return localStorage.length;
}
});
GoogleDrive.prototype.key = function(k) {
var v = localStorage.key(k);
return v;
};
module.exports = GoogleDrive;