summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-01-15 19:11:25 +0100
committerRobin Appelman <icewind@owncloud.com>2012-01-15 19:22:32 +0100
commita883fcca3c93e866a08d69748780c65cbfde4306 (patch)
tree034789ea6e02b9417a625918ef5a96d7190e7ec7
parenta44bbd80052bd597c0387299f657b950412ad8b9 (diff)
downloadnextcloud-server-a883fcca3c93e866a08d69748780c65cbfde4306.tar.gz
nextcloud-server-a883fcca3c93e866a08d69748780c65cbfde4306.zip
add user and instance awere localstorage to prevent collisions when using localstorage
-rw-r--r--core/js/js.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/core/js/js.js b/core/js/js.js
index 2bb6cff0cb0..56ce87f1c21 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -130,6 +130,35 @@ OC.search.lastResults={};
OC.addStyle.loaded=[];
OC.addScript.loaded=[];
+if(typeof localStorage !='undefined'){
+ //user and instance awere localstorage
+ OC.localStorage={
+ namespace:'oc_'+OC.currentUser+'_'+OC.webroot+'_',
+ hasItem:function(name){
+ return OC.localStorage.getItem(name)!=null;
+ },
+ setItem:function(name,item){
+ return localStorage.setItem(OC.localStorage.namespace+name,JSON.stringify(item));
+ },
+ getItem:function(name){
+ return JSON.parse(localStorage.getItem(OC.localStorage.namespace+name));
+ }
+ }
+}else{
+ //dummy localstorage
+ OC.localStorage={
+ hasItem:function(name){
+ return false;
+ },
+ setItem:function(name,item){
+ return false;
+ },
+ getItem:function(name){
+ return null;
+ }
+ }
+}
+
/**
* implement Array.filter for browsers without native support
*/
@@ -410,3 +439,5 @@ if (!Array.prototype.map){
$.fn.filterAttr = function(attr_name, attr_value) {
return this.filter(function() { return $(this).attr(attr_name) === attr_value; });
};
+
+