-
Notifications
You must be signed in to change notification settings - Fork 0
/
iSessionStorage.js
executable file
·83 lines (69 loc) · 1.77 KB
/
iSessionStorage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**
* Объект для работы с SessionStorage
*/
(function (window, root) {
"use strict";
var iSessionStorage = {
_storage: window.sessionStorage,
/**
*
* @returns {boolean}
*/
isSupported: function () {
return !!this._storage;
},
/**
*
* @param name
* @param value
* @returns {boolean}
*/
"set": function (name, value) {
if (!name || !this._storage) {
return false;
}
this._storage.setItem(name, value);
return !!this._storage.getItem(name);
},
/**
*
* @param name
* @returns {*}
*/
"get": function (name) {
if (!name || !this._storage) {
return null;
}
return this._storage.getItem(name);
},
/**
*
* @param name
* @returns {boolean}
*/
remove: function (name) {
if (!name || !this._storage) {
return false;
}
this._storage.removeItem(name);
return true;
},
/**
*
* @returns {boolean}
*/
clear: function () {
if (!this._storage) {
return false;
}
var item;
for (item in this._storage) {
if (this._storage.hasOwnProperty(item)) {
this._storage.removeItem(item);
}
}
return true;
}
};
(root || window).iSessionStorage = iSessionStorage;
}(window, this));