function validateEmail(email) { var re = /^(([^<>()\[\]\\.,;:\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,}))$/; return re.test(email); } // function checkLogin() { // var diff = moment().unix() - parseInt($("body").attr("lastactivity")); // // console.log(diff); // if (diff >= 600) { // var activity = 'Miscellaneous Click'; // var subActivity = 'Auto Logout'; // createPortalActivityLog(activity, subActivity); // /* UNCOMMENT THESE IN PRODUCTION */ // $("body").attr("lastactivity", ""); // window.location.href = "/process/account/logout.php"; // } // } $(document).ajaxSuccess(function(){ if ($("body").attr("lastactivity") != "") { $("body").attr("lastactivity", moment().unix()); }; }); $(document).ready(function(){ $("#loading").show(); offsetHeader(); }); $(window).on("load", function(){ $("#loading").hide(); start(); // if ($("body").attr("lastactivity") != "") { // setInterval(checkLogin, 1000); // } checkLastActivity(); }); $(window).on("hashchange", function(){ //alert("Hello"); }); $(window).resize(function(){ resizeSidebar(); resizeDateContext(); resizeMarketplace(); resizeTour(); offsetHeader(); }) function checkLastActivity(time = 10000) { // check every 10 seconds until last activity is set when session is started. setTimeout(function(){ postURL("/process/last_activity", null, function(response){ var res = JSON.parse(response); // console.log(res); if (res.lastActivity != null) { // the session has been set if this has a value // console.log('Last Activity: ' + getFormattedTime(res.lastActivity)); // console.log('Expires At: ' + getFormattedTime(res.expiresAt)); // console.log('Current Time: ' + getFormattedTime(res.currentTime)); // console.log('Leeway: ' + getFormattedTime(res.leeway)); if (res.currentTime >= res.expiresAt) { // lastActivity HAS expired // console.log('logout'); openInactivityLoginModal(); } else if (res.currentTime >= res.leeway && res.currentTime < res.expiresAt) { // lastActivity will expire SOON, var timeout = (res.expiresAt-res.currentTime)*1000; // console.log('timeout show modal: ' + timeout/1000 + ' seconds'); checkLastActivity(timeout); // timeout at expiry time openInactivityContinueModal(); } else if (res.currentTime < res.leeway) { // lastActivity is still VALID var timeout = (res.leeway-res.currentTime)*1000; // console.log('timeout still valid: ' + timeout/1000 + ' seconds'); checkLastActivity(timeout); // timeout at leeway time } } else { // console.log('last activity timer not started'); checkLastActivity(); } }); }, time); } function openInactivityLoginModal(){ $("#modal_bg").stop().fadeIn("fast"); $('#modal').on('hidden.bs.modal', function (e) { $("#modal_bg").css("display", "none"); }); postURL("/components/account/inactivityLogin", null, function(response){ $("#modal div.modal-content").html(response); $("#modal").modal({ backdrop: 'static', keyboard: false }); }); } function openInactivityContinueModal(){ $("#modal_bg").stop().fadeIn("fast"); $('#modal').on('hidden.bs.modal', function (e) { $("#modal_bg").css("display", "none"); }); postURL("/components/account/inactivityContinue", null, function(response){ $("#modal div.modal-content").html(response); $("#modal").modal({ backdrop: 'static', keyboard: false }); }); } $(document).on("click", ".continueSession", function(){ postURL("/components/account/continueSession", null, function(response){ // console.log('session continued'); }); }); function getFormattedTime(unix) { var date = new Date(unix*1000); var hours = date.getHours(); var minutes = "0" + date.getMinutes(); var seconds = "0" + date.getSeconds(); var formattedTime = hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2); return formattedTime; } function offsetHeader(){ var height = $("nav.navbar").outerHeight(); $("#body").css("margin-top", height+"px"); } function start(){ activeMenu(); preparePage(); resizeSidebar(); setTimezone(); offsetHeader(); showMenuReminders(); } function resizeDateContext(){ $("div.card-header>span.date").each(function(){ var width = $(this).outerWidth(); var width2 = "calc(100% - "+width+"px)"; $(this).parent().find("div.context.date_layout").css("width", width2); }) } function resizeSidebar(){ var height = $(window).height() - $("nav.navbar").outerHeight(); var width = $("#sidebar").outerWidth(); $("#menu_container, #sidebar").css("height", height+"px"); $("#menu_container").css("width", width+"px"); $("#menu_container").css("top", $("nav.navbar").outerHeight()+"px"); } var timezone = ""; function setTimezone(){ timezone = $("body").attr("timezone"); } var prepareFunction = {}; var loadFunction = {}; function preparePage(){ var pathname = window.location.pathname; var pathArray = pathname.split("/"); $("body").attr("path", pathname); if (prepareFunction[pathname] != undefined) { prepareFunction[pathname](); } else if (prepareFunction["/"+pathArray[1]] != undefined) { prepareFunction["/"+pathArray[1]](); } var ignoreList = [ "/", "/credit-cards", "/paid-services", "/prime", "/tour", "/help", "/terms", "/emergency_setup", "/emergency", "/register", "/setup", "/merge", "/guide" ]; var pass = true; $.each(ignoreList, function(i,o){ var oArray = o.split("/"); if ((oArray[1] != "" && pathname.indexOf("/"+oArray[1]) === 0) || pathname == "/"+oArray[1]) { pass = false; } }); pass = pass && $(".do-not-prepare-page").length == 0; if (pass == true) { prepareList(); } var hash = window.location.hash.replace("#", ""); if (hash.indexOf("terms") === 0) { window.location.href = "/"+hash; } else { var status = $("body").attr("status"); if (status == "") { openLogin(); } else if (status == "reset") { openReset(); } else if (status == "terms") { openTerms(); } else if (status == "emergency") { openEmergency(); } if (pathArray[1] == "tour" && pathArray.length == 4) { sf = pathArray[2]; var data = {}; data.object = "Careteam_Member__c"; data.sf = sf; editObject(data); } } } function prepareList(){ var value = $("#content").text(); value = $.trim(value); if (value.indexOf("list_") !== false) { value = value.replace("list_", ""); var array = value.split("/"); value = array[0]; if (array.length == 3) { var sf = array[1]; var action = array[2]; loadList(value, sf, action); } else if (array.length == 2) { var search = array[1]; loadList(value, search); } else { loadList(value); } //alert("Hello"); setTimeout(function(){ $("#top_banner").slideDown(); }, 2000); } } function loadList(value, sf, action){ $("#loading").show(); // $("#content").html(""); var data = {}; data.section = value; data.data = sf; $("body").attr("section", value); postURL("/process/list/load", data, function(response){ $("#content").html(response); $("#loading").hide(); resizeDateContext(); $("#loading").removeClass("important"); $("div.card-header a[title]").tooltip(); $("a.btn[title], button.btn[title]").tooltip({ placement: "bottom" }); if (sf != undefined && sf != "") { if (action != undefined) { if (action == "v") { $("a.object_link[sf='"+sf+"']").click(); } else if (action == "e") { var ref = ""; if (sf.length > 15 && sf.indexOf("-") != -1) { var sfArray = sf.split("-"); sf = sfArray[0]; ref = sfArray[1]; } var object = $("a.object_link[sf='"+sf+"']").attr("object"); var data = {}; data.object = object; data.style = $("a.object_link[sf='"+sf+"']").attr("style"); data.sf = sf; data.ref = ref; editObject(data); } else if (action == "r") { var ref = ""; if (sf.length > 15) { var sfArray = sf.split("-"); sf = sfArray[0]; ref = sfArray[1]; } var object = $("a.object_link[sf='"+sf+"']").attr("object"); var data = {}; data.object = object; data.style = $("a.object_link[sf='"+sf+"']").attr("style"); data.sf = sf; data.ref = ref; relateObject(data); } } } var pathname = window.location.pathname; var pathArray = pathname.split("/"); if (loadFunction["/"+pathArray[1]] != undefined) { loadFunction["/"+pathArray[1]](); } // alert("Hello"); if (pathArray[1] != "overview" && pathArray[1] != "careteam_emergency" && pathArray[1] != "share") { switchTablePage(); } }); } function activeMenu(){ var pathname = window.location.pathname; var pathnameArray = pathname.split("/"); pathname = pathnameArray[1]; $("#menu a[href='/"+pathname+"']").addClass("active"); } $(document).on("click", "a.object_link", function(e){ var section = $("body").attr("section"); e.preventDefault(); var sf = $(this).attr("sf"); var object = $(this).attr("object"); var style = $(this).attr("style"); var prefix = $(this).attr("prefix"); var data = {}; data.object = object; data.sf = sf; data.style = style; data.prefix = prefix; if ($(this).find("i.fa").hasClass("fa-vcard")) { window.open("/components/accesscard/document.php?insurance="+data.sf, '_blank'); return false; } if (section == "overview") { //window.location.href = "/"+data.style+"/"+data.sf+"/v"; loadObject(data); } else if (section == "search") { window.location.href = "/"+data.prefix+"/"+data.sf+"/v"; } else { loadObject(data); } }); $(document).on("click", "div.section_buttons button[action='update']", function(){ var data = {}; data.style = $(this).attr("style"); data.sf = $(this).attr("sf"); editObject(data); }); $(document).on("click", "div.section_buttons button[action='emergency']", function(){ var data = {}; data.sf = $(this).attr("sf"); editPersonal(data, "emergency"); }); $(document).on("click", "#edit_profile_navbar", function(e){ e.preventDefault(); var data = {}; data.sf = $(this).attr("sf"); editPersonal(data, "settings"); }); $(document).on("click", "div.section_buttons button[action='create'], a.object_create", function(e){ e.preventDefault(); var object = $(this).attr("object"); var data = {}; data.object = object; $("#loading").show(); postURL("/process/object/create", data, function(response){ if (response == "") { notify(pullLabel("alert", "notify_generic_error"), "danger"); } else { var response = JSON.parse(response); data.sf = response.Id; var section = $("body").attr("section"); $("#loading").show(); //loadList(section); editObject(data); } }); }); function postURL(url, data, callback){ $.ajax({ url: url+".php", data: data, type: "POST", success: function(data){ data = $.trim(data); callback(data); } }) } function notify(msg, status){ $("#notification_bar").text(msg); $("#notification_bar").removeAttr("class"); $("#notification_bar").addClass("text-center alert alert-"+status); $("#notification_bar").stop().slideDown("fast").delay(5000).slideUp("fast"); } function changePath(path){ history.replaceState(null, null, path); $("body").attr("path", path); } $(document).on("submit", "#search_form", function(e){ e.preventDefault(); var search = $("#search_text").val(); if (search.length >= 3) { window.location.href = "/search/"+search; } }); $(document).on("click", "#menu button[href], #search_form button[href]", function(e){ var href = $(this).attr("href"); window.location.href = href; }); function pullLabel(category, name){ var lang_labels_obj = JSON.parse(window.atob(lang_labels)); var lang = $("body").attr("lang"); if (lang_labels_obj[category] != undefined && lang_labels_obj[category][name] != undefined && lang_labels_obj[category][name][lang] != undefined) { return lang_labels_obj[category][name][lang]; } else { return lang_labels_obj[category][name]['en']; } } $(document).on("submit", "form", function(e){ e.preventDefault(); }); // /* WRAP EVERYTHING IN AN ANONYMOUS FUNCTION TO PREVENT FUNCTION NAMING CLASHES */ // (function () { // prepareFunction["/credit-cards"] = function(){ // $("body").attr("section", "credit-cards"); // setupDocumentListeners(); // } // function setupDocumentListeners() { // $(document).on('click', '.edit-credit-card-link', function (e) { // var cardId = $(this).attr('cardid'); // console.log('edit card clicked', cardId); // editCreditCard(cardId); // e.preventDefault(); // }); // $(document).on('click', '.create-credit-card-link', function (e) { // createCreditCard(); // e.preventDefault(); // }); // $(document).on('credit-card.updated', '#save_credit_card', function (e) { // loadCreditCardSuccessHtml(function (html) { // $('.modal-body').wrapInner('
'); // $('.modal-body').prepend(''); // $('.sliding-up-yo, .modal-footer').slideUp("fast"); // $('.sliding-down-yo').slideDown("fast", function () { // setTimeout(function () { // window.location.reload(); // }, 200); // }); // // setTimeout(function () { // // window.location.reload(); // // }, 1000); // }); // }); // $(document).on('click', '#cancel_credit_card', function (e) { // console.log('cancel credit card clicked'); // hideCreditCardForm(); // // $('#purchase-payment-method').selectpicker('val', ''); // }); // } // function hideCreditCardForm() { // $('#modal').modal('hide'); // $("#modal_bg").stop().fadeOut("fast"); // } // function loadCreditCardSuccessHtml(callback) { // postURL('/components/creditCardSuccess', {}, function (html) { // callback(html); // }); // } // function createCreditCard() { // openCreditCard(); // } // function editCreditCard(cardId) { // openCreditCard(cardId); // } // function getReturnPathToPaidServices() { // return '/' + getURLParameter('returnUrl'); // } // function getURLParameter(name) { // return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null; // } // function openCreditCard(cardId) { // $('#loading').show(); // getCreditCardFormHtml(cardId, function (html) { // $('#loading').hide(); // openCreditCardModal(html); // }); // } // function openCreditCardModal(html) { // $("#modal div.modal-content").html(html); // $("#modal").modal({ // backdrop: "static", // keyboard: false // }); // $("#modal_bg").stop().fadeIn("fast"); // $("#modal>div.modal-dialog").removeClass("modal-lg"); // $('#modal').on('shown.bs.modal', function (e) { // $('#modal').off('shown.bs.modal'); // }); // $("#loading").hide(); // $('#modal').on('hidden.bs.modal', function (e) { // $('#modal').off('hidden.bs.modal'); // }); // } // })(); // /* Opens the credit card modal. If a cardId is supplied, the modal is an edit modal, rather than a create modal. Make sure you attach the html to an element in the callback function you supplied, since this function assumes that certain elements exist in the dom after it calls the callback. */ // function getCreditCardFormHtml(cardId, callback) { // var templateUrl; // var data = {}; // var cleaveItems = { // number: null, // expiry: null, // cvc: null // }; // if (cardId) { // templateUrl = "/components/edit-credit-card"; // data.cardId = cardId; // } else { // templateUrl = "/components/create-credit-card"; // } // postURL(templateUrl, data, function(response) { // callback(response); // setupFormFormatting(); // setupFormSubmissionListeners(); // }); // function setupFormSubmissionListeners() { // $('#save_credit_card').on('click', function (e) { // console.log('clicking save credit card button'); // if (!validateForm()) { // return; // } // var $saveCreditCardButton = $(this); // $("#loading").show(); // submitForm({ // success: function(cardData) { // $("#loading").hide(); // showInvalid($('input[name="card-number"]')); // showInvalid($('input[name="card-expiry"]')); // showInvalid($('input[name="card-cvc"]')); // $('#card-validation-error-message').addClass('d-none'); // $saveCreditCardButton.trigger('credit-card.updated', [cardData]); // }, // error: function (error) { // $("#loading").hide(); // showInvalid($('input[name="card-number"]')); // showInvalid($('input[name="card-expiry"]')); // showInvalid($('input[name="card-cvc"]')); // $('#card-validation-error-message').removeClass('d-none'); // } // }); // }); // $('input').on('keydown', function (e) { // showValid($(this)); // }); // } // function submitForm(callbacks) { // var formData = new FormData($('#credit-card-form') [0]); // var number = null; // if (cleaveItems ['number']) { // number = cleaveItems ['number'].getRawValue(); // } // var month = null; // var year = null; // if (cleaveItems ['expiry']) { // var expiry = cleaveItems ['expiry'].getRawValue(); // month = expiry.substr(0, 2); // year = '20' + expiry.substr(2, 2); // } // var cvc = null; // if (cleaveItems ['cvc']) { // cvc = cleaveItems ['cvc'].getRawValue(); // } // var cardId = null; // var $idInput = $('input[name="card-id"]'); // if ($idInput.length) { // cardId = $idInput.val(); // } // var data = { // cardId: cardId, // number: number, // exp_month: month, // exp_year: year, // cvc: cvc, // name: $('input[name="card-billing-name"]').val(), // address: $('input[name="card-billing-address"]').val(), // city: $('input[name="card-billing-city"]').val(), // country: $('input[name="card-billing-country"]').val(), // state: $('input[name="card-billing-state"]').val(), // zip: $('input[name="card-billing-zip"]').val(), // } // postURL('/process/marketplace/editCreditCard', data, function (response) { // var data = null; // try { // data = JSON.parse(response); // } catch (e) { // callbacks.error({ // error: true, // response: response, // }); // return; // } // if (!data || data ['error']) { // callbacks.error(data); // } else { // callbacks.success(data); // } // }); // } // function validateForm() { // var isValid = true; // if (cleaveItems ['number']) { // var number = cleaveItems ['number'].getRawValue(); // if (!number || number.length == 0) { // showInvalid($('input[name="card-number"]')); // isValid = false; // } // } // if (cleaveItems ['expiry']) { // var expiry = cleaveItems ['expiry'].getRawValue(); // if (!expiry || expiry.length != 4) { // showInvalid($('input[name="card-expiry"]')); // isValid = false; // } // } // if (cleaveItems ['cvc']) { // var cvc = cleaveItems ['cvc'].getRawValue(); // if (!cvc || cvc.length == 0) { // showInvalid($('input[name="card-cvc"]')); // isValid = false; // } // } // var $requiredInputs = $('#credit-card-form input.required'); // $requiredInputs.each(function () { // var $input = $(this); // if (!$input.val()) { // isValid = false; // showInvalid($input); // } // }); // return isValid; // } // function showInvalid($input) { // $input.parents('.form-group').addClass('has-danger'); // } // function showValid($input) { // $input.parents('.form-group').removeClass('has-danger'); // } // function setupFormFormatting() { // if ($('input[name="card-number"]:not(:disabled)').length) { // cleaveItems ['number'] = new Cleave('input[name="card-number"]:not(:disabled)', { // creditCard: true, // onCreditCardTypeChanged: function (type) { // console.log(type) // // update UI ... // } // }); // } // if ($('input[name="card-expiry"]:not(:disabled)').length) { // cleaveItems ['expiry'] = new Cleave('input[name="card-expiry"]:not(:disabled)', { // date: true, // delimiter: '/', // datePattern: ['m', 'y'] // }); // } // if ($('input[name="card-cvc"]:not(:disabled)').length) { // cleaveItems ['cvc'] = new Cleave('input[name="card-cvc"]:not(:disabled)', { // blocks: [3], // numericOnly: true // }); // } // } // } /* WRAP EVERYTHING IN AN ANONYMOUS FUNCTION TO PREVENT FUNCTION NAMING CLASHES */ (function () { /* GLOBAL FUNCTIONS THAT APPLY TO ALL PAGES */ $(document).ready(function () { function initGlobalDocumentListeners() { $(document).on('click', '.show-cpp-button', function (event) { var activity = 'Miscellaneous Click'; var subActivity = 'CPP Downloads'; createPortalActivityLog(activity, subActivity); //prevent the event from propogating since the button may be a link or a button event.preventDefault(); $('#loading').show(); $.getJSON( "/process/cpp/patientRecord.php", function( data ) { $('#loading').hide(); console.log('generated file', data); window.open(data.url,'_blank'); }) .fail(function(err) { $('#loading').hide(); console.error('Could not load patient record'); console.error(err); }); }); } initGlobalDocumentListeners(); }); })(); $(document).on("click", ".intercept_cpp", function(e){ e.preventDefault(); $('.show-cpp-button').click(); }); prepareFunction["/prime"] = function () { //alert("Peek-a-boo"); $("body").attr("section", "prime"); if (window.location.hash != "" && window.location.hash.indexOf("#a0F") === 0) { var sfId = window.location.hash.replace("#", ""); prime_openPurchaseRecord(sfId); } /* $('#marketplace button[title]').tooltip(); $('#marketplace a[title]').tooltip(); var pathname = window.location.pathname; var pathArray = pathname.split("/"); console.log('pathArray', pathArray) if (pathArray.length == 4) { var sfId = pathArray[2]; openPurchase(sfId); } initDocumentListeners(); */ } $(document).on('click', '#prime_quote_buy', function (e) { var element = $(this); console.log(element); console.log(element.data('purchase-id')); prime_openPurchaseRecord(element.data('purchase-id')); }); $(document).on('click', '.prime_purchase', function (e) { $("#loading").show(); var element = $(this); var sku = $(this).attr("sku"); var type = $(this).attr("type"); element.prop("disabled", true); var data = {}; if (type == 'subscription') { data.planId = sku; } else if (type == 'product') { data.skuId = sku; } else if (type == 'charge') { data.productId = sku; } data.object = 'purchase'; prime_openPurchaseObject(data, element); }); function prime_openPurchaseObject(data, element) { console.log('purchasing object', data); postURL("/process/object/create", data, function (response) { console.log('create result', response); if (response == "") { $("#loading").hide(); notify(pullLabel("alert", "notify_generic_error"), "danger"); } else { element.prop("disabled", false); var response = JSON.parse(response); data.sf = response.Id; //alert(data.sf); $("#loading").show(); //changePath("/prime//" + data.sf + "/e"); prime_openPurchaseRecord(data.sf); } }); } function prime_openPurchaseRecord(sfId) { window.location.hash = sfId; var data = { sf: sfId }; $("#loading").show(); postURL("/components/purchase", data, function (response) { $("#loading").hide(); if (response == '') { notify("Oops. There was an error on our end. Please contact us to resolve this issue.", "danger"); return; } $("#modal div.modal-content").html(response); var html = $("#banner h1").html(); $("#purchase_title").html(html); $('#modal').on('shown.bs.modal', function (e) { $('#modal').off('shown.bs.modal'); $("#loading").hide(); }); $('#modal').on('hidden.bs.modal', function (e) { history.replaceState({}, document.title, window.location.pathname); $('#modal').off('hidden.bs.modal'); //changePath("/paid-services"); }); $("#modal").modal({ backdrop: "static", keyboard: false }); var data = {}; setCreditCardSelectHtml(); $("#modal_bg").stop().fadeIn("fast"); $("#modal>div.modal-dialog").removeClass("modal-lg"); //$('#purchase-payment-method').selectpicker(); }); } function setCreditCardSelectHtml() { postURL("/components/stripe/list_cc", null, function (response) { $("#purchase-payment-method").html(response); $("#purchase-payment-method").prop("disabled", false); checkPurchaseButton(); }); } function checkPurchaseButton(){ var card = $("#purchase-payment-method").val(); var province = $("#purchase-province").val(); if (card == "" || province == "") { $("#purchase_proceed").prop("disabled", true); } else { $("#purchase_proceed").prop("disabled", false); } } $(document).on("change", "select#purchase-payment-method, select#purchase-province", function () { var paymentOption = $(this).val(); if (paymentOption == "add-new-card") { console.log("add new card"); $("#purchase_cc_body, #purchase_cc_footer").removeClass("hidden"); /* For prime services pages */ $("#confirm_purchase_body, #confirm_purchase_footer").addClass("hidden"); $("#purchase_overview").addClass("hidden"); /* For paying off document charges */ $("#document_payment_form").addClass("hidden"); } else { } checkPurchaseButton(); }); $(document).on("click", "#cancel_confirmation", function () { $("#purchase_cc_body, #purchase_cc_footer").addClass("hidden"); $("#confirm_purchase_body, #confirm_purchase_footer").addClass("hidden"); $("#purchase_overview").removeClass("hidden"); }); $(document).on("click", "#cancel_credit_card", function () { var data = {}; $("#credit-card-form input[name]").val(""); $("#purchase-payment-method").val(""); checkPurchaseButton(); $("#purchase-payment-method").html(''); $("#purchase-payment-method").prop("disabled", true); postURL("/components/stripe/list_cc", data, function (response) { $("#purchase-payment-method").html(response); $("#purchase-payment-method").prop("disabled", false); }); $("#purchase_cc_body, #purchase_cc_footer").addClass("hidden"); /* For product pages */ $("#confirm_purchase_body, #confirm_purchase_footer").addClass("hidden"); $("#purchase_overview").removeClass("hidden"); /* For paying off document charges */ $("#document_payment_form").removeClass("hidden"); }); $(document).on("click", "#save_credit_card", function () { var obj = {}; var element = $(this); var pass = true; $("#credit-card-form input[name]").each(function(){ var name = $(this).attr("name"); obj[name] = $(this).val(); if (obj[name] == "") { pass = false; return false; } }); if (pass == false) { notify(pullLabel("alert", "notify_fields"), "danger"); } else { obj.id = ""; element.prop("disabled", true); $.ajax({ type: 'POST', data: obj, url: '/process/marketplace/add_cc.php', success: function(data){ element.prop("disabled", false); var json = JSON.parse(data); if (json.error != undefined && json.error == true) { notify(pullLabel("alert", "notify_transaction_failed"), "danger"); } else { $("#cancel_credit_card").click(); } } }); } }); $(document).on("click", "a.prime_comingsoon", function(e){ e.preventDefault(); var data = {}; data.title = 'Learn More'; data.type = 'Service'; // data.product = $(this).closest("div.row").find("h1").text(); data.product = $(this).attr('product'); data.buttonText = 'Notify Me'; comingSoon(data); }); $(document).on("click", "button.prime_comingsoon", function(e){ e.preventDefault(); var data = {}; data.title = 'Reserve Now'; // $(this).text(); data.type = 'Product'; // $(this).attr('type'); data.product = $(this).attr('sku'); data.buttonText = 'Reserve'; comingSoon(data); }); $(document).on("click", "#prime_next", function(e){ var index = $("#index_tab a.active").parent().index(); if (index == 2) { $("#index_tab a:first").click(); $("html, body").scrollTop(0); } else { $("#index_tab a.active").parent().next().find("a").click(); $("html, body").scrollTop(0); } }); /* WRAP EVERYTHING IN AN ANONYMOUS FUNCTION TO PREVENT FUNCTION NAMING CLASHES */ (function () { /* GLOBAL FUNCTIONS THAT APPLY TO ALL PAGES */ $(document).ready(function () { function initGlobalDocumentListeners() { $(document).on('click', '.open-alliance-button', function (event) { openAllianceModal(); }); $(document).on('click', '#cancel_alliance', function (event) { closeAllianceModal(); }); $(document).on('click', '#send_alliance', function (event) { submitForm(); }); $(document).on('keydown change', '.alliance-form input, .alliance-form select', function (e) { showValid($(this)); }); } initGlobalDocumentListeners(); }); function closeAllianceModal() { $("#modal").modal('hide'); $("#modal_bg").stop().fadeOut("fast"); } function openAllianceModal() { $("#modal_bg").stop().fadeIn("fast"); $("#modal>div.modal-dialog").removeClass("modal-lg"); $("#loading").show(); $('#modal').on('shown.bs.modal', function (e) { $('#modal').off('shown.bs.modal'); $("#loading").hide(); }); $('#modal').on('hidden.bs.modal', function (e) { $('#modal').off('hidden.bs.modal'); }); postURL("/components/alliance/alliance-form", {}, function (response) { $("#modal div.modal-content").html(response); $("#modal").modal({ backdrop: "static", keyboard: false }); }); } function submitForm() { var isValid = validateForm(); console.log('is valid', isValid); if (!isValid) { return false; } $('#loading').show(); postURL("/process/alliance/sendInfo", {}, function (response) { var data; try { data = JSON.parse(response); } catch (e) { data = { error: true }; console.error(e); } if (data.error) { $('#alliance-validation-error-message').removeClass('d-none'); } else { showConfirmation(); $('#alliance-validation-error-message').addClass('d-none'); } $('#loading').hide(); // $("#modal div.modal-content").html(response); // $("#modal").modal({ // backdrop: "static", // keyboard: false // }); }); } function showConfirmation() { getConfirmationHtml(function (html) { $('.modal-body').wrapInner('
'); $('.modal-body').prepend(''); $('.sliding-up-yo, .modal-footer').slideUp("fast"); $('.sliding-down-yo').slideDown("fast", function () { // setTimeout(function () { // window.location.reload(); // }, 200); setTimeout(function(){ //$("#modal").modal("hide"); //$("#modal_bg").stop().fadeOut("fast"); window.location.reload(); }, 3000); }); $('#modal').on('hidden.bs.modal', function () { }); }); } function getConfirmationHtml(callback) { postURL('/components/alliance/alliance-success', {}, function (html) { callback(html); }); } function showInvalid($input) { // $input.parents('.form-group').addClass('has-danger'); $input.addClass('is-invalid'); } function showValid($input) { // $input.parents('.form-group').removeClass('has-danger'); $input.removeClass('is-invalid'); } function validateForm() { var isValid = true; var $requiredInputs = $('.alliance-form input.required'); $requiredInputs.each(function () { var $input = $(this); if (!$input.val()) { isValid = false; showInvalid($input); } }); return isValid; } })(); $(document).on('click', '.create-healthqr-button', function (e) { var data = {}; var data = {}; data.sf = "003A000000uG7P1"; data.temp = true; editObject(data); }); function clearHealthQR() { $('.clear-healthqr-button').click(); } $(document).on('click', '.clear-healthqr-button', function (e) { var data = {}; data.field = "HealthQR__c"; data.value = ""; data.sf = $("body").attr("user"); data.obj = "Contact"; postURL("/process/object/edit", data, function(response){ var data = {}; data.field = "Alliance_Id__c"; data.value = ""; data.sf = $("body").attr("user"); data.obj = "Contact"; postURL("/process/object/edit", data, function(response){ window.location.reload(); }); }); }); $(document).on('click', '#create_healthqr_account', function (e) { var element = $(this); element.prop("disabled", true); $("#loading").show(); var pass = true; /* if ($("#create_healthqr_account_agree").prop("checked") != true) { notify("Please agree to HealthQR terms and conditions.", "danger"); pass = false; return false; } */ var province = {}; province["AB"] = 1; province["BC"] = 2; province["MB"] = 3; province["NB"] = 4; province["NL"] = 5; province["NS"] = 6; province["NT"] = 7; province["NU"] = 8; province["ON"] = 9; province["PE"] = 10; province["QC"] = 11; province["SK"] = 12; province["YT"] = 13; var user_state = $("input[name='MailingState']").val(); var user_state_code = 9; if (province[user_state] != undefined) { user_state_code = province[user_state]; } var provinceSingle = province var data = { birthDay: $("select.create_date_day").val(), birthMonth: $("select.create_date_month").val(), birthYear: $("select.create_date_year").val(), city: $("input[name='MailingCity']").val(), password: "hc365", confirmPassword: "hc365", email: $("#create_healthqr_account").attr("username"), firstName: $("input[name='FirstName']").val(), lastName: $("input[name='LastName']").val(), gender: "Male", //homePhone: string (optional entry, phone number format ###-###-#####, formatting of phone number is optional) //mobilePhone: string (optional entry, phone number format ###-###-#####, formatting of phone number is optional) languageResource: { languageId: 1, languageName: "English", languageShortName: "en", }, postalCode: $("input[name='MailingPostalCode']").val(), provinceId: user_state_code, streetAddress: $("input[name='MailingStreet']").val(), }; $.each(data, function(i,o){ if (i != "languageResource" && o == "") { notify(pullLabel("alert", "notify_fields"), "danger"); pass = false; element.prop("disabled", false); $("#loading").hide(); return false; } }); if (pass == true) { element.prop("disabled", true); $("#loading").show(); $("#loading").addClass("important"); postURL("/process/healthqr/register", data, function(response){ $("#loading").hide(); $("#loading").removeClass("important"); $("#edit_columns, div.modal-footer").slideUp("fast"); $("button.close").show(); $("#edit_success h3").html("Congratulations!"); $("#edit_success p").html("You are just steps away from accessing your prescription information. To finish your registration, you need to confirm your email within the next 48 hours. Please check your email ("+$("#create_healthqr_account").attr("username")+") and confirm by clicking the link.

