PageSourceSearch

https://www.diving.org.il/javascripts/divingForms.js?v=9

js diving.org.il collected 2026-10-02 14:49:39 UTC 15,647 bytes, 607 lines download raw bytes

1/* ------------------------------------------------------------------------------------------------------------ */
2/* divingForms_calcPrice																						*/
3/* ------------------------------------------------------------------------------------------------------------ */
4function divingForms_calcPrice ()
5{
6	if ($("form#registrationForm input#formType").val () == "course" &&
7		$("form#registrationForm input#payment").val  () == "none")
8	{
9		return;
10	}
11
12	var total	= -1;
13
14	$("form#registrationForm input.event").each (function ()
15	{
16		if ($(this).is(":checked"))
17		{
18			if (global_isDivingMember)
19			{
20				priceField	= "mPrice";
21			}
22			else
23			{
24				priceField	= "rPrice";
25			}
26			
27			if (total == -1) total = 0;
28
29			total += parseInt($(this).attr(priceField));
30		}
31	});
32
33	$("form#registrationForm input.equip").each (function ()
34	{
35		if ($(this).is(":checked"))
36		{
37			if (total == -1) total = 0;
38
39			total += parseInt($(this).attr("price"));
40		}
41	});
42
43	if ($("form#registrationForm div.enter_noDive").length != 0)
44	{
45		if (total == -1) total = 0;
46
47		if (global_isDivingMember)
48			total += parseInt($("input#diveMemberPrice").val());
49		else
50			total += parseInt($("input#divePrice").val());
51
52		var number = $("select#noDiveNo").val();
53		var price  = $("select#noDiveNo").attr("price");
54
55		total += parseInt(number * price);
56	}
57
58	if ($("form#registrationForm input#formId").val() == 2308)	// special handle for event
59	{
60		total += 180;
61	}
62		
63	$('#sum').val(total);
64	$('#total').html(total);						
65
66	if (total == 0)
67	{
68		$('#sendForm').prop('disabled', true);
69		$('#sendForm').prop('title', 'יש לבחור פעילות');
70	}
71	else
72	{
73		$('#sendForm').prop('title', '');
74		$('#sendForm').prop('disabled', false);
75	}
76}
77
78/* ------------------------------------------------------------------------------------------------------------ */
79/* divingForms_resetEvents																						*/
80/* ------------------------------------------------------------------------------------------------------------ */
81function divingForms_resetEvents ()
82{
83	$("form#registrationForm input.event").each (function ()
84	{
85		$(this).prop("checked", false);
86	});
87
88	$("form#registrationForm input.zero, form#registrationForm input.none").each (function ()
89	{
90		$(this).prop("checked", true);
91	});
92}
93
94/* ------------------------------------------------------------------------------------------------------------ */
95/* divingForms_noNone																							*/
96/* ------------------------------------------------------------------------------------------------------------ */
97function divingForms_noNone ()
98{
99	$("form#registrationForm input.none").each (function ()
100	{
101		$(this).prop("checked", false);
102	});
103}
104
105/* ------------------------------------------------------------------------------------------------------------ */
106/* divingForm_checkDivingMember																					*/
107/* ------------------------------------------------------------------------------------------------------------ */
108function divingForm_checkDivingMember ()
109{
110	var tz 	= $("form#registrationForm input#tz").val();
111
112	if (tz != "")
113	{
114		var xml = "<data>" +
115					"<command>private.checkDivingMember</command>" +
116					"<tz>" + tz + "</tz>" +
117				  "</data>";
118
119		xmlRequest.init (xml);
120		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "divingForm_checkDivingMember_response");
121	}
122
123	return false;
124}
125
126var global_isDivingMember = false;
127
128function divingForm_checkDivingMember_response (i)
129{
130	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));
131						
132	try
133	{
134		var returnCode 		= xmlRequest.getValue("returnCode");
135
136		global_isDivingMember = false;
137
138		if (returnCode == "INVALID_TZ")
139		{
140			alert ("מספר תעודת זהות לא תקין");
141			$("input#tz").focus ();
142			return false;
143		}
144		else if (returnCode == "MEMBER")
145		{
146			global_isDivingMember = true;
147		}
148
149		divingForms_calcPrice ();
150	}
151	catch (e)
152	{
153		alert ("AJAX Error");
154		return false;
155	}
156
157	return false;
158}
159
160/* ------------------------------------------------------------------------------------------------------------ */
161/* divingForms_submitForm																						*/
162/* ------------------------------------------------------------------------------------------------------------ */
163function divingForms_submitForm ()
164{
165	var isValid = true;
166
167	$("form#registrationForm input, form#registrationForm select").each (function ()
168	{
169		if ($(this).attr("isRequired") == 2)
170		{
171			var fieldType = $(this).attr("type");
172
173			if ($(this).val() == "")
174			{
175				var fieldText = $(this).attr("title");
176
177				if (fieldType == "text")
178					alert ("יש להזין " + fieldText);
179				else
180					alert ("יש לבחור " + fieldText);
181
182				$(this).focus ();
183
184				isValid = false;
185
186				return false;
187			}
188			else 
189			{
190				if (fieldType == "radio")	// choose event hour
191				{
192					if ($('input:radio[name="eventHour"]').length != 0 && !$('input:radio[name="eventHour"]').is(':checked'))
193					{
194						alert ("יש לבחור את אחת השעות");
195						$(this).focus ();
196
197						isValid = false;
198
199						return false;
200					}
201				}
202				else if ($(this).attr("id") == "email" && !validateEmailv2($(this).val()))
203				{
204					alert ("יש להזין אימייל חוקי");
205					$(this).focus ();
206
207					isValid = false;
208
209					return false;
210				}
211			}
212		}
213	});
214
215	if (!isValid) return false;
216
217	if ($("input#termsAgree").length != 0 && !$("input#termsAgree").is(":checked"))
218	{
219		alert ("יש לאשר את קריאת התנאים");
220		$("input#termsAgree").focus();
221		return false;
222	}
223
224	$("form#registrationForm input.size").each (function ()
225	{
226		if ($(this).is(":checked"))
227		{
228			if ($(this).attr("size").indexOf ("H") != -1 && $("input#equipHeight").val() == "")
229			{
230				alert ("יש להזין גובה");
231				$("input#equipHeight").focus();
232
233				isValid = false;
234
235				return false;
236			}
237
238			if ($(this).attr("size").indexOf ("W") != -1 && $("input#equipWeight").val() == "")
239			{
240				alert ("יש להזין משקל");
241				$("input#equipWeight").focus();
242
243				isValid = false;
244
245				return false;
246			}
247
248			if ($(this).attr("size").indexOf ("S") != -1 && $("select#equipShoes").val() == "")
249			{
250				alert ("יש לבחור מידת נעליים");
251				$("select#equipShoes").focus();
252
253				isValid = false;
254
255				return false;
256			}
257		}
258	});
259
260	var number = $("select#noDiveNo").val();
261
262	if ($("form#registrationForm div.enter_noDive").length != 0)
263	{
264		var number = $("select#noDiveNo").val();
265
266		for (i = 1; i <= number; i++)
267		{
268			if ($("input#noDive" + i).val() == "")
269			{
270				alert ("יש להזין את שם מלווה " + i);
271				$("input#noDive" + i).focus();
272
273				isValid = false;
274				
275				return false;
276			}
277		}
278	}
279
280	if (isValid)
281	{
282		$('#sendForm').prop('title', 'נא להמתין...');
283		$('#sendForm').prop('disabled', true);
284	}
285
286	return isValid;
287}
288
289/* ------------------------------------------------------------------------------------------------------------ */
290/* divingForms_handleNoDive																						*/
291/* ------------------------------------------------------------------------------------------------------------ */
292function divingForms_handleNoDive ()
293{
294	var number = $("select#noDiveNo").val();
295
296	$("form#registrationForm div.enter_noDive").each (function () 
297	{
298		$(this).hide ();
299	});
300
301	for (i = 1; i <= number; i++)
302	{
303		$("form#registrationForm div#enter_noDive" + i).show();
304	}
305}
306
307/* ------------------------------------------------------------------------------------------------------------ */
308/* divingForm_specificCheckDivingMember																			*/
309/* ------------------------------------------------------------------------------------------------------------ */
310function divingForm_specificCheckDivingMember (which)
311{
312	var tz 	= $("form#registrationForm input#tz" + which).val();
313
314	if (tz != "")
315	{
316		var xml = "<data>" +
317					"<command>private.checkDivingMember</command>" +
318					"<tz>" + tz + "</tz>" +
319					"<which>" + which + "</which>" + 
320				  "</data>";
321
322		xmlRequest.init (xml);
323		xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "divingForm_specificCheckDivingMember_response");
324	}
325	else
326	{
327		divingForms_specificCalcPrice ();
328	}
329
330	return false;
331}
332
333var global_isCompMember 	= false;
334var global_isGuestMember 	= false;
335
336function divingForm_specificCheckDivingMember_response (i)
337{
338	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));
339						
340	try
341	{
342		var returnCode 		= xmlRequest.getValue("returnCode");
343		var which 			= xmlRequest.getValue("which");
344
345		if (which == "Comp")
346			global_isCompMember  = false;
347		else
348			global_isGuestMember = false;
349
350		if (returnCode == "MEMBER")
351		{
352			if (which == "Comp")
353				global_isCompMember  = true;
354			else
355				global_isGuestMember = true;
356		}
357
358		if (returnCode == "DUPLICATE")
359		{
360			alert ("נרשם עם תעודת זהות " + $("form#registrationForm input#tz" + which).val() + " כבר רשום לאירוע");
361			$("form#registrationForm input#tz" + which).focus ();
362			$("form#registrationForm input#tz" + which).val ("");
363		}
364	}
365	catch (e)
366	{
367		alert ("AJAX Error");
368		return false;
369	}
370
371	divingForms_specificCalcPrice ();
372
373	return false;
374}
375
376/* ------------------------------------------------------------------------------------------------------------ */
377/* divingForms_specificCalcPrice																				*/
378/* ------------------------------------------------------------------------------------------------------------ */
379function divingForms_specificCalcPrice ()
380{
381	var total	= 0;
382
383	if ($("form#registrationForm input#tzComp").val() != "")
384	{
385		if (global_isCompMember)
386		{
387			total	+= parseInt($("form#registrationForm input#tzComp").attr("mPrice"));
388		}
389		else
390		{
391			total	+= parseInt($("form#registrationForm input#tzComp").attr("rPrice"));
392		}
393	}
394
395	if ($("form#registrationForm input#tzGuest").val() != "")
396	{
397		if (global_isGuestMember)
398		{
399			total	+= parseInt($("form#registrationForm input#tzGuest").attr("mPrice"));
400		}
401		else
402		{
403			total	+= parseInt($("form#registrationForm input#tzGuest").attr("rPrice"));
404		}
405	}
406
407	$("form#registrationForm input.workshop").each (function ()
408	{
409		var priceField = "";
410
411		if ($(this).is(":checked"))
412		{
413			if ($(this).hasClass ("comp") && $("form#registrationForm input#tzComp").val() != "")
414			{
415				if (global_isCompMember)
416				{
417					priceField	= "mPrice";
418				}
419				else
420				{
421					priceField	= "rPrice";
422				}
423			}
424
425			if ($(this).hasClass ("guest") && $("form#registrationForm input#tzGuest").val() != "")
426			{
427				if (global_isGuestMember)
428				{
429					priceField	= "mPrice";
430				}
431				else
432				{
433					priceField	= "rPrice";
434				}
435			}
436
437			if (priceField != "")
438			{
439				total += parseInt($(this).attr(priceField));
440			}
441		}
442	});
443
444	$('#sum').val(total);
445	$('#total').html(total);						
446
447	if (total == 0)
448	{
449		$('#sendForm').prop('disabled', true);
450		$('#sendForm').prop('title', 'יש להזין נתונים');
451	}
452	else
453	{
454		$('#sendForm').prop('title', '');
455		$('#sendForm').prop('disabled', false);
456	}
457}
458
459/* ------------------------------------------------------------------------------------------------------------ */
460/* divingForms_checkWorkshops																					*/
461/* ------------------------------------------------------------------------------------------------------------ */
462function divingForms_checkWorkshops (pageId)
463{
464	var workshop1Comp 	= $("input#workshop1Comp").is(":checked") ? "1" : "0";
465	var workshop2Comp 	= $("input#workshop2Comp").is(":checked") ? "1" : "0";
466
467	var workshop1Guest 	= $("input#workshop1Guest").is(":checked") ? "1" : "0";
468	var workshop2Guest 	= $("input#workshop2Guest").is(":checked") ? "1" : "0";
469
470	var xml = "<data>" +
471				"<command>private.checkWorkshops</command>" +
472				"<pageId>"  	   + pageId  		+ "</pageId>"  		  +
473				"<workshop1Comp>"  + workshop1Comp  + "</workshop1Comp>"  +
474				"<workshop2Comp>"  + workshop2Comp  + "</workshop2Comp>"  +
475				"<workshop1Guest>" + workshop1Guest + "</workshop1Guest>" +
476				"<workshop2Guest>" + workshop2Guest + "</workshop2Guest>" +
477			  "</data>";
478
479	xmlRequest.init (xml);
480	xmlRequest.sendAsyncRequest ("server.php", xmlRequest.obj, "divingForms_checkWorkshops_response");
481}
482
483function divingForms_checkWorkshops_response (i)
484{
485	xmlRequest.init(commonDecode(asyncHttpObjs[i].responseText));
486						
487	try
488	{
489		var returnCode 		= xmlRequest.getValue("returnCode");
490
491		if (returnCode == "OK")
492		{
493			if (xmlRequest.getValue("workshop1Comp") == -1)
494			{
495				$("input#workshop1Comp").prop("checked", false);
496				$('input#workshop1Comp').prop('disabled', true);
497				$(".workshop1Comp span.price").addClass("hide");
498				$(".workshop1Comp span.noMore").removeClass("hide");
499			}
500			else
501			{
502				$('input#workshop1Comp').prop('disabled', false);
503				$(".workshop1Comp span.price").removeClass("hide");
504				$(".workshop1Comp span.noMore").addClass("hide");
505			}
506
507			if (xmlRequest.getValue("workshop2Comp") == -1)
508			{
509				$("input#workshop2Comp").prop("checked", false);
510				$('input#workshop2Comp').prop('disabled', true);
511				$(".workshop2Comp span.price").addClass("hide");
512				$(".workshop2Comp span.noMore").removeClass("hide");
513			}
514			else
515			{
516				$('input#workshop2Comp').prop('disabled', false);
517				$(".workshop2Comp span.price").removeClass("hide");
518				$(".workshop2Comp span.noMore").addClass("hide");
519			}
520		}
521	}
522	catch (e)
523	{
524		alert ("AJAX Error");
525		return false;
526	}
527
528	divingForms_specificCalcPrice();
529
530	return false;
531}
532
533/* ------------------------------------------------------------------------------------------------------------ */
534/* divingForms_submitSpecificForm																				*/
535/* ------------------------------------------------------------------------------------------------------------ */
536function divingForms_submitSpecificForm (pageId)
537{
538	if ($("form#registrationForm input#tzComp").val() != "")
539	{
540		if ($("form#registrationForm input#firstnameComp").val() == "")
541		{
542			alert ("יש להזין את שמו הפרטי של המתחרה");
543			$("form#registrationForm input#firstnameComp").focus();
544			return false;
545		}
546
547		if ($("form#registrationForm input#lastnameComp").val() == "")
548		{
549			alert ("יש להזין את שם המשפחה של המתחרה");
550			$("form#registrationForm input#lastnameComp").focus();
551			return false;
552		}
553
554		if ($("form#registrationForm select#degreeComp").val() == "")
555		{
556			alert ("יש לבחור את דרגת הצלילה של המתחרה");
557			$("form#registrationForm select#degreeComp").focus();
558			return false;
559		}
560	}
561
562	if ($("form#registrationForm input#tzGuest").val() != "")
563	{
564		if ($("form#registrationForm input#firstnameGuest").val() == "")
565		{
566			alert ("יש להזין את שם פרטי");
567			$("form#registrationForm input#firstnameGuest").focus();
568			return false;
569		}
570
571		if ($("form#registrationForm input#lastnameGuest").val() == "")
572		{
573			alert ("יש להזין שם משפחה");
574			$("form#registrationForm input#lastnameGuest").focus();
575			return false;
576		}
577
578		if ($("form#registrationForm select#degreeGuest").val() == "")
579		{
580			alert ("יש לבחור את דרגת הצלילה");
581			$("form#registrationForm select#degreeGuest").focus();
582			return false;
583		}
584	}
585
586	if ($("form#registrationForm input#cellphone").val() == "")
587	{
588		alert ("יש להזין טלפון נייד");
589		$("form#registrationForm input#cellphone").focus();
590		return false;
591	}
592
593	if ($("form#registrationForm input#email").val() == "")
594	{
595		alert ("יש להזין אימייל");
596		$("form#registrationForm input#email").focus();
597		return false;
598	}
599	else if (!validateEmailv2($("form#registrationForm input#email").val()))
600	{
601		alert ("יש להזין אימייל חוקי");
602		$("form#registrationForm input#email").focus();
603		return false;
604	}
605
606	return true;
607}

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.