var cdnHost = "https://nx.betuscdn.com";var cdnHostShared = "https://a.betuscdn.com/libs";var dotNet4Host = "www.betus.com.pa";var smsOptApiPath = "https://api.betus.com.pa/api/v1";var ssoPath = "https://api.betus.com.pa/";var depositApiPath = "https://api.betus.com.pa/Deposit/";var chatFailedDepositUrl = "https://cb.betus.com.pa/chatbeacon/Sportsbook/8/?accountId=3&siteId=8&queueId=29&theme=blue&popout=true&pc=false&variables=true&customer={0}&skipprechat=true&skippostchat=true";var joinPixelsUrl = "/";// This file is added to .NET4, .NET5 and WP website. Any JS that is required cross-site needs to be added here.
// NOTE: In order to guarantee uniqueness all functions here needs to be prefixed with the word betUs
//***********************************************************************************************
// Added for Chat
//***********************************************************************************************
//@* NOTE: This function is used by CMS, on home page for example *@
function getChatElement() {
let clickyOnCurrentDocument = document.querySelector("#chatBeaconBtn button")
if (clickyOnCurrentDocument === undefined || clickyOnCurrentDocument == null) {
clickyOnCurrentDocument = parent.document.querySelector("#chatBeaconBtn button");
}
return clickyOnCurrentDocument;
}
function clicky() {
let ChatElement = getChatElement();
if (ChatElement != null) {
ChatElement.click();
}
}
(function () {
if (getChatElement() != null) {
return;
}
function async_load() {
var s = document.createElement('script');
let queueId = defaultChatQueueId === undefined || defaultChatQueueId == '' ? 45 : defaultChatQueueId;
if (isStringNullOrEmpty(customerId)) {
customerId = "0";
}
let isCasino = location.href.toLowerCase().includes('/online-casino')
let siteId = (typeof chatSiteId === 'undefined') ? (isCasino ? 7 : 4) : chatSiteId;
queueId = isCasino ? 22 : queueId;
s.type = 'text/javascript';
s.async = true;
s.src = `https://cb.betus.com.pa/chatbeacon/Sportsbook/${siteId}/scripts/chatbeacon.js?accountId=3&siteId=${siteId}&queueId=${queueId}&m=0&i=1&b=1&c=1&theme=frame&pc=false&skipprechat=true&skippostchat=true&variables=true&customer=${customerId}`;
var x = document.getElementsByTagName('head')[0];
x.appendChild(s);
}
if (window.attachEvent)
window.attachEvent('onload', async_load);
else
window.addEventListener('load', async_load, false);
})();
//***********************************************************************************************
// Public function
//***********************************************************************************************
const DepositVariantType = {
ClassicDeposit: 45001001,
QuickDeposit: 45001002,
M1Deposit: 45001003,
C1Deposit: 45001004,
MobileDeposit: 45002001,
DesktopDeposit: 45002002,
}
function showDepositPage() {
if (customerDepositMethodType == DepositVariantType.ClassicDeposit) {
betus_CallOldDepositModal('/deposits/');
} else {
betus_QuickDeposit(customerDepositMethodType);
}
}
//***********************************************************************************************
// Added Deposit Widget
//***********************************************************************************************
function betus_QuickDeposit(depositMethodVariant) {
window.parent.postMessage({
cmd: 'show_quick_deposit',
baseURL: depositApiPath,
ssoBaseURL: ssoPath,
loginURL: "/authentication/logout",
customerId,
customerObjectId,
password: "",
variant: depositMethodVariant,
sharedCDN: "cdnHostShared",
cdnhost: cdnHost == null ? 'https://nx.betuscdn.com' : cdnHost,
supportPhone: '+18009736659',
depositPhoneNumber: '+18885123887',
useCookie: true,
chatFailedDepositUrl
}, '*');
}
//***********************************************************************************************
// Added for VueJS
//***********************************************************************************************
function betus_SlimVueBackToSelectDepositMethod() {
window.parent.postMessage({
cmd: 'backToSelectDepositMethod'
}, '*');
}
function betus_SlimVueHideBackButton() {
window.parent.postMessage({
cmd: 'hideBack'
}, '*');
}
function betus_Open_sms_opt() {
if (!!customerId) {
let smsOptinJson = decodeURIComponent(getCookie('sop'))
if (smsOptinJson == '') {
return false;
} else {
if (localStorage.getItem('sop') != null && localStorage.getItem('sop') === `${customerId}:false`) {
setCookie('sop', '', -5);
return false;
}
smsOptinJson = JSON.parse(smsOptinJson);
if (smsOptinJson.action == "sms-opt" && smsOptinJson.showDialog == true) {
localStorage.setItem('freePlay', '$ ' + smsOptinJson.freePlay)
window.parent.postMessage({
cmd: "showsmsopt",
sharedCDN: cdnHostShared ? 'https://a.betuscdn.com/libs' : cdnHostShared,
cdnhost: cdnHost == null ? 'https://nx.betuscdn.com' : cdnHost,
apiPath: smsOptApiPath,
privacyURL: "https://www.betus.com.pa/privacy-policy/",
termsURL: "https://www.betus.com.pa/terms-conditions/",
customerId
}, "*");
setTimeout(function () {
setCookie('sop', '', -5);
}, 800)
}
}
}
}
function betus_ShowSlimVueJoin() {
let LoginModalIsOpen = document.querySelector('#loginModal.show .close');
if (LoginModalIsOpen != null) {
LoginModalIsOpen.click();
}
if (!window.location.hash.toLowerCase().includes('#join')) {
window.location.hash = window.location.hash + '#join'
}
window.parent.postMessage({
cmd: 'showJoin',
pixelPageURL: joinPixelsUrl == null ? '/' : joinPixelsUrl,
sharedCDN: cdnHostShared ? 'https://a.betuscdn.com/libs' : cdnHostShared,
cdnhost: cdnHost == null ? 'https://nx.betuscdn.com' : cdnHost,
}, '*');
}
function betus_ShowSlimVueDeposit(customerid) {
if (!window.location.hash.toLowerCase().includes('#deposit')) {
window.location.hash = window.location.hash + '#deposit'
}
window.parent.postMessage({
cmd: 'showDeposit',
cdnhost: cdnHost == null ? 'https://nx.betuscdn.com' : cdnHost,
pixelPageURL: joinPixelsUrl == null ? '/' : joinPixelsUrl,
sharedCDN: cdnHostShared ? 'https://a.betuscdn.com/libs' : cdnHostShared,
customerid
}, '*');
}
function betus_CallOldDepositModal(iframeSrc) {
ToggleSharedModal({
id: 'depositModal',
title: 'MAKE A DEPOSIT',
iframeSrc,
class: "",
callback: AfterDepositModalToggle
});
}
//***********************************************************************************************
// Moved from toolbar to be shared with .NET4
//***********************************************************************************************
function iResize() {
var iframeMain = document.getElementById('iframeMain');
if (iframeMain == null) {
return;
} else {
var iframeWrapper = document.getElementById('iframe-wrapper');
iframeMain.style.height = '200px';
iframeWrapper.style.height = '225px';
if (iframeMain != null) {
if (window.innerWidth > 650 &&
iframeMain.contentWindow.document.body.scrollHeight < window.innerHeight - 120) {
iframeMain.style.height =
iframeMain.contentWindow.document.body.scrollHeight + 'px';
iframeWrapper.style.height =
iframeMain.contentWindow.document.body.scrollHeight + 25 + 'px';
} else {
iframeMain.style.height = (window.innerHeight) - 145 + 'px';
iframeWrapper.style.height = (window.innerHeight) - 120 + 'px';
}
}
}
}
function IsMobileDisplay() {
let mobileSize = 992;
return jQuery(window).width() < mobileSize;
}
// Although we are using bootstrap's modal function, we want additional changes to layout on
// opening of the modal. (hiding join button for example)
function ToggleLoginModal() {
var isLoginModalOpen = jQuery('#loginModal').hasClass('show');
if (!isLoginModalOpen) {
//Adds the animation only if is mobile display
if (IsMobileDisplay()) {
jQuery(this).addClass('btn-expand');
jQuery('.btn-join, .navbar-toggler, .user-balances').hide(100);
}
jQuery('body').addClass('login-modal-active');
//Hides the navbar modal in case that it is open
if (jQuery('.animated-icon').hasClass('open')) {
jQuery('.animated').click();
}
} else {
if (IsMobileDisplay()) {
jQuery('.btn-login').removeClass('btn-expand');
jQuery('.btn-join, .user-balances').show();
}
jQuery('body').removeClass('login-modal-active');
//Check the screen size in order to display the hamburguer menu
if (jQuery(window).width() < 992)
jQuery('.navbar-toggler').show();
}
}
jQuery(document).ready(function () {
jQuery('.animated').on('click', function (e) {
jQuery('.animated-icon').toggleClass('open');
jQuery('body').toggleClass('menu-modal-active');
});
//ToggleLoginModal is defined on responsive-loginToolbar.ascx
jQuery('.btn-login').on('click', ToggleLoginModal);
});
jQuery(document).ready(function () {
jQuery('#loginModal button.close').on('click', ToggleLoginModal);
jQuery('.btn-login').on('click', ToggleLoginModal);
});
AfterDepositModalToggle = () => {
jQuery('#depositModal').on('shown.bs.modal', function (e) {
setTimeout(iResize, 100);
});
jQuery('#depositModal').on('hidden.bs.modal', function (e) {
document.getElementById('iframeMain').src = "";
});
}
closeSharedModal = id => {
document.getElementById(id).style.display = "none";
}
ToggleSharedModal = config => {
var html = `
`;
jQuery("#shared-modal-div").html(html);
window.closeModal = () => { closeSharedModal(config.id); }
if (typeof config.callback === "function")
config.callback();
document.getElementById(config.id).style.display = "block";
}
function betusJoinExpress(joinExpressUrl) {
if (typeof trackVirtualPageView === "function") {
trackVirtualPageView("express sign-up", "join express", "1", "step 1 (JX): open account");
}
ToggleSharedModal({
id: "express-sign-up-modal",
headerCls: "d-none",
class: "express",
iframeSrc: joinExpressUrl
});
}
//************************ Manage Cookie by js *************************
function setCookie(cookieName, cookieValue, expireDays) {
var currentDate = new Date();
currentDate.setTime(currentDate.getTime() + (expireDays * 24 * 60 * 60 * 1000));
var expires = 'expires=' + currentDate.toUTCString();
var domainName = document.location.hostname;
var domain = '';
if (domainName !== undefined && domainName != null && domainName != '') {
if (domainName === 'betus.com.pa' ||
domainName === '.betus.com.pa' ||
domainName === 'www.betus.com.pa' ||
domainName.includes('dev.') ||
domainName.includes('stg') ||
domainName.includes('r0.') ||
domainName.includes('r1.')) {
domain = '.betus.com.pa'
} else {
domain = 'localhost'
}
domain = ';Domain=' + domainName;
}
document.cookie = cookieName + '=' + cookieValue + ';' + expires + ';path=/' + domain;
}
function getCookie(cookieName) {
var name = cookieName + "=";
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var c = cookies[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return '';
}
function isExistCookie(name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
return true;
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) {
break;
}
}
return false;
}
function getCookieValueByName(name) {
var value = '; ' + document.cookie;
var parts = value.split('; ' + name + '=');
if (parts.length == 2) {
return parts
.pop()
.split(';')
.shift();
}
}
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
jQuery.fn.clearValidation = function () {
var v = jQuery(this).validate();
jQuery('[name]', this).each(function () {
v.successList.push(this);
v.showErrors();
});
v.resetForm();
v.reset();
};
function HideContent(d) {
if (d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if (d.length < 1) { return; }
var dd = document.getElementById(d);
dd.style.display = "block";
}
// TODO: Refactor. This is not a utility method and is page specific
function validateAge(yearId, monthId, dayId, ageErrorMessage) {
const year = jQuery(`#${yearId}`).val();
const month = jQuery(`#${monthId}`).val();
const day = jQuery(`#${dayId}`).val();
return validateBirthDate(year, month, day, ageErrorMessage);
}
function validateBirthDate(year, month, day, ageErrorMessage) {
const isFullDateSelected = (year.length > 0 && month.length > 0 && day.length > 0);
var ageIsValid = false;
if (isFullDateSelected) {
const dob = `${year}/${month}/${day}`;
const validateDayNumberOfMonthResult = validateDayNumberOfMonth(`${month}/${day}/${year}`);
if (!validateDayNumberOfMonthResult.dateIsValid) {
if (isStringNullOrEmpty(validateDayNumberOfMonthResult.message)) {
jQuery("#age-is-over-18-validation-container").html(`Please enter a valid date.`);
} else {
jQuery("#age-is-over-18-validation-container").html(`Please enter a valid day between 1 and ${validateDayNumberOfMonthResult.message}.`);
}
return false;
}
const today = new Date();
const birthDate = new Date(dob);
let age = today.getFullYear() - birthDate.getFullYear();
const m = today.getMonth() - birthDate.getMonth();
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
ageIsValid = age >= 18;
if (!ageIsValid) {
jQuery("#age-is-over-18-validation-container").html(`${ageErrorMessage}`);
} else {
jQuery("#age-is-over-18-validation-container").empty();
}
}
return ageIsValid;
}
//accepted dateString format is 'mm/dd/yyyy'
function validateDayNumberOfMonth(dateString) {
const result = {
dateIsValid: false,
message: ""
};
const dateFormat = /^(0?[1-9]|1[0-2])[\/](0?[1-9]|[1-2][0-9]|3[01])[\/]\d{4}$/;
if (dateString.match(dateFormat)) {
const operator = dateString.split("/");
let datepart = [];
if (operator.length > 1) {
datepart = dateString.split("/");
}
const month = parseInt(datepart[0]);
const day = parseInt(datepart[1]);
const year = parseInt(datepart[2]);
if (month === 1 || month > 2) {
const listOfDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if (day > listOfDays[month - 1]) {
result.message = listOfDays[month - 1];
return result;
}
} else if (month === 2) {
const leapYear = isLeapYear(year);
if ((leapYear === false) && (day >= 29)) {
result.message = "28";
return result;
} else if ((leapYear === true) && (day > 29)) {
result.message = "29";
return result;
}
}
} else {
return result;
}
result.dateIsValid = true;
return result;
}
function isLeapYear(year) {
let leapYear = false;
if ((!(year % 4) && year % 100) || !(year % 400)) {
leapYear = true;
}
return leapYear;
}
function setFocusOnFirstMissingItem(formId) {
const input = jQuery(".input-validation-error:first");
if (input && formId !== undefined) {
input.focus();
}
}
function setErrorMessages(errorMessageElementId, errorMessage, inputId) {
jQuery(`#${errorMessageElementId}`).html(errorMessage);
if (errorMessage !== undefined && errorMessage !== null && errorMessage !== "") {
jQuery(`#${inputId}`).addClass('input-validation-error');
} else {
jQuery(`#${inputId}`).removeClass('input-validation-error');
}
}
function removeErrorMessages(errorMessageElementId, inputId) {
jQuery(`#${errorMessageElementId}`).html('');
jQuery(`#${inputId}`).removeClass('input-validation-error');
}
function showErrorMessage(errorFieldId, inputField = null, isFocussed = false, hiddenErrorCls = "d-none") {
let errorField = jQuery(errorFieldId);
errorField.removeClass(hiddenErrorCls);
if (isFocussed)
jQuery(inputField).focus();
}
(function (jQuery) {
jQuery.fn.serializeFormJSON = function () {
var o = {};
const a = this.serializeArray();
jQuery.each(a, function () {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
})(jQuery);
function findValueInArrayOfObject(array, key, value) {
var index = -1;
for (let i = 0; i < array.length; i++) {
if (array[i][key] === value) {
index = i;
break;
}
}
return index;
}
function isStringNullOrEmpty(value) {
return typeof value === 'undefined' ||
value === null ||
(typeof value === 'string' && (!value || !value.trim() || value.trim() === '' || value.trim() === "" || value.length === 0 || value.trim().length === 0));
}
function isFunction(value) {
var getType = {};
return value &&
value !== null &&
typeof value !== 'undefined' &&
typeof value === 'function' &&
getType.toString.call(value) === '[object Function]' &&
value instanceof Function;
}
function isFieldValueNullOrEmpty(fieldId) {
const field = jQuery(`#${fieldId}`);
if (field) {
return isStringNullOrEmpty(field.val());
} else
return false;
}
function isEmailValid(mail) {
if (isStringNullOrEmpty(mail)) {
return false;
}
const pattern = /^(([^<>()\[\]\\.,;:\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 pattern.test(mail);
}
function validateNumericInput(evt) {
var digitOnly = String.fromCharCode(evt.which);
if (!(/[0-9]/.test(digitOnly))) {
evt.preventDefault();
}
}
// TODO: Refactor. This is not a utility method and is page specific
function addTemporaryCustomerInfo(id, url) {
var model = jQuery(`#${id}`).serializeFormJSON();
model.LeadSourceTypeId = jQuery('#LeadSourceTypeId :selected').text();
jQuery.ajax({
url: url,
data: {
"jsonData": JSON.stringify(model)
},
type: 'POST',
beforeSend: function (xhr) {
xhr.setRequestHeader("XSRF-TOKEN",
jQuery('input:hidden[name="__RequestVerificationToken"]').val());
}
});
};
function IsEmptyOrWhitespace(fieldId, messageFieldId, errorMessage) {
var result = true;
const field = jQuery(`#${fieldId}`);
const fieldVal = field.val();
if (fieldVal !== undefined && fieldVal !== null && !fieldVal.replace(/\s/g, '').length) {
jQuery(`#${messageFieldId}`)
.html(`${errorMessage}`);
field.addClass("input-validation-error");
} else {
jQuery(`#${messageFieldId}`).empty();
field.removeClass("input-validation-error");
result = false;
}
return result;
}
function avoidWhitespace(event) {
var key = event.keyCode;
if (key === 32) {
event.preventDefault();
} else if (event.clipboardData || window.clipboardData) {
const pastedText = (event.clipboardData || window.clipboardData).getData('text');
if (hasWhiteSpace(pastedText)) {
event.preventDefault();
}
}
}
function hasWhiteSpace(s) {
return /\s/g.test(s);
}
function convertStringToFloat(str) {
if (isStringNullOrEmpty(str) || isNaN(str)) {
return 0;
}
return parseFloat(str);
}
function convertStringToFloatWithDecimalPointCount(str, floatingLength) {
return convertStringToFloat(str).toFixed(floatingLength);
}
function getEnvironment() {
var domainName = window.location.hostname;
if (domainName.includes("localhost") ||
domainName.includes("tst.") ||
domainName.includes("dev.") ||
domainName.includes("stg.")) {
environmentName = "test";
} else {
environmentName = "prod";
}
return environmentName;
}
function isMobile() {
var check = false;
(function (a) {
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4)))
check = true;
})(navigator.userAgent || navigator.vendor || window.opera);
return check;
};