1(function ($) { 2 "use strict"; 3 4 var clientID = 0; 5 var destination; 6 var dialogType; 7 var $infoDialog; 8 var ajaxurl = oaInfo.ajax_url; 9 var initialLoad = true; 10 var loginType; 11 var sumbitListner = false; 12 13 /*! 14 * jquery fontsize æä»¶ 15 * author: xiaolong 16 * 20170530 17 */ 18 19 $.fn.submitCaptcha = function (param) { 20 // DEFAULT VARIABLES 21 var params = $.extend( 22 { 23 idCaptchaText: "fhws-subscribe-captchaText", // The ID for the captcha text. Default is 'captchaText'. 24 idCaptchaInput: "fhws-subscribe-captchaInput", // The ID for the captcha input. Default is 'captchaInput'. 25 class: "", // Class name for the submit button toggle. Default is ''. 26 }, 27 param, 28 ); 29 30 // Find and disable the submit button 31 var submit = $("#fhws-subscribe-widget-submit"); 32 submit.attr("disabled", "disabled"); 33 var showCaptcha = $("#fhws-subscribe-captcha"); 34 35 showCaptcha.html(""); 36 // Insert captcha text and input before the submit button with the given ID's 37 showCaptcha.html( 38 '<label class="me-2" id="' + 39 params.idCaptchaText + 40 '"></label>' + 41 '<input id="' + 42 params.idCaptchaInput + 43 '" aria-label="Captcha Input" type="text" class="form-control" style="width:50px;display:inline-block"; required>', 44 ); 45 46 // Select text and input elements to fill 47 var label = this.find("#" + params.idCaptchaText); 48 var input = this.find("#" + params.idCaptchaInput); 49 50 // Generate random numbers and the sum of them 51 var rndmNr1 = Math.floor(Math.random() * 10), 52 rndmNr2 = Math.floor(Math.random() * 10), 53 totalNr = rndmNr1 + rndmNr2; 54 55 // Print the numbers to screen 56 $(label).text(rndmNr1 + " + " + rndmNr2 + " ="); 57 58 // Check the input value, enable it if the sum is correct 59 $(input).keyup(function () { 60 if ($(this).val() == totalNr) 61 submit.removeAttr("disabled").addClass(params.class); 62 else submit.attr("disabled", "disabled").removeClass(params.class); 63 }); 64 65 // Don't breake jQuery chain! 66 return this; 67 }; 68 69 $.fn.fhwsCaptcha = function (param) { 70 // DEFAULT VARIABLES 71 var params = $.extend( 72 { 73 idCaptchaText: "fhws-captchaText", // The ID for the captcha text. Default is 'captchaText'. 74 idCaptchaInput: "fhws-captchaInput", // The ID for the captcha input. Default is 'captchaInput'. 75 class: "", // Class name for the submit button toggle. Default is ''. 76 }, 77 param, 78 ); 79 80 // Find and disable the submit button 81 var submit = $("#fhws-share-subscribe-submit"); 82 submit.attr("disabled", "disabled"); 83 var showCaptcha = $("#fhws-captcha"); 84 85 showCaptcha.html(""); 86 // Insert captcha text and input before the submit button with the given ID's 87 showCaptcha.html( 88 '<p class="">Please answer the following:</p>' + 89 '<label class="me-2" id="' + 90 params.idCaptchaText + 91 '"></label>' + 92 '<input id="' + 93 params.idCaptchaInput + 94 '" aria-label="Captcha Input" type="text" class="form-control" style="width:50px;display:inline-block"; required>', 95 ); 96 97 // Select text and input elements to fill 98 var label = this.find("#" + params.idCaptchaText); 99 var input = this.find("#" + params.idCaptchaInput); 100 101 // Generate random numbers and the sum of them 102 var rndmNr1 = Math.floor(Math.random() * 10), 103 rndmNr2 = Math.floor(Math.random() * 10), 104 totalNr = rndmNr1 + rndmNr2; 105 106 // Print the numbers to screen 107 $(label).text(rndmNr1 + " + " + rndmNr2 + " ="); 108 109 // Check the input value, enable it if the sum is correct 110 $(input).keyup(function () { 111 if ($(this).val() == totalNr) 112 submit.removeAttr("disabled").addClass(params.class); 113 else submit.attr("disabled", "disabled").removeClass(params.class); 114 }); 115 116 // Don't breake jQuery chain! 117 return this; 118 }; 119 120 $(document).ready(function () { 121 $("#fhws-subscribe-widget").submitCaptcha(); 122 123 //move modal to body 124 $(".bootstrap-fhws-obituaries-container-1").appendTo("body"); 125 //to close modals 126 $(".fhws-modal").on("click", function (event) { 127 $(event.target).modal("hide"); 128 });
129 130 //text size control 131 var originalSize = parseInt( 132 $(".bootstrap-fhws-obituaries-container").css("font-size"), 133 ); 134 var $sizeCtrl = $(".f1fd-size-ctl"); 135 $sizeCtrl.on("click", function (e) { 136 $sizeCtrl.removeClass("active"); 137 $(this).addClass("active"); 138 window.localStorage.setItem( 139 "fhwstextsize", 140 $(this).index(".f1fd-size-ctl"), 141 ); 142 switch ($(this).attr("id")) { 143 case "f1fd-text-size-base": 144 var f1FdSize = originalSize + "px"; 145 break; 146 case "f1fd-text-size-zoom1": 147 var f1FdSize = originalSize + 3 + "px"; 148 break; 149 case "f1fd-text-size-zoom2": 150 var f1FdSize = originalSize + 6 + "px"; 151 break; 152 } 153 $(".bootstrap-fhws-obituaries-container").css("font-size", f1FdSize); 154 }); 155 156 /*$('#fhws-fullscreen-button').on('click', function(){ 157 var $_icon = $('#fhws-fullscreen-button-icon'); 158 var fullscreen = '<svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1"><path d="M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"></path></svg>'; 159 var exitFullscreen = '<svg viewBox="0 0 24 24" width="24" height="24" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round" class="css-i6dzq1"><path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"></path></svg>'; 160 if ( 161 document.fullscreenElement || 162 document.webkitFullscreenElement || 163 document.mozFullScreenElement || 164 document.msFullscreenElement 165 ) { 166 if (document.exitFullscreen) { 167 document.exitFullscreen(); 168 } else if (document.mozCancelFullScreen) { 169 document.mozCancelFullScreen(); 170 } else if (document.webkitExitFullscreen) { 171 document.webkitExitFullscreen(); 172 } else if (document.msExitFullscreen) { 173 document.msExitFullscreen(); 174 } 175 $_icon.html(fullscreen); 176 } else { 177 var element = document.getElementById("fhws-main-obit"); 178 if (element.requestFullscreen) { 179 element.requestFullscreen(); 180 } else if (element.mozRequestFullScreen) { 181 element.mozRequestFullScreen(); 182 } else if (element.webkitRequestFullscreen) { 183 element.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); 184 } else if (element.msRequestFullscreen) { 185 element.msRequestFullscreen(); 186 } 187 $_icon.html(exitFullscreen); 188 189 } 190 191 }); */ 192 193 var localStorageTextSize = JSON.parse( 194 window.localStorage.getItem("fhwstextsize"), 195 ); 196 if (localStorageTextSize != null) { 197 $(".f1fd-size-ctl").eq(localStorage.getItem("fhwstextsize")).click(); 198 } 199 200 $(".fhws-modal-dialog").draggable(); 201 202 $("#fhws-share-subscribe-form").fhwsCaptcha(); 203 204 // tab event 205 $(".nav-link").on("shown.bs.tab", function (event) { 206 var win = $(window).width(); //this = window 207 if (win <= 767) { 208 $([document.documentElement, document.body]).animate( 209 { 210 scrollTop: $("#pills-tabContent").offset().top, 211 }, 212 2000, 213 ); 214 } 215 216 $(".share").find("button").removeClass("active"); 217 event.target; // newly activated tab 218 event.relatedTarget; // previous active tab 219 if (event.target.id == "pills-condolence") { 220 $("#share_memory").addClass("active"); 221 } 222 if (event.target.id == "pills-flowers") { 223 $("#florist-one-flower-delivery-menu-link-1").trigger("click"); 224 $("#send_flowers").addClass("active"); 225 } 226 if (event.target.id == "pills-tree") { 227 $("#florist-one-flower-delivery-menu-link-0").trigger("click"); 228 $("#plant_a_tree").addClass("active"); 229 } 230 });
231 232 // check if share and subscribe modal is present on page 233 if (document.getElementById("fhws-share-subscribe-modal")) { 234 var fhwsModal = document.getElementById("fhws-share-subscribe-modal"); 235 // share and subscribe modal 236 fhwsModal.addEventListener("show.bs.modal", function (event) { 237 $("#fhws-share-subscribe-form").fhwsCaptcha(); 238 239 var id = event.relatedTarget.id; 240 var buttonAction = 241 event.relatedTarget.getAttribute("data-modal-action"); 242 var form = document.getElementById("fhws-share-subscribe-form"); 243 var modalId = document.getElementById("fhws-share-subscribe-modal"); 244 var changeTitle = modalId.getElementsByClassName("modal-title")[0]; 245 var changeInfo = modalId.getElementsByClassName("modal-info")[0]; 246 var changeText = modalId.getElementsByClassName("form-label")[0]; 247 var changeButton1 = 248 modalId.getElementsByClassName("button-one-text")[0]; 249 var changeButton2 = 250 modalId.getElementsByClassName("button-two-text")[0]; 251 var $statusBox = $(".fhws-share-subscribe-message"); 252 var destination = event.relatedTarget.getAttribute("data-address"); 253 var $submitButton = $("#fhws-share-subscribe-submit"); 254 var $input = $("#fhws-share-subscribe-input"); 255 256 changeButton2.innerHTML = $("#popup_submit").val(); 257 changeButton1.innerHTML = $("#popup_cancel").val(); 258 259 changeInfo.innerHTML = ""; 260 261 $statusBox.html(""); 262 263 form.reset(); 264 265 switch (buttonAction) { 266 case "Email Direction": 267 case "Text Direction": 268 changeTitle.innerHTML = 269 buttonAction == "Text Direction" 270 ? $("#enter_your_phone_number").val() 271 : $("#enter_your_email_address").val(); 272 changeText.innerHTML = 273 buttonAction == "Text Direction" 274 ? $("#enter_your_phone_number").val() 275 : $("#enter_your_email_address").val(); 276 var data = { 277 action: "obituary_assistant_send_directions", 278 location: destination, 279 }; 280 var successMsg = "Directions successfully sent"; 281 var placeholder = 282 buttonAction == "Text Direction" 283 ? "123-123-1234" 284 : "[email protected]"; 285 $("#button_action").val( 286 buttonAction == "Text Direction" ? "SMS" : "EMAIL", 287 ); 288 break; 289 case "Subscribe to Obit": 290 changeTitle.innerHTML = $("#popup_subscribe_header").val(); 291 changeText.innerHTML = $("#popup_subscribe_explanation").val(); 292 var data = { 293 action: "obituary_assistant_subscribe_to_obituary", 294 obit_id: $("#obit_id").val(), 295 }; 296 var successMsg = "Thanks for subscribing!"; 297 var placeholder = $("#fhws_input_placeholder").val(); 298 break; 299 case "Share Text": 300 case "Share Email": 301 changeTitle.innerHTML = 302 buttonAction == "Share Text" 303 ? $("#share_by_phone").val() 304 : $("#share_by_email").val(); 305 changeText.innerHTML = 306 buttonAction == "Share Text" 307 ? $("#enter_your_phone_number").val() 308 : $("#enter_your_email_address").val(); 309 var data = { 310 action: "obituary_assistant_share_obituary", 311 client_id: $("#client_id").val(), 312 obit_id: $("#obit_id").val(), 313 type: buttonAction == "Share Text" ? "sms" : "email", 314 url: window.location.href, 315 }; 316 var successMsg = 317 buttonAction == "Share Text" 318 ? "Your text has been sent" 319 : "Your email has been sent"; 320 var placeholder = 321 buttonAction == "Share Text" 322 ? $("#enter_your_phone_number").val() 323 : $("#enter_your_email_address").val(); 324 $("#button_action").val( 325 buttonAction == "Share Text" ? "SMS" : "EMAIL", 326 ); 327 break; 328 case "Subscribe to Obits": 329 changeTitle.innerHTML = ""; 330 changeText.innerHTML = $( 331 "#subscribe_to_client_popup_explanation", 332 ).val(); 333 var data = { 334 action: "obituary_assistant_subscribe_to_client",
335 }; 336 var successMsg = 337 "Thanks for subscribing! Please check your inbox and confirm your email address"; 338 var placeholder = $("#fhws_input_placeholder").val(); 339 break; 340 } 341 342 //add info to submit button for action 343 $submitButton 344 .attr("data-info", JSON.stringify(data)) 345 .attr("data-msg", successMsg); 346 $input.attr("placeholder", placeholder); 347 348 function sendAction() { 349 var validMsg = $("#fhws-share-subscribe-modal") 350 .find($input) 351 .attr("placeholder"); 352 var data = JSON.parse( 353 $("#fhws-share-subscribe-submit").attr("data-info"), 354 ); 355 var successMsgShow = $("#fhws-share-subscribe-submit").attr( 356 "data-msg", 357 ); 358 var $sumbitMsg = $(".fhws-share-subscribe-message"); 359 data.address = $input.val(); 360 var inputValid = /^(1[-]*)?\d{3}[-]*\d{3}[-]*\d{4}$|^\S+@\S+\.\S+$/; 361 if (inputValid.test(data.address)) { 362 // validate 363 jQuery.post( 364 ajaxurl + "?_r=" + Math.random(), 365 data, 366 function (response, status) { 367 var obj = JSON.parse(response); 368 console.log(obj); 369 if (obj["SUCCESS"] || obj["success"]) { 370 $sumbitMsg.html( 371 '<div class="alert alert-success mt-3" role="alert">' + 372 successMsgShow + 373 "</div>", 374 ); 375 window.setTimeout(function () { 376 $sumbitMsg.fadeOut(2500, function () { 377 $(this).empty().show(); 378 $("#fhws-share-subscribe-modal").hide(); 379 }); 380 }, 3000); 381 } else { 382 var errorMsg = 383 data["action"] == 384 "obituary_assistant_subscribe_to_client" || 385 data["action"] == "obituary_assistant_subscribe_to_obituary" 386 ? "Weâre sorry but there was a problem in subscribing. Either you are already subscribed or please check the information you are submitting." 387 : "Sorry, there was an error. Please try again."; 388 $sumbitMsg.html( 389 '<div class="alert alert-danger mt-3" role="alert">' + 390 errorMsg + 391 "</div>", 392 ); 393 } 394 }, 395 "html", 396 ); 397 } else { 398 $("#fhws-share-subscribe-input").focus(); 399 if ($("#button_action").val() == "SMS") { 400 $sumbitMsg.html( 401 '<div class="alert alert-danger mt-3" role="alert">Please enter a 10 digit phone number.</div>', 402 ); 403 } else { 404 $sumbitMsg.html( 405 '<div class="alert alert-danger mt-3" role="alert">Please try again, enter as ' + 406 validMsg + 407 "</div>", 408 ); 409 } 410 } 411 } 412 413 if (!sumbitListner) { 414 // only add listener once 415 document 416 .getElementById("fhws-share-subscribe-submit") 417 .addEventListener("click", sendAction); 418 sumbitListner = true; 419 } 420 }); // end modal function 421 } 422 423 createInfoDialog(); 424 $createDialog(); 425 426 initialLoad = false; 427 428 //extra share buttons 429 $(".fhws-additioin-button").click(function (e) { 430 window.open($(this).attr("href")); 431 }); 432 433 $("#send_flowers, #share_memory, #plant_a_tree, #testing").click( 434 function (e) { 435 e.preventDefault(); 436 437 $(".share").find("button").removeClass("active"); 438 $(this).addClass("active"); 439 440 showTab($(this).attr("data-tab")); 441 }, 442 ); 443 444 // subscribe shortcode function 445 $(document).on("click", "#fhws-subscribe-widget-submit", function (e) { 446 e.preventDefault(); 447 448 var $email = $("#fhws-subscribe-widget-email"); 449 var $message = $("#fhws-subscribe-widget-message"); 450 var userinput = $email.val(); 451 var pattern = 452 /^(([^<>()\[\]\\.,;:\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,}))$/; 453 454 $message.text(""); 455 if (!pattern.test(userinput)) { 456 $message.text("Please enter an valid email."); 457 } else { 458 var data = { 459 action: "obituary_assistant_subscribe_to_client",
460 address: userinput, 461 }; 462 jQuery.post( 463 ajaxurl + "?_r=" + Math.random(), 464 data, 465 function (response, status) { 466 var successMsg; 467 var apiResponse = JSON.parse(response); 468 apiResponse = JSON.parse(apiResponse.success); 469 console.log(apiResponse); 470 if (apiResponse === false) { 471 successMsg = 472 "Either you are already subscribed or please check the information you are submitting."; 473 } else { 474 successMsg = 475 "Thanks for subscribing. Please check your inbox to verify your email."; 476 $email.val(""); 477 } 478 $message.text(successMsg); 479 }, 480 "html", 481 ); 482 } 483 }); 484 485 $(document).on("click", ".purchase-recognition-buttons", function (e) { 486 e.preventDefault(); 487 showTab($(this).attr("data-tab")); 488 489 document 490 .querySelector(".florist-one-flower-delivery-menu") 491 .scrollIntoView(true); 492 }); 493 494 /***************ShortCode_Sub_PoP****************/ 495 496 $("#subscribe_to_client_widgt").click(function (e) { 497 e.preventDefault(); 498 dialogType = 6; 499 $(".dialog-msg").html($("#subscribe_to_client_popup_explanation").val()); 500 $("#phone-in").val(""); 501 $("#phone-in").attr("placeholder", $("#placeholder").val()); 502 $(".refreshButton").trigger("click"); 503 $infoDialog.dialog("option", "title", $("#popup_subscribe_header").val()); 504 $infoDialog.dialog("open"); 505 }); 506 507 $("#mms_photo").click(function (e) { 508 if ($getLogin() == 0) { 509 $(".login").trigger("click"); 510 } else { 511 dialogType = 4; 512 $(".dialog-msg").html( 513 "You can also add photos via text message. Give us your number and we'll send you a text and then you can reply with photos and they will show up in the gallery!", 514 ); 515 $("#phone-in").val(""); 516 $("#phone-in").attr("placeholder", "123-123-1234"); 517 $(".refreshButton").trigger("click"); 518 $infoDialog.dialog("option", "title", "Enter Your Phone Number"); 519 $infoDialog.dialog("open"); 520 } 521 }); 522 523 $(document).on( 524 "click", 525 ".fhw-solutions-obituaries_search-all-obits-button", 526 function (e) { 527 e.preventDefault(); 528 searchForObit($(".fhw-solutions-obituaries_search-all-obits").val()); 529 }, 530 ); 531 532 $(document).on("click", ".additional_link", function (e) { 533 e.preventDefault(); 534 window.open($(this).attr("data-href"), "_blank"); 535 }); 536 537 var showDirections = function (address) { 538 var url = "http://maps.google.com/maps?saddr=&daddr=" + address; 539 window.open(url, "_blank"); 540 }; 541 542 //$("head").prepend('<meta property="og:image" content="https://res.cloudinary.com/ltkadmfy5/image/upload/t_individual_obituary_old/client/10/obit/0/profile/jibhwytwve4rrahodebb.jpg" />'); 543 //$("head").prepend('<meta property="og:site_name" content="Your Website Title" />'); 544 //$("meta[property='og:title']").attr("content", "Obituary For Test Middle Tescsfsfster"); 545 546 $(document).on("click", ".oa-share-popup", function (e) { 547 var width = 575, 548 height = 400, 549 left = ($(window).width() - width) / 2, 550 top = ($(window).height() - height) / 2, 551 url = $(this).attr("data-href"), 552 opts = 553 "status=1" + 554 ",width=" + 555 width + 556 ",height=" + 557 height + 558 ",top=" + 559 top + 560 ",left=" + 561 left; 562 window.open(url, "twitter", opts); 563 return false; 564 }); 565 }); 566 567 var setLoginType = function (data) { 568 loginType = data; 569 }; 570 571 var getLoginType = function () { 572 return loginType; 573 }; 574 575 var checkCaptcha = function (callback) { 576 var data = { 577 action: "obituary_assistant_check_captcha", 578 captchaSelection: $("input[name=captchaSelection]").val(), 579 }; 580 jQuery.post( 581 ajaxurl + "?_r=" + Math.random(), 582 data, 583 function (response, status) { 584 callback(response.human); 585 }, 586 "json", 587 ); 588 }; 589 590 function returnData(param) { 591 return param; 592 } 593 594 var showTab = function (tab) { 595 //hide all 596 597 var $tab = $("#pills-tab"); 598 var $tabContent = $("#pills-tabContent"); 599 600 $tab.find("a").removeClass("active"); 601 $tabContent.find(".tab-pane").removeClass("show active"); 602 603 switch (tab) { 604 case "obit": 605 $("#obit_text").css("display", "block"); 606 if ($(window).width() <= 800 && initialLoad == false) { 607 $([document.documentElement, document.body]).animate( 608 { 609 scrollTop: $(".obit_body").offset().top, 610 }, 611 2000, 612 ); 613 } 614 break; 615 case "photo": 616 $("#obit_photos_and_video").css("display", "block"); 617 if ($(window).width() <= 800) { 618 $([document.documentElement, document.body]).animate( 619 { 620 scrollTop: $("#obit_photos_and_video").offset().top, 621 }, 622 2000, 623 ); 624 } 625 break; 626 case "condolence": 627 $("#condolence, #pills-condolence").addClass("show active"); 628 document 629 .querySelector("#obituary-share-memory-container") 630 .scrollIntoView(false); 631 break; 632 case "flowers": 633 $("#flowers, #pills-flowers").addClass("show active"); 634 635 if ($(".florist-one-flower-delivery").html().length < 1) { 636 } 637 638 if ($("#florist-one-flower-delivery-menu-link-0").hasClass("active")) { 639 $("#florist-one-flower-delivery-menu-link-1").trigger("click"); 640 } 641 //$("#florist-one-flower-delivery-menu-link-1").trigger("click"); 642 if ($(window).width() <= 800) { 643 $([document.documentElement, document.body]).animate( 644 { 645 scrollTop: $(".florist-one-flower-delivery").offset().top, 646 }, 647 2000, 648 ); 649 } 650 break; 651 case "trees": 652 if ( 653 $("#client_type").val() == 5 || 654 $("#client_type").val() == 7 || 655 $("#flowers_enabled").val() == 0 656 ) { 657 $("#trees, #pills-tree").addClass("show active"); 658 } else { 659 if ($(".florist-one-flower-delivery").html().length < 1) { 660 //$("#florist-one-flower-delivery-menu-link-0").trigger("click"); 661 } 662 if ( 663 !$("#florist-one-flower-delivery-menu-link-0").hasClass("active") 664 ) { 665 $("#florist-one-flower-delivery-menu-link-0").trigger("click"); 666 } 667 $("#flowers, #pills-tree").addClass("show active"); 668 if ($(window).width() <= 800) { 669 $([document.documentElement, document.body]).animate( 670 { 671 scrollTop: $(".florist-one-flower-delivery").offset().top, 672 }, 673 2000, 674 ); 675 } 676 } 677 678 break; 679 } 680 }; 681 682 var createInfoDialog = function () { 683 $infoDialog = $("#dialog-enter-info").dialog({ 684 autoResize: true, 685 autoOpen: false, 686 height: "auto", 687 width: "auto", 688 maxWidth: 575, 689 modal: true, 690 position: { 691 my: "center", 692 at: "center", 693 }, 694 buttons: [ 695 { 696 text: $("#popup_submit").val(), 697 click: infoIn, 698 }, 699 { 700 text: $("#popup_cancel").val(), 701 click: function () { 702 $infoDialog.dialog("close"); 703 }, 704 }, 705 ], 706 });
707 }; 708 709 function infoIn() { 710 checkCaptcha(function (human) { 711 if (human == true) { 712 if (dialogType == 0) { 713 var data = { 714 action: "obituary_assistant_send_directions", 715 address: $("#phone-in").val(), 716 location: destination, 717 }; 718 jQuery.post( 719 ajaxurl + "?_r=" + Math.random(), 720 data, 721 function (response, status) { 722 var obj = JSON.parse(response); 723 if (obj["SUCCESS"] == true) { 724 $(".dialog-enter-info-status").html( 725 "Directions successfully sent", 726 ); 727 $(".dialog-enter-info-status").addClass( 728 "dialog-enter-info-status-success", 729 ); 730 window.setTimeout(function () { 731 $infoDialog.dialog("close"); 732 $(".dialog-enter-info-status").html(""); 733 $(".dialog-enter-info-status").removeClass( 734 "dialog-enter-info-status-success", 735 ); 736 }, 1500); 737 } else { 738 $(".dialog-enter-info-status").html( 739 "Sorry, there was an error. Please try again.", 740 ); 741 $(".dialog-enter-info-status").addClass( 742 "dialog-enter-info-status-error", 743 ); 744 window.setTimeout(function () { 745 $(".dialog-enter-info-status").html(""); 746 $(".dialog-enter-info-status").removeClass( 747 "dialog-enter-info-status-error", 748 ); 749 }, 1500); 750 } 751 }, 752 "html", 753 ); 754 } else if (dialogType == 1) { 755 var data = { 756 action: "obituary_assistant_share_obituary", 757 client_id: $("#client_id").val(), 758 obit_id: $("#obit_id").val(), 759 type: "sms", 760 address: $("#phone-in").val(), 761 url: window.location.href, 762 }; 763 jQuery.post( 764 ajaxurl + "?_r=" + Math.random(), 765 data, 766 function (response, status) { 767 var obj = JSON.parse(response); 768 if (obj["SUCCESS"] == true) { 769 $(".dialog-enter-info-status").html("Your text has been sent"); 770 $(".dialog-enter-info-status").addClass( 771 "dialog-enter-info-status-success", 772 ); 773 window.setTimeout(function () { 774 $infoDialog.dialog("close"); 775 $(".dialog-enter-info-status").html(""); 776 $(".dialog-enter-info-status").removeClass( 777 "dialog-enter-info-status-success", 778 ); 779 }, 1500); 780 } else { 781 $(".dialog-enter-info-status").html( 782 "Sorry, there was an error. Please try again.", 783 ); 784 $(".dialog-enter-info-status").addClass( 785 "dialog-enter-info-status-error", 786 ); 787 window.setTimeout(function () { 788 $(".dialog-enter-info-status").html(""); 789 $(".dialog-enter-info-status").removeClass( 790 "dialog-enter-info-status-error", 791 ); 792 }, 1500); 793 } 794 }, 795 "html", 796 ); 797 } else if (dialogType == 2) { 798 var data = { 799 action: "obituary_assistant_share_obituary", 800 client_id: $("#client_id").val(), 801 obit_id: $("#obit_id").val(), 802 type: "email", 803 address: $("#phone-in").val(), 804 url: window.location.href, 805 }; 806 jQuery.post( 807 ajaxurl + "?_r=" + Math.random(), 808 data, 809 function (response, status) { 810 var obj = JSON.parse(response); 811 if (obj["SUCCESS"] == true) { 812 $(".dialog-enter-info-status").html("Your email has been sent"); 813 $(".dialog-enter-info-status").addClass( 814 "dialog-enter-info-status-success", 815 ); 816 window.setTimeout(function () { 817 $infoDialog.dialog("close"); 818 $(".dialog-enter-info-status").html(""); 819 $(".dialog-enter-info-status").removeClass( 820 "dialog-enter-info-status-success", 821 ); 822 }, 1500); 823 } else { 824 $(".dialog-enter-info-status").html( 825 "Sorry, there was an error. Please try again.", 826 ); 827 $(".dialog-enter-info-status").addClass( 828 "dialog-enter-info-status-error", 829 ); 830 window.setTimeout(function () { 831 $(".dialog-enter-info-status").html(""); 832 $(".dialog-enter-info-status").removeClass( 833 "dialog-enter-info-status-error", 834 ); 835 }, 1500); 836 } 837 }, 838 "html", 839 ); 840 } else if (dialogType == 4) { 841 var data = { 842 action: "obituary_assistant_share_obituary", 843 client_id: $("#client_id").val(), 844 obit_id: $("#obit_id").val(), 845 type: "sms-photo", 846 address: $("#phone-in").val(), 847 url: window.location.href, 848 }; 849 jQuery.post( 850 ajaxurl + "?_r=" + Math.random(), 851 data, 852 function (response, status) { 853 var obj = JSON.parse(response); 854 if (obj["SUCCESS"] == true) { 855 $(".dialog-enter-info-status").html("Your text has been sent"); 856 $(".dialog-enter-info-status").addClass( 857 "dialog-enter-info-status-success", 858 ); 859 window.setTimeout(function () { 860 $infoDialog.dialog("close"); 861 $(".dialog-enter-info-status").html(""); 862 $(".dialog-enter-info-status").removeClass( 863 "dialog-enter-info-status-success", 864 ); 865 }, 1500); 866 } else { 867 $(".dialog-enter-info-status").html( 868 "Sorry, there was an error. Please try again.", 869 ); 870 $(".dialog-enter-info-status").addClass( 871 "dialog-enter-info-status-error", 872 ); 873 window.setTimeout(function () { 874 $(".dialog-enter-info-status").html(""); 875 $(".dialog-enter-info-status").removeClass( 876 "dialog-enter-info-status-error", 877 ); 878 }, 1500); 879 } 880 }, 881 "html", 882 ); 883 } else if (dialogType == 5) { 884 var data = { 885 action: "obituary_assistant_subscribe_to_obituary", 886 obit_id: $("#obit_id").val(), 887 address: $("#phone-in").val(), 888 }; 889 jQuery.post( 890 ajaxurl + "?_r=" + Math.random(), 891 data, 892 function (response, status) { 893 var obj = JSON.parse(response); 894 if (obj["success"] == true) { 895 $(".dialog-enter-info-status").html("Subscription added"); 896 $(".dialog-enter-info-status").addClass( 897 "dialog-enter-info-status-success", 898 ); 899 window.setTimeout(function () { 900 $infoDialog.dialog("close"); 901 $(".dialog-enter-info-status").html(""); 902 $(".dialog-enter-info-status").removeClass( 903 "dialog-enter-info-status-success", 904 ); 905 }, 1500); 906 } else { 907 $(".dialog-enter-info-status").html( 908 "Sorry, there was an error. Please try again.", 909 ); 910 $(".dialog-enter-info-status").addClass( 911 "dialog-enter-info-status-error", 912 ); 913 window.setTimeout(function () { 914 $(".dialog-enter-info-status").html(""); 915 $(".dialog-enter-info-status").removeClass( 916 "dialog-enter-info-status-error", 917 ); 918 }, 1500); 919 } 920 }, 921 "html", 922 ); 923 } else if (dialogType == 6) { 924 var data = { 925 action: "obituary_assistant_subscribe_to_client",
926 address: $("#phone-in").val(), 927 }; 928 jQuery.post( 929 ajaxurl + "?_r=" + Math.random(), 930 data, 931 function (response, status) { 932 var obj = JSON.parse(response); 933 if (obj["success"] == true) { 934 $(".dialog-enter-info-status").html("Subscription added"); 935 $(".dialog-enter-info-status").addClass( 936 "dialog-enter-info-status-success", 937 ); 938 window.setTimeout(function () { 939 $infoDialog.dialog("close"); 940 $(".dialog-enter-info-status").html(""); 941 $(".dialog-enter-info-status").removeClass( 942 "dialog-enter-info-status-success", 943 ); 944 }, 1500); 945 } else { 946 $(".dialog-enter-info-status").html( 947 "Sorry, there was an error. Please try again.", 948 ); 949 $(".dialog-enter-info-status").addClass( 950 "dialog-enter-info-status-error", 951 ); 952 window.setTimeout(function () { 953 $(".dialog-enter-info-status").html(""); 954 $(".dialog-enter-info-status").removeClass( 955 "dialog-enter-info-status-error", 956 ); 957 }, 1500); 958 } 959 }, 960 "html", 961 ); 962 } 963 } else { 964 $(".dialog-enter-info-status").html( 965 "Sorry, there was an issue with your image verification. Please try again.", 966 ); 967 $(".dialog-enter-info-status").addClass( 968 "dialog-enter-info-status-error", 969 ); 970 window.setTimeout(function () { 971 $(".dialog-enter-info-status").html(""); 972 $(".dialog-enter-info-status").removeClass( 973 "dialog-enter-info-status-error", 974 ); 975 }, 1500); 976 } 977 }); 978 } 979 980 var $createDialog = function () { 981 var dialog; 982 var form; 983 var emailRegex = 984 "/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/"; 985 var name = $("#name-in"); 986 var email = $("#email-in"); 987 var allFields = $([]).add(name).add(email); 988 var tips = $(".validateTips"); 989 990 function updateTips(t) { 991 tips.text(t).addClass("ui-state-highlight"); 992 setTimeout(function () { 993 tips.removeClass("ui-state-highlight", 1500); 994 }, 500); 995 } 996 997 function checkLength(o, n, min, max) { 998 if (o.val().length > max || o.val().length < min) { 999 o.addClass("ui-state-error"); 1000 updateTips( 1001 "Length of " + n + " must be between " + min + " and " + max + ".", 1002 ); 1003 return false; 1004 } else { 1005 return true; 1006 } 1007 } 1008 1009 function checkRegexp(o, regexp, n) { 1010 if (!regexp.test(o.val())) { 1011 o.addClass("ui-state-error"); 1012 updateTips(n); 1013 return false; 1014 } else { 1015 return true; 1016 } 1017 } 1018 1019 function basiclogin() { 1020 var valid = true; 1021 allFields.removeClass("ui-state-error"); 1022 1023 valid = valid && checkLength(name, "username", 3, 100); 1024 valid = valid && checkLength(email, "email", 6, 100); 1025 1026 /*<!---valid = valid && checkRegexp( name, /^[a-z]([0-9a-z_\s])+$/i, "Username may consist of a-z, 0-9, underscores, spaces and must begin with a letter." ); 1027 valid = valid && checkRegexp( email, emailRegex, "eg. [email protected]" );--->*/ 1028 1029 if (valid) { 1030 $setLogin(1, $("#name-in").val(), $("#email-in").val()); 1031 1032 if ($(".login_type").val() == "condolence") { 1033 console.log("auto submit condolence form after login"); 1034 $(".input-new-condolence-submit").trigger("click"); 1035 } 1036 1037 $login.dialog("close"); 1038 $getLogin(); 1039 } 1040 1041 return valid; 1042 } 1043 1044 var $setLogin = function (type, user, email) { 1045 $.cookie("o-s-t", type); 1046 $.cookie("o-s-u", user); 1047 $.cookie("o-s-e", email); 1048 $(".refresh_condolence_button").trigger("click"); 1049 }; 1050 1051 var $login = $("#dialog").dialog({ 1052 autoResize: true, 1053 autoOpen: false, 1054 height: "auto", 1055 width: "auto", 1056 maxWidth: 575, 1057 modal: true, 1058 position: { 1059 my: "center", 1060 at: "center", 1061 }, 1062 buttons: [ 1063 { 1064 text: $("#popup_submit").val(), 1065 click: basiclogin, 1066 }, 1067 { 1068 text: $("#popup_cancel").val(), 1069 click: function () { 1070 $login.dialog("close"); 1071 }, 1072 }, 1073 ], 1074 close: function () { 1075 form[0].reset(); 1076 allFields.removeClass("ui-state-error"); 1077 }, 1078 });
1079 1080 form = $login.find("form").on("submit", function (event) { 1081 event.preventDefault(); 1082 basiclogin(); 1083 }); 1084 1085 $(".login") 1086 .button() 1087 .click(function () { 1088 $login.dialog("open"); 1089 }); 1090 1091 $(".logout").click(function () { 1092 $logout(); 1093 }); 1094 1095 function isName(name) { 1096 var regex = /(.*[a-z]){3}/i; 1097 return regex.test(name); 1098 } 1099 1100 function isEmail(email) { 1101 var regex = 1102 /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; 1103 return regex.test(email); 1104 } 1105 1106 //download 1107 $(document).on("click", "#obituary-share-icon-print", function (e) { 1108 window 1109 .open( 1110 "https://www.obituary-assistant.com/fhws/templates/standalone-new/print.cfm?obit_id=" + 1111 $(this).attr("data-obit-id"), 1112 "_blank", 1113 ) 1114 .focus(); 1115 }); 1116 1117 // submit login 1118 $(document).on( 1119 "click", 1120 "#fws-solutions-obit-login-sumbit", 1121 function (event) { 1122 event.preventDefault(); 1123 var name = $("#name-in"); 1124 var email = $("#email-in"); 1125 1126 if (!isEmail(email.val())) { 1127 email.addClass("alert-danger"); 1128 } else { 1129 email.removeClass("alert-danger"); 1130 } 1131 1132 if (!isName(name.val())) { 1133 name.addClass("alert-danger"); 1134 } else { 1135 name.removeClass("alert-danger"); 1136 } 1137 1138 if (isEmail(email.val()) && isName(name.val())) { 1139 $setLogin(1, $("#name-in").val(), $("#email-in").val()); 1140 1141 if ($(".login_type").val() == "condolence") { 1142 console.log("auto submit condolence form after login"); 1143 $(".input-new-condolence-submit").trigger("click"); 1144 } else { 1145 $("#upload_photo").trigger("click"); 1146 } 1147 1148 $("#fws-solutions-obit-login-close").trigger("click"); 1149 } 1150 }, 1151 ); 1152 }; 1153 1154 var getUrlParameter = function getUrlParameter(sParam) { 1155 var sPageURL = decodeURIComponent(window.location.search.substring(1)), 1156 sURLVariables = sPageURL.split("&"), 1157 sParameterName, 1158 i; 1159 1160 for (i = 0; i < sURLVariables.length; i++) { 1161 sParameterName = sURLVariables[i].split("="); 1162 1163 if (sParameterName[0] === sParam) { 1164 return sParameterName[1] === undefined ? true : sParameterName[1]; 1165 } 1166 } 1167 }; 1168 1169 var $getLoginVal = function (field) { 1170 switch (field) { 1171 case "type": 1172 return $.cookie("o-s-t"); 1173 break; 1174 case "user": 1175 return $.cookie("o-s-u"); 1176 break; 1177 case "email": 1178 return $.cookie("o-s-e"); 1179 break; 1180 } 1181 }; 1182 1183 var $getLogin = function () { 1184 if ( 1185 $.cookie("o-s-t") === undefined || 1186 $.cookie("o-s-u") === undefined || 1187 $.cookie("o-s-e") === undefined 1188 ) { 1189 return 0; 1190 } else { 1191 return 1; 1192 } 1193 }; 1194 1195 var searchForObit = function (searchString) { 1196 var data = { 1197 action: "obituary_assistant_search_for_obit", 1198 search_string: searchString, 1199 }; 1200 jQuery.post( 1201 ajaxurl + "?_r=" + Math.random(), 1202 data, 1203 function (response, status) { 1204 $(".obit_listing").remove(); 1205 $(".fhw-solutions-obituaries_all-obituary-listings").html(response); 1206 }, 1207 "html", 1208 ); 1209 }; 1210 1211 $(document).on("click", ".fhws-scroll-page", function (e) { 1212 var div = $(this).attr("data-fhws-scroll"); 1213 $("html, body").animate( 1214 { 1215 scrollTop: $("#" + div).offset().top - 200, 1216 }, 1217 2000, 1218 ); 1219 }); 1220 1221 $(document).on("click", ".oa-useful-link-contact-us", function (e) { 1222 e.preventDefault(); 1223 $("#submit_useful_link_div").removeClass("d-none"); 1224 $("#success_message").addClass("d-none"); 1225 }); 1226 1227 $(document).on("click", ".oa-useful-link-contact-us-submit", function (e) { 1228 // validate here 1229 var $form = $(".oa-send-useful-link-form"); 1230 $form.validate({ 1231 rules: { 1232 useful_link_name: { 1233 required: true, 1234 minlength: 1, 1235 maxlength: 100, 1236 }, 1237 useful_link_phone_number: { 1238 required: true, 1239 minlength: 1, 1240 maxlength: 20, 1241 }, 1242 useful_link_email_address: { 1243 required: true, 1244 minlength: 1, 1245 maxlength: 100, 1246 email: true, 1247 }, 1248 useful_link_business_name: { 1249 required: true, 1250 minlength: 1, 1251 maxlength: 100, 1252 }, 1253 useful_link_description: { 1254 required: true, 1255 minlength: 1, 1256 maxlength: 100, 1257 }, 1258 }, 1259 onkeyup: false, 1260 onblur: false, 1261 onchange: false, 1262 errorClass: "alert alert-danger w-100", 1263 invalidHandler: function (event, validator) {}, 1264 showErrors: function (errorMap, errorList) { 1265 this.defaultShowErrors(); 1266 }, 1267 submitHandler: function () { 1268 var data = { 1269 action: "obituary_assistant_submit_useful_link", 1270 name: $("#useful_link_name").val(), 1271 phone_number: $("#useful_link_phone_number").val(), 1272 email_address: $("#useful_link_email_address").val(), 1273 business_name: $("#useful_link_business_name").val(), 1274 description: $("#useful_link_description").val(), 1275 client_id: $("#client_id").val(), 1276 }; 1277 jQuery.post( 1278 ajaxurl + "?_r=" + Math.random(), 1279 data, 1280 function (response, status) { 1281 if (response.SUCCESS) { 1282 $("#submit_useful_link_div").addClass("d-none"); 1283 $("#success_message").html( 1284 "<h5>Your submission was received, thank you!</h5>", 1285 ); 1286 $("#success_message").removeClass("d-none"); 1287 } else { 1288 $("#submit_useful_link_div").addClass("d-none"); 1289 $("#success_message").html("<h5>Something went wrong.</h5>"); 1290 $("#success_message").removeClass("d-none"); 1291 } 1292 }, 1293 "json", 1294 ); 1295 }, 1296 });
1297 }); 1298 1299 $(document).on( 1300 "keypress", 1301 ".fhw-solutions-obituaries_search-all-obits", 1302 function (e) { 1303 if (e.which == 10 || e.which == 13) { 1304 $("#fhw-solutions-obituaries_search-all-obits-button").trigger("click"); 1305 } 1306 }, 1307 ); 1308})(jQuery);
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.