PageSourceSearch

https://www.socialmotus.com/js/wl_Store.js

js socialmotus.com collected 2026-10-04 21:14:48 UTC 2,480 bytes, 118 lines download raw bytes

1/*----------------------------------------------------------------------*/
2/* wl_Store v 1.0 by revaxarts.com
3/* description: Uses LocalStorage to save information within the Browser
4/*				enviroment
5/* dependency:  >IE7 :)
6/*----------------------------------------------------------------------*/
7
8
9$.wl_Store = function (namespace) {
10
11		//IE7 isn't a cool client :(
12	var coolClient = (typeof window.localStorage !== 'undefined' && typeof JSON !== 'undefined'),
13		//namespace for the storage
14		namespace = namespace || 'wl_store',
15
16
17		loc = {
18
19			//method to save data
20			save: function (key, value) {
21				var _save;
22				if (typeof key !== 'object') {
23					var _current = get() || {};
24					var _obj = {};
25					_obj[key] = value;
26					_save = $.extend({}, _current, _obj);
27				} else {
28					_save = key;
29				}
30				localStorage[namespace] = JSON.stringify(_save);
31				return true;
32			},
33			
34			//method to get data
35			get: function (key) {
36				var _obj = $.parseJSON(localStorage[namespace]);
37
38				if (typeof key !== 'undefined' && _obj) {
39					return _obj[key];
40				}
41				return _obj;
42			},
43			
44			//method to remove data
45			remove: function (key) {
46				var obj = get();
47				if (typeof key !== 'undefined' && obj[key]) {
48					delete obj[key];
49					for (var i in obj) {
50						var notempty = true;
51						break;
52					}
53					if (notempty) {
54						save(obj);
55						return true;
56					}
57				}
58				localStorage.removeItem(namespace);
59				return true;
60			},
61			
62			//delete all saved data
63			flush: function () {
64				localStorage.clear();
65				return true;
66			}
67		},
68
69		//IE 7 can't handle localStorage but cookies are to bad for storing huge data
70		cok = {
71			save: function (key, value) {
72				return false;
73			},
74			get: function (key) {
75				return false;
76			},
77			remove: function (key) {
78				return false;
79			},
80			flush: function () {
81				return false;
82			}
83		},
84		save = function (key, value) {
85			return (coolClient) ? loc.save(key, value) : cok.save(key, value);
86		},
87
88		remove = function (key) {
89			return (coolClient) ? loc.remove(key) : cok.remove(key);
90		},
91
92		flush = function () {
93			return (coolClient) ? loc.flush() : cok.flush();
94		},
95
96		get = function (key) {
97			return (coolClient) ? loc.get(key) : cok.get(key);
98		};
99
100	//public methods
101	return {
102		save: function (key, value) {
103			return save(key, value);
104		},
105		get: function (key) {
106			return get(key);
107		},
108		remove: function (key) {
109			return remove(key);
110		},
111		flush: function () {
112			return flush();
113		}
114
115	}
116
117
118};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.