1const alinmaLoader = document.getElementById("alinmaLoader"); 2 3$(document).ready(function(){ 4 5 $('#custMobile').on('input', function() { 6 7 this.value = this.value.replace(/\D/g, ''); // remove non-digits 8 9 // If user types first digit not 0, clear it 10 if (this.value.length === 1 && this.value !== '0') { 11 this.value = ''; 12 } 13 14 // If user types second digit and it's not 5, remove it 15 if (this.value.length === 2 && this.value.substring(0, 2) !== '05') { 16 this.value = '0'; // keep only first 0 17 } 18 19 const val = $(this).val(); 20 console.log(val); 21 // Remove non-digit characters 22 const digits = val.replace(/\D/g, ''); 23 24 if (val.length === 10) { 25 26 $("#servErr").hide(); 27 const start = Date.now(); 28 29 alinmaLoader.classList.add("active"); 30 31 console.log('Phone number entered:', digits); 32 33 $("#brachService").empty().append('<option value=""></option>'); 34 $("#city").empty().append('<option value=""></option>'); 35 36 $.ajax({ 37 url: '/api/sitecore/GreeterAppoinments/loadGreeterBranchServices', 38 method: 'POST', 39 contentType: 'application/json', 40 data: JSON.stringify({ custMobile: digits }), 41 async:false, 42 success: function(response) { 43 console.log('Server response:', response); 44 45 if(response != null && response.result != null){ 46 47 if(response.result.isCustomer == "N"){ 48 $("#custName_wrapper").val('').show(); 49 } 50 if(response.result.isCustomer == "Y"){ 51 $("#custName").val(response.result.custName); 52 $("#custName_wrapper").hide(); 53 } 54 55 if(response.result.branchServList != null){ 56 let branchServiceDropdown = $("#brachService"); 57 58 $.each(response.result.branchServList, function (index, item) { 59 branchServiceDropdown.append(`<option value="${item.Name}">${item.Value}</option>`); 60 }); 61 } 62 63 if(response.result.cityList != null){ 64 let cityDropdown = $("#city"); 65 66 $.each(response.result.cityList, function (index, item) { 67 cityDropdown.append(`<option value="${item.Name}">${item.Value}</option>`); 68 }); 69 } 70 } 71 72 }, 73 error: function(xhr, status, error) { 74 $("#servErr").show(); 75 console.log('Error:', error); 76 }, 77 complete:function(){ 78 alinmaLoader.classList.remove("active"); 79 } 80 }); 81 82 83 84 } 85 }); 86 87 88 89 90 $('#city').on('change', function () { 91 92 $("#alinmaLoader").addClass("active"); 93 94 const selectedCity = $(this).val(); 95 console.log('selectedCity:', selectedCity); 96 97 $("#servErr").hide(); 98 $("#branch").empty().append('<option value=""></option>'); 99 $("#availableDates").empty(); 100 $("#availableTimes").empty(); 101 102 $.ajax({ 103 url: '/api/sitecore/GreeterAppoinments/loadGreeterBranches', 104 method: 'POST', 105 contentType: 'application/json', 106 data: JSON.stringify({ city: selectedCity }), 107 async:false, 108 success: function(response) { 109 console.log('Server response:', response); 110 111 if(response != null && response.result != null){ 112 113 if(response.result.branchList != null){ 114 let branchDropdown = $("#branch"); 115 116 $.each(response.result.branchList, function (index, item) { 117 branchDropdown.append(`<option value="${item.Name}">${item.Value}</option>`); 118 }); 119 } 120 121 122 } 123 124 }, 125 error: function(xhr, status, error) { 126 $("#servErr").show(); 127 console.log('Error:', error); 128 }, 129 complete:function(){ 130 $("#alinmaLoader").removeClass("active"); 131 } 132 }); 133 134 }); 135 136 137 $('#branch').on('change', function () { 138 139 140 $("#alinmaLoader").addClass("active"); 141 const selectedBranch = $(this).val(); 142 console.log('selectedBranch:', selectedBranch); 143 144 $("#servErr").hide(); 145 $("#availableDates").empty(); 146 $("#availableTimes").empty(); 147 148 $.ajax({ 149 url: '/api/sitecore/GreeterAppoinments/loadAvailableDates', 150 method: 'POST', 151 contentType: 'application/json', 152 data: JSON.stringify({ 153 branch: selectedBranch, 154 branchService : $("#brachService").val() 155 }), 156 async:false, 157 success: function(response) { 158 console.log('Server response:', response); 159 160 if(response != null && response.result != null){ 161 162 if(response.result.availableDates != null){ 163 let availableDates = $("#availableDates"); 164 165 $.each(response.result.availableDates, function (index, item) { 166 availableDates.append(` 167 <div class="form-check"> 168 <input class="form-check-input" type="radio" name="appointmentDate" id="radioDate_${item.Name}" value="${item.Name}" lbl="${item.Value}"> 169 <label class="form-check-label" for="radioDate_${item.Name}">${item.Value}</label> 170 </div> 171 `); 172 173 });
174 } 175 176 177 } 178 179 }, 180 error: function(xhr, status, error) { 181 $("#servErr").show(); 182 console.log('Error:', error); 183 }, 184 complete:function(){ 185 $("#alinmaLoader").removeClass("active"); 186 } 187 }); 188 189 }); 190 191 192 193 194 $(document).on('change', 'input[name="appointmentDate"]', function() { 195 196 197 $("#alinmaLoader").addClass("active"); 198 const selectedDate = $(this).val(); 199 console.log('Selected appointment date:', selectedDate); 200 201 $("#servErr").hide(); 202 $("#availableTimes").empty(); 203 204 $.ajax({ 205 url: '/api/sitecore/GreeterAppoinments/loadAvailableTimes', 206 method: 'POST', 207 contentType: 'application/json', 208 async:false, 209 data: JSON.stringify({ 210 branch: $("#branch").val(), 211 branchService : $("#brachService").val(), 212 appointmentDate : selectedDate 213 }), 214 success: function(response) { 215 console.log('Server response:', response); 216 217 if(response != null && response.result != null){ 218 219 if(response.result.availableTimes != null){ 220 let availableTimes = $("#availableTimes"); 221 222 $.each(response.result.availableTimes, function (index, item) { 223 availableTimes.append(` 224 <div class="form-check"> 225 <input class="form-check-input" type="radio" name="appointmentTime" id="radioTime_${item.Name}" value="${item.Name}" lbl="${item.Value}"> 226 <label class="form-check-label" for="radioTime_${item.Name}">${item.Value}</label> 227 </div> 228 `); 229 230 }); 231 } 232 233 234 } 235 236 }, 237 error: function(xhr, status, error) { 238 $("#servErr").show(); 239 console.log('Error:', error); 240 }, 241 complete:function(){ 242 $("#alinmaLoader").removeClass("active"); 243 } 244 }); 245 246 }); 247 248 $("#previewBtn_old").click(function(){ 249 250 251 252 253 $("#sel_custMobile").html($("#custMobile").val()); 254 $("#sel_custName").html($("#custName").val()); 255 $("#sel_branchService").html($('#brachService option:selected').text()); 256 $("#sel_city").html($('#city option:selected').text()); 257 $("#sel_branch").html($('#branch option:selected').text()); 258 $("#sel_appointmentDate").html($('input[name="appointmentDate"]:checked').attr('lbl')); 259 $("#sel_appointmentTime").html($('input[name="appointmentTime"]:checked').attr('lbl')); 260 }); 261 262 263 $("#sedco_previewBtn").click(function(e) { 264 265 e.preventDefault(); 266 267 let isValid = true; 268 269 // Clear previous errors 270 ['custMobile', 'custName', 'brachService', 'city', 'branch'].forEach(id => { 271 $('#' + id).removeClass('is-invalid'); 272 $('#error-' + id).text(''); 273 }); 274 275 // Validate Mobile Number 276 const custMobile = $('#custMobile').val().trim(); 277 if (!custMobile) { 278 isValid = false; 279 $('#custMobile').addClass('is-invalid'); 280 $('#error-custMobile').text(CustMobileRequired); 281 } else if (!/^\d{10}$/.test(custMobile)) { 282 isValid = false; 283 $('#custMobile').addClass('is-invalid'); 284 $('#error-custMobile').text(CustMobileInValid); 285 } 286 287 // Validate Name 288 289 const htmlTag = document.documentElement; 290 const pagelang = htmlTag.getAttribute("lang"); 291 const custName = $('#custName').val().trim(); 292 if (!custName) { 293 isValid = false; 294 $('#custName').addClass('is-invalid'); 295 $('#error-custName').text(NameRequired); 296 }else if(pagelang === "en" && !/^[A-Za-z\s]+$/.test(custName)){ 297 isValid = false; 298 $('#custName').addClass('is-invalid'); 299 $('#error-custName').text(CustNameInvalid); 300 }else if(pagelang === "ar" && ! /^[\u0600-\u06FF\s]+$/.test(custName)){ 301 isValid = false; 302 $('#custName').addClass('is-invalid'); 303 $('#error-custName').text(CustNameInvalid); 304 } 305 306 // Validate Service Type 307 const service = $('#brachService').val(); 308 if (!service) { 309 isValid = false; 310 $('#brachService').addClass('is-invalid'); 311 $('#error-brachService').text(ServiceTypeRequired); 312 } 313 314 // Validate City 315 const city = $('#city').val(); 316 if (!city) { 317 isValid = false; 318 $('#city').addClass('is-invalid'); 319 $('#error-city').text(CityRequired); 320 } 321 322 // Validate Branch 323 const branch = $('#branch').val(); 324 if (!branch) { 325 isValid = false; 326 $('#branch').addClass('is-invalid'); 327 $('#error-branch').text(BranchRequired); 328 } 329 330 // Validate Appointment Date selected 331 if (!$('input[name="appointmentDate"]:checked').length) { 332 isValid = false;
333 $('#availableDates').next('.invalid-feedback').remove(); 334 $('#availableDates').after('<div class="invalid-feedback d-block">'+AppointmentDateRequired+'</div>'); 335 } else { 336 $('#availableDates').next('.invalid-feedback').remove(); 337 } 338 339 // Validate Appointment Time selected 340 if (!$('input[name="appointmentTime"]:checked').length) { 341 isValid = false; 342 $('#availableTimes').next('.invalid-feedback').remove(); 343 $('#availableTimes').after('<div class="invalid-feedback d-block">'+AppointmentTimeRequired+'</div>'); 344 } else { 345 $('#availableTimes').next('.invalid-feedback').remove(); 346 } 347 348 if (!isValid) { 349 return false; // stop here if invalid 350 } 351 352 // Populate summary fields if valid 353 $("#sel_custMobile").text(custMobile); 354 $("#sel_custName").text(custName); 355 $("#sel_branchService").text($('#brachService option:selected').text()); 356 $("#sel_city").text($('#city option:selected').text()); 357 $("#sel_branch").text($('#branch option:selected').text()); 358 $("#sel_appointmentDate").text($('input[name="appointmentDate"]:checked').attr('lbl')); 359 $("#sel_appointmentTime").text($('input[name="appointmentTime"]:checked').attr('lbl')); 360 361 362 363 const nextTabBtn = $('button[data-bs-target="#step-2"]'); 364 if (nextTabBtn.length) { 365 nextTabBtn.prop('disabled', false).removeClass('disabled'); 366 // Activate step 2 tab programmatically using Bootstrap Tab API: 367 const tabTrigger = new bootstrap.Tab(nextTabBtn[0]); 368 tabTrigger.show(); 369 } 370 371 var scrollElement = document.getElementById("myTabContent"); 372 scrollElement.scrollIntoView({behaviour:"smooth"}); 373 374}); 375 376 377 378$('.prevBtn').click(function() { 379 const activeTab = $('.tab-pane.active'); 380 if (activeTab.attr('id') === 'step-2') { 381 382 const step2Btn = $('button[data-bs-target="#step-2"]'); 383 step2Btn.prop('disabled', true).addClass('disabled'); 384 385 const step1Btn = $('button[data-bs-target="#step-1"]'); 386 const tab = new bootstrap.Tab(step1Btn[0]); 387 tab.show(); 388 } else if (activeTab.attr('id') === 'step-3') { 389 const step2Btn = $('button[data-bs-target="#step-2"]'); 390 const tab = new bootstrap.Tab(step2Btn[0]); 391 tab.show(); 392 } 393}); 394 395 396$('#confirmBtn').click(function(e) { 397 398 e.preventDefault(); 399 400 $("#alinmaLoader").addClass("active"); 401 402 $("#servErr").hide(); 403 404 console.log($("#aptform").serialize()); 405 406 $.ajax({ 407 url: '/api/sitecore/GreeterAppoinments/bookAppointment', 408 method: 'POST', 409 //contentType: 'application/json', 410 data: $("#aptform").serialize(), 411 async:false, 412 success: function(response) { 413 console.log('Server response:', response); 414 415 if(response != null && response.result != null){ 416 417 // Enable Step 3 tab button 418 const step3Btn = $('button[data-bs-target="#step-3"]'); 419 step3Btn.prop('disabled', false).removeClass('disabled'); 420 421 // Show Step 3 tab (confirmation) 422 const tab = new bootstrap.Tab(step3Btn[0]); 423 tab.show(); 424 425 426 } 427 428 }, 429 error: function(xhr, status, error) { 430 $("#servErr").show(); 431 console.log('Error:', error); 432 }, 433 complete:function(){ 434 $("#alinmaLoader").removeClass("active"); 435 } 436 }); 437 438 439 440 441}); 442 443 444 445}); 446 447
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.