LocalStorage Size
by spydmobile
JavaScript
console.clear();
console.log("SmartMap Storage use: " + localStorageSpace());
function localStorageSpace() {
var allStrings = '';
for(var key in window.localStorage){
if(window.localStorage.hasOwnProperty(key)){
allStrings += window.localStorage[key];
}
}
var sizekb = 3 + ((allStrings.length*16)/(8*1024));
var sizemb = (sizekb/1024)
sizemb = +sizemb.toFixed(2);
sizekb = +sizekb.toFixed(2);
if (sizekb > 1024){
var storageSize = sizemb + ' MB';
}
else {
var storageSize = sizekb + ' KB';
}
return allStrings ? storageSize : 'Empty (0 KB)';
};