session storage
var sessionStorage;
$(function () {"use strict";
if (typeof sessionStorage === 'undefined') {
sessionStorage = (function () {
var data = window.top.name ? JSON.parse(window.top.name) : {};
return {
clear: function () {
data = {};
window.top.name = '';
},
getItem: function (key) {
return data[key] || null;
},
key: function (i) {
// not perfect, but works
var ctr = 0,
k;
for (k in data) {
if (ctr === i) {
return k;
} else {
ctr += 1;
}
}
},
removeItem: function (key) {
delete data[key];
window.top.name = JSON.stringify(data);
},
setItem: function (key, value) {
data[key] = value + ""; // forces the value to a string
window.top.name = JSON.stringify(data);
}
};
})();
}
});