jeromegn/Backbone.localStorage — Issue #22: Allowing localStorage on Blackberry devices
Author: mowbell
Created: 2012-02-17 00:08:15+00:00
State: open

The old devices are not compatible with localStorage, I found a code that adds support to these devices as the BlackBerry, IE etc, it works with cache,

mozilla https://developer.mozilla.org/en/DOM/Storage#localStorage

I hope that is helpful for your plug-in

`

if (!window.localStorage) {
window.localStorage = {
getItem: function (sKey) {
if (!sKey || !this.hasOwnProperty(sKey)) { return null; }
return unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"), "$1"));
},
key: function (nKeyId) { return unescape(document.cookie.replace(/\s*\=(?:.(?!;))*$/, "").split(/\s*\=(?:[^;](?!;))*[^;]?;\s*/)[nKeyId]); },
setItem: function (sKey, sValue) {
if(!sKey) { return; }
document.cookie = escape(sKey) + "=" + escape(sValue) + "; path=/";
this.length = document.cookie.match(/\=/g).length;
},
length: 0,
removeItem: function (sKey) {
if (!sKey || !this.hasOwnProperty(sKey)) { return; }
var sExpDate = new Date();
sExpDate.setDate(sExpDate.getDate() - 1);
document.cookie = escape(sKey) + "=false; expires=" + sExpDate.toGMTString() + "; path=/";
this.length--;
},
hasOwnProperty: function (sKey) { return (new RegExp("(?:^|;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie); }
};
window.localStorage.length = (document.cookie.match(/\=/g) || window.localStorage).length;
window.localStorage.clear=function(){

while(window.localStorage.length){
var cookies = document.cookie.split(";");
var nameCookie=cookies[0].split("=")[0];
window.localStorage.removeItem(nameCookie);
}

}
}
`
(My code clears all cookies, it should not be so)

Best regards