1(function($) { 2 3 document.addEventListener('DOMContentLoaded', function () { 4 const tabselement = document.getElementsByClassName("elementor-tabs"); 5 for (var i = 0; i < tabselement.length; i++) { 6 tabselement[i].classList.add('rs_preserve'); 7 } 8 }); 9 10 $('li.search').on('click', function(){ 11 $('.elementor-widget-search-form .elementor-search-form__container').toggleClass('.elementor-search-form--full-screen.elementor-lightbox elementor-search-form--full-screen elementor-lightbox'); 12 }); 13 14 $('a.search').on('click', function(){ 15 $('.elementor-widget-search-form .elementor-search-form__container').toggleClass('.elementor-search-form--full-screen.elementor-lightbox elementor-search-form--full-screen elementor-lightbox'); 16 }); 17 18 19 $(".dropdown-toggle").hover( 20 function () { 21 $(this).addClass("hover"); 22 }, 23 function () { 24 $(this).removeClass("hover"); 25 } 26 ); 27 $(".has-submenu").hover( 28 function () { 29 $(this).siblings(".megasubmenu").addClass("hover"); 30 }, 31 function () { 32 $(this).siblings(".megasubmenu").removeClass("hover"); 33 } 34 ); 35 36 $(".has-submenu").hover( 37 function () { 38 $(this).next().addClass("d-block"); 39 }, 40 function () { 41 $(this).next().removeClass("d-block"); 42 } 43 ); 44 45 $(".megasubmenu").hover( 46 function () { 47 $(this).addClass("d-block"); 48 }, 49 function () { 50 $(this).removeClass("d-block"); 51 } 52 ); 53 54 $('#cab-tabs p img').unwrap().addClass('image-custom'); 55 56 57jQuery(document).ready(function($) { 58// Example: form ID 5, field ID 3 59$('#input_5_96').attr('readonly', true); 60$('#input_5_115').attr('readonly', true); 61}); 62 63$("#input_5_24,#input_5_45,#input_5_47,#input_5_46,#input_5_63,#input_5_62,#input_5_12,#input_5_42,#input_6_12,#input_6_24,#input_6_62,#input_6_62,#input_6_42,#input_6_45,#input_6_63,#input_6_47").on("input", function() { 64 this.value = this.value.replace(/[^0-9.]/g, ''); 65}); 66 67 68jQuery('#input_5_119, #input_6_112').on("input", function () { 69 this.value = this.value 70 .replace(/\D/g, '') // numbers only 71 .slice(0, 5); // max 5 digits 72}); 73 74$("#input_5_4, #input_6_4").on("input", function () { 75 // Allow digits only 76 this.value = this.value.replace(/\D/g, ''); 77 78 // Max length = 14 79 if (this.value.length > 14) { 80 this.value = this.value.slice(0, 14); 81 } 82 83 84 85 const isArabicPage = $("html").attr("lang")?.startsWith("ar"); 86 87 const messages = { 88 ar: { 89 keyboard: "Ø§ÙØ±Ø¬Ø§Ø¡ تغÙÙØ± ÙØºØ© ÙÙØØ© اÙÙ ÙØ§ØªÙØ Ø¥ÙÙ Ø§ÙØ¥ÙجÙÙØ²ÙØ©.", 90 length: "ÙØ¬Ø¨ Ø£Ù ÙØªÙÙÙ٠رÙ٠اÙÙØ§ØªÙ Ù Ù 10 Ø£Ø±ÙØ§Ù عÙÙ Ø§ÙØ£ÙÙ." 91 }, 92 en: { 93 keyboard: "Please switch your keyboard to English.", 94 length: "Phone number must be at least 10 digits." 95 } 96 }; 97 98 const msg = isArabicPage ? messages.ar : messages.en; 99 100 let raw = this.value; 101 let val = raw.toUpperCase(); 102 let cleaned = ""; 103 let error = ""; 104 105 // Detect Arabic characters 106 if (/[\u0600-\u06FF]/.test(raw)) { 107 error = msg.keyboard; 108 } 109 110 if (!error && raw.length < 10) { 111 error = msg.length; 112 } 113 else 114 error = ""; 115 116 const $field = $(this).closest(".gfield"); 117 $field.find(".gf-live-error").remove(); 118 119 if (error) { 120 $field.append( 121 '<div class="gf-live-error" style="color:#c02b0a;font-size:13px;margin-top:5px;">' + 122 error + 123 '</div>' 124 ); 125 } 126 127}); 128 129 130 131 132 133$("#input_5_116, #input_6_5").on("input", function() { 134 135 const isArabicPage = $("html").attr("lang")?.startsWith("ar"); 136 137 const messages = { 138 ar: { 139 keyboard: "Ø§ÙØ±Ø¬Ø§Ø¡ تغÙÙØ± ÙØºØ© ÙÙØØ© اÙÙ ÙØ§ØªÙØ Ø¥ÙÙ Ø§ÙØ¥ÙجÙÙØ²ÙØ©.", 140 first3: "Ø£ÙÙ 3 Ø®Ø§ÙØ§Øª ÙØ¬Ø¨ أ٠تÙÙÙ Ø£ØØ±ÙÙØ§ Ø¥ÙØ¬ÙÙØ²ÙØ©.", 141 last5: "آخر 5 Ø®Ø§ÙØ§Øª ÙØ¬Ø¨ أ٠تÙÙÙ Ø£Ø±ÙØ§Ù ÙØ§.", 142 length: "ÙØ¬Ø¨ إدخا٠8 Ø®Ø§ÙØ§Øª Ø¨Ø§ÙØ¶Ø¨Ø· (3 Ø£ØØ±Ù + 5 Ø£Ø±ÙØ§Ù )." 143 }, 144 en: { 145 keyboard: "Please switch your keyboard to English.", 146 first3: "First 3 characters must be English letters.", 147 last5: "Last 5 characters must be numbers.", 148 length: "Must be exactly 8 characters (3 letters + 5 numbers)." 149 } 150 }; 151 152 const msg = isArabicPage ? messages.ar : messages.en; 153 154 let raw = this.value; 155 let val = raw.toUpperCase();
156 let cleaned = ""; 157 let error = ""; 158 159 // Detect Arabic characters 160 if (/[\u0600-\u06FF]/.test(raw)) { 161 error = msg.keyboard; 162 } 163 164 for (let i = 0; i < val.length && i < 8 && !error; i++) { 165 166 if (i < 3) { 167 if (/[A-Z]/.test(val[i])) { 168 cleaned += val[i]; 169 } else { 170 error = msg.first3; 171 break; 172 } 173 } else { 174 if (/[0-9]/.test(val[i])) { 175 cleaned += val[i]; 176 } else { 177 error = msg.last5; 178 break; 179 } 180 } 181 } 182 183 this.value = cleaned; 184 185 if (!error && cleaned.length < 8) { 186 error = msg.length; 187 } 188 189 const $field = $(this).closest(".gfield"); 190 $field.find(".gf-live-error").remove(); 191 192 if (error) { 193 $field.append( 194 '<div class="gf-live-error" style="color:#c02b0a;font-size:13px;margin-top:5px;">' + 195 error + 196 '</div>' 197 ); 198 } 199}); 200 201 202})(jQuery); 203 204 205 206jQuery("#input_11_3, #input_12_3").on("input", function () { 207 208 let val = this.value; 209 let cleaned = val.replace(/\D/g, ''); 210 cleaned = cleaned.substring(0, 14); 211 this.value = cleaned; 212 213 const $field = jQuery(this).closest(".gfield"); 214 $field.find(".gf-live-error").remove(); 215 216 // Detect page language 217 const isArabic = document.documentElement.lang.startsWith("ar"); 218 219 let error = ""; 220 221 if (cleaned.length > 0 && cleaned.length < 14) { 222 error = isArabic 223 ? "ÙØ¬Ø¨ إدخا٠14 رÙÙ Ø¨Ø§ÙØ¶Ø¨Ø·." 224 : "You must enter exactly 14 digits."; 225 } 226 227 if (error) { 228 $field.append( 229 '<div class="gf-live-error" style="color:#c02b0a;font-size:13px;margin-top:5px;">' + 230 error + 231 '</div>' 232 ); 233 } 234 235}); 236 237 238// ============================================================ 239// LOAN FORM DUPLICATE CHECK â Form 5 (EN) + Form 6 (AR) - e-loan 240// ============================================================ 241 242jQuery(document).ready(function () { 243 244 function normalizeArabic(str) { 245 var arabic = ['Ù ','Ù¡','Ù¢','Ù£','Ù¤','Ù¥','Ù¦','Ù§','Ù¨','Ù©']; 246 var western = ['0','1','2','3','4','5','6','7','8','9']; 247 arabic.forEach(function(a, i) { 248 str = str.split(a).join(western[i]); 249 }); 250 return str; 251 } 252 253 // ââ Form 5 conditional field dependents (English) âââââââââ 254 var loanDependents_5 = { 255 'Car' : [37,38,39,76,41,96,115,42,44,45,46,47,48,78,123], 256 'Credit Cards' : [51,95,56,59,62,60,61,119,120], 257 'Personal' : [118,94,10,29,30,31,12,24,77,124] 258 }; 259 260 // ââ Form 6 conditional field dependents (Arabic) ââââââââââ 261 var loanDependents_6 = { 262 'Ø³ÙØ§Ø±Ø©' : [37,38,39,76,41,108,109,42,44,45,46,47,48,78,116], 263 'Ø¨Ø·Ø§ÙØ§Øª Ø§ÙØ§Ø¦ØªÙ اÙ' : [51,55,56,59,62,60,61,112,114], 264 'شخصÙ' : [34,91,10,29,30,31,12,24,77,117] 265 }; 266 267 // ââ Forms configuration ââââââââââââââââââââââââââââââââââââ 268 var formsConfig = [ 269 { 270 formId : 5, 271 nationalInputId : '#input_5_5', 272 loanSelectId : '#input_5_26', 273 loanDependents : loanDependents_5, 274 appliedLabel : ' - You already applied to this loan', 275 errorMessage : function(loanType) { 276 return 'You have already applied for a <strong>' + loanType + '</strong> loan with this National ID. Please choose a different loan type.'; 277 } 278 }, 279 { 280 formId : 6, 281 nationalInputId : '#input_6_110', 282 loanSelectId : '#input_6_26', 283 loanDependents : loanDependents_6, 284 appliedLabel : ' - ØªÙ Ø§ÙØªÙدÙ٠عÙÙÙ Ù Ø³Ø¨ÙØ§Ù', 285 errorMessage : function(loanType) { 286 return 'ÙÙØ¯ ØªÙØ¯Ù ت Ù Ø³Ø¨ÙØ§Ù Ø¨Ø·ÙØ¨ <strong>' + loanType + '</strong> Ø¨Ø§Ø³ØªØ®Ø¯Ø§Ù ÙØ°Ø§ Ø§ÙØ±Ù٠اÙÙØ·ÙÙ. ÙØ±Ø¬Ù Ø§Ø®ØªÙØ§Ø± ÙÙ
286ع ÙØ±Ø¶ ٠ختÙÙ.'; 287 } 288 } 289 ]; 290 291 292 // ââ Initialize each form âââââââââââââââââââââââââââââââââââ 293 formsConfig.forEach(function(formCfg) { 294 initLoanCheck(formCfg); 295 }); 296 297 298 function initLoanCheck(formCfg) { 299 var formId = formCfg.formId; 300 var nationalInputId = formCfg.nationalInputId; 301 var loanSelectId = formCfg.loanSelectId; 302 var loanDependents = formCfg.loanDependents; 303 var appliedLabel = formCfg.appliedLabel; 304 var errorMessage = formCfg.errorMessage; 305 var configKey = 'loanFormConfig_' + formId; 306 307 function waitForConfig() { 308 var config = window[configKey]; 309 if (!config) { 310 setTimeout(waitForConfig, 500); 311 return; 312 } 313 314 console.log('Loan config found for form ' + formId + ':', config); 315 316 var usedLoans = []; 317 var checkTimer = null; 318 319 320 // ââ Core AJAX check function âââââââââââââââââââââââ 321 function checkNationalId(nationalNumber, onComplete) { 322 jQuery.ajax({ 323 url : config.ajaxUrl, 324 type : 'POST', 325 data : { 326 action : 'loan_check_submissions', 327 nonce : config.nonce, 328 form_id : formId, 329 national_number : nationalNumber, 330 }, 331 xhrFields: { withCredentials: false }, 332 success: function (response) { 333 if (response.success) { 334 usedLoans = response.data.used_loans; 335 updateDropdown(); 336 console.log('Form ' + formId + ' used loans:', usedLoans); 337 338 // Check if currently selected loan is now blocked 339 var currentLoan = jQuery(loanSelectId).val(); 340 if (currentLoan && usedLoans.indexOf(currentLoan) !== -1) { 341 jQuery(loanSelectId).val(''); 342 jQuery(loanSelectId).trigger('chosen:updated'); 343 showLoanError(currentLoan); 344 hideConditionalFields(); 345 } 346 347 if (typeof onComplete === 'function') { 348 onComplete(); 349 } 350 } else { 351 console.warn('Response error:', response); 352 } 353 }, 354 error: function (xhr) { 355 console.error('AJAX failed:', xhr.status, xhr.responseText); 356 } 357 }); 358 } 359 360 361 // ââ When national ID is typed ââââââââââââââââââââââ 362 jQuery(document).on('input change', nationalInputId, function () { 363 var nationalNumber = normalizeArabic(jQuery(this).val().trim()); 364 clearTimeout(checkTimer); 365 366 if (nationalNumber.length < 10) { 367 // Only reset if field is cleared completely 368 if (nationalNumber.length === 0) { 369 usedLoans = []; 370 resetDropdown(); 371 } 372 return; 373 } 374 375 // Fire instantly at exactly 10 digits 376 if (nationalNumber.length === 10) { 377 checkNationalId(nationalNumber); 378 return; 379 } 380 381 // Above 10 digits â short debounce 382 checkTimer = setTimeout(function () { 383 checkNationalId(nationalNumber); 384 }, 300); 385 }); 386 387 388 // ââ When loan dropdown changes âââââââââââââââââââââ 389 jQuery(document).on('change', loanSelectId, function () { 390 var selected = jQuery(this).val(); 391 392 if (usedLoans.indexOf(selected) !== -1) { 393 var blockedLoan = selected; 394 395 jQuery(this).val(''); 396 jQuery(this).trigger('chosen:updated'); 397 398 showLoanError(blockedLoan); 399 hideConditionalFields(); 400 401 } else { 402 hideLoanError(); 403 } 404 }); 405 406 407 // ââ Auto-check on page load after validation error â 408 setTimeout(function() { 409 var existingNationalId = normalizeArabic( 410 jQuery(nationalInputId).val().trim() 411 ); 412 413 if (existingNationalId.length >= 10) { 414 console.log('Form ' + formId + ': National ID found on load, re-checking...'); 415 416 checkNationalId(existingNationalId, function() { 417 var currentLoan = jQuery(loanSelectId).val(); 418 419 if (currentLoan && usedLoans.indexOf(currentLoan) !== -1) { 420 jQuery(loanSelectId).val(''); 421 jQuery(loanSelectId).trigger('chosen:updated'); 422 showLoanError(currentLoan); 423 hideConditionalFields(); 424 } 425 }); 426 } 427 }, 500); 428 429 430 // ââ Dim used options in dropdown âââââââââââââââââââ 431 function updateDropdown() { 432 jQuery(loanSelectId).find('option').each(function () { 433 var val = jQuery(this).val(); 434 if (!val) return; 435 436 var cleanText = jQuery(this).text().split(appliedLabel)[0].trim(); 437 438 if (usedLoans.indexOf(val) !== -1) { 439 jQuery(this) 440 .css({'color': '#bbb', 'font-style': 'italic'}) 441 .attr('data-used', 'true') 442 .text(cleanText + appliedLabel); 443 } else { 444 jQuery(this) 445 .css({'color': '', 'font-style': ''}) 446 .removeAttr('data-used') 447 .text(cleanText); 448 } 449 }); 450 451 jQuery(loanSelectId).trigger('chosen:updated'); 452 } 453 454 455 // ââ Reset dropdown âââââââââââââââââââââââââââââââââ 456 function resetDropdown() { 457 jQuery(loanSelectId).find('option').each(function () { 458 var cleanText = jQuery(this).text().split(appliedLabel)[0].trim(); 459 jQuery(this) 460 .css({'color': '', 'font-style': ''}) 461 .removeAttr('data-used') 462 .text(cleanText); 463 }); 464 jQuery(loanSelectId).trigger('chosen:updated'); 465 hideLoanError(); 466 } 467 468 469 // ââ Show error âââââââââââââââââââââââââââââââââââââ 470 function showLoanError(loanType) {
471 jQuery('#loan-duplicate-error-' + formId).remove(); 472 jQuery(loanSelectId).closest('.gfield').append( 473 '<p id="loan-duplicate-error-' + formId + '" style="color:#c0392b;margin-top:8px;font-weight:600;font-size:14px;">' + 474 errorMessage(loanType) + 475 '</p>' 476 ); 477 } 478 479 480 // ââ Hide error âââââââââââââââââââââââââââââââââââââ 481 function hideLoanError() { 482 jQuery('#loan-duplicate-error-' + formId).remove(); 483 } 484 485 486 // ââ Hide all loan conditional fields âââââââââââââââ 487 function hideConditionalFields() { 488 var allLoanFields = []; 489 for (var loan in loanDependents) { 490 allLoanFields = allLoanFields.concat(loanDependents[loan]); 491 } 492 493 // Remove duplicates 494 allLoanFields = allLoanFields.filter(function(v, i, a) { 495 return a.indexOf(v) === i; 496 }); 497 498 // Hide each field 499 allLoanFields.forEach(function(fieldId) { 500 jQuery('#field_' + formId + '_' + fieldId).hide(); 501 }); 502 503 // Reset dropdown and update Chosen 504 jQuery(loanSelectId).val(''); 505 jQuery(loanSelectId).trigger('chosen:updated'); 506 507 // Let GF re-evaluate rules 508 setTimeout(function() { 509 if (typeof gf_apply_rules === 'function') { 510 gf_apply_rules(formId, [], true); 511 } 512 }, 150); 513 } 514 515 } 516 517 waitForConfig(); 518 } 519 520});
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.