1// if(typeof($) != undefined) 2 // $.noConflict(); 3 4 function redirect(url) { 5 if ($('body').hasClass('boot') && (!url.match(/^http/) || url.indexOf(base) != -1)) { 6 loadByAJAXURL = url; 7 loadPageByAJAX(url); 8 } else 9 window.top.location = url; 10 } 11 12 function na() { 13 alert('This feature is not yet implemented.'); 14 return false; 15 } 16 function addFavorites(){ 17 let favorites = localStorage.favorites; 18 if(favorites){ 19 favorites = JSON.parse(favorites); 20 }else favorites = {}; 21 } 22 23 function setRadioValue(name, value) { 24 if (!$('input[type=radio][name="' + name + '"]').length) 25 return; 26 27 var ids = $('input[type=radio][name="' + name + '"]'); 28 29 for (i = 0; i < ids.length; i++) 30 if (ids[i].value == value || (i == 0 && !value)) 31 ids[i].checked = true; 32 else 33 ids[i].checked = null; 34 } 35 36 function selectValue(id, val, suffix) { 37 if ($('#' + id + ' option[value="' + val + '"]').length || (suffix && $('#' + id + ' option[value$="' + val + '"]').length)) 38 $('#' + id + ' option:selected:eq(0)').prop('selected', null); 39 if ($('#' + id + ' option[value="' + val + '"]').length) 40 $('#' + id + ' option[value="' + val + '"]:eq(0)').prop('selected', true); 41 else if(suffix && $('#' + id + ' option[value$="' + val + '"]').length) 42 $('#' + id + ' option[value$="' + val + '"]:eq(0)').prop('selected', true); 43 else if(val) 44 $('#' + id).val(val); 45 else 46 $('#' + id + ' option:not(.hide):not(.ihide):eq(0)').prop('selected', true); 47 // if ($('#' + id + ' option[value="' + val + '"]').length) 48 // $('#' + id).trigger('change').trigger('input'); 49 } 50 51 function selectValueTrigger(id, val) { 52 selectValue(id, val); 53 $('#' + id).trigger('change').trigger('input'); 54 } 55 56 function selectValueRetainOld(id, val) { 57 if (val && (val + "") !== "0" && !$('#' + id + ' option[value="' + val + '"]:not(.hide)').length) { 58 $('#' + id).append('<option class="old" value="' + val + '">' + val + '</option>'); 59 $('#' + id).attr('title', '"' + val + '" is no longer a valid choice.'); 60 if ($('#' + id).parent().attr('class') && $('#' + id).parent().attr('class').indexOf('select') != -1) 61 $('#' + id).parent().attr('title', '"' + val + '" is no longer a valid choice.'); 62 63 $('#' + id).bind('change', function() { 64 if ($(this).val() != val) { 65 $('#' + id + ' option[value="' + val + '"]').remove(); 66 67 $('#' + id).attr('title', ''); 68 if ($('#' + id).parent().attr('class') && $('#' + id).parent().attr('class').indexOf('select') != -1) 69 $('#' + id).parent().attr('title', ''); 70 } 71 }); 72 } 73 $('#' + id + ' option[value="' + val + '"]:not(.hide):eq(0)').prop('selected', true); 74 } 75 76 function resetBrowserStorageCache() { 77 if (!confirm('This will reset your session with the website and delete all cookies and browser cached data.\n\nAre you sure you wish to proceed?')) { 78 return false; 79 } 80 81 // Clear localStorage 82 if (typeof localStorage !== 'undefined') { 83 localStorage.clear(); 84 } 85 86 // Clear sessionStorage 87 if (typeof sessionStorage !== 'undefined') { 88 sessionStorage.clear(); 89 } 90 91 // Clear all cookies 92 document.cookie.split(";").forEach(function(c) { 93 var name = c.replace(/^ +/, "").replace(/=.*/, ""); 94 // Try multiple path combinations 95 ['/', '/admin/', '/core/', window.location.pathname].forEach(function(path) { 96 document.cookie = name + "=;expires=" + new Date(0).toUTCString() + ";path=" + path; 97 document.cookie = name + "=;expires=" + new Date(0).toUTCString() + ";path=" + path + ";domain=" + window.location.hostname; 98 }); 99 }); 100 101 // Reload the page to reset session 102 window.location.reload(true); 103 } 104 105 function resizePopup_old() { 106 $('#popup').show().css('width', $('#popupDynamic').width()); 107 108 var fixed = false; 109 110 if ($('#popup').height() > $(window).height()) { 111 $('#popup').css({ 112 'left': ($(window).width() - $('#popup').width()) / 2, 113 'top': '50px', 114 'position': (fixed ? "fixed" : "absolute") 115 }).fadeIn(); 116 } else { 117 $('#popup').css({ 118 'left': ($(window).width() - $('#popup').width()) / 2, 119 'top': ($(window).height() - $('#popup').height()) / 2, 120 'position': (fixed ? "fixed" : "absolute") 121 }).fadeIn(); 122 } 123 124 var openEditor = $('table[name^=idArea]:visible'); 125 if (openEditor && typeof(openEditor) != 'undefined' && openEditor.attr('width') && openEditor.attr('width').replace('px', '') != openEditor.css('width').replace('px', '')) 126 fixed = true; 127 128 if (!fixed) 129 $('html,body').animate({ scrollTop: $('#popup').offset().top }, 1000); 130 } 131 132 // var dataParams = {}; 133 function pagingRecordEdited(type, id) {
134 if (!$('#divListing_' + type).length) 135 return; 136 137 // ' + ((dataParams && Object.keys(dataParams).length) ? '?' + $.param(dataParams) : '') 138 139 $.ajax({ 140 // url: base_app + type + '/getSingle', 141 // data: (ajax: true, id: id}, 142 url: (type == 'notes'?base:base_app) + type + '/getSingle?ajax=true&id=' + id, 143 data: ($('#frmSearch_' + type).length ? $('#frmSearch_' + type).serialize() : {}), 144 success: function(response) { 145 loadTabbedListingParams($('#divListing_' + type)); 146 147 $('body').append('<div class="hide" id="divSingle' + type + '"></div>'); 148 $('#divSingle' + type).append(response); 149 150 if ($('#divSingle' + type + ' table tbody > tr:eq(0)').length) { 151 if ($('#' + type + id).length) 152 $('#' + type + id).replaceWith($('#divSingle' + type + ' table tbody > tr:eq(0)')); 153 else if ($('#divSingle' + type + ' table tbody > tr:eq(0)').attr('id') && $('#divListing_' + type + ' table > tbody:eq(0)').find('#' + $('#divSingle' + type + ' table tbody > tr:eq(0)').attr('id')).length) 154 $('#' + $('#divSingle' + type + ' table tbody > tr:eq(0)').attr('id')).replaceWith($('#divSingle' + type + ' table tbody > tr:eq(0)')); 155 else 156 $('#divSingle' + type + ' table tbody > tr:eq(0)').appendTo($('#divListing_' + type + ' table > tbody:eq(0)')); 157 158 $('#' + type + id + ' .adminimages').click(adminImageClicked); 159 160 if (objects_meta && typeof(objects_meta[type]) != 'undefined' && objects_meta[type].edit) 161 bindEditRow(type, objects_meta[type].edit, objects_meta[type].fullpage); 162 } 163 164 var records = $('#divListing_' + type + ' table tbody tr').length; 165 166 try { 167 if (typeof(tabbedListingsLoaded[currentTabbedListing]) != 'undefined') { 168 if (!$(tabbedListingsLoaded[currentTabbedListing].tabbedTabsSelector + ' li:eq(0)').hasClass('active')) 169 switchListingTab(null, $(tabbedListingsLoaded[currentTabbedListing].tabbedTabsSelector + ' a.active')); 170 deEnsureTabbedListingDragIcon($('#divListing_' + type)); 171 } 172 if (typeof(deTabbedListingsLoaded[deCurrentTabbedListing]) != 'undefined') { 173 if (!$(deTabbedListingsLoaded[deCurrentTabbedListing].deTabbedTabsSelector + ' li:eq(0)').hasClass('active')) 174 deSwitchListingTab(null, $(deTabbedListingsLoaded[deCurrentTabbedListing].deTabbedTabsSelector + ' a.active'), null, force); 175 ensureTabbedListingDragIcon($('#divListing_' + type)); 176 } 177 } catch (e) {} 178 179 if ($('#divPaging_' + type).length && records) 180 $('#divPaging_' + type + ' .pagesize option:last').val(records); 181 182 $('#divSingle' + type).remove(); 183 if (typeof(pagingCallbacks[type]) == 'function') 184 pagingCallbacks[type](); 185 186 afterQuickSearch(type); 187 try { 188 if (records > 100) 189 $('#divListing_' + type + ' table').trigger('addRows.tablesorter', [null, $('#' + type + id)]); 190 else 191 $('#divListing_' + type + ' table').trigger('updateAll.tablesorter'); 192 } catch (e) {} 193 $('#divListing_' + type + ' table tfoot tr:not(.summary)').hide(); 194 195 if ($("#divListing_" + type).find("input[type=checkbox]").length || $("#divListing_" + type).find("input[type=radio]").length) 196 $("#divListing_" + type).removeClass('jqtransformdone').jqTransform(); 197 198 initAJAXpage($('#' + type + id)); 199 } 200 }); 201 } 202 203 function pagingRecordRemoved(type) { 204 var records = $('#divListing_' + type + ' .tablesorter tbody tr').length; 205 // console.debug(records + " records after delete"); 206 if (records <= 100 || typeof(pagingtypes[type]) == 'undefined') 207 $('#divListing_' + type + ' .tablesorter').trigger('updateAll.tablesorter'); 208 if (records == 0) 209 $('#divListing_' + type + ' .tablesorter tfoot tr:not(.summary)').show(); 210 // else 211 // $('#divListing_' + type + ' .tablesorter').trigger('updateRows.tablesorter'); 212 } 213 214 var deleteConfirmationPrompt = {}; 215 216 function removeRecord(type, id) { 217 $('#' + type + id).remove(); 218 if (pagingNew[type]) 219 pagingRecordRemoved(type); 220 else 221 pagingRecordDeleted(type); 222 } 223 224 function deleteRecord(type, id, url, callback, skipPrompt) { 225 if (!type || !id) { 226 var row_id = $(this).parents('tr:eq(0)').attr('id'); 227 var matches = row_id.match(/^([^0-9]+)(\-?[0-9]+)$/); 228 if (matches && matches.length == 3) { 229 if (!type) 230 type = matches[1]; 231 if (!id) 232 id = matches[2]; 233 } 234 } 235 236 if (type && id && (skipPrompt || confirm((deleteConfirmationPrompt[type] ? deleteConfirmationPrompt[type] : "Are you sure you wish to delete this entry?\n\nThis change can not be undone.")))) { 237 $.ajax({ 238 type: 'GET', 239 url: (url ? url : base_app + type + '/delete'), 240 data: { ajax: 'true', id: id }, 241 success: function(data) { 242 data = data.toString(); 243 if (data) { 244 if((data + "").indexOf('<script') != -1) 245 {
246 $('#popupDynamic').append('<div id="divEdit_' + type + '"></div>'); 247 $('#divEdit_' + type).html(data); 248 } 249 250 if (callback) 251 callback(type, id, data); 252 else 253 removeRecord(type, id); 254 } 255 } 256 }); 257 } 258 259 try { 260 var e = e || window.event || arguments.callee.caller.arguments[0]; 261 if (e) 262 e.stopPropagation(); 263 } catch (e) {} 264 265 return false; 266 } 267 268 function editRecord(type, id) { 269 if (!type || !id) { 270 var id = $(this).parents('tr:eq(0)').attr('id'); 271 var matches = id.match(/^([^0-9]+)([0-9]+)$/); 272 if (matches && matches.length == 3) { 273 type = matches[1]; 274 id = matches[2]; 275 } 276 } 277 if (type && id) 278 toggleEdit(type, id); 279 } 280 281 function gotoEdit(type, id, close, url) { 282 try { 283 var e = e || window.event || arguments.callee.caller.arguments[0]; 284 if (e) { 285 e.stopPropagation(); 286 e.preventDefault(); 287 } 288 } catch (e) {} 289 290 if (close) 291 redirect((url ? url : base_app + type)); 292 else { 293 if (type == 'navigation' && $('#navigation' + id + ' > div > span > a.icon-small-lock').length) 294 if (!confirm('This page is locked for editing. If you proceed, we can try to unlock it (if the other user has abandoned the edit).\n\nDo you wish to proceed?')) 295 return; 296 url = (url ? url : base_app + type + '/edit'); 297 if(id) 298 url += (url.indexOf('?') == -1?'?':'&') + 'id=' + id; 299 300 if (e && e.shiftKey) 301 window.open(url, '_blank'); 302 else 303 redirect(url); 304 } 305 306 return false; 307 } 308 309 function isEmail(add) { 310 if (add && $.trim(add) && /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test($.trim(add))) 311 return true; 312 else 313 return false; 314 } 315 316 function updateTextAreaFromOEdit() { 317 try { 318 var i = 0; 319 while (i < 1 || typeof(window['oEdit' + i]) != 'undefined') { 320 try { 321 $('#' + window['oEdit' + i].idTextArea).val(window['oEdit' + i].getXHTMLBody()); 322 } catch (e) {} 323 i++; 324 } 325 } catch (e) {} 326 } 327 328 function makeAJAXEditForm(type, id) { 329 if ($('#frmEdit_' + type).length) { 330 var myForm = null; 331 332 $('#frmEdit_' + type).ajaxForm({ 333 type: 'POST', 334 beforeSerialize: function($form, options) { 335 try { 336 if (!$('#frmEdit_' + type).validate()) 337 return false; 338 } catch (e) { alert(e); } 339 340 // console.log('serializing', $($form).attr('class')); 341 if($($form).hasClass('submitting')) 342 return false; 343 344 $($form).addClass('submitting'); 345 updateTextAreaFromOEdit(); 346 347 $form.find('.note-editor.codeview .btn-codeview').trigger('click'); 348 }, 349 beforeSubmit: function(arr, $form, options) { 350 // console.log('submitting', $($form).attr('class')); 351 $($form).find('input[type=submit],button[type=submit]').addClass('loading_btn'); 352 if ($($form).attr('data-buttons')) 353 $($($form).attr('data-buttons')).addClass('loading_btn'); 354 myForm = $($form); 355 356 if (typeof(uploadProgress) != 'function') { 357 $('#frmEdit_' + type).hide(); 358 $('#divEdit_' + type).children().hide(); 359 $('#divEdit_' + type).append('<div class="loading" style="width: 680px;"></div>'); 360 } 361 }, 362 uploadProgress: (typeof(uploadProgress) == 'function' ? uploadProgress : null), 363 success: function(data, textStatus, jqXHR) { 364 // console.log(data); 365 // console.log(type, id); 366 $('#divEdit_' + type).html(data).hide(); 367 if (!data || data.toString().toUpperCase().indexOf('SUCCESS') == 0) { 368 closePopup(); 369 if (pagingNew[type]) 370 pagingRecordEdited(type, id); 371 else 372 pagingRecordAdded(type); 373 } else 374 $('#divEdit_' + type).show(); 375 if (myForm) { 376 $(myForm).find('input[type=submit],button[type=submit]').removeClass('loading_btn'); 377 if ($(myForm).attr('data-buttons')) 378 $($(myForm).attr('data-buttons')).removeClass('loading_btn'); 379 } 380 }, 381 error: function(e) { 382 $('#msgBox').html('<div class="fail">There was a problem updating this record.</div>').show(); 383 $('#divEdit_' + type).html(e.toString()).hide(); 384 closePopup(); 385 if (myForm) { 386 $(myForm).find('input[type=submit],button[type=submit]').removeClass('loading_btn'); 387 if ($(myForm).attr('data-buttons')) 388 $($(myForm).attr('data-buttons')).removeClass('loading_btn'); 389 } 390 } 391 }); 392 393 if (typeof(setUpRefreshAdminSessionIDInterval) != 'undefined') 394 setUpRefreshAdminSessionIDInterval(true); 395 } 396 } 397
398 /** 399 * Shows div as popup 400 * 401 * @param {string} id - id of the div, without hash 402 * @param {bool} close - whether to close existing popup 403 * @param {bool{ second - whether to open div as a second popup 404 * @param {*} reset - function to reset form, if not provided function resets by default 405 */ 406 function toggleInlineDiv(id, close, second, reset) { 407 try { 408 var e = e || window.event || arguments.callee.caller.arguments[0]; 409 if (e) 410 e.stopPropagation(); 411 } catch (e) {} 412 413 if (close) 414 closePopup(); 415 else { 416 $('#popupDynamic').append($('#' + id).addClass('inline').show()); 417 showScreen(second); 418 if (second) { 419 $('#popupDynamic > div:not(#' + id + ')').hide(); 420 $('#' + id).addClass('popup2'); 421 } 422 423 resizePopup(); 424 425 if (reset && typeof(reset) == 'function') 426 reset(); 427 else if (!reset) 428 $('#' + id).find('form').resetForm(); 429 // if(!reset) 430 // $('#' + id).find('form').resetForm(); 431 432 if ($('#' + id).find('input[type=text], input[type=password], textarea').length) 433 $('#' + id).find('input[type=text], input[type=password], textarea')[0].focus(); 434 } 435 return false; 436 } 437 438 function showScreen(second) { 439 if (second) 440 $('#popup').addClass('popup2'); 441 else 442 $('#popup').removeClass('popup2'); 443 444 if ($('body').hasClass('boot')) { 445 // $('#popup').unbind('hide.bs.modal'); //.bind('hide.bs.modal', closePopup); 446 return; 447 } 448 449 if (!$('#screen').length) { 450 if (base.indexOf('admin/') == -1) 451 $('body').append('<div id="screen"></div>'); 452 else 453 $('#pageWrap').append('<div id="screen"></div>'); 454 } 455 $('#screen').show(); 456 } 457 458 function closePopup() { 459 if ($('body').hasClass('boot')) { 460 if ($('#popup').hasClass('popup2')) { 461 $('#popup').removeClass('popup2'); 462 $('#popupDynamic .popup2').remove(); 463 if ($('#popupDynamic > div').length) { 464 $('#popupDynamic > div').show(); 465 resizePopup(); 466 } else 467 closePopup(); 468 } else { 469 $('#popup').unbind('hide.bs.modal'); 470 $('#popup').modal('hide'); 471 $('#popupDynamic > div.inline').removeClass('inline').hide().appendTo($('body')); 472 $('#popupDynamic').html(''); 473 474 if ($('tbody.batch_entry.active').length) 475 $('tbody.batch_entry.active :input:eq(0)').focus(); 476 477 if (typeof(toggleHelpVideos) != 'undefined') 478 toggleHelpVideos(null, null, true); 479 } 480 } else { 481 $('#popup').css('z-index', ''); 482 483 if ($('#popup').find(".PoSinlineDIV:visible").length > 0 && $('#popup').find(".PoSinlineDIV:visible").attr('callback')) { 484 var callback = $('#popup').find(".PoSinlineDIV:visible").attr('callback'); 485 eval(callback)(); 486 } 487 488 $('#popupDynamic .inline:visible').removeClass('inline').removeClass('popup2').hide().appendTo($('body')); 489 490 if ($('#popup').hasClass('popup2')) { 491 $('#popup').removeClass('popup2'); 492 $('#popupDynamic .popup2').remove(); 493 if ($('#popupDynamic > div').length) { 494 $('#popupDynamic > div:not(.inline)').show(); 495 resizePopup(); 496 } else 497 closePopup(); 498 } else { 499 $('#screen, #popup').hide(); 500 $('#popupDynamic').html(''); 501 502 if (typeof(toggleHelpVideos) != 'undefined') 503 toggleHelpVideos(null, null, true); 504 } 505 506 if (window.top.location.href.toString().indexOf('/admin/production/d
506ashboard/barcode') != -1) 507 window.location.reload(true); 508 } 509 510 return false; 511 } 512 513 function helpPopup(){ 514 if ($("#popup").find(".lw_help:visible").length && !$("#popup").find(".helpMOD").length) { 515 let h_value = '<a class="h-v-click helpMOD" href="javascript:void(0);"><span class="tooltip-h-v">Show all Help videos on screen</span><i class="fa fa-question fa-lg"></i></a>' 516 $(h_value).appendTo('.modal-body'); 517 $('.h-v-click').click(function(){ 518 $(this).toggleClass('active'); 519 $('a.jsDONE').trigger("click"); 520 }) 521 } 522 else if (!$("#popup").find(".lw_help:visible").length && $("#popup").find(".helpMOD").length){ 523 $("#popup").find(".helpMOD").remove(); 524 } 525 } 526 527 function resizePopup(e, update) { 528 if (update && !$('#popup').is(':visible')) 529 return; 530 531 if ($('body').hasClass('boot')) { 532 $('#popup').modal({ 533 backgrop: "static", 534 keyboard: false, 535 show: true, 536 focus: true 537 }).addClass('modal'); 538 // return; 539 540 if (parseInt($('#popup').width()) < (0.2 & parseInt($(window).width()))) 541 $('#popupDynamic > *:visible:eq(0)').css('width', Math.min($(window).width() * 0.4, Math.max(400, parseInt($(window).width() / 2)))); 542 543 if ($('#popupDynamic').outerHeight() >= $(window).height()) { 544 $('#popup .modal-dialog').css('margin-top', '1rem'); 545 546 if (!update) { 547 $('#popup').animate({ scrollTop: 0 }, 0); 548 setTimeout("$('#popup').animate({scrollTop: 0}, 0);", 250); 549 } 550 } else { 551 var modalDialog = $('#popup .modal-dialog'); 552 modalDialog[0].style.setProperty('margin-top', Math.max(0, ($(window).height() - modalDialog.height()) / 2) + 'px', 'important'); 553 } 554 555 $('#popup .modal-dialog').css('width', '80%'); 556 var ele = $('#popupDynamic > *:visible:eq(0)'); 557 var d = ele.css('display'); 558 ele.css('display', 'inline-flex'); 559 $('#popup .modal-dialog').css('width', ele.outerWidth() + $('#popup .modal-dialog').outerWidth() - $('#popupDynamic').outerWidth()); 560 ele.css('display', d); 561 562 $('#popup').unbind('hide.bs.modal').bind('hide.bs.modal', closePopup); 563 $('#popup').unbind('click'); 564 $('#popup .icon-close-popup').unbind('click').bind('click', closePopup); 565 helpPopup(); 566 } else { 567 $('#popup').show().css('width', parseInt($('#popupDynamic').width()) + 'px'); 568 569 $('#screen').css('height', $(document).outerHeight() + 'px'); 570 $('#popup').css({ 571 'left': ($(window).width() - ($('#popupDynamic').width() + 62)) / 2, 572 'top': ($(window).scrollTop() + 50) + 'px', 573 'position': "absolute" 574 }).fadeIn(); 575 576 if ($('#popup').outerHeight() < ($(window).height() - 100) && $('table[name^=idArea]:visible').length) 577 $('#popup').css({ 578 'top': '50px', 579 'position': 'fixed' 580 }); 581 else 582 $('html,body').animate({ scrollTop: parseInt(($('#popup').css('top') + "").replace('px', '')) - 50 }, 0); 583 } 584 } 585 586 function toggleEdit(type, id, close, url, second) { 587 try { 588 var e = e || window.event || arguments.callee.caller.arguments[0]; 589 if (e) 590 e.stopPropagation(); 591 } catch (e) {} 592 593 if (close) 594 closePopup(); 595 else { 596 for(e in editorsLoaded) 597 { 598 if(editorsLoaded[e] > 0 && typeof(window['oEdit' + editorsLoaded[e]]) == 'undefined') 599 delete editorsLoaded[e]; 600 } 601 602 if (!$('#popupDynamic').length && base.indexOf('admin/') == -1) 603 $('body').append('<div id="popup" class="popupBox"><div class="popupBoxInner"><a class="x-button" onclick="javascript: closePopup();"></a><div id="popupDynamic"></div></div></div>'); 604 605 $('#popupDynamic > div.inline').removeClass('inline').hide().appendTo($('body')); 606 if (second) { 607 $('#popupDynamic > div:not(:visible):not(#divEdit_' + type + '):not(.inline)').remove(); 608 $('#popup').addClass('popup2'); 609 } else 610 $('#popupDynamic > div:not(#divEdit_' + type + '):not(.inline)').remove(); 611 612 $('#popupDynamic > div:visible:not(#divEdit_' + type + ')').hide(); 613 614 if (!$('#divEdit_' + type).length)
615 $('#popupDynamic').append('<div id="divEdit_' + type + '"></div>'); 616 else 617 $('#divEdit_' + type).html('').show(); 618 619 if (second) 620 $('#divEdit_' + type).addClass('popup2'); 621 622 if (!url) 623 url = base_app + type + '/edit'; 624 625 showScreen(second); 626 627 $('#divEdit_' + type).html('<div class="loading_big"></div>').load(url, { 628 ajax: true, 629 id: parseInt(id) 630 }, function() { 631 if ($('#divEdit_' + type).text() == "") { 632 closePopup(); 633 return; 634 } 635 636 resizePopup(); 637 638 if (!$('#frmEdit_' + type).length) 639 $('#divEdit_' + type + ' form:eq(0)').attr('id', 'frmEdit_' + type); 640 641 $('#divEdit_' + type + ' .row:last').removeClass('mb-3'); 642 643 _setupAJAXEditForm(type, id); 644 645 setTimeout(function() { 646 if(!$('#frmEdit_' + type).hasClass('no-focus') && $('#frmEdit_' + type).find('input[type=text]:not(.hasDatepicker), input[type=password], textarea').length) 647 $('#frmEdit_' + type).find('input[type=text]:not(.hasDatepicker), input[type=password], textarea')[0].focus(); 648 }, 250); 649 }); 650 } 651 652 return false; 653 } 654 655 function _setupAJAXEditForm(type, id) { 656 if (!$('#frmEdit_' + type).data('ajax.setup')) { 657 $('#frmEdit_' + type).validate(); 658 makeAJAXEditForm(type, id); 659 initAJAXpage('#divEdit_' + type); 660 } 661 } 662 663 (function($) { 664 $.fn.enterKey = function(fnc) { 665 return this.each(function() { 666 $(this).keypress(function(ev) { 667 var keycode = (ev.keyCode ? ev.keyCode : ev.which); 668 if (keycode == '13') 669 fnc.call(this, ev); 670 }); 671 }); 672 }; 673 674 $.fn.fileName = function() { 675 var $this = $(this), 676 $val = $this.val(), 677 valArray = $val.split('\\'), 678 newVal = valArray[valArray.length - 1], 679 $button = $this.siblings('.button'); 680 if (newVal !== '') { 681 $button.text(newVal); 682 } 683 }; 684 685 jQuery.browser = {}; 686 (function() { 687 jQuery.browser = jQuery.browser | {}; 688 jQuery.browser.msie = false; 689 jQuery.browser.version = 0; 690 if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) { 691 jQuery.browser.msie = true; 692 jQuery.browser.version = RegExp.$1; 693 } 694 })(); 695 696 $.zIndex = $.fn.zIndex = function(opt) { 697 var def = { inc: 10, group: "*" }; 698 $.extend(def, opt); 699 var zmax = 0; 700 $(def.group).each(function() { 701 var cur = parseInt($(this).css('z-index')); 702 zmax = cur > zmax ? cur : zmax; 703 }); 704 if (!this.jquery) 705 return zmax; 706 707 return this.each(function() { 708 zmax += def.inc; 709 $(this).css("z-index", zmax); 710 }); 711 }; 712 713 jQuery.fn.extend({ 714 propAttr: $.fn.prop || $.fn.attr 715 }); 716 717 if (typeof(jQuery.fn.andSelf) != 'function') 718 jQuery.fn.andSelf = function() { 719 try { 720 return this.addBack.apply(this, arguments); 721 } catch (e) { 722 return null; 723 } 724 }; 725 })(jQuery); 726 727 var myClipboard = null; 728 729 function makeClipboardLinksClickable(container) { 730 if (!container) 731 container = 'body'; 732 733 if ($(container).find('.copyToClipboard:not(.cpDONE)').length) { 734 if (myClipboard) 735 myClipboard.destroy(); 736 myClipboard = new Clipboard('.copyToClipboard'); 737 myClipboard.on('error', function(e) { 738 alert("Your browser does not support our copy to clipboard function. The text you were trying to copy was: " + e.trigger.getAttribute('data-clipboard-text')); 739 }); 740 $('.copyToClipboard:not(.cpDONE)').addClass('cpDONE').on('click', function() { 741 let dataToCopy = $(this).attr('data-clipboard-text'); // Get the data 742 navigator.clipboard.writeText(dataToCopy); 743 if (debug) console.log("Text to copy: " + dataToCopy); 744 }); 745 } 746 } 747 748 function truncate(str, n, useWordBoundary) { 749 var toLong = str.length > n, 750 s_ = toLong ? str.substr(0, n - 1) : str; 751 s_ = useWordBoundary && toLong ? s_.substr(0, s_.lastIndexOf(' ')) : s_; 752 return toLong ? s_ + '…' : s_; 753 }; 754 755 function setInputTime(id, value) { 756 var tmp = value.split(':'); 757 if (tmp.length == 2 || tmp.length == 3) { 758 tmp[0] = parseInt(tmp[0]); 759 tmp[1] = parseInt(tmp[1]); 760 if (tmp[0] >= 12) { 761 $('#ampm_' + id + '12').prop('checked', true); 762 if (tmp[0] != 12) 763 tmp[0] -= 12; 764 } else { 765 $('#ampm_' + id + '0').prop('checked', true); 766 if (tmp[0] == 0) 767 tmp[0] = 12; 768 } 769 tmp = (tmp[0] >= 10 ? tmp[0] : "0" + tmp[0]) + ":" + (tmp[1] >= 10 ? tmp[1] : "0" + tmp[1]); 770 $('#' + id).val(tmp).timepicker('setTime', tmp); 771 } 772 } 773 774 function number_format(number, decimals, dec_point, thousands_sep) { 775 number = (number + '').replace(/,/, '').replace(/\s/, ''); 776 var n = !isFinite(+number) ? 0 : +number, 777 prec = !isFinite(+decimals) ? 0 : Math.abs(decimals), 778 sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep, 779 dec = (typeof dec_point === 'undefined') ? '.' : dec_point, 780 s = '', 781 toFixedFix = function(n, prec) { 782 var k = Math.pow(10, prec); 783 return '' + Math.round(n * k) / k; 784 }; 785 s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.'); 786 if (s[0].length > 3) { 787 s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep); 788 } 789 if ((s[1] || '').length < prec) { 790 s[1] = s[1] || ''; 791 s[1] += new Array(prec - s[1].length + 1).join('0'); 792 } 793 return s.join(dec); 794 } 795 796 function updateStatus(type, id, url, callback) { 797 if (!type || !id) { 798 var row_id = $(this).parents('tr:eq(0)').attr('id'); 799 var matches = row_id.match(/^([^0-9]+)(\-?[0-9]+)$/); 800 if (matches && matches.length == 3) { 801 if (!type) 802 type = matches[1]; 803 if (!id) 804 id = matches[2]; 805 } 806 } 807 808 if (type && id && confirm((deleteConfirmationPrompt[type] ? deleteConfirmationPrompt[type] : "Are you sure you wish to change this entry?\n\nThis change can not be undone."))) { 809 $.ajax({ 810 type: 'GET', 811 url: (url ? url : base_app + type + '/updateStatus'), 812 data: { ajax: 'true', id: id }, 813 success: function(data) { 814 data = data.toString(); 815 if (data) { 816 if (callback) 817 callback(type, id, data); 818 else 819 pagingRecordEdited(type, id); 820 } 821 } 822 }); 823 } 824 825 try { 826 var e = e || window.event || arguments.callee.caller.arguments[0]; 827 if (e) 828 e.stopPropagation(); 829 } catch (e) {} 830 831 return false;
832 } 833 834 function nl2br(str, is_xhtml) { 835 if (typeof str === 'undefined' || str === null) { 836 return ''; 837 } 838 839 if (is_xhtml !== false) 840 is_xhtml = true; 841 842 var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>'; 843 return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2'); 844 } 845 846 847 Date.createFromMysql = function(mysql_string) { 848 if (typeof mysql_string === 'string') { 849 var t = mysql_string.split(/[- :]/); 850 var t1 = mysql_string.match(/[0-9]{2}\:([0-9]{2})(\:[0-9]{2})?\s*(am|pm)?/i); 851 if (t1) { 852 // '30pm'; 853 if (t1.length >= 2) 854 t[4] = t1[1]; 855 if (t1.length >= 4) { 856 if ((t1[3] + '').toLowerCase() == 'pm' && parseInt(t[3]) < 12) 857 t[3] = parseInt(t[3]) + 12; 858 } 859 } 860 861 //when t[3], t[4] and t[5] are missing they defaults to zero 862 return new Date(t[0], t[1] - 1, t[2], (t[3] > 0 ? t[3] : 0), (t[4] > 0 ? t[4] : 0), (t[5] > 0 ? t[5] : 0)); 863 } 864 865 return null; 866 }; 867 868 function showNotification(type, msg) { 869 if (typeof(msg) == 'string') 870 msg = $('<h4>' + msg + '</h4>'); 871 else 872 msg = $(msg).clone().removeClass('hide').show(); 873 874 $('#topNotification').remove(); 875 if ($('section.actual-page').length) 876 $('section.actual-page').append('<div id="topNotification" class="box-module"></div>'); 877 else 878 $('body').append('<div id="topNotification" class="box-module"></div>'); 879 $('#topNotification').append(msg); 880 881 if (type == 'fail' || type == 'error') 882 $('#topNotification').addClass('bg-ll-bg-warning').find('> *:first-child').addClass('text-ll-danger'); 883 else 884 $('#topNotification').addClass('bg-ll-light-blue').find('> *:first-child').addClass('text-ll-white'); 885 886 $('#topNotification').show().attr('title', 'click to close').bind('click', function() { 887 $(this).fadeOut(1500, function() { 888 $(this).remove(); 889 }); 890 }); 891 } 892 893 function disableBrowserAutoComplete(container) { 894 if ((window.location.href + "").indexOf("/admin/") != -1) { 895 $(container).find('form').attr('autocomplete', 'off'); 896 $(container).find('form').find('input[type=text],input[type=password]').attr('autocomplete', 'off'); // 'new-password' 897 } else { 898 $(container).find('form:not(.jsACdone)').each(function() { 899 $(this).attr('autocomplete', 'off').addClass('jsACdone'); 900 var id = $(this).attr('id'); 901 if (!id) 902 id = $(this).attr('name'); 903 if (!id) { 904 id = parseInt($('body').data('form_ac')); 905 if (!id || isNaN(id)) 906 id = 1; 907 $('body').data('form_ac', id++); 908 id = 'form' + id; 909 } 910 $(this).prepend('\n<input type="text" name="x" id="' + id + '_x" style="display:none !important;" />' + 911 '\n<input type="password" name="y" id="' + id + '_y" style="display:none" />\n'); 912 913 // $(this).find('input[type=text]').attr('autocomplete', 'new-password'); 914 $(this).find('input[type=text]').attr('autocomplete', 'off'); 915 $(this).find('input[type=password]').attr('autocomplete', 'new-password'); 916 }); 917 } 918 } 919 920 function shortTimePeriod(s, e) { 921 if (typeof(s) == 'string' && (s + "").length <= 8) 922 s = moment('2000-01-01 ' + s); 923 else 924 s = moment(s); 925 if (typeof(e) == 'string' && (e + "").length <= 8) 926 e = moment('2000-01-01 ' + e); 927 else 928 e = moment(e); 929 930 if(e.format('h:mma') == s.format('h:mma')) 931 return s.format('h:mma'); 932 else 933 return s.format('h:mma').replace(':00', '').replace((s.format('a') == e.format('a') ? e.format('a') : ''), '') + ' - ' + e.format('h:mma').replace(':00', ''); 934 } 935 936 function escapeHtml(text) { 937 var map = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }; 938 return text.replace(/[&<>"']/g, function(m) { return map[m]; }); 939 } 940 941 function spliceIntoChunks(arr, chunkSize) { 942 const res = []; 943 while (arr.length > 0) { 944 const chunk = arr.splice(0, chunkSize); 945 res.push(chunk); 946 } 947 return res; 948 } 949 950 if(typeof (window['makeTwoNumbers']) != 'function') 951 { 952 function makeTwoNumbers(num) { 953 return ((num < 10) ? "0" : "") + num; 954 } 955 } 956 957 if(typeof (window['toTimeFormat']) != 'function') 958 { 959 function toTimeFormat(secs) { 960 let hours = Math.floor(secs / 3600); 961 let minutes = Math.floor(secs / 60) - (hours * 60); 962 let seconds = Math.trunc(secs % 60); 963 964 let val = [hours, minutes, seconds].map(makeTwoNumbers).join(":"); 965 return val; 966 } 967 } 968 969 if(typeof (window['toSecondsFormat']) != 'function') 970 { 971 function toSecondsFormat(time) { 972 const [hours, minutes, seconds] = ("" + time).split(":").map(Number); 973 return hours * 3600 + minutes * 60 + seconds; 974 } 975 } 976 977 var intlPhoneNumberSetup = 0; 978 var intlPhoneCountries = null; 979 function makeIntlPhoneInput(self) { 980 if(intlPhoneNumberSetup < 2) 981 { 982 if(typeof(window.intlTelInput) == 'undefined') 983 { 984 if(typeof(window['makeIntlPhoneInputPending']) == 'undefined') 985 window['makeIntlPhoneInputPending'] = []; 986 window['makeIntlPhoneInputPending'].push(self); 987 988 if(intlPhoneNumberSetup == 1) 989 return; 990 991 if(intlPhoneNumberSetup == 0) 992 intlPhoneNumberSetup = 1; 993 994 $('head').append('<link rel="stylesheet" type="text/css" href="/core/3rdparty/composer/vendor/jackocnr/intl-tel-input/build/css/intlTelInput.min.css" />'); 995 996 $.getScript('/core/3rdparty/composer/vendor/jackocnr/intl-tel-input/build/js/intlTelInput.min.js', function() { 997 intlPhoneNumberSetup = 2; 998 makeIntlPhoneInput(null); 999 }); 1000 1001 return; 1002 } 1003 1004 $('<style type="text/css">\ 1005 :root {\
1006 --iti-path-flags-1x: url("' + base_core + '3rdparty/composer/vendor/jackocnr/intl-tel-input/build/img/flags.png?1");\ 1007 --iti-path-flags-2x: url("' + base_core + '3rdparty/composer/vendor/jackocnr/intl-tel-input/build/img/[email protected]?1");\ 1008 --iti-path-globe-1x: url("' + base_core + '3rdparty/composer/vendor/jackocnr/intl-tel-input/build/img/globe.png");\ 1009 --iti-path-globe-2x: url("' + base_core + '3rdparty/composer/vendor/jackocnr/intl-tel-input/build/img/[email protected]");\ 1010 }\ 1011 </style>').appendTo('head'); 1012 1013 $(window).on('load', function() { 1014 $('.iti__tel-input').unbind('focus.first_phone').bind('focus.first_phone', function() { 1015 $(this).unbind('focus.first_phone'); 1016 $(this).trigger('blur').trigger('focus.first_phone').trigger('change'); 1017 }); 1018 // $('.iti__tel-input').trigger('focus').trigger('blur').trigger('focus').trigger('change'); 1019 }); 1020 1021 intlPhoneNumberSetup = 2; 1022 } 1023 1024 if(!self) 1025 { 1026 if(typeof(window['makeIntlPhoneInputPending']) != 'undefined') 1027 { 1028 for(let i in window['makeIntlPhoneInputPending']) 1029 makeIntlPhoneInput(window['makeIntlPhoneInputPending'][i]); 1030 delete window['makeIntlPhoneInputPending']; 1031 } 1032 1033 return; 1034 } 1035 1036 self = $(self); 1037 1038 if(self.hasClass('intl_phone_disable')) 1039 return; 1040 1041 if(self.is('form > input[type=email]+input[type=tel]')) 1042 return; 1043 1044 if(self.hasClass('iti__tel-input')) 1045 { 1046 if(self.data('intl_phone')) 1047 return; 1048 if(self.parents('.iti:eq(0)').length) 1049 self.parents('.iti:eq(0)').replaceWith($('<div></div>').append(self.removeClass('iti__tel-input').attr('data-intl-tel-input-id', null))); 1050 else 1051 window.intlTelInput(self).destroy(); 1052 1053 // return; 1054 } 1055 if(self.is('input[tpe=hidden]')) 1056 return; 1057 1058 self.siblings('input[type=hidden][name*=full_]').remove(); 1059 self.siblings('input[type=hidden][name*=country_code_]').remove(); 1060 self.prop('data-original', (self.val() + "").replace(/[^\+0-9]+/g, '')); 1061 1062 self.removeClass('phoneUS phoneNL phoneUK phonesUK mobileUK'); 1063 1064 self.attr('maxlength', 24); 1065 _emptyPhonePlaceholder(self); 1066 if(typeof($.fn.unmask) != 'undefined' && self.data('mask')) 1067 self.unmask(); 1068 1069 // https://github.com/jackocnr/intl-tel-input/blob/master/README.md#public-methods 1070 try { 1071 self.data('intl_phone', window.intlTelInput(self.get(0), { 1072 preferredCountries: ["ca", "us"], 1073 formatOnDisplay: true, 1074 autoPlaceholder: 'polite', 1075 separateDialCode: false, 1076 allowDropdown: false, 1077 // initialCountry: 'auto', 1078 formatAsYouType: false, 1079 formatOnDisplay: false, 1080 nationalMode: false,
1081 strictMode: true, 1082 customPlaceholder: function(selectedCountryPlaceholder, selectedCountryData) { 1083 let masked_phone = selectedCountryPlaceholder.replace(/([^\+\d])\d{2,}/g, match => match[0] + "0".repeat(match.length - 1)); 1084 return "e.g. " + masked_phone; 1085 }, 1086 // hiddenInput: () => ({ phone: 'full_' + self.attr('name'), country: 'country_code_' + self.attr('name') }), 1087 utilsScript: base_core + '3rdparty/composer/vendor/jackocnr/intl-tel-input/build/js/utils.js', 1088 geoIpLookup: function(success, failure) { 1089 var countryCode = $.cookie('countryCode'); 1090 if(debug) console.log('phone country', countryCode, this); 1091 if(countryCode) 1092 return success(countryCode); 1093 1094 $.get('https://ipinfo.io', function() {}, "jsonp").always(function(resp) { 1095 var countryCode = (resp && resp.country) ? resp.country : ""; 1096 if(debug) console.log('phone country', countryCode); 1097 if(countryCode) 1098 { 1099 $.cookie('countryCode', countryCode, { path: '/', domain: window.location.host, secure: (window.location.protocol == 'https:') }); 1100 try { 1101 success(countryCode); 1102 } catch(e) { 1103 console.log('geoip phone set country', e); 1104 } 1105 } 1106 else 1107 failure(); 1108 }); 1109 } 1110 })); 1111 } catch(e) { 1112 console.log('intl phone initialization error', e); 1113 } 1114 1115 try { 1116 self.each(function() { 1117 let h = Math.max(20, parseInt($(this).outerHeight()), parseInt($('input[type=text],select').filter(':visible:eq(0)').outerHeight())) + 'px'; 1118 $(this).prev('.iti__country-container').css({ 1119 bottom: h, 1120 height: h 1121 }); 1122 }); 1123 1124 /* 1125 self.data('intl_phone').promise.then(() => { 1126 if(debug) console.log("Initialized", self); 1127 if(typeof(window['initPhoneInitialized']) == 'undefined') 1128 window['initPhoneInitialized'] = []; 1129 window['initPhoneInitialized'].push(self.attr('id')); 1130 }); 1131 */ 1132 1133 self.bind('blur', function() { 1134 let val = $(this).val(); 1135 if(val && val.match(/^[^0-9]*00\s*/)) 1136 $(this).val(val = val.replace(/^[^0-9]*00\s*/, '+')).trigger('change'); 1137 1138 try { 1139 if(val && val.length >= 9 && (self.prop('data-original') + "").indexOf('+') == -1) 1140 { 1141 // let country = ($('#country').val() + "").toLowerCase(); 1142 let country = ($(this).closest('form').find(':input[name*=country]').eq(0).val() + "").toLowerCase(); 1143 let country_other = ($(this).closest('form').find(':input[name*=country_other]').eq(0).val() + "").toLowerCase(); 1144 1145 if(country == 'other' && country_other) country = country_other; 1146 1147 if(debug) console.log('country for phone', country); 1148 if(!intlPhoneCountries) 1149 { 1150 try { 1151 intlPhoneCountries = window.intlTelInputGlobals.getCountryData(); 1152 for(let i in intlPhoneCountries) 1153 intlPhoneCountries[i].name1 = (intlPhoneCountries[i].name + "").replace(/[^a-z]/ig, '').toLowerCase(); 1154 } catch(e) { 1155 console.log('phone country data error', e); 1156 } 1157 } 1158 1159 let country2 = null; 1160 if(intlPhoneCountries) 1161 { 1162 let country1 = (country + "").replace(/[^a-z]/ig, '').toLowerCase(); 1163 for(let i in intlPhoneCountries) 1164 { 1165 if(country1 == intlPhoneCountries[i].name1 || country1 == intlPhoneCountries[i].iso2) 1166 { 1167 country2 = country = intlPhoneCountries[i].iso2; 1168 if(debug) console.log('phone country', country); 1169 } 1170 } 1171 } 1172 1173 if(!country2) country2 = 'us'; 1174 $(this).data('intl_phone').setCountry(country2); 1175 if(debug) console.log('phone country set to', country2); 1176 let c = $(this).data('intl_phone').getSelectedCountryData(); 1177 let v = $(this).data('intl_phone').getNumber(2); 1178 if(debug) console.log('phone country data', c, 'phone formatted number', v); 1179 if(v && v.length >= val.length) val = v; 1180 else val = val.replace(/^\s*\+[0-9]+\s*/, ''); 1181 1182 if(c && c.dialCode && !val.match(/^\s*\+/)) $(this).val('+' + c.dialCode + ' ' + val).trigger('change'); 1183 } 1184 } catch(e) { 1185 console.log('phone format error', e); 1186 } 1187 1188 if(/^\+[0-9]{1,3}\s*$/.test($(this).val() + "")) 1189 $(this).val(''); 1190 }); 1191 1192 if((window.top.location.href + "").indexOf('/admin/') == -1) 1193 { 1194 $(document).ready(function() { 1195 setTimeout(function() { 1196 self.prop('maxlength', 24); 1197 _emptyPhonePlaceholder(self); 1198 if(typeof($.fn.unmask) != 'undefined' && self.data('mask')) 1199 self.unmask(); 1200 }, 500); 1201 }); 1202 1203 $(window).on('load', function() { 1204 let self = $('.intl_phone'); 1205 self.prop('maxlength', 24); 1206 _emptyPhonePlaceholder(self); 1207 if(typeof($.fn.unmask) != 'undefined' && self.data('mask')) 1208 self.unmask(); 1209 }); 1210 } 1211 1212 /* 1213 self.bind('countrychange change', function() { 1214 let intl = self.data('intl_phone'); 1215 if(self.val() && intl && intl.getNumber()) 1216 { 1217 self.siblings('input[type=hidden][name*=full_]').val((intl.getNumber() + "").replace(/[^\+0-9]/g, '')); 1218 self.prop('data-original', ''); 1219 if(debug) console.log('phone change', intl.getNumber()); 1220 } 1221 else 1222 { 1223 let v = self.val(), v1 = self.prop('data-original'); 1224 if(v && (!v1 || (v + "").length >= (v1 + "").length)) 1225 self.siblings('input[type=hidden][name*=full_]').val(v); 1226 else 1227 self.siblings('input[type=hidden][name*=full_]').val(v1); 1228 if(debug) console.log('phone change val & object', self.val(), intl); 1229 } 1230 if(debug) console.log('final phone', self.siblings('input[type=hidden][name*=full_]').val()); 1231 }).trigger('change'); 1232 */ 1233 } catch(e) { 1234 console.log('intl phone post initialization error', e); 1235 } 1236 } 1237 1238 function _emptyPhonePlaceholder(self) { 1239 let id = self.attr('id'); 1240 if(id && $('label[for="' + id + '"]').length && $('label[for="' + id + '"]').text()) 1241 self.prop('placeholder', ''); 1242 } 1243 function replaceDateTypeIn(ele) { 1244 if(!ele) 1245 ele = $('.hasDatepicker'); 1246 else 1247 ele = ele.filter('.hasDatepicker'); 1248 ele.datepicker('destroy'); 1249 ele.attr('placeholder', 'type in the date').prop('readonly', false).each(function() { 1250 let name = $(this).attr('name'); 1251 let id = $(this).attr('id'); 1252 $(this).attr('data-toggle', 'tooltip').attr('title', 'You can type in the date. Please avoid using st, nd, rd or th after the date').tooltip(); 1253 $(this).after('<input type="hidden" name="' + name + '" id="' + id + '" value="' + $(this).val() + '" data-original="' + $(this).val() + '" /><div class="text-warning"></div>'); 1254 $(this).removeAttr('name').attr('name', name + '_old'); 1255 $(this).removeAttr('id').attr('id', id + '_old'); 1256 $(this).bind('input blur', function(e) { 1257 try { 1258 if(!$(this).val()) 1259 throw new Error("Empty Date"); 1260 if(debug) console.log('parsing date', $(this).val()); 1261 let m = moment($(this).val()); 1262 if(m && !isNaN(m.date())) 1263 { 1264 $(this).next('input[type=hidden]').val(m.format('YYYY-MM-DD')).next('div').text(m.format('MMMM D, YYYY')); 1265 $(this).removeClass('error'); 1266 } 1267 else 1268 throw new Error("Invalid Date"); 1269 } catch(er) { 1270 if(e.type == 'blur') 1271 { 1272 if($(this).val() == "") 1273 $(this).removeClass('error'); 1274 else 1275 $(this).addClass('error'); 1276 } 1277 if(debug) console.log('date parse error', e, er); 1278 $(this).next('input[type=hidden]').val($(this).next('input[type=hidden]').attr('data-original')).next('div').text(''); 1279 } 1280 }); 1281 }); 1282 }
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.