Commit 77630cb4 authored by Tristan Cavelier's avatar Tristan Cavelier

local storage connector only use html5 localStorage

parent 11b53fab
...@@ -54,8 +54,7 @@ var newLocalStorage = function ( spec, my ) { ...@@ -54,8 +54,7 @@ var newLocalStorage = function ( spec, my ) {
* @return {array} The list of users. * @return {array} The list of users.
*/ */
priv.getUserArray = function () { priv.getUserArray = function () {
return LocalOrCookieStorage.getItem( return localStorage.getItem(storage_user_array_name) || [];
storage_user_array_name) || [];
}; };
/** /**
...@@ -66,8 +65,7 @@ var newLocalStorage = function ( spec, my ) { ...@@ -66,8 +65,7 @@ var newLocalStorage = function ( spec, my ) {
priv.addUser = function (user_name) { priv.addUser = function (user_name) {
var user_array = priv.getUserArray(); var user_array = priv.getUserArray();
user_array.push(user_name); user_array.push(user_name);
LocalOrCookieStorage.setItem(storage_user_array_name, localStorage.setItem(storage_user_array_name,user_array);
user_array);
}; };
/** /**
...@@ -92,8 +90,7 @@ var newLocalStorage = function ( spec, my ) { ...@@ -92,8 +90,7 @@ var newLocalStorage = function ( spec, my ) {
* @return {array} All the existing file paths. * @return {array} All the existing file paths.
*/ */
priv.getFileNameArray = function () { priv.getFileNameArray = function () {
return LocalOrCookieStorage.getItem( return localStorage.getItem(storage_file_array_name) || [];
storage_file_array_name) || [];
}; };
/** /**
...@@ -104,8 +101,7 @@ var newLocalStorage = function ( spec, my ) { ...@@ -104,8 +101,7 @@ var newLocalStorage = function ( spec, my ) {
priv.addFileName = function (file_name) { priv.addFileName = function (file_name) {
var file_name_array = priv.getFileNameArray(); var file_name_array = priv.getFileNameArray();
file_name_array.push(file_name); file_name_array.push(file_name);
LocalOrCookieStorage.setItem(storage_file_array_name, localStorage.setItem(storage_file_array_name,file_name_array);
file_name_array);
}; };
/** /**
...@@ -120,8 +116,7 @@ var newLocalStorage = function ( spec, my ) { ...@@ -120,8 +116,7 @@ var newLocalStorage = function ( spec, my ) {
new_array.push(array[i]); new_array.push(array[i]);
} }
} }
LocalOrCookieStorage.setItem(storage_file_array_name, localStorage.setItem(storage_file_array_name,new_array);
new_array);
}; };
priv.checkSecuredDocId = function (secured_docid,docid,method) { priv.checkSecuredDocId = function (secured_docid,docid,method) {
...@@ -178,7 +173,7 @@ var newLocalStorage = function ( spec, my ) { ...@@ -178,7 +173,7 @@ var newLocalStorage = function ( spec, my ) {
doc.content = command.getDocContent(); doc.content = command.getDocContent();
doc._last_modified = Date.now(); doc._last_modified = Date.now();
} }
LocalOrCookieStorage.setItem(path, doc); localStorage.setItem(path, doc);
that.success ({ok:true,id:command.getDocId()}); that.success ({ok:true,id:command.getDocId()});
}); });
}; // end put }; // end put
...@@ -199,7 +194,7 @@ var newLocalStorage = function ( spec, my ) { ...@@ -199,7 +194,7 @@ var newLocalStorage = function ( spec, my ) {
if (!priv.checkSecuredDocId( if (!priv.checkSecuredDocId(
secured_docid,command.getDocId(),'get')) {return;} secured_docid,command.getDocId(),'get')) {return;}
doc = LocalOrCookieStorage.getItem( doc = localStorage.getItem(
'jio/local/'+priv.secured_username+'/'+ 'jio/local/'+priv.secured_username+'/'+
priv.secured_applicationname+'/'+secured_docid); priv.secured_applicationname+'/'+secured_docid);
if (!doc) { if (!doc) {
...@@ -233,7 +228,7 @@ var newLocalStorage = function ( spec, my ) { ...@@ -233,7 +228,7 @@ var newLocalStorage = function ( spec, my ) {
array = priv.getFileNameArray(); array = priv.getFileNameArray();
for (i = 0, l = array.length; i < l; i += 1) { for (i = 0, l = array.length; i < l; i += 1) {
file_object = file_object =
LocalOrCookieStorage.getItem(path+'/'+array[i]); localStorage.getItem(path+'/'+array[i]);
if (file_object) { if (file_object) {
if (command.getOption('metadata_only')) { if (command.getOption('metadata_only')) {
new_array.push ({ new_array.push ({
...@@ -268,7 +263,7 @@ var newLocalStorage = function ( spec, my ) { ...@@ -268,7 +263,7 @@ var newLocalStorage = function ( spec, my ) {
if (!priv.checkSecuredDocId( if (!priv.checkSecuredDocId(
secured_docid,command.getDocId(),'remove')) {return;} secured_docid,command.getDocId(),'remove')) {return;}
// deleting // deleting
LocalOrCookieStorage.deleteItem(path); delete localStorage[path];
priv.removeFileName(secured_docid); priv.removeFileName(secured_docid);
that.success ({ok:true,id:command.getDocId()}); that.success ({ok:true,id:command.getDocId()});
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment