PageSourceSearch

https://ep.nelsonmandelabay.gov.za/js/common.js

js nelsonmandelabay.gov.za collected 2026-09-24 22:01:53 UTC 6,223 bytes, 303 lines download raw bytes

1var __szElement = null;
2var __szElementContent = null;
3
4function getElement( element )
5{
6	if( typeof element == 'string' ) {
7		return getElementById( element );
8	}
9	else if( typeof element == 'object' ) {
10		return element;
11	}
12	else {
13		return null;
14	}
15}
16
17function getElementById( elementId )
18{
19	if( document.getElementById != null ) {
20		return document.getElementById( elementId );
21	}
22	else {
23		if( document.all != null ) {
24			return document.all[ elementId ];
25		}
26		else if( document.layers != null ) {
27			return document.layers[ elementId ];
28		}
29		else {
30			alert( 'getElementById(): Cannot retrieve element.' );
31		}
32	}
33}
34
35function computedStyle( element )
36{
37	if( window.getComputedStyle != null ) {
38         	return window.getComputedStyle( getElement( element ), null );
39	}
40	else if( element.currentStyle != null ) {
41		return element.currentStyle;
42	}
43	else if( element.runtimeStyle != null ) {
44		return element.runtimeStyle;
45	}
46
47}
48
49function parseStyleValue( styleStr )
50{
51
52
53	if( styleStr ) {
54
55        	var ret = '';
56
57		var str = styleStr.split( '' );
58
59		var ch;
60
61		for( i in str ) {
62
63			ch = str[ i ];
64
65			//alert( ch );
66
67			switch( ch ) {
68				case '0':
69				case '1':
70				case '2':
71				case '3':
72				case '4':
73				case '5':
74				case '6':
75				case '7':
76				case '8':
77				case '9':
78
79				ret += ch;
80
81				break;
82			}
83
84
85
86
87		}
88
89		return 1 * ( ret );
90	}
91	else return 0;
92
93
94}
95
96
97function createElement( elementTag )
98{
99	return document.createElement( elementTag );
100}
101
102function createTextNode( text )
103{
104	return document.createTextNode( text );
105}
106
107function abs( number )
108{
109	if( number < 0 ) return number * -1; else return number;	
110}
111
112function parseJSON( json )
113{
114	if( json.length != '' ) return eval( '(' + json + ')' ); else return null;
115}
116
117function textSize( str, css, cleanUp )
118{
119	if( __szElement == null ) {
120		__szElement = createElement( 'div' );
121		document.body.appendChild( __szElement );
122		__szElement.id = '__textSizeBox';
123
124		// set the main elements css properties
125
126		__szElement.style.width = '0px';
127		__szElement.style.height = '0px';
128
129		__szElement.style.left = '0px';
130		__szElement.style.top = '0px';
131
132		__szElement.style.position = 'absolute';
133	
134		__szElement.style.visibility = 'hidden';
135		__szElement.style.overflow = 'hidden';
136		__szElement.style.display = 'block';
137		
138		// create the content element
139
140		__szElementContent = createElement( 'span' );
141		__szElement.appendChild( __szElementContent );
142		__szElementContent.id = '__textSizeContent';
143
144		__szElementContent.style.display = 'inline';
145		__szElementContent.style.whiteSpace = 'nowrap';
146
147	}
148
149	// create a span that will determine the minimum size for this string
150
151	if( css ) __szElementContent.className = css;
152
153	__szElementContent.innerHTML = str;
154
155	
156	var ret = {
157		'width': __szElementContent.offsetWidth,
158		'height': __szElementContent.offsetHeight
159	} 
160
161	if( ( cleanUp ) && ( cleanUp == true ) ) {
162		document.body.removeChild( __szElement );
163	}
164
165	return ret;
166}
167
168function min( origVal, newVal )
169{
170	if( origVal < newVal ) return origVal; return newVal;
171}
172
173function max( origVal, newVal )
174{
175	if( origVal > newVal ) return origVal; return newVal;
176}
177
178function timeStamp()
179{
180	return 'TIME';
181}
182
183function except( className, fname, message, iname )
184{
185	var m = '';
186
187	if( this._id != null ) {
188		m += '[' + this._id + '] ';
189	}
190
191	if( ( fname != null ) && ( iname != null )) {
192		m += className + '.' + fname + '() - "' + iname + '": ' + message + '.';
193	}
194	else if( fname != null ) {
195		m += className + '.' + fname + '(): ' + message + '.';
196	}
197	else {
198		m += className + '(): ' + message + '.';
199	}
200		
201	throw m;
202}
203
204
205var event_mouseClick = 1;
206var event_mouseDown = 2;
207var event_mouseUp = 3;
208var event_mouseMove = 4;
209var event_mouseOver = 5;
210var event_mouseOut = 6;
211
212function addEventListener( e, event, handler )
213{
214	if( e ) {
215		if( e.addEventListener ) {
216			switch( event ) {
217				case event_mouseMove : e.addEventListener( 'mousemove', handler, false ); break;
218				case event_mouseUp   : e.addEventListener( 'mouseup', handler, false ); break;
219				case event_mouseDown : e.addEventListener( 'mousedown', handler, false ); break;
220				case event_mouseClick: e.addEventListener( 'click', handler, false ); break;
221				case event_mouseOver : e.addEventListener( 'mouseover', handler, false ); break;
222				case event_mouseOut  : e.addEventListener( 'mouseout', handler, false ); break;
223			}
224		}
225
226		else if( e.attachEvent ) {
227			switch( event ) {
228				case event_mouseMove : e.attachEvent( 'onmousemove', handler ); break;
229				case event_mouseUp   : e.attachEvent( 'onmouseup', handler ); break;
230				case event_mouseDown : e.attachEvent( 'onmousedown', handler ); break;
231				case event_mouseClick: e.attachEvent( 'onclick', handler ); break;
232				case event_mouseOver : e.attachEvent( 'onmouseover', handler ); break;
233				case event_mouseOut  : e.attachEvent( 'onmouseout', handler ); break;
234			}
235		}
236		else {
237			switch( event ) {
238				case event_mouseMove : e.onmousemove = handler; break;
239				case event_mouseUp   : e.onmouseup = handler; break;
240				case event_mouseDown : e.onmousedown = handler; break;
241				case event_mouseClick: e.onclick = handler; break;
242				case event_mouseOver : e.onmouseover = handler; break;
243				case event_mouseOut  : e.onmouseout = handler; break;
244			}
245		}
246
247	}
248}
249
250function pdf( ctlId, ctlArray )
251{
252
253	var qs = "";
254
255	var opt;
256
257	var loc = '' + window.location;
258	if( loc.indexOf( '?', 0 ) != -1 ) {
259		var tmp = new Array();
260		tmp = loc.split( '?' );
261		loc = tmp[ 0 ];
262	}
263
264	var url = loc + '?&render=pdf&';
265
266	if( ctlArray != null ) {
267
268		opt = ctlArray[ ctlId ].getLastRefreshOptions();
269
270		var qry = '';
271
272		for( var key in opt ) {
273	
274			switch( key ) {
275
276		
277				case 'get':
278				case 'sfId':
279				case 'ctlId': 
280				case 'structId':
281				case 'patchId':
282				case 'patch': break;
283
284				default: {
285					qry += key + '=' + opt[ key ] + '&';
286				}
287
288			}
289		}
290
291
292
293		url = url + qry;
294
295		if( ctlId != null ) {
296			url += 'ctlId=' + ctlId;
297		}
298	}
299
300
301	window.open( url );
302
303}

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.