PageSourceSearch

https://geneinfinity.org/scripts/sessvars.js

js geneinfinity.org collected 2026-10-02 06:47:56 UTC 6,712 bytes, 215 lines download raw bytes

1/*
2sessvars ver 1.01
3- JavaScript based session object
4copyright 2008 Thomas Frank
5
6This EULA grants you the following rights:
7
8Installation and Use. You may install and use an unlimited number of copies of the SOFTWARE PRODUCT.
9
10Reproduction and Distribution. You may reproduce and distribute an unlimited number of copies of the SOFTWARE PRODUCT either in whole or in part; each copy should include all copyright and trademark notices, and shall be accompanied by a copy of this EULA. Copies of the SOFTWARE PRODUCT may be distributed as a standalone product or included with your own product.
11
12Commercial Use. You may sell for profit and freely distribute scripts and/or compiled scripts that were created with the SOFTWARE PRODUCT.
13
14v 1.0 --> 1.01
15sanitizer added to toObject-method & includeFunctions flag now defaults to false
16
17*/
18
19sessvars=function(){
20
21	var x={};
22	
23	x.$={
24		prefs:{
25			memLimit:2000,
26			autoFlush:true,
27			crossDomain:false,
28			includeProtos:false,
29			includeFunctions:false
30		},
31		parent:x,
32		clearMem:function(){
33			for(var i in this.parent){if(i!="$"){this.parent[i]=undefined}};
34			this.flush();
35		},
36		usedMem:function(){
37			x={};
38			return Math.round(this.flush(x)/1024);
39		},
40		usedMemPercent:function(){
41			return Math.round(this.usedMem()/this.prefs.memLimit);
42		},
43		flush:function(x){
44			var y,o={},j=this.$$;
45			x=x||top;
46			for(var i in this.parent){o[i]=this.parent[i]};
47			o.$=this.prefs;
48			j.includeProtos=this.prefs.includeProtos;
49			j.includeFunctions=this.prefs.includeFunctions;
50			y=this.$$.make(o);
51			if(x!=top){return y.length};
52			if(y.length/1024>this.prefs.memLimit){return false}
53			x.name=y;
54			return true;
55		},
56		getDomain:function(){
57				var l=location.href
58				l=l.split("///").join("//");
59				l=l.substring(l.indexOf("://")+3).split("/")[0];
60				while(l.split(".").length>2){l=l.substring(l.indexOf(".")+1)};
61				return l
62		},
63		debug:function(t){
64			var t=t||this,a=arguments.callee;
65			if(!document.body){setTimeout(function(){a(t)},200);return};
66			t.flush();
67			var d=document.getElementById("sessvarsDebugDiv");
68			if(!d){d=document.createElement("div");document.body.insertBefore(d,document.body.firstChild)};
69			d.id="sessvarsDebugDiv";
70			d.innerHTML='<div style="line-height:20px;padding:5px;font-size:11px;font-family:Verdana,Arial,Helvetica;'+
71						'z-index:10000;background:#FFFFCC;border: 1px solid #333;margin-bottom:12px">'+
72						'<b style="font-family:Trebuchet MS;font-size:20px">sessvars.js - debug info:</b><br/><br/>'+
73						'Memory usage: '+t.usedMem()+' Kb ('+t.usedMemPercent()+'%)&nbsp;&nbsp;&nbsp;'+
74						'<span style="cursor:pointer"><b>[Clear memory]</b></span><br/>'+
75						top.name.split('\n').join('<br/>')+'</div>';
76			d.getElementsByTagName('span')[0].onclick=function(){t.clearMem();location.reload()}
77		},
78		init:function(){
79			var o={}, t=this;
80			try {o=this.$$.toObject(top.name)} catch(e){o={}};
81			this.prefs=o.$||t.prefs;
82			if(this.prefs.crossDomain || this.prefs.currentDomain==this.getDomain()){
83				for(var i in o){this.parent[i]=o[i]};
84			}
85			else {
86				this.prefs.currentDomain=this.getDomain();
87			};
88			this.parent.$=t;
89			t.flush();
90			var f=function(){if(t.prefs.autoFlush){t.flush()}};
91			if(window["addEventListener"]){addEventListener("unload",f,false)}
92			else if(window["attachEvent"]){window.attachEvent("onunload",f)}
93			else {this.prefs.autoFlush=false};
94		}
95	};
96	
97	x.$.$$={
98		compactOutput:false, 		
99		includeProtos:false, 	
100		includeFunctions: false,
101		detectCirculars:true,
102		restoreCirculars:true,
103		make:function(arg,restore) {
104			this.restore=restore;
105			this.mem=[];this.pathMem=[];
106			return this.toJsonStringArray(arg).join('');
107		},
108		toObject:function(x){
109			if(!this.cleaner){
110				try{this.cleaner=new RegExp('^("(\\\\.|[^"\\\\\\n\\r])*?"|[,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t])+?$')}
111				catch(a){this.cleaner=/^(true|false|null|\[.*\]|\{.*\}|".*"|\d+|\d+\.\d+)$/}
112			};
113			if(!this.cleaner.test(x)){return {}};
114			eval("this.myObj="+x);
115			if(!this.restoreCirculars || !alert){return this.myObj};
116			if(this.includeFunctions){
117				var x=this.myObj;
118				for(var i in x){if(typeof x[i]=="string" && !x[i].indexOf("JSONincludedFunc:")){
119					x[i]=x[i].substring(17);
120					eval("x[i]="+x[i])
121				}}
122			};
123			this.restoreCode=[];
124			this.make(this.myObj,true);
125			var r=this.restoreCode.join(";")+";";
126			eval('r=r.replace(/\\W([0-9]{1,})(\\W)/g,"[$1]$2").replace(/\\.\\;/g,";")');
127			eval(r);
128			return this.myObj
129		},
130		toJsonStringArray:function(arg, out) {
131			if(!out){this.path=[]};
132			out = out || [];
133			var u; // undefined
134			switch (typeof arg) {
135			case 'object':
136				this.lastObj=arg;
137				if(this.detectCirculars){
138					var m=this.mem; var n=this.pathMem;
139					for(var i=0;i<m.length;i++){
140						if(arg===m[i]){
141							out.push('"JSONcircRef:'+n[i]+'"');return out
142						}
143					};
144					m.push(arg); n.push(this.path.join("."));
145				};
146				if (arg) {
147					if (arg.constructor == Array) {
148						out.push('[');
149						for (var i = 0; i < arg.length; ++i) {
150							this.path.push(i);
151							if (i > 0)
152								out.push(',\n');
153							this.toJsonStringArray(arg[i], out);
154							this.path.pop();
155						}
156						out.push(']');
157						return out;
158					} else if (typeof arg.toString != 'undefined') {
159						out.push('{');
160						var first = true;
161						for (var i in arg) {
162							if(!this.includeProtos && arg[i]===arg.constructor.prototype[i]){continue};
163							this.path.push(i);
164							var curr = out.length; 
165							if (!first)
166								out.push(this.compactOutput?',':',\n');
167							this.toJsonStringArray(i, out);
168							out.push(':');                    
169							this.toJsonStringArray(arg[i], out);
170							if (out[out.length - 1] == u)
171								out.splice(curr, out.length - curr);
172							else
173								first = false;
174							this.path.pop();
175						}
176						out.push('}');
177						return out;
178					}
179					return out;
180				}
181				out.push('null');
182				return out;
183			case 'unknown':
184			case 'undefined':
185			case 'function':
186				if(!this.includeFunctions){out.push(u);return out};
187				arg="JSONincludedFunc:"+arg;
188				out.push('"');
189				var a=['\n','\\n','\r','\\r','"','\\"'];
190				arg+=""; for(var i=0;i<6;i+=2){arg=arg.split(a[i]).join(a[i+1])};
191				out.push(arg);
192				out.push('"');
193				return out;
194			case 'string':
195				if(this.restore && arg.indexOf("JSONcircRef:")==0){
196					this.restoreCode.push('this.myObj.'+this.path.join(".")+"="+arg.split("JSONcircRef:").join("this.myObj."));
197				};
198				out.push('"');
199				var a=['\n','\\n','\r','\\r','"','\\"'];
200				arg+=""; for(var i=0;i<6;i+=2){arg=arg.split(a[i]).join(a[i+1])};
201				out.push(arg);
202				out.push('"');
203				return out;
204			default:
205				out.push(String(arg));
206				return out;
207			}
208		}
209	};
210	
211	x.$.init();
212	return x;
213}()
214
215

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.