PageSourceSearch

https://www.gcoftheeverglades.com/html/js/common.js

js gcoftheeverglades.com collected 2026-09-26 18:48:34 UTC 9,918 bytes, 416 lines download raw bytes

1// Start: js validators
2
3function isNumber(evt) {
4	evt = (evt) ? evt : window.event;
5	var ctr = evt.ctrlKey;
6	var charCode = (evt.which) ? evt.which : evt.keyCode;
7	if (ctr) {
8		if (charCode === 97 || charCode === 99 || charCode === 118)
9			return true;
10	}
11	if (charCode > 31 && (charCode < 48 || charCode > 57)) {
12		return false;
13	}
14	return true;
15}
16
17function isAlpahebet(evt) {
18	evt = (evt) ? evt : window.event;
19	var charCode = (evt.which) ? evt.which : evt.keyCode;
20
21	if ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123)) {
22		return true;
23	}
24
25	return false;
26	
27}
28
29function checkForCity(evt) {
30	evt = (evt) ? evt : window.event;
31	var charCode = (evt.which) ? evt.which : evt.charCode;
32
33	// Arrow Up, Down, Left, Right, Backspace and Tab also doesn't work in
34	// firefox
35	var ignoredKeys = [ 8, 9, 37, 38, 39, 40 ];
36
37	if (ignoredKeys.indexOf(event.which) >= 0
38			|| (charCode > 64 && charCode < 91)
39			|| (charCode > 96 && charCode < 123) || charCode === 32
40			|| event.which === 0) {
41		return true;
42	}
43
44	return false;
45	
46}
47
48// Updated isDecimalNumber function with automatic locale detection
49function isDecimalNumber(elem, event) {
50	var isValid = false;
51	if (elem === undefined || elem == null) {
52		return isValid;
53	}
54	
55	var charCode = getCharCode(event);
56	// Get locale from global variable
57	var isSecondaryFormat = (typeof APP_LOCALE !== 'undefined' && APP_LOCALE === 'sv_SE');
58	var decimalCharCode = isSecondaryFormat ? 44 : 46;
59	var decimalSeparator = isSecondaryFormat ? ',' : '.';
60	
61	// Don't allow manual space entry for secondary format
62	if (isSecondaryFormat && charCode === 32) {
63		return false;
64	}
65	
66	var currentValue = elem.value;
67	// Basic number validation (0-9, minus, allowed keys)
68	if ((charCode >= 48 && charCode <= 57)
69			|| (event.key === '-' && getCleanValue(currentValue, isSecondaryFormat) === '')
70			|| ((event.key === decimalSeparator || charCode === decimalCharCode) && currentValue.indexOf(decimalSeparator) < 0)
71			|| isAllowedKeyForNumber(charCode) 
72			|| isShortKey(event, charCode)) {
73		isValid = true;
74	}
75	
76	// Handle automatic zero prefixing
77	if (isValid && (event.key === '-' || event.key === decimalSeparator)) {
78		var value = currentValue + event.key;
79		if (value === "-" + decimalSeparator) {
80			setTimeout(function() { elem.value = "-0" + decimalSeparator; }, 0);
81		} else if (value === decimalSeparator) {
82			setTimeout(function() { elem.value = "0" + decimalSeparator; }, 0);
83		}
84	}
85	
86	return isValid;
87}
88
89// Helper function to get clean numeric value (remove formatting)
90function getCleanValue(value, isSecondaryFormat) {
91	if (!value) return '';
92	
93	if (isSecondaryFormat) {
94		// Remove spaces and replace comma with dot for parsing
95		return value.replace(/\s/g, '').replace(',', '.');
96	} else {
97		// Remove commas for primary format
98		return value.replace(/,/g, '');
99	}
100}
101
102
103function isWholeNumber(evt) {
104	var charCode = getCharCode(evt);
105
106	if ((charCode >= 48 && charCode <= 57) || isAllowedKeyForNumber(charCode)
107			|| isShortKey(event, charCode)) {
108		return true;
109	}
110	
111	return false;
112	
113}
114
115function isPercentage(evt, id) {
116	evt = (evt) ? evt : window.event;
117	var charCode = (evt.which) ? evt.which : event.keyCode;
118	var isValid = false;
119	var ch = "";
120	var allowDot = singleDot(document.getElementById(id).value);
121	if ((charCode >= 48 && charCode <= 57) || charCode === 8
122			|| (charCode === 46 && allowDot)) {
123		isValid = true;
124		ch = charCode;
125	} else {
126		isValid = false;
127	}
128
129	if (isValid) {
130		var t = document.getElementById(id);
131		var value = t.value + String.fromCharCode(charCode);
132		if (parseInt(value) > 100 && allowDot === true) {
133			isValid = false;
134		}
135	}
136	return isValid;
137}
138
139function isCurrency(evt, id) {
140	var charCode = (evt.which) ? evt.which : event.keyCode;
141	var isValid = false;
142	var allowDot = singleDot(document.getElementById(id).value);
143	if ((charCode >= 48 && charCode <= 57) || charCode === 8
144			|| (charCode === 46 && allowDot)) {
145		isValid = true;
146	} else {
147		isValid = false;
148	}
149
150	if (isValid) {
151		var t = document.getElementById(id);
152		var value = t.value + String.fromCharCode(charCode);
153		if (value == "-.") {
154			document.getElementById(id).value = "-0";
155		} else if (value == ".") {
156			document.getElementById(id).value = "0";
157		} else if (value.length == 1) {
158			document.getElementById(id).value = "$";
159		}
160	}
161	return isValid;
162}
163
164function validateEmail(value) {
165	var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
166	if (value.match(mailformat)) {
167		return true;
168	} else {
169		if (value !== "") {
170			alert(value + "\nInvalid email address!");
171			return false;
172		}
173		return true;
174	}
175}
176
177function isPhoneNumberNoAreaCode(evt, id) {
178	evt = (evt) ? evt : window.event;
179	var charCode = (evt.which) ? evt.which : event.keyCode;
180	var isValid = false;
181	if ((charCode >= 48 && charCode <= 57) || charCode === 8) {
182		isValid = true;
183	} else {
184		isValid = false;
185	}
186
187	if (isValid) {
188		var t = document.getElementById(id);
189		var value = t.value + String.fromCharCode(charCode);
190		if (value.length == 4 && charCode !== 8) {
191			document.getElementById(id).value = document.getElementById(id).value
192					+ "-";
193		}
194	}
195	return isValid;
196}
197
198function isPhoneNumberWithAreaCode(evt, id) {
199	evt = (evt) ? evt : window.event;
200	var charCode = (evt.which) ? evt.which : event.keyCode;
201	var isValid = false;
202	if ((charCode >= 48 && charCode <= 57) || charCode === 8) {
203		isValid = true;
204	} else {
205		isValid = false;
206	}
207
208	if (isValid) {
209		var t = document.getElementById(id);
210		var value = t.value + String.fromCharCode(charCode);
211		if (value.length == 1 && charCode !== 8) {
212			document.getElementById(id).value = "(";
213		} else if (value.length == 5 && charCode !== 8) {
214			document.getElementById(id).value = document.getElementById(id).value
215					+ ") ";
216		} else if (value.length == 10 && charCode !== 8) {
217			document.getElementById(id).value = document.getElementById(id).value
218					+ "-";
219		}
220	}
221	return isValid;
222}
223
224
225function getCharCode(evt) {
226	evt = (evt) ? evt : window.event;
227	var charCode = (evt.which) ? evt.which : evt.keyCode;
228	return charCode;
229}
230
231function isAllowedKeyForNumber(charCode) {
232
233	// backspace
234	if (charCode === 8) {
235		return true;
236	}
237	// tab
238	else if (charCode === 9) {
239		return true;
240	}
241	// enter
242	else if (charCode === 13) {
243		return true;
244	}
245	// shift
246	else if (charCode === 16) {
247		return true;
248	}
249	// ctrl
250	else if (charCode === 17) {
251		return true;
252	}
253	// alt
254	else if (charCode === 18) {
255		return true;
256	}
257	// left arrow
258	else if (charCode === 37) {
259		return true;
260	}
261	// right arrow
262	else if (charCode === 39) {
263		return true;
264	}
265	// otherwise
266	else {
267		return false;
268	}
269}
270
271function isShortKey(evt, charCode) {
272	var ctrlDown = evt.ctrlKey || evt.metaKey;
273
274	// select all
275	if (ctrlDown && (charCode === 65 || charCode === 97)) {
276		return true;
277	}
278	// cut
279	else if (ctrlDown && (charCode === 88 || charCode === 120)) {
280		return true;
281	}
282	// copy
283	else if (ctrlDown && (charCode === 67 || charCode === 99)) {
284		return true;
285	}
286	// paste
287	else if (ctrlDown && (charCode === 86 || charCode === 118)) {
288		return true;
289	}
290
291	return false;
292}
293
294function allowKeyCodes(event, keyCodes) {
295	var isAllowed = false;
296	var charCode = getCharCode(event);
297	for (var i = 0; i < keyCodes.length; i++) {
298		if (charCode === keyCodes[i]) {
299			isAllowed = true;
300			break;
301		}
302	}
303	return isAllowed;
304}
305
306function singleDot(value) {
307	var dot = 0;
308	for (var i = 0; i < value.length; i++) {
309		if (value[i] === '.') {
310			dot++;
311		}
312	}
313	
314	if (dot == 0) {
315		return true;
316	}
317
318	return false;
319}
320
321function minusSign(value) {
322	if (value.length === 0) {
323		return true;
324	}
325
326	return false;
327}
328
329function isNumberKey(evt) {
330	evt = (evt) ? evt : window.event;
331	var ctr = evt.ctrlKey;
332	var charCode = (evt.which) ? evt.which : evt.keyCode;
333	if (ctr) {
334		if (charCode === 97 || charCode === 99 || charCode === 118)
335			return true;
336	}
337	if (charCode > 31 && (charCode < 48 || charCode > 57)) {
338		return false;
339	}
340	return true;
341}
342
343// End: js validators
344
345// Start: js util
346
347function getElementById(elementId) {
348	return document.getElementById(elementId);
349}
350
351function getElement(elementId, options) {
352	
353	var elementNameSpace = '';
354	
355	if (typeof options != 'undefined') {
356		if (options['namespace']) {
357			elementNameSpace = options['namespace'] + ':'
358		}
359		
360		if (options['formId']) {
361			elementNameSpace = elementNameSpace + options['formId'] + ':';
362		}
363	}
364	
365	return document.getElementById(elementNameSpace + elementId);
366}
367
368function isSmartDevice() {
369
370	if (/Android|webOS|iPhone|iPad|iPod|Tablet|BlackBerry/i
371			.test(navigator.userAgent)
372			|| (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i
373					.test(navigator.platform))) {
374		return true;
375	}
376
377	return false;
378}
379
380function hideElementInDevices(element) {
381
382	if (/Android|webOS|iPhone|iPad|iPod|Tablet|BlackBerry/i
383			.test(navigator.userAgent)
384			|| (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i
385					.test(navigator.platform))) {
386		jQuery_ns_connect(element).css("display", "none");
387	}
388}
389
390jQuery_ns_connect(function() {
391	jQuery_ns_connect('.disable-copy-paste').on('cut copy paste', function(e) {
392		e.preventDefault();
393	});
394});
395
396// End: js util
397
398// Start: loader
399function showLoader() {
400
401	getElement('loaderImage').style.display = 'block';
402	getElement('overlay').style.display = 'block';
403}
404
405function hideLoader() {
406
407	getElement('loaderImage').style.display = 'none';
408	getElement('overlay').style.display = 'none';
409}
410// End: loader
411
412(function () {
413    const script = document.createElement("script");
414    script.src = "/html/js/native-bridge.js";
415    document.head.appendChild(script);
416})();

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.