PageSourceSearch

https://craxford-family.co.uk/js/litbox.js

js craxford-family.co.uk collected 2026-10-02 14:13:24 UTC 10,645 bytes, 310 lines download raw bytes

1var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
2var selects = new Array();
3var selidx = 0;
4
5LITBox = function(url, options){
6   this.url = url;
7   this.options = {
8      width: 700,
9      height: 500,
10      type: 'window',
11      func: null,
12      onremove: null,
13      draggable: true,
14      resizable: true,
15      overlay: true,
16      opacity: 1,
17      left: false,
18      top: false,
19	  doneLoading: null
20   };
21   var winwidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
22   jQuery.extend(this.options, options || {});
23   if(winwidth < this.options.width) this.options.width = winwidth - 35;
24
25   this.setup();
26}
27
28LITBox.prototype = {
29   setup: function(){
30	    var self = this;
31	    jQuery(document).ready(function(){
32		   self._setup();
33	    });
34   },
35   _setup: function(){
36		var self = this;
37		if(jQuery('#searchdrop').length) jQuery('#searchdrop').hide();
38		this.rn = ( Math.floor ( Math.random ( ) * 100000000 + 1 ) );
39		this.getWindow();
40
41		if(IE6) {
42			selects[selidx] = document.getElementsByTagName("select");
43			for(i=0; i < selects[selidx].length; i++) {
44		   		selects[selidx][i].style.visibility = 'hidden';
45			}
46			selidx += 1;
47		}
48
49		switch(this.options.type){
50         case 'window' :
51	 	var tempvar = this.getAjax(this.url);
52		this.d4.innerHTML = tempvar;
53        	//jQuery.get(this.url, function(html) {
54        		//jQuery(self.d4).html(html);
55			//self.display();
56        	//});
57            break;
58         case 'alert' : this.d4.innerHTML = this.url;
59            break;
60         case 'confirm' : this.d4.innerHTML = '<p>' + this.url + '</p>';
61            this.button_y = document.createElement('input');
62            this.button_y.type='button';
63            this.button_y.value='Yes';
64            this.d4.appendChild(this.button_y);
65            this.button_y.d= this.d; this.button_y.d2 = this.d2;
66            this.button_y.temp = this.options.func;
67            this.button_y.onclick=this.remove;
68            this.button_n = document.createElement('input');
69            this.button_n.type='button';
70            this.button_n.value='No';
71            this.d4.appendChild(this.button_n);
72            this.button_n.d= this.d; this.button_n.d2 = this.d2;
73            this.button_n.onclick=this.remove;
74		}
75		this.display();
76   },
77   getWindow: function(){
78      this.over = null;
79      if(this.options.overlay == true) {
80	      this.d = document.createElement('div');
81	      document.body.appendChild(this.d);
82	      this.d.className = 'LB_overlay';
83		  //if($('LB_overlay')) this.d.style.backgroundColor = '#444';
84		  this.d.id = 'LB_overlay';
85	      this.d.style.display = 'block';
86	      //this.d.onclick=this.remove;
87      }
88      this.d2 = document.createElement('div');
89      document.body.appendChild(this.d2);
90      this.d2.className = 'LB_window';
91	  this.d2.id = 'LB_window';
92      this.d2.style.height = parseInt(this.options.height) + 'px';
93      //this.d2.style.position = 'absolute';
94      this.d2.style.zIndex = '101';
95
96      this.d3 = document.createElement('div');
97      this.d2.appendChild(this.d3);
98      this.d3.className='LB_closeAjaxWindow';
99      this.d3.d2 = this.d2;
100      this.d3.over = this.over;
101      this.d3.options = this.options;
102	  if(this.options.draggable)
103	  	$(this.d2).draggable({handle: '.LB_closeAjaxWindow'}).resizable();
104      this.close = document.createElement('a');
105      this.d3.appendChild(this.close);
106      this.d3.style.width = parseInt(this.options.width) + 'px';
107      this.close.d = this.d;
108      this.close.d2 = this.d2;
109      this.close.href='#';
110      this.close.onclick=this.remove;
111      this.close.innerHTML='<img src="' + closeimg + '" border="0">';
112      this.close.id = 'LB_close';
113      this.close.onremove = this.options.onremove;
114      this.d3text = document.createElement('div');
115      this.d3text.id = 'LB_titletext';
116	  this.d3text.className = 'fieldname';
117      if(this.options.title) this.d3text.innerHTML = '<strong>' + this.options.title + '</strong>';
118      this.d3.appendChild(this.d3text);
119      this.d4 = document.createElement('div');
120      this.d4.className='LB_content';
121      //this.d4.id = 'tlitbox';
122      this.d4.style.height = parseInt(this.options.height) + 'px';
123      this.d4.style.width = parseInt(this.options.width) + 'px';
124      this.d2.appendChild(this.d4);
125      this.clear = document.createElement('div');
126      this.d2.appendChild(this.clear);
127      this.clear.style.clear='both';
128      if(this.options.overlay == true){
129      this.d.d = this.d;
130      this.d.d2 = this.d2;
131      }
132   },
133   display: function(){
134	  jQuery(this.d2).css('opacity',0);
135      this.position();
136      jQuery(this.d2).animate({opacity:this.options.opacity},200, this.options.doneLoading);
137   },
138   position: function(){
139      var de = document.documentElement;
140   	  var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
141	  //w = jQuery(window).width();
142   	  var h = self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
143
144	//alert('wi='+window.innerHeight+', wsm='+window.scrollMaxY+', bsh='+document.body.scrollHeight+', boh='+document.body.offsetHeight);
145	var yScroll = 0;
146    if (window.innerHeight) {
147   		yScroll = window.innerHeight;
148		if(window.scrollMaxY)
149			yScroll += window.scrollMaxY;
150   	}
151	if (document.body.scrollHeight >= document.body.offsetHeight && document.body.scrollHeight > yScroll){ // all but Explorer Mac
152   		yScroll = document.body.scrollHeight + 30;
153	}
154	if (document.documentElement.clientHeight && document.documentElement.clientHeight > yScroll) {
155		yScroll = document.documentElement.clientHeight
156   	}
157	if(!yScroll) { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
158   		yScroll = document.body.offsetHeight;
159    }
160	this.d2.style.width = this.options.width + 'px';
161	this.d2.style.display = 'block';
162	if(!this.options.left || this.options.left < 0){
163		this.d2.style.left = ((w - this.options.width)/2)+"px";
164	}else{
165		this.d2.style.left=parseInt(this.options.left)+'px';
166	}
167	
168	var pagesize = this.getPageSize();
169	var arrayPageScroll = this.getPageScrollTop();
170/*	
171	if(this.d2.offsetHeight > h - 100){
172		if(!this.options.top || this.options.top < 0){
173			this.d2.style.top = "45px";
174		}else{
175			this.d2.style.top=parseInt(this.options.top)+'px';
176		}
177		this.d2.style.height=h-100 + 'px';
178		//this.d4.style.height=h-145 + 'px';
179		this.d4.style.overflow ='auto';
180	} else {   
181*/
182	if(!this.options.top || this.options.top < 0){
183		var newtop = arrayPageScroll[1] + ((pagesize[1]-this.d2.offsetHeight)/2);
184		this.d2.style.top = newtop > 0 ? newtop +"px" : "0px";
185	}else{
186		this.d2.style.top=parseInt(this.options.top)+'px';
187	}
188	/*}*/
189	if(this.d){this.d.style.height =   yScroll +"px";}
190   },
191   remove: function(){
192      if(this.temp) this.temp();
193      var d2 = jQuery(this.d2);
194      var onremove = this.onremove;
195      
196      d2.animate({opacity:0}
196,200, function(){d2.remove()});
197      if(this.d) {
198          var d = jQuery(this.d);
199    	  d.animate({opacity:0},200, function(){
200    		  d.remove();
201    		  if(onremove) onremove();
202    	  });
203      }
204
205	if(IE6) {
206		selects[selidx] = document.getElementsByTagName("select");
207		for(i=0; i < selects[selidx].length; i++) {
208			selects[selidx][i].style.visibility = 'visible';
209		}
210		selidx -= 1;
211	}
212      return false;
213   },
214   parseQuery: function(query){
215      var Params = new Object ();
216      if ( ! query ) return Params; // return empty object
217      var Pairs = query.split(/[;&]/);
218      for ( var i = 0; i < Pairs.length; i++ ) {
219         var KeyVal = Pairs[i].split('=');
220         if ( ! KeyVal || KeyVal.length != 2 ) continue;
221         var key = unescape( KeyVal[0] );
222         var val = unescape( KeyVal[1] );
223         val = val.replace(/\+/g, ' ');
224         Params[key] = val;
225      }
226      return Params;
227   },
228   getPageScrollTop: function(){
229      var yScrolltop;
230      if (self.pageYOffset) {
231         yScrolltop = self.pageYOffset;
232      } else if (document.documentElement && document.documentElement.scrollTop){    // Explorer 6 Strict
233         yScrolltop = document.documentElement.scrollTop;
234      } else if (document.body) {// all other Explorers
235         yScrolltop = document.body.scrollTop;
236      }
237      arrayPageScroll = new Array('',yScrolltop)
238      return arrayPageScroll;
239   },
240   getPageSize: function(){
241      var de = document.documentElement;
242      var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
243      var h = self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
244      
245      arrayPageSize = new Array(w,h) 
246      return arrayPageSize;
247   },
248   getAjax: function(url){
249      var xmlhttp=false;
250      /*@cc_on @*/
251      /*@if (@_jscript_version >= 5)
252      // JScript gives us Conditional compilation, we can cope with old IE versions.
253      // and security blocked creation of the objects.
254        try {
255        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
256        } catch (e) {
257         try {
258          xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
259         } catch (E) {
260          xmlhttp = false;
261         }
262        }
263      @end @*/
264      if (!xmlhttp && typeof XMLHttpRequest!='undefined') xmlhttp = new XMLHttpRequest();
265      if(xmlhttp.overrideMimeType) xmlhttp.overrideMimeType('text/xml');
266      if(url != ""){
267         xmlhttp.open("GET", url, false);
268         xmlhttp.send(null);
269         return xmlhttp.responseText;
270      }
271   }
272}
273
274function openFind(form,findscript) {
275	var params = jQuery.param(form);
276	if(jQuery('#findspin').length) jQuery('#findspin').show();
277	jQuery.ajax({
278		url: findscript,
279		data: params,
280		dataType: 'html',
281		success: function(req){
282			jQuery('#findresults').html(req);
283			if(jQuery('#findspin').length) jQuery('#findspin').hide();
284			jQuery('#finddiv').toggle(200,function(){
285				jQuery('#findresults').toggle(200);
286			});
287		}
288	});
289	return false;
290}
291
292function reopenFindForm() {
293	jQuery('#findresults').toggle(200,function(){
294		clearForm(document.findform1);
295		jQuery('#finddiv').toggle(200);
296	});
297}
298
299function clearForm(form) {
300	jQuery(form).children(':input').each(function(index,element) {
301		if(element.type == 'text') element.value = '';
302	});
303}
304
305function openHelp(filename) {
306	var newwindow = window.open(filename, 'newwindow', 'height=600,width=700,resizable=yes,scrollbars=yes');
307	newwindow.focus();
308
309	return false;
310}

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.