PageSourceSearch

https://immersence.com/include/javascript/functions.js

js immersence.com collected 2026-10-02 11:15:46 UTC 12,306 bytes, 280 lines download raw bytes

1function clearList(srcListName)
2{ var list = document.getElementById(srcListName); for(var i = list.options.length - 1; i >= 0; --i) list.options.remove(i); return; }
3
4function selectValue(srcList, valueToSelect)
5{ for(var i = 0; i < srcList.options.length; ++i) { if(srcList.options[i].value == valueToSelect) { srcList.selectedIndex = i; return; } } srcList.selectedIndex = 0; return; }
6
7function toggleCheckBox(startCheckBoxName, otherCheckBoxNames)
8{ var startCheckBox = document.getElementById(startCheckBoxName); var checkBox; if(startCheckBox.checked) {  for(var i = 1; i < arguments.length; ++i) { checkBox = document.getElementById(arguments[i]); checkBox.checked = false; } } }
9
10function padLeft(source, length, paddingChar)
11{ if((source != null) && (source.length >= length))	return source; var padding = new Array((source == null) ? length : (length - source.length)); for(var i = 0; i < padding.length; i++) padding[i] = paddingChar; return padding.join("") + source; }
12
13function padRight(source, length, paddingChar)
14{ if((source != null) && (source.length >= length))	return source; var padding = new Array((source == null) ? length : (length - source.length)); for(var i = 0; i < padding.length; i++) padding[i] = paddingChar; return source + padding.join(""); }
15
16function trim(source)
17{ while (source.substring(0, 1) == ' ') { source = source.substring(1, source.length); } while (source.substring(source.length - 1, source.length) == ' ') { source = source.substring(0, source.length-1); } return source; }
18
19function SetUniqueRadioButton(nameregex, current)
20{ re = new RegExp(nameregex); for(i = 0; i < document.forms[0].elements.length; i++) { elm = document.forms[0].elements[i]; if (elm.type == 'radio') { if (re.test(elm.name)) { elm.checked = false; } } } current.checked = true; }
21
22function URLEncode(plaintext )
23{ var SAFECHARS = "0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	"abcdefghijklmnopqrstuvwxyz" + "-_.!~*'()";	var HEX = "0123456789ABCDEF"; var encoded = ""; for (var i = 0; i < plaintext.length; i++ ) { var ch = plaintext.charAt(i); if (ch == " ") { encoded += "+"; } else if (SAFECHARS.indexOf(ch) != -1) { encoded += ch;} else { var charCode = ch.charCodeAt(0); if (charCode > 255) { alert( "Unicode Character '" + ch + "' cannot be encoded using standard URL encoding.\n" + "(URL encoding only supports 8-bit characters.)\n" + "A space (+) will be substituted." ); encoded += "+"; } else { encoded += "%"; encoded += HEX.charAt((charCode >> 4) & 0xF);encoded += HEX.charAt(charCode & 0xF);	} } } return encoded; }
24
25function URLDecode(encoded )
26{ var HEXCHARS = "0123456789ABCDEFabcdef";  var plaintext = ""; var i = 0; while (i < encoded.length) { var ch = encoded.charAt(i); if (ch == "+") { plaintext += " "; i++; } else if (ch == "%") { if (i < (encoded.length-2) && HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 && HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) { plaintext += unescape( encoded.substr(i,3) ); i += 3; } else {	alert( 'Bad escape combination near ...' + encoded.substr(i) );	plaintext += "%[ERROR]"; i++; } } else { plaintext += ch; i++; } } return plaintext; }
27
28function getElementsByClassName(strClass, strTag, objContElm) 
29{ strTag = strTag || "*"; objContElm = objContElm || document;  var objColl = objContElm.getElementsByTagName(strTag); if (!objColl.length &&  strTag == "*" &&  objContElm.all) objColl = objContElm.all; var arr = new Array(); var delim = strClass.indexOf('|') != -1  ? '|' : ' ';  var arrClass = strClass.split(delim);  for (var i = 0, j = objColl.length; i < j; i++) {  var arrObjClass = objColl[i].className.split(' '); if (delim == ' ' && arrClass.length > arrObjClass.length) continue; var c = 0; comparisonLoop: for (var k = 0, l = arrObjClass.length; k < l; k++) { for (var m = 0, n = arrClass.length; m < n; m++) { if (arrClass[m] == arrObjClass[k]) c++; if (( delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) { arr.push(objColl[i]); break comparisonLoop; } } } } return arr; }
30
31function ErrorHandler(result)
32{ var msg=result.get_exceptionType() + "\r\n"; msg += result.get_message() + "\r\n"; msg += result.get_stackTrace(); window.alert(msg); }
33
34function TimeOutHandler(result)
35{ window.alert("Timeout :" + result); }
36
37function XBrowserAddHandler(target,eventName,handlerName)
38{ if ( target.addEventListener ) target.addEventListener(eventName, handlerName, false); else if ( target.attachEvent ) target.attachEvent("on" + eventName, handlerName); else target["on" + eventName] = handlerName; }
39
40function isValuesValid(className, invalidDivClass = null) {
41    $("." + className + ", [class*=' " + className + "\\.']").each(function () {
42        if (!$(this).val().match(/\S/g)) {
43            if (!$(this).hasClass("optionnal")) {
44                if (!$(this).hasClass("is-invalid")) {
45                    $(this).addClass("is-invalid");
46                }
47            }
48            else {
49                //S'il est optionnel et vide, on retire le invalid
50                $(this).removeClass("is-invalid");
51            }
52        }
53        else {
54            $(this).removeClass("is-invalid");
55        }
56    });
57
58    $("." + className + "\\.phone").each(function () {
59        //Permet les optionnels
60        if ($(this).val().trim().length == 0)
61            return;
62
63        var phonenumber = $(this).val().replace(/\D/g, '');
64
65        //si le numéro de téléphone contient le nombre de chiffre standard
66        if (phonenumber.length == 10) {
67            $(this).val("(" + phonenumber.substr(0, 3) + ") " + phonenumber.substr(3, 3) + "-" + phonenumber.substr(6));
68        }
69        else {
70            if (!$(this).hasClass("is-invalid")) {
71                $(this).addClass("is-invalid");
72            }
73        }
74    });
75
76    $("." + className + "\\.email").each(function () {
77        //Permet les optionnels
78        if ($(this).val().trim().length == 0)
79            return;
80
81        if (!$(this).val().match(/(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/g)) {
82            if (!$(this).hasClass("is-invalid")) {
83                $(this).addClass("is-invalid");
84            }
85        }
86    });
87
88    var hasOneValue;
89    $("." + className + "\\.needOne").each(function () {
90        if ($(this).val().match(/\S/g)) {
91            hasOneValue = true;
92        }
93    });
94
95    if (hasOneValue === true) {
96        $("." + className + "\\.needOne").each(function () {
97            $(this).removeClass("is-invalid");
98        });
99    }
100
101    hasOneValue = false;
102
103    $("." + className + "\\.needOneChecked").each(function () {
104
105        var checkBox = $(this);
106
107        if ($(this).find("input[type=checkbox]").length > 0) {
108            checkBox = $(this).find("input[type=checkbox]");
109        }
110
111        if (checkBox.is(':checked')) {
112            hasOneValue = true;
113        }
114    });
115
116    if (hasOneValue === true) {
117        $("." + className + "\\.needOneChecked").each(function () {
118            $(this).removeClass("is-invalid");
119        });
120    }
121
122    $("." + className + "\\.postalCode").each(function () {
123        //Permet les optionnels
124        if ($(this).val().trim().length == 0)
125            return;
126
127        var postalCode = $(this).val().replace(/\s/g, '').toUpperCase();;
128
129        if (!postalCode.match(/^[(a-z)|(A-Z)]\d[(a-z)|(A-Z)]\d[(a-z)|(A-Z)]\d$/g)) {
130            if (!$(this).hasClass("is-invalid")) {
131                $(this).addClass("is-invalid");
132            }
133        }
134        else {
135            $(this).val(postalCode.substr(0, 3) + " " + postalCode.substr(3, 3));
136        }
137    });
138
139    $("." + className + "\\.ddl").each(function () {
140        if ($(this).val() != "0") {
141            if ($(this).hasClass("is-invalid")) {
142                $(this).removeClass("is-invalid");
143            }
144        }
145        else {
146            if (!$(this).hasClass("is-invalid")) {
147                $(this).addClass("is-invalid");
148            }
149        }
150    });
151
152    $("." + className + "\\.file").each(function () {
153        if ($(this)[0].files.length > 0) {
154            if ($(this).hasClass("is-invalid")) {
155                $(this).removeClass("is-invalid");
156            }
157        }
158        else {
159            if (!$(this).hasClass("is-invalid")) {
160                $(this).addClass("is-invalid");
161            }
162        }
163    });
164
165    $("." + className + "\\.check").each(function () {
166
167        var checkBox = $(this);
168
169        if ($(this).find("input[type=checkbox]").length > 0) {
170            checkBox = $(this).find("input[type=checkbox]");
171        }
172
173        if (checkBox.is(':checked')) {
174            if ($(this).hasClass("is-invalid")) {
175                $(this).removeClass("is-invalid");
176            }
177        }
178        else {
179            if (!$(this).hasClass("is-invalid")) {
180                $(this).addClass("is-invalid");
181            }
182        }
183    });
184
185    $("." + className + "\\.custom").each(function () {
186        //Permet les optionnels
187        if ($(this).val().trim().length == 0)
188            return;
189
190        var iNum = parseFloat($(this).val().replace(",", "."));
191
192
193        if (iNum == 0 && $('[id*=ddl_evaluator]').prop('selectedIndex') > 0) {
194            if (!$(this).hasClass("is-invalid")) {
195                $(this).addClass("is-invalid");
196            }
197        } else {
198            $(this).removeClass("is-invalid");
199        }
200    });
201
202
203    $("." + className + "\\.creditCard").each(function () {
204
205        var cardType = $('#ddl_card_type :selected').val();
206        var creditCardNumber = $(this).val().replace(/\D/g, '');
207        var regEx;
208
209        if (cardType != 0) {
210            if (cardType == CardTypeEnum.VISA || cardType == CardTypeEnum.VISA_DEBIT) {
211                regEx = /^4[0-9]{12}(?:[0-9]{3})?$/;
212            } else if (cardType == CardTypeEnum.MASTERCARD || cardType == CardTypeEnum.DEBIT_MASTERCARD) {
213                regEx = /^5[1-5][0-9]{14}$|^2(?:2(?:2[1-9]|[3-9][0-9])|[3-6][0-9][0-9]|7(?:[01][0-9]|20))[0-9]{12}$/;
214            } else { //American Express
215                regEx = /^3[47][0-9]{13}$/;
216            }
217
218            if (creditCardNumber.match(regEx)) {
219                if ($(this).hasClass("is-invalid")) {
220                    $(this).removeClass("is-invalid");
221                }
222            } else {
223                if (!$(this).hasClass("is-invalid")) {
224                    $(this).addClass("is-invalid");
225                }
226            }
227        }
228    });
229
230    $("." + className + "\\.cvv").each(function () {
231
232        var regEx = /^[0-9]{3,4}$/;
233
234        if ($(this).val().match(regEx)) {
235            if ($(this).hasClass("is-invalid")) {
236                $(this).removeClass("is-invalid");
237            }
238        } else {
239            if (!$(this).hasClass("is-invalid")) {
240                $(this).addClass("is-invalid");
241            }
242        }
243    });
244
245    if (invalidDivClass != null) {
246        if ($("[class*='is-invalid']").filter($("[class*='" + className + "']")).length > 0) {
247            $("." + invalidDivClass).show();
248        }
249        else {
250            $("." + invalidDivClass).hide();
251        }
252    }
253
254    return $("[class*=' is-invalid']").length == 0;
255}
256
257/*!--Dark mode
258    ===================================================================================== --*/
259
260        let mode = window.localStorage.getItem('mode'),
261            root = document.getElementsByTagName('html')[0];
262        if (mode !== null && mode === 'dark') {
263            root.classList.add('dark-mode');
264        } else {
265            root.classList.remove('dark-mode');
266        }
267
268
269    /*!--Page loading scripts
270    ===================================================================================== --*/
271
272            (function () {
273                window.onload = function () {
274                    const preloader = document.querySelector('.page-loading');
275                    preloader.classList.remove('active');
276                    setTimeout(function () {
277                        preloader.remove();
278                    }, 1000);
279                };
280        })();

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.