PageSourceSearch

https://bilet.gigstix.com/media/javascript/ClientStore.js

js gigstix.com collected 2026-10-03 21:21:01 UTC 3,881 bytes, 151 lines download raw bytes

1function decodeDate(dateString, format){
2	//format not used, maybe in future
3	//now format is standard JSON date format YYYY-MM-DDTHH:mm:ss
4	var dateParts = dateString.match(/(\d{4})-(\d{2})-(\d{2})[T\s](\d{2}):(\d{2}):(\d{2})/).slice(1);
5	
6	if (!dateParts) 
7		return null;
8	var dateValue = new Date();
9	dateValue.setFullYear(dateParts[0], dateParts[1] - 1, dateParts[2]);
10	dateValue.setHours(dateParts[3], dateParts[4], dateParts[5]);
11	return dateValue;
12}
13
14ClientStore = {
15	init: function(){
16		if (!window.localStorage) {
17			var mem = document.createElement("div");
18			mem.id = "localClientStore";
19			mem.style.display = "none";
20			mem.style.behavior = "url('#default#userData')";
21			Ext.getBody().appendChild(mem);
22			this.userData = mem;
23			this.userData.load("VMSLocal");
24		}
25		else {
26			this.localClientStorage = window.localStorage;
27		}
28	},
29	getKeyByScope: function(key, scope){
30		if (scope) {
31			switch (scope.toLowerCase().substring(0, 1)) {
32				case 'p':
33					return document.location.pathname.replace(/[\/\.\:]/g, "_") + "_" + key;
34					break;
35				case 'f':
36					return document.location.pathname.replace(/[^\/]+$/, "").replace(/[\/]/g, "_") + key;
37					break;
38			}
39		}
40		else {
41			return document.location.host.replace(/[\/\.\:]/g, "_") + "_" + key;
42		}
43	},
44	addItem: function(key, value, scope, expires){
45	
46		key = this.getKeyByScope(key, scope);
47		
48		if (expires && !Ext.isDate(expires)) {
49			var interval;
50			var eValue = parseInt(expires.substring(1, 4));
51			var expDate = new Date();
52			switch (expires.substring(0, 1)) {
53				case 'y':
54				case 'Y':
55					interval = Date.YEAR;
56					expDate.setYear(expDate.getYear() + eValue);
57					break;
58				case 'M':
59					interval = Date.MONTH;
60					expDate.setMonth(expDate.getMonth() + eValue);
61					break;
62				case 'd':
63				case 'D':
64					interval = Date.DAY;
65					expDate.setDate(expDate.getDate() + eValue);
66					break;
67				case 'h':
68				case 'H':
69					interval = Date.HOUR;
70					expDate.setHours(expDate.getHours() + eValue);
71					break;
72				case 'm':
73					interval = Date.MINUTE;
74					expDate.setMinutes(expDate.getMinutes() + eValue);
75					break;
76				case 's':
77				case 'S':
78					interval = Date.SECOND;
79					expDate.setSeconds(expDate.getSeconds() + eValue);
80					break;
81			}
82			//expires = new Date().add(interval, eValue);
83			expires = expDate;
84			console.log(expires);
85		}
86		
87		storageItem = {
88			value: value,
89			expires: expires
90		};
91		
92		if (!window.localStorage) {
93			this.userData.setAttribute(key, Ext.encode(storageItem));
94			this.userData.save("VMSLocal");
95		}
96		else {
97			window.localStorage.setItem(key, Ext.encode(storageItem));
98		}
99	},
100	getItem: function(key, scope){
101	
102		key = this.getKeyByScope(key, scope);
103		var storageItem;
104		var itemValue;
105		var expired;
106		if (!window.localStorage) {
107			storageItem = Ext.decode(this.userData.getAttribute(key));
108		}
109		else {
110			storageItem = Ext.decode(window.localStorage.getItem(key));
111		}
112		expired = storageItem.expires &&
113		decodeDate(storageItem.expires) < new Date();
114		if (expired) {
115			this.removeItem(key);
116			return null;
117		}
118		if (Ext.isString(storageItem.value) &&
119		storageItem.value.match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/)) {
120			//item value is date
121			itemValue = decodeDate(storageItem.value);
122		}
123		else {
124			itemValue = storageItem.value;
125		}
126		return itemValue;
127		
128	},
129	removeItem: function(key, scope){
130		key = this.getKeyByScope(key, scope);
131		if (!window.localStorage) {
132			this.userData.removeAttribute(key);
133		}
134		else {
135			window.localStorage.removeItem(key);
136		}
137	}
138	
139};
140
141/*
142 ClientStore.addItem("d1local","d1",null,"m1");
143 ClientStore.addItem("d1folder","d1f","f");
144 ClientStore.addItem("d1domain","d1d","d");
145 console.clear();
146 console.log(localStorage);
147 console.log(ClientStore.getItem("d1local"));
148 console.log(ClientStore.getItem("d1folder","f"));
149 console.log(ClientStore.getItem("d1domain","d"));
150 */
151ClientStore.init();

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.