PageSourceSearch

https://lvministries.org/lib/js/core_kit.js

js lvministries.org collected 2026-10-05 21:59:53 UTC 12,659 bytes, 507 lines download raw bytes

1/*
2	NetMinistry/VOSpace Javascript Core Kit v1.0	(Replaces inline <head> functions)
3
4	Created by CPruitt Monday, January 30, 2006 4:16:25 PM
5	This file defines constants, classes, functions & subs used for managing the template system
6
7*/
8
9vLoader = '<table border=0 cellpadding=0 cellspacing=0 width=100% height=100%><tr valign=middle><td align=center><img src=/images/gui/loading1.gif border=0 width=32 height=32><br><b>Loading...</b></td></tr></table>';
10
11/*  Function to output system messages & alerts  */
12
13function nmAddSystemMessage(messageToAdd){
14	nmOpenSystemFeedbackView()
15	return nmAddToSystemFeedback('nm_system_message_view', messageToAdd);
16}
17
18function nmAddSystemAlert(messageToAdd){
19	nmOpenSystemFeedbackView()
20	return nmAddToSystemFeedback('nm_system_alert_view', messageToAdd);
21}
22
23function nmAddSystemError(messageToAdd){
24	nmOpenSystemFeedbackView()
25	return nmAddToSystemFeedback('nm_system_error_view', messageToAdd);
26}
27
28function nmOpenSystemFeedbackView() {
29	document.getElementById('nm_system_feedback_view').style.display='block'
30}
31
32function nmAddToSystemFeedback(IDOfMessageContainer, messageToAdd){
33	if (document.getElementById(IDOfMessageContainer)) {
34		var targetFeedbackView = document.getElementById(IDOfMessageContainer);
35		testString = new String(messageToAdd)
36		if(testString.length > 0) {
37			targetFeedbackView.innerHTML = targetFeedbackView.innerHTML + '<div>' + messageToAdd + '</div>';
38			}
39		targetFeedbackView.style.display='block';
40		return true;
41	} else {
42		return false;
43	}
44}
45
46function nmDisplaySystemFeedback(IdOfMessageContainer, messageToAdd){
47	var targetFeedbackView = document.getElementById(IdOfMessageContainer);
48	targetFeedbackView.innerHTML = targetFeedbackView.innerHTML + '<div>' + messageToAdd + '</div>';
49	targetFeedbackView.style.display='block';
50	return true;
51}
52
53
54/*  WIndow & Display Controls  */
55
56
57// Simple Open a new window
58function nmPopWin(v_url, v_windowName, v_width, v_height){
59	window.open(v_url, v_windowName, "width=" + v_width + ",height=" + v_height);
60}
61
62// Open a new window with scroll bars
63function nmPopWinWithScroll(v_url, v_windowName, v_width, v_height){
64	window.open(v_url, v_windowName, "scrollbars=1,width=" + v_width + ",height=" + v_height);
65}
66
67/*  Generic Use Functions  */
68function nmHandleError(){
69	alert('An error has occurred.  You may experience trouble viewing this page.');
70	return true;
71}
72
73function nmSupressError(){
74	return true;
75}
76
77
78
79
80
81//	Toggle Visability by element ID
82
83function nmToggleDisplay(element_id)
84{
85	if (document.getElementById(element_id)) {
86		toggleElement = document.getElementById(element_id);
87		elementStatus = toggleElement.style.display
88		if (elementStatus == 'none')
89		{
90			toggleElement.style.display = 'block';
91		} else {
92			toggleElement.style.display = 'none';
93		}
94		return true;
95	} else {
96		return false;
97	}
98}
99
100function nmToggleOverflow(element_id, opt1, opt2)
101{
102	if (document.getElementById(element_id)) {
103		toggleElement = document.getElementById(element_id);
104		elementStatus = toggleElement.style.overflow
105		if (elementStatus == opt1)
106		{
107			toggleElement.style.overflow = opt2;
108		} else {
109			toggleElement.style.overflow = opt1;
110		}
111		return true;
112	} else {
113		return false;
114	}
115}
116
117function nmSetInnerHTMLOfElementOfClass_toValue(fv_className, fv_newVal)
118{
119	arr = nmGetElementsByClassName(fv_className)
120	for (i=0; i<arr.length; i++)
121	{
122		arr[i].innerHTML = fv_newVal;
123	}
124}
125			
126function nmGetElementsByClassName(fv_className){
127	var idx = 0;
128	returnArray = Array;
129	if (document.getElementsByTagName())
130	{
131		var tagColletion = document.getElementsByTagName("*");
132	
133	} else if (document.all) {
134		var tagColletion = document.all;
135	}
136	for (i=0; i < tagColletion.length; i++)
137	{
138		if (tagColletion[i].className==fv_className)
139		{
140			returnArray[idx]=tagColletion[i];
141			idx++;
142		}
143	}
144	//alert(returnArray.length)
145	return returnArray;
146}
147
148
149
150
151/*  DEBUGGING FUNCTIONS  */
152
153function nmLog(logVal)
154{
155	console_id_string = 'javascript_debug_console';
156	if (document.getElementById(console_id_string))
157	{
158		strCurrentLogVal = document.getElementById(console_id_string).value;
159		document.getElementById(console_id_string).value = strCurrentLogVal  + '\n\n' + logVal;
160	} else {
161		if (false) {
162			alert('nmLog(): ' + logVal);
163		}
164	}
165}
166
167
168
169
170/*  Function to gracefully append a function to the body.onload event  */
171function nmAppendOnload(func) {
172	if (typeof window.onload != 'function') {
173		window.onload = func;
174	} else {
175		var oldonload = window.onload;
176		window.onload = function() {
177			oldonload();
178			func();
179		}
180	}
181}
182
183//		Let the system know that this kit was successfully loaded
184var nmcore_kit_loaded = true;
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
204/*                      BORROWED LIBRARY                      */
205/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
206
207
208
209/**
210SAL - Simple Ajax Lib. 23-Sep-2005
211by Nigel Liefrink
212Email: [email protected]
213*/
214
215var debug = false;
216/**
217Browser Compatability function.
218Returns the correct XMLHttpRequest depending on the current browser.
219*/
220function GetXmlHttp()
221{	
222	var xmlhttp = false;
223	if (window.XMLHttpRequest)
224	{
225		xmlhttp = new XMLHttpRequest();
226	}
227		else if (window.ActiveXObject)	// code for IE
228	{
229		try
230		{
231			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
232		} 
233		catch (e) 
234		{
235			try 
236			{
237				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
238			} catch (E) {
239				xmlhttp=false;
240			}
241		}
242	}
243	//alert('XMLReq OK');
244	return xmlhttp;
245}
246
247
248/**
249<summary>
250Gets the response stream from the passed url, and then calls the callbackFuntion passing the response and the div_ids.
251</summary>
252<param name="url">The url to make the request to get the response data.</param>
253<param name="callbackFunction">The function to call after the response has been recieved. the response <b>must</b> always be the first argument to the function.</param>
254<param name="params"> (optional) Any other parameters you want to pass to the functions. (Note: only constants/strings/globals can be passed as params, most variables will be out of scope.) </param>
255</summary>
256<example>
257	<code>
258PassAjaxResponseToFunction('?getsomehtml=1', 'FunctionToHandleTheResponse', "\'div1\',\'div2\',\'div3\'');
259
260function FunctionToHandleTheResponse(response, d1, d2, d3){
261	var data = response.split(';');
262	document.getElementById(d1).innerHTML = data[0];
263	document.getElementById(d2).innerHTML = data[1];
264	document.getElementById(d3).innerHTML = data[2];
265}
266	</code>
267</example>
268*/
269function PassAjaxResponseToFunction(url, callbackFunction, params)
270{
271	debug = true;
272	if (debug) { nmLog('Preparing to send XMLHTTP...'); }
273	 var xmlhttp = new GetXmlHttp();
274	 if (debug) { nmLog('New XMLHTTP OK...'); }
275	 //now we got the XmlHttpRequest object, send the request.
276	 if (xmlhttp)
277	 {
278	 	try
279	 	{
280			xmlhttp.onreadystatechange = 	function ()
281											{
282												debug = true;
283												if (debug) { nmLog('State Change: ' + xmlhttp.readyState); }
284												if (xmlhttp && (xmlhttp.readyState==4))
285												{	//we got something back..
286													if (xmlhttp.status==200)
287													{
288														var response = xmlhttp.responseText;
289														var functionToCall = callbackFunction+'(response,'+params+')';
290														if(debug)
291														{
292															nmLog(response);
293															nmLog (functionToCall);
294														}
295													eval(functionToCall);
296													} else if(debug) {
297														alert('PassAjaxResponseToFunction Debug Flag - ' + xmlhttp.responseText);
298													}
299												}
300											}
301			
302			
303			// prob
304			nmLog('AJAX Lib Sending to: ' + url);
305			xmlhttp.open("GET",url,true);
306			xmlhttp.send(null);
307		} 
308		
309		catch(e_err)
310		
311		{
312			if (debug) { 'PassAjaxResponseToFunction: ' + nmLog(e_err); }
313		}
314		
315		
316		
317			
318		
319	 } else {
320	 	nmLog('Error: No XML Object');
321	 	alert('Error: No XML Object');
322	 }
323}
324
325
326function PassAjaxResponseToFunctionUsingPost(url, formData, callbackFunction, params)
327{
328	debug = true;
329	if (debug) { nmLog('Preparing to send XMLHTTP with POST...'); }
330	 var xmlhttp = new GetXmlHttp();
331	 if (debug) { nmLog('New XMLHTTP OK...'); }
332	 //now we got the XmlHttpRequest object, send the request.
333	 if (xmlhttp)
334	 {
335	 	try
336	 	{
337			xmlhttp.onreadystatechange = 	function ()
338											{
339												debug = true;
340												if (debug) { nmLog('State Change: ' + xmlhttp.readyState); }
341												if (xmlhttp && (xmlhttp.readyState==4))
342												{	//we got something back..
343													if (xmlhttp.status==200)
344													{
345														var response = xmlhttp.responseText;
346														var functionToCall = callbackFunction+'(response,'+params+')';
347														if(debug)
348														{
349															nmLog('PassAjaxResponseToFunctionUsingPost::SeadyStateChange.Function::Response - ' + response);
350															//nmLog (functionToCall);
351														}
352													eval(functionToCall);
353													
354													} else if(debug) {
355														alert('PassAjaxResponseToFunction Debug Flag - ' + xmlhttp.responseText);
356													}
357												}
358											}
359			
360			
361			// prob
362			nmLog('AJAX Lib Sending to: ' + url);
363			nmLog('AJAX Lib FORM DATA: ' + formData);
364			xmlhttp.open("POST",url,true);
365			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
366			xmlhttp.send(formData);
367		} 
368		
369		catch(e_err)
370		
371		{
372			if (debug) { 'PassAjaxResponseToFunction: ' + nmLog(e_err); }
373		}
374		
375		
376		
377			
378		
379	 } else {
380	 	nmLog('Error: No XML Object');
381	 	alert('Error: No XML Object');
382	 }
383}
384
385
386/**
387///<summary>
388///Sets the innerHTML property of obj_id with the response from the passed url./
389///</summary>
390///<param name="url">The url to make the request to get the response data.</param>
391///<param name="obj_id">The object or the id of the object to set the innerHTML for.</param>
392*/
393function SetInnerHTMLFromAjaxResponse(url, obj_id)
394{		
395	var xmlhttp = new GetXmlHttp();
396	//now we got the XmlHttpRequest object, send the request.
397	if (xmlhttp)
398	{
399		xmlhttp.onreadystatechange = 	function () 
400										{
401											debug = false;
402											if (xmlhttp && xmlhttp.readyState==4)
403											{//we got something back..
404												if (xmlhttp.status==200)
405												{
406													if(debug)
407													{
408														alert(xmlhttp.responseText);
409													}
410													
411													if(typeof obj_id == 'object'){
412														obj_id.innerHTML = xmlhttp.responseText;
413													} else {
414														document.getElementById(obj_id).innerHTML = xmlhttp.responseText;
415													}
416												} else if(debug){
417													alert(xmlhttp.responseText);
418												}
419											}
420										}
421	xmlhttp.open("GET",url,true);
422	xmlhttp.send(null);
423	}
424}
425
426
427function formatCurrency(num)
428{
429	num = num.toString().replace(/\$|\,/g,'');
430	if(isNaN(num))
431	{
432		num = "0";
433	}
434	sign = (num == (num = Math.abs(num)));
435	num = Math.floor(num*100+0.50000000001);
436	cents = num%100;
437	num = Math.floor(num/100).toString();
438	if(cents<10)
439	{
440		cents = "0" + cents;
441	}
442	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
443	{
444		num = num.substring(0,num.length-(4*i+3))+','+ num.substring(num.length-(4*i+3));
445	}
446	
447	return (((sign)?'':'-') + '' + num + '.' + cents);
448}
449
450
451
452
453/*
454	Submit form & pass ammount to paypal
455	USAGE EXAMPLE: onSubmit="return paypal_submit(this, {business:'[email protected]', item:'registration', itemNumber:'reg01'});"
456*/
457function paypal_submit(form_obj, opts){
458	var pp_url;
459	var options = {
460		totalField: 'total',
461		business: null,
462		item: null,
463		itemNumber: null
464	};
465	for(var p in opts){
466		options[p] = opts[p];
467	}
468	for(var p in options){
469		if(!options[p]){
470			alert('An error prevented this form from being processed.  Please contact the site administrator. (-1)');
471			return false;
472		}
473	}
474	if(!(form_obj && form_obj[options.totalField])){
475		alert('An error prevented this form from being processed.  Please contact the site administrator. (-2)');
476		return false;
477	}
478	if(!checkrequired(form_obj)) {
479		return false;
480	} else {
481		pp_url = 'https://www.paypal.com/cgi-bin/webscr?';
482		pp_url += 'cmd=_xclick';
483		pp_url += '&business=' + encodeURIComponent(options.business);
484		pp_url += '&item_name=' + encodeURIComponent(options.item);
485		pp_url += '&item_number=' + encodeURIComponent(options.itemNumber);
486		pp_url += '&amount=' + form_obj[options.totalField].value + '';
487		pp_url += '&no_shipping=0';
488		pp_url += '&no_note=1';
489		pp_url += '&currency_code=USD';
490		pp_url += '&lc=US';
491		pp_url += '&bn=PP%2dBuyNowBF';
492		pp_url += '&charset=UTF%2d8';
493		window.open(pp_url,'PayPal');
494		return true;
495	}
496}
497
498
499Core = {
500    QS : null,
501
502    queryString : function(key, forceRead){
503        if(Core.QS == null || forceRead){
504            alert(key);
505        }
506    }
507}

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.