To link your account with your prescription information, visit your participating pharmacy and your pharmacist will connect the accounts.

Click here for a list of participating pharmacies.

Alliance Pharmacy is one of the participating pharmacies. They deliver your medications to your house for free! Click here to learn more about Alliance Pharmacy."); $("#edit_success").slideDown("fast", function(){ $("button.close").show(); /* setTimeout(function(){ $("#modal").modal("hide"); $("#modal_bg").stop().fadeOut("fast"); }, 3000); */ }); //notify("Thanks for joining Your Health Report from HealthQR. To finish your registration, you need to confirm your email within the next 48 hours. Please check your email ("+$("#create_healthqr_account").attr("username")+") and confirm by clicking the link. ", "success"); //$("h4.modal-title").text("Check: " + $("#create_healthqr_account").attr("username")); }); /* $.ajax({ url: "https://rx.healthqr.com/accounts/create", type: "POST", data: data, success: function(data){ } })*/ } }); // $(document).on('click', '.open-healthqr-button', function (e) { // var data = {}; // postURL("/components/healthqr/form", data, function(response){ // $('#modal').on('hidden.bs.modal', function (e) { // $('#modal').off('hidden.bs.modal'); // var section = $("body").attr("section"); // loadList(section); // }); // $('#modal').on('shown.bs.modal', function (e) { // $('#modal').off('shown.bs.modal'); // $("#healthqr_submit").click(); // }); // $("#modal>div.modal-dialog").removeClass("modal-lg"); // $("#modal div.modal-content").html(response); // $("#modal_bg").stop().fadeIn("fast"); // $("#modal").modal({ // backdrop: "static", // keyboard: false // }); // }); // }); // $(document).on('click', '#healthqr_submit', function (e) { $(document).on('click', '.open-healthqr-button', function (e) { var data = {}; $("#loading").show(); postURL("/process/healthqr/fetch", data, function(response){ console.log(response); try { response = JSON.parse(response); } catch (e) { console.error(e); response = { error: true, message: 'Could not parse response' } } if (response.error) { notify(pullLabel("alert", "healthQR_pull_error"), "danger"); $("#loading").hide(); return; } $("#healthqr_log").val(response); $("#loading").hide(); $("#modal>div.modal-dialog").removeClass("modal-lg"); $("#modal div.modal-content").html(response.modalSuccessHtml); $("#modal_bg").stop().fadeIn("fast"); $("#modal").modal({ backdrop: "static", keyboard: false }); $("div.modal-footer, #edit_healthqr_form").slideUp("fast"); $("button.close").hide(); $("#edit_success").slideDown("fast", function(){ setTimeout(function(){ $("#modal").modal("hide"); $("#modal_bg").stop().fadeOut("fast"); }, 3000); }); }); }); var chat_socket; $(document).on('click', '#open_chat', function (e) { var data = {}; $("#loading").show(); postURL("/components/chat/index", data, function(response){ $("#loading").hide(); $("#modal>div.modal-dialog").removeClass("modal-lg"); $("#modal div.modal-content").html(response); $("#modal_bg").stop().fadeIn("fast"); $("#modal").modal({ backdrop: "static", keyboard: false }); $('#modal').on('shown.bs.modal', function (e) { chat_socket = io.connect('https://dev_chat.hc365.org:3000', {reconnect: true, secure: true}); chat_socket.on('chat message', function(msg){ $('#chat_list').append($('
  • ').text(msg)); }); $('#modal').off('shown.bs.modal'); }); $('#modal').on('hidden.bs.modal', function (e) { chat_socket.disconnect(); $('#modal').off('hidden.bs.modal'); }); }); }); $(document).on('click', '#chat_submit', function (e) { var user_name = $("#chat_msg").attr("contact"); var msg = user_name + ": "+ $('#chat_msg').val(); chat_socket.emit('chat message', msg); $('#chat_msg').val(''); return false; }); loadFunction["/careteam_emergency"] = function(){ if ($("#emergency-setup-container").length) { console.log($("#section_emergency_contacts")); var section = $("#section_emergency_contacts"); switchTable(section); switchTableMode(section, "table"); updateEmergencySections(); } }; function updateEmergencySections() { var container = $("#emergency-setup-container"); var careteamContainer = container.find("#emergency-setup-careteam"); var accessContainer = container.find("#emergency-setup-access"); var notesContainer = container.find("#emergency-setup-notes"); var printContainer = container.find("#emergency-setup-print"); var infoContainer = container.find("#emergency-setup-information"); var regenerateContainer = container.find("#emergency-setup-regenerate"); var statusGroup1 = container.find("#emergency-setup-step-1"); var statusGroup2 = container.find("#emergency-setup-step-2"); var statusGroup3 = container.find("#emergency-setup-step-3"); var statusGroup4 = container.find("#emergency-setup-step-4"); var statusDot1 = statusGroup1.find(".status_dot"); var statusDot2 = statusGroup2.find(".status_dot"); var statusDot3 = statusGroup3.find(".status_dot"); var statusDot4 = statusGroup4.find(".status_dot"); var statusLine1 = statusGroup1.find(".status_pipe"); var statusLine2 = statusGroup2.find(".status_pipe"); var statusLine3 = statusGroup3.find(".status_pipe"); accessContainer.addClass('disabled'); notesContainer.addClass('disabled'); printContainer.addClass('disabled'); infoContainer.addClass('disabled'); regenerateContainer.addClass('disabled'); statusGroup3.addClass('disabled'); statusGroup4.addClass('disabled'); statusLine2.addClass('disabled'); statusLine3.addClass('disabled'); statusDot1.removeClass('active'); statusDot2.removeClass('active'); statusDot3.removeClass('active'); statusDot4.removeClass('active'); statusLine1.removeClass('active'); statusLine2.removeClass('active'); statusLine3.removeClass('active'); statusDot3.addClass('disabled'); statusDot4.addClass('disabled'); var isContactsInitilized= careteamContainer.find(".card.object").length > 0; if (isContactsInitilized) { accessContainer.removeClass('disabled'); statusDot1.addClass('active'); } var isAccessInitialized = $("#ea_input_access_initialized").prop("checked"); if (isAccessInitialized && isContactsInitilized) { statusDot2.addClass('active'); } var isAccess = $("#ea_input_access").prop("checked"); if (isAccess && isAccessInitialized && isContactsInitilized) { notesContainer.removeClass('disabled'); statusLine2.removeClass('disabled'); statusLine3.removeClass('disabled'); statusDot3.removeClass('disabled'); statusDot4.removeClass('disabled'); statusGroup3.removeClass('disabled'); statusGroup4.removeClass('disabled'); } var isNotes = $("#ea_input_info").val() != ""; if (isNotes && isAccess && isAccessInitialized && isContactsInitilized) { statusDot3.addClass('active'); statusLine3.addClass('active'); infoContainer.removeClass('disabled'); printContainer.removeClass('disabled'); } var isPrinted = $("#ea_input_print_initialized").prop("checked"); if (isPrinted && isNotes && isAccess && isAccessInitialized && isContactsInitilized) { statusDot4.addClass('active'); regenerateContainer.removeClass('disabled'); } console.log( 'isAccess', isAccess, 'isAccessInitialized', isAccessInitialized, 'isNotes', isNotes, 'isPrinted', isPrinted ); } $(document).on("keyup", "#ea_input_info", function(){ var element = $(this); if (element.val() != element.attr("value")) { element.removeClass("form-control-success"); element.closest("div.form-group").removeClass("has-success"); element.addClass("form-control-loading"); element.closest("div.form-group").addClass("has-loading"); delay(function(){ updateObj_simple(element); }, 500); } updateEmergencySections(); }); $(document).on("change", "#ea_input_access", function(){ var element = $(this); if (element.prop("checked") == true) { $("#ea_column_right").removeClass("hidden"); } else { $("#ea_column_right").addClass("hidden"); } var accessTouched = $("#ea_input_access_initialized"); accessTouched.prop("checked", true); updateObj_simple(element); updateObj_simple(accessTouched); updateEmergencySections(); }); $(document).on("click", "#ea_link_print", function () { var accessPrinted = $("#ea_input_print_initialized"); accessPrinted.prop("checked", true); updateObj_simple(accessPrinted); updateEmergencySections(); }); $(document).on("click", "#ea_regenerate", function(){ var element = $(this); element.prop("disabled", true); regenerateAccessCard(); }); function regenerateAccessCard(callback) { postURL("/process/ea/regenerate_token", {}, function(response){ //window.location.reload(); loadList("careteam_emergency"); }); } function updateObj_simple(element){ console.log(element); var field = element.attr("name"); var sf = element.attr("sf"); var obj = element.attr("obj"); if (element.attr("type") == "checkbox") { if (element.prop("checked") == true) { var value = "true"; } else { var value = "false"; } } else { var value = element.val().trim(); } var data = {}; data.field = field; data.value = value; data.sf = sf; data.obj = obj; element.addClass("form-control-loading"); element.closest("div.form-group").addClass("has-loading"); postURL("/process/object/edit", data, function(response){ element.removeClass("form-control-loading"); element.closest("div.form-group").removeClass("has-loading"); element.removeClass("form-control-danger"); element.closest("div.form-group").removeClass("has-danger"); if (data.value != "") { element.addClass("form-control-success"); element.closest("div.form-group").addClass("has-success"); } }); } $(document).on("click", ".card_form", function(e){ e.preventDefault(); e.stopPropagation(); }); $(document).on("change", ".card_form input[name]", function(){ var element = $(this); updateObj_simple(element); }); $(document).on("click", "#ea_test_link", function(e){ if ($("#ea_input_access").prop("checked") == true) { } else { e.preventDefault(); notify("Please activate Emergency Access first.", "danger"); } }); function switchTable(section) { var list = []; var table = section.find("table"); section.find("h4").text(""); section.find(".object_link").each(function(){ // var clone = table.find("tbody tr:first").clone(); // table.find("tbody").append(clone); var obj = {}; obj.sf = $(this).attr("sf"); var objectName = $(this).attr("sobject-name"); /** * Check in label */ if ($(this).attr("sf-last-modified")) { try { var sfId = obj.sf; if (doesRequireCheckin($(this))) { obj ["Check In"] = { requireCheckin: true, sfId: sfId, objectName: objectName } } else { obj ["Check In"] = { requireCheckin: false, sfId: sfId, objectName: objectName }; } } catch (e) { console.error("Could not understand the last modified date. See below error for details."); console.error(e); } } var remindersCount = $(this).attr("reminders-count"); var sfId = obj.sf; obj["Reminders"] = { count: remindersCount, sfId: sfId }; var titleLabel = "Title"; if ($(this).find("h5").attr("label") != "") { titleLabel = $(this).find("h5").attr("label"); } obj[titleLabel] = $(this).find("h5").text().trim(); var dateLabel = "Date"; if ($(this).find("span:not(.fa-stack)").attr("label") != undefined && $(this).find("span:not(.fa-stack)").attr("label") != "") { dateLabel = $(this).find("span:not(.fa-stack)").attr("label"); } if ($(this).find("span:not(.fa-stack)").length > 0) { obj[dateLabel] = $(this).find("span:not(.fa-stack)").text().trim(); } var captionLabel = "Caption"; if ($(this).find("h6").attr("label") != undefined && $(this).find("h6").attr("label") != "") { captionLabel = $(this).find("h6").attr("label"); } if ($(this).find("h6").length > 0) { obj[captionLabel] = $(this).find("h6").text().trim(); } $(this).attr("sort-"+titleLabel.toString().hexEncode(), obj[titleLabel]); $(this).attr("sort-"+dateLabel.toString().hexEncode(), obj[dateLabel]); $(this).attr("sort-"+captionLabel.toString().hexEncode(), obj[captionLabel]); var elem = $(this); $(this).find(".col.sub").each(function(){ var key = $(this).find("dd:first").text().trim(); var value = $(this).find("dd:last").text().trim(); obj[key] = value; elem.attr("sort-"+key.hexEncode(), value); }); list.push(obj); }); $.each(list[0], function(i,o){ if (i == "head" || i == "sub" || i == "date") { i = ""; } if (i == "Check In") { table.find("thead tr").append(""); } else if (i == "Reminders") { table.find("thead tr").append(""); } else if (i != "sf") { table.find("thead tr").append(""+i+""); } }); table.find("thead tr").append(""); $.each(list, function(i,item){ table.find("tbody").append(""); $.each(item, function(i,o){ if (i == "Check In") { var buttonClasses = o.requireCheckin ? '' : 'active'; var iconClasses = o.requireCheckin ? 'far' : 'fas'; table.find("tbody tr:last").append( "\
    \ \
    \ " ); } else if (i == "Reminders") { var hiddenClass = o.count == 0 ? "hidden" : ""; var html = "\ \ \ \ "; table.find("tbody tr:last").append(html); } else if (i != "sf") { table.find("tbody tr:last").append(""+o+""); } }); table.find("tbody tr:last").append(""); }); if (list.length > 0) { section.find("div.card-header div.header_menu").prepend('
    '); $.each(list[0], function(i,o){ if (i != "sf") { section.find(".section_item_sort .dropdown-menu").append(''+i+''); } }); } } function doesRequireCheckin(card) { var thirtyDaysAgo = Date.now() - 30 * 24 * 60 * 60 * 1000;// 30 days // var thirtyDaysAgo = Date.now() - 15 * 1000; // 15 seconds var lastModifiedString = card.attr("sf-last-modified"); var lastModified = new Date(lastModifiedString).getTime(); // console.log('lastModified', lastModified, thirtyDaysAgo); return lastModified < thirtyDaysAgo; } var tableActiveIndex = null; function switchTablePage(){ $("#content").prepend(''); $(".section_item").each(function(){ var section = $(this); $("#content nav").append(''+section.find("h4").text()+''); var length = section.find(".object_link").length; if (length > 0) { section.find("div.card-header div.header_menu").prepend('
    '); } switchTable(section); section.hide(); }); if (tableActiveIndex != null) { $("#content nav a:eq("+tableActiveIndex+")").click(); } else { $("#content nav a:first").click(); } } function switchTableMode(section, mode) { var table = section.find("table"); // console.log('switch table', table); if (mode == "table") { table.parent().show(); section.find(".object_link, .object_create").hide(); } else { table.parent().hide(); section.find(".object_link, .object_create").show(); } } $(document).on("click", ".section_layout_mode button", function(e){ var mode = $(this).attr("mode"); $(this).addClass("active-2").addClass("btn-primary").removeClass("btn-light"); $(this).siblings().removeClass("active-2").removeClass("btn-primary").addClass("btn-light"); var section = $(this).closest(".section_item"); switchTableMode(section, mode); }); $(document).on("click", "#content nav a", function(e){ e.preventDefault(); $(this).addClass("active"); $(this).siblings().removeClass("active"); var index = $(this).index(); tableActiveIndex = index; var section = $(".section_item:eq("+index+")"); section.show(); section.siblings("div.section_item").hide(); if ($(".section_item:eq("+index+") tbody tr").length > 3 || doesSectionHaveCheckins(section)) { section.find(".section_layout_mode button:last").click(); } else { section.find(".section_layout_mode button:first").click(); } }); function doesSectionHaveCheckins(section) { var cards = section.find(".object_link"); var reminderCards = cards.filter(function (index) { return doesRequireCheckin($(this)); }); return reminderCards.length > 0; } $(document).on("click", ".object_redirect", function(e){ var sf = $(this).attr("sf"); $("a.object_link[sf='"+sf+"']").click(); }); function switchTable_comparer(column) { console.log(column); return function(a, b) { var valA = $(a).find("td[column='"+column+"']").text(); var valB = $(b).find("td[column='"+column+"']").text(); if (valA == undefined) { valA = null; } if (valB == undefined) { valB = null; } var result = $.isNumeric(valA) && $.isNumeric(valB) ? valA - valB : valA.toString().localeCompare(valB); return result; } } function switchTable_comparer_card(column) { console.log(column); return function(a, b) { var valA = $(a).attr("sort-"+column); var valB = $(b).attr("sort-"+column); console.log(valA); console.log(valB); if (valA == undefined) { valA = null; } if (valB == undefined) { valB = null; } var result = $.isNumeric(valA) && $.isNumeric(valB) ? valA - valB : valA.toString().localeCompare(valB); return result; } } $(document).on("click", ".section_item_sort a", function(e){ var value = $(this).attr("sort"); var table = $("table.table:visible"); var section = $("div.section_item:visible>div.card-body"); if (table.length > 0) { var rows = table.find('tbody tr').toArray().sort(switchTable_comparer(value)); for (var i = 0; i < rows.length; i++){table.append(rows[i])} } else if (section.length > 0) { var rows = section.find('a.object_link').toArray().sort(switchTable_comparer_card(value)); for (var i = 0; i < rows.length; i++){section.append(rows[i])} console.log(rows); $(section).cleanWhitespace(); } // console.log(rows); // this.asc = !this.asc // if (!this.asc){rows = rows.reverse()} }); String.prototype.hexEncode = function(){ var hex, i; var result = ""; for (i=0; i\
    \
    \ \
    \
    \
    \
    \ ' + contact.FirstName + ' ' + lastInitial + '\
    \
    \
    \
    \
    '; } $(document).on("click", ".share_accept_friend", function() { var contactId = $(this).attr("sf"); $("#loading").show(); createPortalPermission(contactId, function () { loadList("share"); }); }); function findContacts(email, callback) { var data = { emailAddress: email }; postURL("/process/account/share/checkEmail", data, function(response) { try { response = JSON.parse(response); } catch (e) { response = { error: true } } if (response.error) { callback([]); } else { callback(response.SObject); } }); } // function generateInviteCode(name, callback) { // var data = {}; // data.name = name; // data.object = 'portal_permission'; // postURL("/process/object/create", data, function(response){ // createResponse = JSON.parse(response); // var data = {}; // data.portalPermissionId = createResponse["Id"]; // postURL("/process/account/share/getPortalPermission", data, function(response){ // var portalPermission = JSON.parse(response); // var inviteCode = portalPermission["SObject"]["Invite_Code__c"]; // console.log("portalPermission", portalPermission); // callback(inviteCode); // }); // }); // } function createPortalPermission(friendFamilyId, callback) { var data = {}; data.object = 'portal_permission'; data.friendFamilyId = friendFamilyId; postURL("/process/object/create", data, function(response){ createResponse = JSON.parse(response); callback(); }); } $(document).on("click", "#submit_invite_code", function(e){ e.preventDefault(); var inviteCode = $("#received_invite_code").val(); var data = {}; data.inviteCode = inviteCode.trim(); if (inviteCode != "") { postURL("/process/account/share/applyCode", data, function(response){ response = JSON.parse(response); if (response.error) { $("#submit_invite_code_error").html(response.message); $("#submit_invite_code_success").addClass("hidden"); } else { // $("#submit_invite_code_success").removeClass("hidden"); // $("#submit_invite_code_error").html(""); loadList("share"); } // $('#invite_code').val(portalPermission["Invite_Code__c"]); }); } else { return false; } }); function openSharing(){ $("#modal_bg").stop().fadeIn("fast"); $("#modal>div.modal-dialog").removeClass("modal-lg"); $("#loading").show(); $('#modal').on('shown.bs.modal', function (e) { $('#modal').off('shown.bs.modal'); $("#loading").hide(); }) $('#modal').on('hidden.bs.modal', function (e) { $('#modal').off('hidden.bs.modal'); }) var data = {}; postURL("/components/account/switchModal", data, function(response){ $("#modal div.modal-content").html(response); $("#modal").modal({ backdrop: "static", keyboard: false }); }); } function showMenuReminders(){ var data = {}; postURL("/process/reminders/retrieve", data, function(response){ var reminders = JSON.parse(response); $("#menu > a").each(function (index, value) { var href = $(value).attr('href'); var menuSObjects = $(value).data('sobjects'); var reminderIcon = $(this).find(".reminder-icon"); var remindersCount = 0; for (var i = 0; i < menuSObjects.length; i++) { var sObjectNameReminders = reminders[menuSObjects[i]]; if (sObjectNameReminders != undefined) { remindersCount += sObjectNameReminders.length; } } if (remindersCount > 0) { reminderIcon.attr("data-count", remindersCount); } else { reminderIcon.attr("data-count", null); } }); }); } $(document).on("click", ".edit-reminder-button", function () { var container = $(this).parents('.reminder-item'); toggleReminderEdit(container); }); $(document).on("click", ".save-reminder-button", function () { var container = $(this).parents('.reminder-item'); toggleReminderEdit(container); }); $(document).on("change", ".reminder-edit input[name='Subject']", function () { var container = $(this).parents('.reminder-item'); updateReminderText(container, "Subject", $(this).val()); }); $(document).on("change", ".reminder-edit .create_calendartime_year", function () { var container = $(this).parents('.reminder-item'); // console.log("updating date", container.find("input[name='ActivityDate']"), container.find("input[name='ActivityDate']").val()); // /* Hacky way to let the calendar event handler do its thing first */ // setTimeout(function () { // updateReminderText(container, "ActivityDate", container.find("input[name='ActivityDate']").attr("value")); // }, 0); }); $(document).on("change", ".reminder-edit input[name='ActivityDate']", function () { var container = $(this).parents('.reminder-item'); console.log("updating date", $(this), container.find("input[name='ActivityDate']").val()); updateReminderText(container, "ActivityDate", $(this).val()); }); $(document).on("click", ".add-reminder-button", function () { var parentObjId = $(this).attr("whatid"); addNewTask(parentObjId); /* update reminder icons on the page to match the new number */ updateReminderIcons(parentObjId, 1); }); $(document).on("click", ".complete-reminder-button", function () { var container = $(this).parents('.reminder-item'); showChecked($(this)); setTimeout(function () { animateCompleteTask(container); }, 400); completeTask(container.attr("sf"), "Completed"); /* update reminder icons on the page to match the new number */ var parentObjId = $(this).attr("whatid"); updateReminderIcons(parentObjId, -1); }); $(document).on("click", ".delete-reminder-button", function () { var container = $(this).parents('.reminder-item'); animateCompleteTask(container); completeTask(container.attr("sf"), "Cancelled"); /* update reminder icons on the page to match the new number */ var parentObjId = $(this).attr("whatid"); updateReminderIcons(parentObjId, -1); }); function updateReminderIcons(sfId, addition) { var icon = $(".reminder-icon[sf='" + sfId + "']"); console.log("updating reminder icons", sfId, icon); if (icon.length) { var count = icon.attr("data-count"); try { count = parseInt(count); console.log("icon count", count, count + addition); icon.attr("data-count", count + addition); if (count + addition > 0) { icon.removeClass("hidden"); } else { icon.addClass("hidden"); } } catch (e) { console.error("Could not parse count"); } } } function animateCompleteTask(container) { container.animate({ height: 0, opacity: 0}, 600, "easeOutQuad", function () { container.remove(); }); } function completeTask(taskId, status) { var data = {}; data.field = "Status"; data.value = status; data.sf = taskId; data.obj = "Task"; console.log("completing task", data); postURL("/process/object/edit", data, function(response){ showMenuReminders(); }); } function addNewTask(parentId) { var data = { object: "task", WhatId: parentId }; $("#loading").show(); postURL("/process/object/create", data, function(response){ var data = {}; data.object = "Task"; data.sf = parentId; data.style = null; $("#loading").hide(); loadObject(data); showMenuReminders(); }); } function toggleReminderEdit(container) { var viewContainer = container.find('.reminder-view'); var editContainer = container.find('.reminder-edit'); viewContainer.toggleClass("hidden"); editContainer.toggleClass("hidden"); } function updateReminderText(container, field, value) { var textEl = container.find(".reminder-text[field='" + field + "']"); textEl.html(value); } prepareFunction["/"] = function(){ checkStatus(); } loadFunction["/overview"] = function(){ var lastLogin = $.cookie('lastLogin'); var status = $("body").attr("status"); if (lastLogin == undefined && status == "clear") { openLastLogin(); $.cookie('lastLogin', 'true'); } else { if (status == "tour") { //window.location.href = "/tour"; } } /** * As of Jun 1, 2018, this function is commented out. we disabled the chart until we figure * out the gamification process */ setupChart(); } prepareFunction["/register"] = function(){ checkStatus(); } /** * As of Jun 1, 2018, this function was not called. we disabled the chart until we figure * out the gamification process */ function setupChart() { var percentage = parseFloat($("#overview_chart").attr("percentage")); new Chart(document.getElementById("overview_chart"), { "type":"doughnut", "data":{ "labels":["Red", "White"], "datasets":[ { "label":"My First Dataset", "data":[percentage, 100-percentage], "backgroundColor": [$("#overview_chart").attr("color"), "rgb(255, 255, 255)"] } ] }, "options": { "tooltips": { "enabled": false }, "legend": { "display": false } } } ); /* var ctx = document.getElementById("overview_chart"); var myChart = new Chart(ctx, { type: 'doughnut', datasets:[ { label: "My First Dataset", data:[300,50,100], backgroundColor:[ "rgb(255, 99, 132)", "rgb(54, 162, 235)", "rgb(255, 205, 86)" ] } ], options: { } });*/ // var myDoughnutChart = new Chart("chartjs-4", {"labels":["Red","Blue","Yellow"],"datasets":[{"label":"My First Dataset","data":[300,50,100],"backgroundColor":["rgb(255, 99, 132)","rgb(54, 162, 235)","rgb(255, 205, 86)"]}]}); } function checkStatus(){ var response = $("body").attr("status"); if (response == "") { if (window.location.pathname != "/" && window.location.pathname.indexOf("/register") !== 0) { window.location.href = "/"; } } else if (response == "tour") { window.location.href = "/tour"; } else { window.location.href = "/overview"; } /* if (response == "clear") { window.location.href = "/overview"; } else if (response == "emergency") { window.location.href = "/overview"; } else if (response == "terms") { window.location.href = "/overview"; } else if (response == "reset") { window.location.href = "/overview"; } else if (response == "tour") { } */ } $(document).on("click", "#setup_btn", function(){ var btn = $(this); var data = {}; data.username = $("#setup_username").val(); data.password = $("#setup_password").val(); data.password2 = $("#setup_password2").val(); data.data = $("#setup_btn").attr("data"); if (data.username == "" || data.password == "") { notify(pullLabel("alert", "notify_credentials"), "danger"); return false; } if (data.password == "" || data.password != data.password2) { notify(pullLabel("alert", "notify_password"), "danger"); return false; } btn.prop("disabled", true); postURL("/process/account/setup", data, function(response){ btn.prop("disabled", false); if (response == "true") { window.location.href = "/overview"; } else { window.location.href = "/merge/"+response; } /* $("#modal").modal("hide"); $("#modal_bg").stop().fadeOut("fast"); */ }) }) $(document).on("click", "#merge_btn", function(){ var btn = $(this); var data = {}; data.password = $("#merge_password").val(); data.data = $("#merge_btn").attr("data"); if (data.password == "") { notify(pullLabel("alert", "notify_password"), "danger"); return false; } btn.prop("disabled", true); postURL("/process/account/merge", data, function(response){ btn.prop("disabled", false); if (response == "true") { window.location.href = "/overview"; } else { notify(pullLabel("alert", "notify_login"), "danger"); } /* $("#modal").modal("hide"); $("#modal_bg").stop().fadeOut("fast"); */ }) }) $(document).on("click", "#merge_back_btn", function(){ window.history.back(); }); $(document).on("click", "#reset_btn", function(){ var btn = $(this); var data = {}; data.password = $("#reset_password").val(); data.password2 = $("#reset_password2").val(); if (data.password == "" || data.password != data.password2) { notify(pullLabel("alert", "notify_password"), "danger"); return false; } btn.prop("disabled", true); postURL("/process/account/reset", data, function(response){ btn.prop("disabled", false); window.location.href = "/"; }) }) $(document).on("click", "#forgot_btn", function(){ $("#forgot_btn, #login_btn").addClass("hidden"); $("#retrieve_btn, #login_back_btn").removeClass("hidden"); $("#retrieve_btn").attr("type", "submit"); $("#login_btn").attr("type", "button"); $("#login_password, #fileHelp").parent("div.form-group").addClass("hidden"); }); $(document).on("click", "#login_back_btn", function(){ $("#forgot_btn, #login_btn").removeClass("hidden"); $("#retrieve_btn, #login_back_btn").addClass("hidden"); $("#retrieve_btn").attr("type", "button"); $("#login_btn").attr("type", "submit"); $("#login_password, #fileHelp").parent("div.form-group").removeClass("hidden"); }); $(document).on("click", "#retrieve_btn", function(){ var btn = $(this); var data = {}; data.username = $("#login_email").val(); if (data.username == "") { notify(pullLabel("alert", "notify_check_email"), "danger"); return false; } btn.prop("disabled", true); postURL("/process/account/forgot", data, function(response){ btn.prop("disabled", false); if (response == "false") { notify(pullLabel("alert", "notify_login"), "danger"); } else { notify(pullLabel("alert", "notify_new_password"), "success"); } }) }) $(document).on("click", "#login_btn", function(e){ e.preventDefault(); var btn = $(this); var data = {}; data.username = $("#login_email").val(); data.password = $("#login_password").val(); if (data.username == "" || data.password == "") { notify(pullLabel("alert", "notify_credentials"), "danger"); return false; } btn.prop("disabled", true); postURL("/process/account/login", data, function(response){ btn.prop("disabled", false); if (response == "false") { notify(pullLabel("alert", "notify_login"), "danger"); } else { window.location.reload(); } }) }) $(document).on("click", "#terms_btn", function(){ var btn = $(this); btn.prop("disabled", true); var data = {}; postURL("/process/account/accept_terms", data, function(response){ btn.prop("disabled", false); window.location.href = "/"; }) }) $(document).on("click", "#emergency_btn", function(e){ e.preventDefault(); $("#loading").show(); var data = {}; data.notes = $("#emergency_notes").val(); data.access = $("#emergency_access").prop("checked"); $("#emergency_btn, #emergency_skip").prop("disabled", true); postURL("/process/account/create_emergency", data, function(response){ var data = {}; data.object = "person_emergency"; $("#loading").show(); var sf = $("div.card-block[create='person_emergency']").attr("sf"); if (sf == "") { postURL("/process/object/create", data, function(response){ var response = JSON.parse(response); emergencySf = response.Id; $("#modal").modal("hide"); $("#modal_bg").stop().fadeOut("fast"); }); } else { emergencySf = sf; $("#modal").modal("hide"); $("#modal_bg").stop().fadeOut("fast"); } }) }); $(document).on("click", "#emergency_skip", function(e){ e.preventDefault(); $("#emergency_btn, #emergency_skip").prop("disabled", true); var data = {}; postURL("/process/account/skip_emergency", data, function(response){ window.location.reload(); }) }); $(document).on("click", "#readonly_btn", function(e){ e.preventDefault(); var btn = $(this); var pathname = window.location.pathname; var data = {}; data.member = $("#readonly_member").val(); data.policy = $("#readonly_policy").val(); data.url = pathname.split("/")[2]; if (data.url == undefined) { data.url = ""; } if (data.member == "" || data.policy == "") { notify(pullLabel("alert", "notify_policy"), "danger"); return false; } btn.prop("disabled", true); postURL("/process/account/login_emergency", data, function(response){ btn.prop("disabled", false); if (response == "false") { notify(pullLabel("alert", "notify_login"), "danger"); } else { window.location.href = "/"; } }) }) $(document).on("click", "#register_btn", function(e){ e.preventDefault(); var btn = $(this); var pathname = window.location.pathname; var data = {}; data.member = $("#readonly_member").val(); data.policy = $("#readonly_policy").val(); data.url = pathname.split("/")[2]; if (data.url == undefined) { data.url = ""; } if (data.member == "" || data.policy == "") { notify(pullLabel("alert", "notify_policy"), "danger"); return false; } btn.prop("disabled", true); postURL("/process/account/register", data, function(response){ btn.prop("disabled", false); if (response == "false") { notify(pullLabel("alert", "notify_already_activated"), "danger"); } else { window.location.href = "/setup/"+response; } }) }) $(document).on("click", "#top_banner_static", function(e){ $("#top_banner_content").slideToggle(); var newCookieValue = $.cookie('hide_banner') == 'true' ? 'false' : 'true'; $.cookie('hide_banner', newCookieValue); $("#top_banner_static .close-banner").toggleClass("fa-chevron-right fa-chevron-down"); }); $(document).on("click", "#overview_chart", function(e){ window.location.href = "/tour"; }); $(document).on("click", "#purchase_proceed_request", function (e) { createDocumentPurchase(); }); function createDocumentPurchase() { //data.cardid: $("#purchase-payment-method").val(); $("#loading").show(); var data = { productId: "pro-cpp-translation", type: "charge", object: "purchase", amount: parseFloat($("#purchase_proceed_request").attr("amount")) } postURL("/process/object/create", data, function (response) { console.log('create result', response); if (response == "") { $("#loading").hide(); notify(pullLabel("alert", "notify_generic_error"), "danger"); } else { var response = JSON.parse(response); var purchaseId = response.Id; var chargeData = { stripetype: "charge", stripeid: "pro-record-retrieval", purchaseid: purchaseId, cardid: $("#purchase-payment-method").val(), province: $("#purchase-province").val() } console.log('chargeData', chargeData); postURL("/process/marketplace/purchase", chargeData, function (response) { console.log("wow", response); $("#loading").hide(); response = $.trim(response); var data; try { data = JSON.parse(response); } catch (e) { data = { error: true, message: response } } if (data.error === false) { var editData = { obj: "Request", field: "Status__c", sf: $("#purchase_proceed_request").attr("documentsf"), value: "Payment Received" } console.log('editing record', editData); postURL("/process/object/edit", editData, function (response) { console.log('response', response); $("#modal").modal("hide"); $("#modal_bg").stop().fadeOut("fast"); notify(pullLabel("alert", "notify_purchase"), "success"); setTimeout(function () { window.location.reload(); }); }); } else { notify(pullLabel("alert", "notify_generic_error"), "danger"); } }); } }); } $(document).on("click", "#translation_document_selection a", function(e) { e.preventDefault(); var $card = $(this); toggleCardSelected($card); }); $(document).on("change", "#translation-upload-input", function (e) { // console.log($("#translation-upload-input").val()); let $card = $(this).parents('.card-link'); if ($(this).val()) { $card.addClass('selected'); $card.find("i.checkmark-icon").removeClass("far fa-circle").addClass("fas fa-check-circle active"); $card.find("#translation-upload-title-container").removeClass("d-none"); if (this.files.length) { let fileName = this.files [0].name; $card.find("#translation-upload-title").val(fileName); } } else { $card.removeClass('selected'); $card.find("i.checkmark-icon").removeClass("fas fa-check-circle active").addClass("far fa-circle"); $card.find("#translation-upload-title-container").addClass("d-none"); } }) $(document).on("click", "#translate_generate_quote", function (e) { var submitResult = doFormSubmission(); $("#translate_generate_quote_text").html("Regenerate Quote"); if (submitResult) { $("#translate_generate_quote_arrow_icon").removeClass("fa-arrow-right").addClass("fa-arrow-down"); } else { $("#translate_generate_quote_arrow_icon").removeClass("fa-arrow-down").addClass("fa-arrow-right"); } }); $(document).on("click", "#translate_quote_purchase", function (e) { var purchaseId = $(this).attr("purchaseid"); prime_openPurchaseRecord(purchaseId); }); function toggleCardSelected($card) { $card.toggleClass("selected"); $card.find("i.checkmark-icon").toggleClass("far fa-circle").toggleClass("fas fa-check-circle active"); } function doFormSubmission() { var data; try { data = getFormData(); /** * If the upload file has been set, we have to do something first to get * the base 64 content before we submit the form */ if (data.upload) { getFileInputData(data.upload, function (uploadData) { data.upload = uploadData; submitForm(data); }) } else { submitForm(data); } return true; } catch (e) { console.log('error', e); if (e.name == "FileType") { notify(pullLabel("alert", "notify_filetype"), "danger"); } else if (e.name == "FileSize") { notify(pullLabel("alert", "notify_filesize"), "danger"); } else if (e.name == "NoFiles") { notify("You must select something to translate", "danger"); } else if (e.name == "LanguageNotSet") { notify("You must select a language", "danger"); } else { notify(pullLabel("alert", "notify_generic_error"), "danger"); } return false; } } function submitForm(data) { $("#loading").show(); $.ajax({ url: "/process/translation/generateDocumentAndQuote.php", type: "POST", data: data, success: function(data) { showQuote(data); $("html, body").animate({ scrollTop: $(document).height() }); }, error: function (data) { hideQuote(); if (data.responseJSON && data.responseJSON.message) { notify(data.responseJSON.message, "danger"); } else { notify(pullLabel("alert", "notify_generic_error"), "danger"); } }, complete: function (data) { $("#loading").hide(); } }); } function showQuote(data) { var $quoteSection = $("#translation_quote_section"); var $iframe = $quoteSection.find("#translation_document_iframe"); var $numOfPages = $quoteSection.find("#number_of_pages"); var $pricePerPage = $quoteSection.find("#price_per_page"); var $targetLanguage = $quoteSection.find("#target_language_name"); var $subtotal = $quoteSection.find("#translation_subtotal"); var $quoteHelpId = $quoteSection.find("#quote_help_id"); var $continueButton = $quoteSection.find("#translate_quote_purchase"); $iframe.attr("src", data.url); $numOfPages.html(data.numberOfPages); $pricePerPage.html("$" + data.pricePerPage.toFixed(2)); $targetLanguage.html(data.language); $subtotal.html("$" + data.subtotal.toFixed(2)); $quoteHelpId.html(data.attachmentId); $continueButton.attr("purchaseid", data.purchaseId); $quoteSection.removeClass("d-none"); } function hideQuote() { $("#translation_quote_section").addClass("d-none"); } function getFormData() { var data = {}; /** * Check that the language is set */ var langaugeSelect = $("#translation-language-picker"); data.language = langaugeSelect.val(); /** * Check if cpp is checked */ var isCpp = $("#ccp_document_card.selected").length > 0; data.cpp = isCpp; /** * Find all selected documents */ var $selectedDocuments = $("#translation_document_selection a.selected"); var documentIds = $selectedDocuments.map(function () { return $(this).attr("sf"); }) .get(); data.documents = documentIds; /** * Check if uploaded a new document */ var $uploadInput = $("#translation-upload-input"); if ($uploadInput.val()) { data.upload = $uploadInput [0].files [0]; data.uploadTitle = $("#translation-upload-title").val(); } /** * Validate that the data is correct */ if (!data.language) { var e = new Error('Language not set'); e.name = 'LanguageNotSet'; throw e; } if (!data.cpp && !data.documents.length && !data.upload) { var e = new Error('No Files Selected'); e.name = 'NoFiles'; throw e; } return data; } function getFileInputData(file, callback) { var fileName = file.name.toLowerCase(); var allowedTypes = ['.pdf', '.png', '.jpg', '.jpeg', '.tif', '.tiff', '.xdoc', '.xdocx', '.xtxt', '.xrtf']; var isValidType = allowedTypes.some(function (type) { return fileName.indexOf(type) != -1; }); var isValidSize = file.size < 10000000; if (!isValidType) { var e = new Error('Invalid file type'); e.name = 'FileType'; throw e; } else if (!isValidSize) { var e = new Error('Invalid file size'); e.name = 'FileSize'; throw e; } var reader = new FileReader(); reader.onload = function(event) { var data = {}; data.filename = fileName; data.content = event.target.result; //contents of the file callback(data); }; reader.readAsDataURL(file); } // createPortalActivityLog might exist in other files $(document).on("click", "#menu_container a[href*='/']", function(e){ // Menu clicks var activity = 'Menu Click'; var subActivity = getSubActivity($(this).attr('href')); createPortalActivityLog(activity, subActivity); }); $(document).on("click", "#tour_blocks a[href*='/']", function(e){ // Pop down clicks var activity = 'Pop Down Click'; var subActivity = getSubActivity($(this).attr('href')); createPortalActivityLog(activity, subActivity); }); $(document).on("click", "#content a[href*='/careteam_emergency']", function(e){ // Emergency page click var activity = 'Miscellaneous Click'; var subActivity = 'Emergency Page Viewed'; createPortalActivityLog(activity, subActivity); }); $(document).on("click", "#navbar_right button[href*='/']", function(e){ // Manual Logout var activity = 'Miscellaneous Click'; var subActivity = 'Manual Logout'; createPortalActivityLog(activity, subActivity); }); $(document).on("click", "#pills-home-tab", function(e){ // Primary Services Page Viewed var activity = 'Prime Tabs Click'; var subActivity = 'Primary Services Page Viewed'; createPortalActivityLog(activity, subActivity); }); $(document).on("click", "#pills-profile-tab", function(e){ // Travel Services Page Viewed var activity = 'Prime Tabs Click'; var subActivity = 'Travel Services Page Viewed'; createPortalActivityLog(activity, subActivity); }); $(document).on("click", "#pills-contact-tab", function(e){ // Other Services Page Viewed var activity = 'Prime Tabs Click'; var subActivity = 'Other Services Page Viewed'; createPortalActivityLog(activity, subActivity); }); $(document).on("click", "#pills-tabContent a[href*='/']", function(e){ // Single Product Page Viewed var activity = 'Prime Learn More Click'; var subActivity = getSubActivity($(this).attr('href')); createPortalActivityLog(activity, subActivity); }); function getSubActivity(href) { var routeOne = { 'overview': 'Overview Page Viewed', 'document': 'Records Page Viewed', 'careteam': 'Care Team Page Viewed', 'appointment': 'Appointments Page Viewed', 'prescription': 'Medications Page Viewed', 'condition': 'Conditions Page Viewed', 'prime': 'Prime Services Page Viewed', 'help': 'Help Page Viewed', 'careteam_emergency': 'Emergency Page Viewed' }; var routeTwo = { 'jumpstart': 'Concierge', 'doc': 'Call A Doctor', 'nurse': 'Call A Nurse', 'concierge': 'Care Coordination', 'travel': 'Travel Support', 'trip': 'Trip Readiness', 'prime': 'Translation', 'alliance': 'Alliance', 'tap2tag': 'Tap2Tag' }; var pathArray = href.split("/"); pathArray = pathArray.filter(page => { return page != ""; }); if (pathArray.length == 1 && pathArray[0] in routeOne) { // /prime var subActivity = routeOne[pathArray[0]]; return subActivity; } else if (pathArray.length == 2 && pathArray[0] in routeOne && pathArray[1] in routeTwo) { // /prime/jumpstart var subActivity = routeTwo[pathArray[1]]; return subActivity; } else { return null; } } function createPortalActivityLog(activity, subActivity) { var data = {}; data.activity = activity; data.subActivity = subActivity; postURL("/process/portal_activity_log", data, function(response){ // console.log(response); }); // https://developers.google.com/analytics/devguides/collection/gtagjs/events gtag('event', 'View', { // is the string that will appear as the event action in Google Analytics Event reports. 'event_category': activity, // is the string that will appear as the event category. 'event_label': subActivity //