Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Search codebase for "visible-xs navbar-fixed-top mobile header-en"
- (class attribute values of top header which is getting injected after page-load by JS)
- ------------------------------------------------------------
- // ALC COMMON FUNCTIONS
- var ALC = ALC || {};
- ALC.constants = {
- CONTENT_ROOT: '/content/alc/',
- MY_PROFILE_PATH : '/my-account/my-profile.html',
- REINSTATEMENT_CONFIRMATION_PATH: '/self-exclusion-reinstatement/reinstatement-confirmation.html',
- SELF_EXCLUSION_PATH: '/my-account/play-responsibly.html#3',
- DIGITAL_INSTANTS_WRAPPER: '/play-online/instant-win-games/game.html?',
- REVERIFY_PATH: '/registration/reverify-account.html',
- LOGIN_REDIRECT_PATH: '/login.html?redirectUrl=',
- CART_PATH: '/cart.html',
- CHECKOUT_PATH: '/checkout.html',
- CHECKOUT_PENDING_PATH: '/checkout-pending.html',
- CONFIRMATION_REDIRECT_PATH: '/confirmation.html',
- ADD_FUNDS_PATH: '/my-account/add-withdraw-funds.html#0_1',
- PAYMENT_PREFERENCES_PATH: '/my-account/add-withdraw-funds.html#1',
- AEM_DISPATCHER_FAILOVER_PATH: '/errors/error.html',
- LOTTOMAX_JPID: ALC.applicationProperties.LottoMax_JPID,
- LOTTO649_JPID: ALC.applicationProperties.Lotto649_JPID,
- SALSABINGO_JPID: ALC.applicationProperties.SalsaBingo_JPID,
- ATLANTIC49_JPID: ALC.applicationProperties.Atlantic49_JPID,
- KENOATLANTIC_JPID: ALC.applicationProperties.KenoAtlantic_JPID,
- BUCKO_JPID: ALC.applicationProperties.Bucko_JPID,
- POKERLOTTO_JPID: ALC.applicationProperties.PokerLotto_JPID,
- DAILYGRAND_JPID: ALC.applicationProperties.DailyGrand_JPID,
- LOTTO4_JPID: ALC.applicationProperties.Lotto4_JPID,
- lottoTicketErrorStates: [-1,0,4,6],
- lottoTicketAdvanceErrorStates: [-1,0,2,7,8]
- };
- /**
- * isMobileSafari
- * Fixes long-standing iOS "fixed position modal" bug
- * @returns boolean true if the RegEx of the User Agent string evaluates as iOS/WebKit
- */
- function isMobileSafari () {
- return ( /iP(hone|od|ad)/i.test(navigator.userAgent) && /WebKit/i.test(navigator.userAgent) && !/Chrome|CriOS|OPiOS/i.test(navigator.userAgent) );
- }
- // Modal on iOS Safari needs a window listener to maintain 100% WxH scale (orientation flips or screen focus/resize)
- if ( isMobileSafari() ) {
- $(window).resize(function(){
- $(".modal-login").css("width","100vw");
- $(".modal-login").css("height","100vh");
- $("body").css("height","100vh");
- });
- }
- ALC.common = {
- dashboardPromise: null,
- termsOfServicePromise: null,
- lang: $("html").attr("lang"),
- allowCharacters: function(myfield, event, allowedType) {
- if(event.altKey){
- event.preventDefault();
- return;
- }
- var elm = $(myfield),
- elmVal = elm.val(),
- code;
- if (event.keyCode){
- code = event.keyCode;
- } else if(event.which){
- code = event.which;
- }
- // Allow: backspace, insert, delete, tab, escape, enter, home, end, left, right, num lock
- if ($.inArray(code, [45, 46, 8, 9, 27, 13, 35, 36, 37, 39, 144]) !== -1 ||
- // Allow: Ctrl+A, Command+A
- (code == 65 && ( event.ctrlKey === true || event.metaKey === true ))){
- return;
- }
- if(elm.attr('arrowinput') === 'disabled'){
- if($.inArray(code, [38, 40]) !== -1){
- event.preventDefault();
- return;
- }
- } else {
- if($.inArray(code, [38, 40]) !== -1){
- // Allow up and down
- return;
- }
- }
- if(allowedType === 'numericonly'){
- if(elm.attr('step') === '1'){
- if($.inArray(code, [110, 190]) !== -1){
- event.preventDefault();
- return;
- }
- } else if(elm.attr('step') === '0.01'){
- if($.inArray(code, [110, 190]) !== -1 && $.inArray(ALC.common.numericOnly.lastTyped, [110, 190]) !== -1){ // prevent 2 consecutive decimal points
- event.preventDefault();
- return;
- } else if(elmVal.indexOf('.') !== -1) {
- var fraction = elmVal.split('.')[1];
- if(fraction && fraction.length === 2){
- event.preventDefault();
- return;
- }
- }
- ALC.common.numericOnly.lastTyped = code;
- }
- // If not a number or decimal point stop the event
- if ((event.shiftKey || (code < 48 || code > 57)) &&
- (code < 96 || code > 105) &&
- $.inArray(code, [110, 190]) === -1){
- event.preventDefault();
- }
- } else if(allowedType === 'alphanumericonly'){
- //Detect Chrome for Android
- if (code === 0 || code === 229){
- var regexSpecialChars = new RegExp("/[^A-Z0-9]/gi");
- if (regexSpecialChars.test(myfield.value)){
- myfield.value = myfield.value.replace(/[^A-Z0-9]/gi, '');
- return;
- }
- }
- // If not alphanumeric stop the event
- if (event.originalEvent.type === "keypress"){
- if(!((code >= 97) && (code <= 122) || (code >= 48) && (code <= 57))){
- event.preventDefault();
- return;
- }
- }else{
- //for keyup & keydown
- if(!((code >= 65) && (code <= 90) || (code >= 96) && (code <= 105) || (code >= 48) && (code <= 57))){
- event.preventDefault();
- return;
- }
- }
- //Includes french language special characters
- var regex = new RegExp("^[a-zA-Z0-9]+$");
- var regexAlphaOnly = new RegExp("^[a-zA-Z]+$");
- var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
- if ((!regex.test(event.key) || !regex.test(key)) || (event.key === undefined && event.shiftKey === true)) {
- if(!regexAlphaOnly.test(key)){
- event.preventDefault();
- return;
- }
- }
- }
- },
- numericOnly: function(event) {
- ALC.common.allowCharacters(this, event, 'numericonly');
- },
- alphaNumericOnly: function(event){
- ALC.common.allowCharacters(this, event, 'alphanumericonly');
- },
- shortProvince: function(province){
- switch (province){
- case "Nova Scotia":
- return Granite.I18n.get("NS");
- case "New Brunswick":
- return Granite.I18n.get("NB");
- case "PEI":
- return Granite.I18n.get("PE");
- case "Newfoundland":
- return Granite.I18n.get("NL");
- default:
- return "No Atlantic Province Found";
- }
- },
- numberFormat: function(number, locale){
- if (locale === 'en-ca' || locale === 'en') {
- return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
- } else {
- //FRENCH NUMBER
- return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
- }
- },
- priceFormat: function(number, locale, digits, dollarspan){
- var fixedDigits = isNaN(digits) ? 2 : digits,
- dollarSign;
- number = parseFloat(number).toFixed(fixedDigits);
- if(dollarspan === true){
- dollarSign = "<span class='dollarSign'>$</span>"
- } else {
- dollarSign = "$";
- }
- if (locale === 'en-ca' || locale === 'en') {
- //ENGLISH PRICE Negative
- if (number < 0){
- number = number.replace(/[^0-9.]/g, "");
- return '-'+dollarSign + number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
- }
- //ENGLISH PRICE
- return dollarSign + number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
- } else {
- //FRENCH PRICE
- return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ").replace('.', ',') + " " + dollarSign;
- }
- },
- priceFormatHTML: function(number){
- var twoDecimalPlaces = (number % 1 != 0) ? parseFloat(Math.round(number * 100) / 100).toFixed(2) : number;
- return '<span>' + twoDecimalPlaces.toString().replace(/\B(?=(\d{3})+(?!\d))|(?=(\.))/g, "</span><span>") + "</span>";
- },
- getLang : function(){
- return Cookies.get('locale');
- },
- getShortLang : function() {
- return ALC.common.getLang() === "fr-ca" ? "fr" : "en";
- },
- getLocale : function() {
- return ALC.common.getLang() === "fr-ca" ? "fr_CA" : "en_CA";
- },
- isEditMode : function() {
- return (CQ.WCM !== null && typeof CQ.WCM === 'object' && typeof CQ.WCM.isEditMode === 'function' && CQ.WCM.isEditMode());
- },
- enableButton : function(targetButton) {
- targetButton.prop('disabled', false);
- },
- parseMomentDateFromFeed : function(rawDateString){
- // Assumes rawDateString is "\/Date(1435719600000-0300)\/" format
- var parsedDate = rawDateString.match(/\d+/g);
- return moment(parseInt(parsedDate[0])).utcOffset("-" + parsedDate[1]);
- },
- scrollTop: function(rootEl){
- $(rootEl).find('.scroll-top').on('click', function(e){
- e.preventDefault();
- $("html, body").animate({ scrollTop: 0 }, "slow");
- });
- },
- breadcrumbsPathChange: function(pageID, pageTitle) {
- $(pageID).find('.currentPage').text(pageTitle);
- },
- getHashParams : function() {
- var hashParams = {};
- var e,
- a = /\+/g, // Regex for replacing addition symbol with a space
- r = /([^&;=]+)=?([^&;]*)/g,
- d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
- q = window.location.hash.substring(1);
- while (e = r.exec(q))
- hashParams[d(e[1])] = d(e[2]);
- return hashParams;
- },
- fetchNewTermsOfService: function() {
- var locale = Cookies.get("locale");
- if (!locale) locale = "en-ca";
- ALC.common.termsOfServicePromise = Q($.ajax({
- url : "/services/pam/GetTermsOfService?subJurisdictionId=1&locale=" + locale,
- dataType: "json"
- }));
- return ALC.common.termsOfServicePromise;
- },
- fetchTermsOfService: function() {
- if (!ALC.common.termsOfServicePromise) ALC.common.fetchNewTermsOfService();
- return ALC.common.termsOfServicePromise;
- },
- termsModalLaunch : function() {
- ALC.common.fetchTermsOfService().then(function(data) {
- var termsText = data.TermsOfService || "";
- $('#terms-modal .modal-body').html(termsText);
- $('#termsId').val(data.TermsOfServiceId);
- }).fail(function(errordata) {
- console.log("CAN'T GET TERMS: ", errordata);
- });
- },
- privacyModalLaunch : function() {
- var lang = (Cookies.get("locale") == "fr-ca") ? "fr" : "en";
- $.ajax({
- url : "/content/alc/" + lang + "/legal/privacy-policy.infinity.json",
- success : function(data){
- var policyText = data['jcr:content']['privacyPolicy'].text;
- $('#privacy-modal .modal-body').html(policyText);
- },
- error : function(errordata){
- console.log("CAN'T GET PRIVACY POLICY: ", errordata);
- }
- });
- },
- getQueryParameters : function(str) {
- return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
- },
- fetchNewUserDashboard : function() {
- var dashboardAjax = function(){
- return $.ajax({
- url: "/services/pam/Dashboard",
- dataType: "json",
- cache: false
- });
- };
- ALC.common.dashboardPromise = Q(dashboardAjax()).then(function(data){
- if(data.error_code === 500 || data.error_code === 408){
- // Add a one-time retry in the event the dashboard call fails
- return Q(dashboardAjax());
- }
- return data;
- });
- return ALC.common.dashboardPromise;
- },
- fetchUserDashboard : function(){
- if (!ALC.common.dashboardPromise) ALC.common.fetchNewUserDashboard();
- return ALC.common.dashboardPromise;
- },
- /**
- * Updates the data-verify-url data attr or returns the users login+verified status.
- *
- * @param {object} dashboard - The expectation is that this will be
- * a dashboard object retrieved from a fetchUserDashboard call.
- *
- * @param {jQuery object} $linkEl - A jQuery wrapped <a> element
- * If this parameter is included, then the function will update
- * the element's data attr accordingly. If it isn't included, then
- * the function will return the state (for a knockout bind to use)
- * (Optional)
- */
- verifyLink : function(dashboard, $linkEl){
- var userLimitStatus,
- userLimitOnly;
- if (!dashboard || !ALC.UserInfo.isLoggedIn()) {
- userLimitStatus = 'GUEST';
- } else if (dashboard.IsAgeVerified === false){
- userLimitStatus = 'REVERIFY';
- } else if (dashboard.IsAgeVerified === true) {
- if (dashboard.ExclusionType && dashboard.ExclusionType != "NotExcluded"){
- userLimitStatus = "EXCLUDED";
- } else {
- userLimitStatus = null;
- }
- } else {
- userLimitStatus = 'GUEST';
- }
- if ($linkEl) {
- userLimitOnly = $linkEl.attr('data-verify-only');
- if (!userLimitStatus) {
- $linkEl.removeAttr('data-verify-url');
- if(userLimitOnly){
- $linkEl.removeAttr('data-verify-only');
- }
- } else {
- if(userLimitOnly){
- if(userLimitOnly.indexOf(userLimitStatus) === -1){
- $linkEl.removeAttr('data-verify-url');
- } else {
- $linkEl.attr('data-verify-url', userLimitStatus);
- }
- $linkEl.removeAttr('data-verify-only');
- } else {
- $linkEl.attr('data-verify-url', userLimitStatus);
- }
- }
- }
- return userLimitStatus;
- },
- launchLoginModal : function(){
- if (typeof NativeApp === 'object' && NativeApp !== null && typeof NativeApp.login === 'function') {
- NativeApp.login();
- return false;
- }
- return ALC.Modal.showModal({
- id: "modal-login",
- onShow: function() {
- if(ALC.common.sessionStorage.getItem('sessionExpires', true)) {
- $('.modal-login').find('.account-timeout').removeClass('hidden');
- ALC.common.sessionStorage.removeItem('sessionExpires', true);
- }
- if(ALC.common.sessionStorage.getItem('sessionError', true)) {
- $('.modal-login').find('.session-error').removeClass('hidden');
- ALC.common.sessionStorage.removeItem('sessionError', true);
- }
- //iOS fix
- if ( isMobileSafari() ) {
- //set modal to have absolute positioning rather than Fixed for iOS/Safari combo
- $(".modal-login").css("position","absolute");
- //all other elements need to be hidden
- $("body > :not(.modal-login)").hide();
- $(window).trigger("resize");
- }
- },
- onHidden: function() {
- $('.modal-login').find('.account-timeout, .session-error').addClass('hidden');
- if(ALC.common.sessionStorage.getItem('sessionExpires', true)) {
- ALC.common.sessionStorage.removeItem('sessionExpires', true);
- }
- if(ALC.common.sessionStorage.getItem('sessionError', true)) {
- ALC.common.sessionStorage.removeItem('sessionError', true);
- }
- //iOS fix
- if ( isMobileSafari() ) {
- //all other elements shown again
- $("body > :not(.modal-login)").show();
- $(window).trigger("resize");
- }
- }
- });
- },
- alcLogin : function(email, password, componentRoot, reloadPage, mobileapp) {
- function requestLogin(loginData) {
- Q(mobileapp || loginRequest(loginData))
- .then(checkLoginResponseMessage)
- .then(promoteAnonymousCartRequest)
- .then(reloadPageOnSuccess);
- }
- var loginRequest = function(loginData) {
- return Q($.ajax({
- type: 'POST',
- dataType: 'json',
- contentType: "application/json",
- url:'/services/pam/Login',
- data: loginData
- }));
- };
- var checkLoginResponseMessage = function(response) {
- if (response.error_code) {
- loginFail(response.message || response.MessageCode || Granite.I18n.get('Login Error'));
- // AJAX was successful but service threw an error
- throw response;
- } else {
- // if player has Post-Exclusion Reinstatement flag set, redirect to self-exclusion-reinstatement video page
- if ($.inArray("MUST_ACCEPT_EXCLUSION_EXPIRE", response.Player.playerStateFlag) !== -1) {
- ALC.common.sessionStorage.setItem('REVERIFY_URL',ALC.constants.CONTENT_ROOT + ALC.common.getShortLang() + '/self-exclusion-reinstatement.html');
- }
- }
- };
- var promoteAnonymousCartRequest = function() {
- var anonCartId = Cookies.get('AnonymousCartId');
- if (!anonCartId) return true;
- return Q($.ajax({
- type: 'POST',
- url: '/services/cart/PromoteAnonymousCart?AnonCartId=' + anonCartId,
- contentType: 'application/json'
- })).then(function(response) {
- if (response.error_code) {
- // AJAX was successful but service threw an error
- if(!mobileapp){
- promoteAnonymousCartFail(response.error_code);
- }
- throw response;
- } else {
- Cookies.remove('AnonymousCartId', { path: '/' }, {domain: 'alc.ca'});
- return response;
- }
- });
- };
- var promoteAnonymousCartFail = function(err) {
- $('.modal-body, .modal-header').addClass('hidden');
- $('#promote-anonymous-cart-alert').removeClass('hidden').insertAfter('.modal-header');
- };
- var loginFail = function(err) {
- $(componentRoot).find('.wrong-credentials').removeClass('hidden').html('<div class="error-message-content">' + $("<textarea/>").html(err).text() + '</div>');
- };
- var reloadPageOnSuccess = function() {
- if ($('#page-login').length) {
- window.location.href = decodeURIComponent(ALC.common.getQueryParameters().redirectUrl);
- } else if (ALC.common.sessionStorage.getItem('sessionReturnURL')) {
- var returnURL = ALC.common.sessionStorage.getItem('sessionReturnURL');
- ALC.common.sessionStorage.removeItem('sessionReturnURL');
- window.location = returnURL;
- } else if (ALC.common.sessionStorage.getItem('REVERIFY_URL')) {
- var reverifyUrl = ALC.common.sessionStorage.getItem('REVERIFY_URL');
- ALC.common.sessionStorage.removeItem('REVERIFY_URL');
- window.location.href = reverifyUrl;
- } else if (reloadPage) {
- window.location.reload(true);
- }
- };
- var geoRequestLogin = function (geoData) {
- var geoLocation = {
- IpAddress : JSON.parse(geoData).IpAddress,
- GeoLocation: JSON.parse(geoData)
- };
- // Get User Credentials
- var userCredentials = {
- EmailUserName: email,
- Password: password,
- AuditData : geoLocation
- };
- if (Cookies.get("Referrer")) {
- userCredentials.Referrer = Cookies.get("Referrer");
- }
- var userCredentialsJSON = JSON.stringify(userCredentials);
- requestLogin(userCredentialsJSON);
- };
- ALC.common.getIPGeolocation()
- .then(function(data){
- geoRequestLogin(data);
- })
- .fail(function (error) {
- loginFail("Geolocation Failed");
- });
- },
- alcLogout : function(redirecturl){
- var userCookies = ["PlayerCardId","LoginTime","CartHandle","AnonymousCartId","WalletId","locale","AuthTokenExpires","AuthSignature","InactivitySeconds","SessionSignature","Province","NickName", "LastActivity"];
- var endSession = function(){
- //Clear cookies/data before calling BE endSession service
- ALC.UserInfo.isLoggedIn(false);
- for (var i = 0; i < userCookies.length; ++i) {
- Cookies.remove(userCookies[i], { path: '/', domain: '.alc.ca'});
- }
- ALC.userUrchinTracking.removeUTMString();
- return Q($.ajax({
- url: '/services/pam/EndSession',
- type: 'POST'
- }).then(function(response){
- if(response !== "success"){
- throw response;
- }
- return response;
- }));
- };
- endSession().then(function(){
- if(redirecturl) {
- window.location.href = redirecturl;
- }
- if(typeof NativeApp === 'object'){
- NativeApp.logout();
- }
- }).fail(function(error){
- console.error('endSession() =>', error);
- });
- },
- ticketsSubmit: function( ticketsArr ){
- Q( ALC.common.packageTicketsJSON( ticketsArr ) )
- .then( ALC.common.sendToCart )
- .then( ALC.common.handleCartResponse )
- .fail( ALC.common.handleSubmitFail );
- },
- lookupBetTypeId : function(jackpotId, betType) {
- switch(jackpotId){
- case ALC.constants.DAILYGRAND_JPID : // Daily Grand
- switch(betType){
- case "CBO5" :
- return "105";
- default:
- return "100";
- }
- case ALC.constants.LOTTOMAX_JPID : // Lotto Max
- switch(betType){
- case "CBO6" :
- return "106";
- case "CBO8" :
- return "108";
- case "CBO9" :
- return "109";
- default :
- return "100";
- }
- case ALC.constants.LOTTO649_JPID : // Lotto 6/49
- switch(betType){
- case "CBO5" :
- return "105";
- case "CBO7" :
- return "107";
- case "CBO8" :
- return "108";
- case "CBO9" :
- return "109";
- default :
- return "100";
- }
- case ALC.constants.KENOATLANTIC_JPID : // Keno-Atlantic
- switch(betType){
- case "2Spot" :
- return "102";
- case "3Spot" :
- return "103";
- case "4Spot" :
- return "104";
- case "5Spot" :
- return "105";
- case "6Spot" :
- return "106";
- case "7Spot" :
- return "107";
- case "8Spot" :
- return "108";
- case "9Spot" :
- return "109";
- case "10Spot" :
- return "110";
- default :
- return "100";
- }
- default :
- return "100";
- }
- },
- getCombinationName : function(combination){
- if(typeof combination === "string"){
- return Granite.I18n.get("Combination - {0}", [parseInt(combination.slice(3), 10)])
- }
- },
- distributeAddons : function(tickets, addons, index) {
- var fatTickets = addons % tickets,
- commonNumber = Math.floor(addons/tickets);
- return (index < fatTickets) ? commonNumber + 1 : commonNumber;
- },
- packageTicketsJSON: function(response){
- var ItemsObj = [];
- $(response.itemsConfig.games).each(function(index){
- var addonsObj = this.AddOns,
- itemsObj = this.Items,
- totalCost = 0,
- jackpotId = String(itemsObj.JackpotId),
- jackpotName = String(itemsObj.JackpotName),
- inPerpetuity = Boolean(this.Subscribe),
- advanceDraws = parseInt(this.AdvanceDraws);
- $(itemsObj.Numbers).each(function(index){
- var addonsCost = 0;
- if( addonsObj ){
- var AddOns = $.map(addonsObj, function(data) {
- var count = ALC.common.distributeAddons(itemsObj.Numbers.length, parseInt(data.count), index),
- cost = parseInt(data.cost);
- if(count){
- addonsCost += count * cost;
- }
- return {
- "AddonName": String(data.name),
- "Count": count,
- "Numbers": "",
- "Cost": count * cost,
- "UnitCost": cost
- };
- });
- }
- var Panels = [],
- panelNumbers = this[0].toString(),
- betType = this[1].toString(),
- ticketCost = parseInt(this[2]),
- quickPicks = parseInt(this[3]),
- totalCost = (addonsCost + ticketCost)*advanceDraws,
- panel = {
- "Numbers": panelNumbers,
- "BetType": betType,
- "QuickPicks": quickPicks,
- "CostPerDraw": ticketCost + addonsCost,
- "CostBasis": ticketCost,
- "ComboBet": ""
- };
- Panels.push(panel);
- //Daily Grand -- Only add if NOT a combo play
- if (jackpotName === "DailyGrand" && this[1].toString().substring(0,3) !== "CBO"){
- var grandNumber = {
- "Numbers": this[4],
- "BetType":this[1].toString(),
- "QuickPicks":(quickPicks) ? 1 : 0,
- "CostPerDraw":0,
- "CostBasis":0,
- "ComboBet":""
- };
- Panels.push(grandNumber);
- }
- var subscriptionItem = {
- "SubscriptionItem":{
- "LottoPanelsContainer": {
- "JackpotId": jackpotId,
- "Multiplier": false,
- "MidDay":false,
- "Panels": Panels
- },
- "AddonPanelsContainer": {
- "AddonsCostPerDraw": addonsCost,
- "Panels": AddOns
- },
- "PlayerGroupId": null,
- "JackpotId": jackpotId,
- "NumDraws": advanceDraws,
- "InPerpetuity": inPerpetuity,
- "TotalCost": totalCost,
- "JackpotName": jackpotName,
- "BetTypeId": ALC.common.lookupBetTypeId(itemsObj.JackpotId, betType),
- "BetTypeCost": ticketCost,
- "CostPerDraw": ticketCost + addonsCost
- }
- };
- ItemsObj.push(subscriptionItem);
- });
- });
- ALC.common.gaECommerce.addToCartItems = ItemsObj;
- var itemsJSON = JSON.stringify({"Items": ItemsObj});
- return itemsJSON;
- },
- sendToCart : function( itemsJSON ){
- return Q($.ajax({
- url :'/services/cart/AddItemsToCart',
- data : itemsJSON,
- dataType: 'json',
- contentType: "application/json",
- type: 'POST'
- }));
- },
- handleCartResponse : function(response) {
- if(response.error_code) {
- throw response;
- } else {
- ALC.common.gaECommerce.addToCart(ALC.common.gaECommerce.createProductsList(ALC.common.gaECommerce.addToCartItems));
- ALC.common.gaECommerce.addToCartItems = null;
- var locale = locale || ALC.common.getShortLang();
- window.location = ALC.constants.CONTENT_ROOT + locale + ALC.constants.CART_PATH + '?Updated=' + new Date().getTime();
- }
- },
- gaECommerce : {
- productImpression : function(products) {
- dataLayer.push({
- 'ecommerce' : {
- 'detail' : {
- 'products' : products
- }
- }
- });
- },
- addToCartItems : null,
- createProductsList : function(items) {
- var products = [];
- items.forEach(function(ticket){
- products.push(
- {
- 'name': ticket.SubscriptionItem.JackpotName,
- 'id': ticket.SubscriptionItem.JackpotId,
- 'price': ticket.SubscriptionItem.BetTypeCost/100,
- 'brand': ticket.SubscriptionItem.JackpotName,
- 'category': ALC.common.gaECommerce.lookUpGTMCategory(ticket.SubscriptionItem.JackpotName),
- 'quantity': ticket.SubscriptionItem.NumDraws
- }
- );
- ticket.SubscriptionItem.AddonPanelsContainer.Panels.forEach(function(addon){
- products.push(
- {
- 'name': addon.AddonName,
- 'id': ALC.common.gaECommerce.lookUpGTMAddonId(addon.AddonName),
- 'price': addon.UnitCost/100,
- 'brand': addon.AddonName,
- 'category': ALC.common.gaECommerce.lookUpGTMCategory(addon.AddonName),
- 'quantity': addon.Count * ticket.SubscriptionItem.NumDraws
- }
- );
- });
- });
- var productsCollection = products.reduce(function(collection, product){
- if(!collection[product.name]){
- collection[product.name] = product;
- } else {
- collection[product.name].quantity += product.quantity;
- }
- return collection;
- }, Object.create(null));
- products.length = 0;
- Object.keys(productsCollection).forEach(function(key){
- products.push(productsCollection[key]);
- });
- return products;
- },
- addToCart : function(products) {
- if(!products.length) return;
- dataLayer.push({
- 'event': 'addToCart',
- 'ecommerce': {
- 'currencyCode': 'CAD',
- 'add': {
- 'products': products
- }
- }
- });
- },
- removeFromCart : function(products) {
- if(!products.length) return;
- dataLayer.push({
- 'event': 'removeFromCart',
- 'ecommerce': {
- 'currencyCode': 'CAD',
- 'add': {
- 'products': products
- }
- }
- });
- },
- cartCheckout : function(products) {
- if(!products.length) return;
- dataLayer.push({
- 'event': 'checkout',
- 'ecommerce': {
- 'checkout': {
- 'actionField': {
- 'step': 1,
- 'option': 'Wallet'
- },
- 'products': products
- }
- }
- });
- },
- cartConfirmation : function(order, products) {
- if(!products.length) return;
- dataLayer.push({
- 'event': 'purchase',
- 'ecommerce': {
- 'purchase': {
- 'actionField': {
- 'id': order.PurchaseId,
- 'revenue': (order.TotalCost/100).toFixed(2)
- },
- 'products': products
- }
- }
- });
- },
- lookUpGTMCategory : function(name){
- switch(name) {
- case 'Lotto649' :
- case 'LottoMax' :
- case 'Atlantic 49' :
- case 'Tag' :
- case 'Bucko' :
- case 'SalsaBingo' :
- case 'KenoAtlantic' :
- case 'DailyGrand' :
- case 'Twist' :
- return 'Lottery';
- default :
- return '';
- }
- },
- lookUpGTMAddonId : function(name){
- switch(name) {
- case 'Atlantic 49' :
- return '6';
- case 'Tag' :
- return '9';
- case 'Twist' :
- return '3';
- default :
- return '';
- }
- }
- },
- handleSubmitFail : function(error){
- console.log("Fail to submit to cart:", error);
- ALC.common.enableButton($('button[data-action="addtocart"]'));
- },
- getSubscriptionDraws : function(gameid) {
- switch(gameid) {
- case ALC.constants.ATLANTIC49_JPID : // atlantic-49 ex 17
- return 2*4;
- case ALC.constants.BUCKO_JPID : // bucko ex 20
- return 7*4;
- case ALC.constants.KENOATLANTIC_JPID : // kenoatlantic ex 18
- return 7*4;
- case ALC.constants.LOTTO649_JPID : // lotto-649 ex 15
- return 2*4;
- case ALC.constants.LOTTOMAX_JPID : // lotto-max ex 16
- return 1*4;
- case ALC.constants.POKERLOTTO_JPID : // poker-lotto ex 23
- return 7*4;
- case ALC.constants.SALSABINGO_JPID : // salsa-bingo ex 22
- return 7*4;
- case ALC.constants.DAILYGRAND_JPID : // daily-grand ex 21
- return 2*4;
- default :
- return 1;
- };
- },
- getParameterByName : function(name, url) {
- if (!url) url = window.location.href;
- name = name.replace(/[\[\]]/g, "\\$&");
- var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
- results = regex.exec(url);
- if (!results) return null;
- if (!results[2]) return '';
- return decodeURIComponent(results[2].replace(/\+/g, " "));
- },
- QueryStringToJSON : function(qs) {
- qs = qs || location.search.slice(1);
- var pairs = qs.split('&');
- var result = {};
- pairs.forEach(function(pair) {
- var pair = pair.split('=');
- var key = pair[0];
- var value = decodeURIComponent(pair[1] || '');
- if( result[key] ) {
- if(result[key].constructor === Array) {
- result[key].push( value );
- } else {
- result[key] = [ result[key], value ];
- }
- } else {
- result[key] = value;
- }
- });
- return JSON.parse(JSON.stringify(result));
- },
- padDigits : function(number, digits) {
- return Array(Math.max(digits - String(number).length + 1, 0)).join(0) + number;
- },
- formatPrizeNumber: function(number) {
- return number.slice(0, -2) + '-' + number.slice(-2);
- },
- validationUtils:{
- /**
- * Validate postal code against Atlantic province prefixes. If a spefic province is selected then it will be used instead
- */
- postalCode: function(value, requirements){
- var postalValue = ALC.common.multiFieldUtils.concatMultiField(requirements, '', true);
- var provinces = {'NL' : 'A', 'NS' : 'B', 'PE' : 'C', 'NB' : 'E'};
- var postalPrefix = ($('#province').val()) ? provinces[$('#province').val()] : 'ABCE';
- var rxString = '^['+postalPrefix+'][0-9][ABCEGHJKLMNPRSTVWXYZ][0-9][ABCEGHJKLMNPRSTVWXYZ][0-9]';
- var validPostalRX = new RegExp( rxString, 'i' );
- return validPostalRX.test(postalValue);
- },
- /**
- * Opposite of built-in Equalto validator.
- * @param {string} requirements - set on the validator data attr
- * requirements starting with # will use the value of the element with that id
- * otherwise, requirements are used directly as the value to compare against
- *
- * Updated functionality to do a 'fuzzy' match that converts everything to lowercase before comparing
- */
- notEqualto: function(value, requirements){
- if (requirements.charAt(0) === '#'){
- return $(requirements).toArray()
- .every( function(elem) {
- return $(elem).val().toLowerCase() !== value.toLowerCase();
- });
- }else {
- return value.toLowerCase() !== requirements.toLowerCase();
- }
- },
- /**
- * Parsley has a built-in phone validator, but we have specific requirements:
- * 1. Merge three separate input fields and validate as one string
- * 2. SGI has the following field validation that must be duplicated on the FE:
- * - The First two "exchanges" can't be 0 or 1 (Essentially the 1st and 4th character can't be 0 or 1)
- */
- phoneNumber: function(value, requirements) {
- var phoneValue = ALC.common.multiFieldUtils.concatMultiField(requirements);
- var rxString = /^[2-9]\d{2}[2-9]\d{6}$/;
- return rxString.test(phoneValue);
- },
- checkPassword: function(password, requirements){
- var rx = {
- number: /[0-9]/,
- lowerCase: /[a-z]/,
- upperCase: /[A-Z]/,
- full: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])[0-9a-zA-Z!@#$%^&*()_+-=<>?,.|{}`~]{8,}$/
- };
- var errorMessage = $('.password-criteria').first().clone().removeClass('hidden');
- errorMessage.find('.psw-count').toggleClass('checked', password.length >= 8);
- errorMessage.find('.psw-num').toggleClass('checked', rx.number.test(password));
- errorMessage.find('.psw-lwr').toggleClass('checked', rx.lowerCase.test(password));
- errorMessage.find('.psw-uppr').toggleClass('checked', rx.upperCase.test(password));
- $('[name='+requirements+']').parsley().options.passwordValidMessage = errorMessage[0].outerHTML;
- return rx.full.test(password);
- },
- nameWithSpecialChars: function(value) {
- /*
- * Name Regex:
- * Valid: roman letters, fr-ca accented letters, hypens, spaces, apostrophes
- * Invalid: Numbers, symbols, foreign characters (ie: asian, arabic)
- */
- var validNameRX = /^[-'’\sa-zàâçéèêëîïôûùüÿ]+$/i;
- return validNameRX.test(value);
- }
- },
- popoverDefaults : {
- // For list of options check http://www.w3schools.com/bootstrap/bootstrap_ref_js_popover.asp
- animation : true,
- html : true,
- container: 'body',
- title: '',
- trigger : "focus",
- placement : function(el, triggerEl){
- if($(window).width() >= 768) {
- return "right";
- } else {
- return "bottom";
- }
- }
- },
- multiFieldUtils : {
- arrayHasUndefined: function(arr){
- return arr.indexOf("") >= 0;
- },
- concatMultiField : function(requirements, sep, allFieldsRequired){
- /**
- * Returns a concatenated string from all the fields in a multi-field-group
- * allFieldsRequired = true will trigger an additional check to make sure all the fields have values. Returns false if there are undefined values
- */
- var separator = sep || '';
- var fieldValues = $( '[data-multi-field="'+requirements+'"]' ).map(function() {
- return $(this).val();
- }).get();
- if(allFieldsRequired && this.arrayHasUndefined(fieldValues)){
- return false;
- }else{
- return fieldValues.join(separator);
- }
- },
- multiFieldIsDirty : function(fieldGroup){
- //Returns true if all the fields in the group have been blurred (using pristine vs dirty states)
- var fieldsInGroup = $('[data-multi-field="'+fieldGroup+'"]').length;
- var dirtyFieldsInGroup = $('[data-multi-field="'+fieldGroup+'"][data-validation-state="dirty"]').length;
- return fieldsInGroup === dirtyFieldsInGroup;
- },
- clearPopover : function(multiFieldsGroup, triggerField){
- //Only clear popover if entire multi-field group is blurred
- setTimeout(function(){
- if(!multiFieldsGroup.is(':focus')){
- triggerField.popover('hide');
- }
- }, 10); //Delayed functions are undesirable but the focus event is only _nearly_ instantaneous after a blur when tabbing or clicking, so it has to be this way
- }
- },
- parsleyValidation : (function() {
- var isInitialized = false;
- return {
- init: function(formEls, validationOptions){
- var initForm = function(formEl){
- formEl.parsley({
- errorClass: 'has-error',
- successClass: 'has-success',
- classHandler: function(el) {
- // classes added on closest .form-group element
- return el.$element.closest('.form-group');
- },
- errorsWrapper: '',
- errorTemplate: '',
- validationOptions: validationOptions
- });
- }
- //Add support for handling an array of forms on one page or just one
- if($.isArray(formEls)){
- formEls.forEach(function(el){
- initForm(el);
- });
- }else{
- initForm(formEls);
- }
- if(!isInitialized){
- isInitialized = true;
- window.Parsley.on('field:success', function(fieldInstance) {
- var elm = $(this.$element);
- var targetElm = elm;
- if(elm.closest('.validation-container').length){
- //Conditional parent target class for fields like radio and checkbox that have hidden inputs with styled replacements
- targetElm = elm.closest('.validation-container');
- }
- // This global callback will be called for any field that passes validation.
- targetElm.popover("destroy");
- });
- window.Parsley.on('field:error', function(fieldInstance) {
- // This global callback will be called for any field that fails validation.
- var elm = $(this.$element);
- var targetElm = elm;
- var arrErrorMsg = targetElm.parsley().getErrorsMessages(fieldInstance);
- var errorMsg = arrErrorMsg.join(';');
- var content = errorMsg;
- var popoverClass = 'error-popover';
- var validationOptions = fieldInstance.parent.options.validationOptions;
- var options = (validationOptions && validationOptions.popoverOptions) ? validationOptions.popoverOptions : {};
- if(validationOptions){
- if(validationOptions.extraMargins){
- popoverClass += (elm.closest('.validation-container').length) ? ' extra-margin-group' : ' extra-margin';
- }
- if(validationOptions.modalPopover){
- popoverClass += ' modal-popover';
- }
- }
- //Conditional parent target class for fields like radio and checkbox that have hidden inputs with styled replacements
- if(elm.closest('.validation-container').length){
- targetElm = elm.closest('.validation-container');
- }
- if(targetElm.data && targetElm.data('bs.popover')){
- //Element already has popover initialized -- check if message has changed
- var popover = targetElm.data('bs.popover');
- if(popover.options.content != content){
- popover.options.content = content;
- if(popover.$tip){
- //Dynamically trigger a redraw of content for an active popup. Most of the positioning/calcuation stuff is repurposed from the original bootstrap/js/tooltip.js file
- var pos, actualWidth, actualHeight, calculatedOffset;
- var placement = typeof popover.options.placement == 'function' ?
- popover.options.placement.call(popover, popover.$tip[0], popover.$element[0]) :
- popover.options.placement;
- popover.setContent();
- popover.$tip.addClass(placement);
- // Recalculate popover and tip positioning
- pos = popover.getPosition();
- actualWidth = popover.$tip[0].offsetWidth;
- actualHeight = popover.$tip[0].offsetHeight;
- calculatedOffset = popover.getCalculatedOffset(placement, pos, actualWidth, actualHeight);
- popover.applyPlacement(calculatedOffset, placement);
- }
- }
- }else{
- if(elm.is('[data-multi-field]')){
- options.trigger = 'manual';
- }
- //Popover not initialized
- targetElm.popover(
- $.extend({}, ALC.common.popoverDefaults, {
- content: content,
- template: '<div class="popover '+popoverClass+'" role="tooltip"><div class="arrow"></div><div class="popover-content"></div></div>'
- }, options)
- );
- //Only show if the field is currently in focus
- if(elm.is(':focus')){
- targetElm.popover('show');
- }
- }
- });
- window.Parsley.on('field:validated', function(fieldInstance) {
- var validationOptions = fieldInstance.parent.options.validationOptions;
- //Submit button will only be enabled if the form is visible
- if(!validationOptions || (validationOptions && !validationOptions.enableSubmit)){
- var parentForm = fieldInstance.parent.$element,
- submitBtn = parentForm.find('[type="submit"]'),
- hasErrorClasses = parentForm.find('.has-error').length > 0;
- var hasEmptyRequired = parentForm.find('input').prop('required', true).filter(function () {
- return !this.value;
- }).length > 0;
- submitBtn.toggleClass('disabled', hasErrorClasses || hasEmptyRequired);
- }
- });
- /**
- * Multi-field extension for Parsley, which currently has no built-in support for this feature
- * Uses the pristine vs. dirty concept from Angular JS to track/detect if a field has been 'touched'. Validation for the group shouldn't happen until all the fields are dirty
- * Adds the ability to trigger the error popover from the focus event a non-trigger field and other manual popover show/clear functions
- */
- $('[data-multi-field]').each(function(){
- var fieldGroup = $(this).data('multiField');
- var multiFields = $('[data-multi-field="'+fieldGroup+'"]');
- var triggerField = $('[data-multi-field="'+fieldGroup+'"][data-parsley-trigger]');
- //Apply pristine field state to all fields by default
- $(this).attr('data-validation-state', 'pristine');
- $(this).on('focus', function(){
- //Set field state to 'dirty' on focus
- $(this).attr('data-validation-state', 'dirty');
- //Check for and fire popover on trigger field
- var targetElm = triggerField;
- if(targetElm.data && targetElm.data('bs.popover')){
- var popover = targetElm.data('bs.popover');
- if(!popover.$tip || (popover.$tip && !popover.$tip.hasClass('in'))){
- popover.show();
- }
- }
- });
- if(!this.hasAttribute('data-parsley-trigger')){
- // Run validation on trigger field from any of the other fields in the group if all fields are dirty
- $(this).on('change', function(){
- if(ALC.common.multiFieldUtils.multiFieldIsDirty(fieldGroup)){
- triggerField.parsley().validate();
- }
- });
- $(this).on('blur', function(){
- //Manual clearing of popover on blur
- ALC.common.multiFieldUtils.clearPopover(multiFields, triggerField);
- });
- }else{
- $(this).on('blur', function(){
- // Automatically set all fields to dirty once the trigger field has been changed
- multiFields.each(function(){
- $(this).attr('data-validation-state', 'dirty');
- });
- //Manual clearing of popover on blur
- ALC.common.multiFieldUtils.clearPopover(multiFields, triggerField);
- });
- }
- });
- // Equalto validation (such as 'Confirm Email') works in reverse
- // if first input is edited/re-edited after Confirm input
- $('[data-parsley-equalto]').each(function() {
- var firstFieldId = $(this).attr('data-parsley-equalto');
- var secondField = $(this);
- $(firstFieldId).on('input', function() {
- if ($(secondField).val()) {
- $(secondField).parsley().validate();
- }
- });
- });
- //Generic validation/input helpers
- $(document).on('input', '[data-autoadvance-after]', function (e) {
- if ( $(this)[0].hasAttribute('data-validate-type') && $(this)[0].hasAttribute('pattern') ){
- var regexPattern = '^' + $(this).attr('pattern') + '$';
- var regexSpecialChars = new RegExp ( regexPattern );
- if(regexSpecialChars.test(this.value) && $(this).val().length === $(this).data('autoadvanceAfter')) {
- $(this).nextAll("input")[0].focus();
- }
- }else{
- if($(this).val().length === $(this).data('autoadvanceAfter')) {
- $(this).nextAll("input")[0].focus();
- }
- }
- });
- }
- }
- };
- })(),
- getUrlParameter: function(paramName) {
- //gets all url parameters and returns the value of the paramters name passed in
- var searchString = window.location.search.substring(1),
- i,
- val;
- if (searchString.indexOf('?') !== -1) {
- params = searchString.split("?")[1].split("&");
- } else {
- params = searchString.split("&");
- }
- for (i=0; i<params.length; i++) {
- val = params[i].split("=");
- if (val[0] === paramName) {
- return val[1];
- }
- }
- return null;
- },
- getMobileUserAgent: function(){
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
- },
- /**
- * HTML5 Geolocation API
- *
- * returns: a Q promise based on user's browser settings/choices regarding sharing of Geolocation data
- */
- getGeolocation: function(geoOptions){
- var deferred = Q.defer();
- var geoData = {
- Latitude : "",
- Longitude : ""
- };
- var options = geoOptions || {};
- options.timeout = 5000;
- function resolvePromise(){
- deferred.resolve(geoData);
- }
- function getPositionSuccess(position) {
- //Truncate geo values for SGI API if enableHighaccuracy flag isn't set
- if(!options.enableHighAccuracy){
- geoData.Latitude = position.coords.latitude.toString().substr(0,10);
- geoData.Longitude = position.coords.longitude.toString().substr(0,10);
- }else{
- geoData.Latitude = position.coords.latitude.toString();
- geoData.Longitude = position.coords.longitude.toString();
- }
- resolvePromise();
- }
- function getPositionFailure() {
- resolvePromise();
- return;
- }
- if (!navigator.geolocation) {
- getPositionFailure();
- } else {
- navigator.geolocation.getCurrentPosition(getPositionSuccess, getPositionFailure, options);
- }
- // Trigger timeout manually since Edge doesn't trigger fail
- setTimeout(getPositionFailure, options.timeout);
- return deferred.promise;
- },
- geolocationDebug: {
- //Debugging object allows QA/Devs to manually override Browser geolocation (lat/long) values
- settings : {
- enabled: false,
- geoData:{
- Latitude : "",
- Longitude : "",
- IpAddress: ""
- }
- },
- setValues: function(latitude, longitude, ipAddress){
- if(ALC.applicationProperties.enableDebugging == 'true'){
- //Override is only availble in specific environments
- this.settings.enabled = true;
- this.settings.geoData.Latitude = latitude.toString().substr(0,10);
- this.settings.geoData.Longitude = longitude.toString().substr(0,10);
- this.settings.geoData.IpAddress = ipAddress;
- }
- }
- },
- getIP: function(forceIP){
- var environment = ALC.applicationProperties.envName;
- if(environment === 'sgiprod' && forceIP){
- return Q($.ajax({
- url: '/services/GetClientIp',
- dataType: 'text',
- cache: true
- }));
- }else if(environment !== 'sgiprod'){
- return Q($.ajax({
- url: 'https://api.ipify.org',
- dataType: 'text',
- cache: true
- }));
- }else{
- return Q('');
- }
- },
- convertLotto4WinningNumbers: function (lotto4WinningNumbers) {
- //Lotto4 is a Digit game and comes with a single 0-9999 digit. We want to split up the numbers for display purposes.
- return lotto4WinningNumbers[0].split("");
- },
- getIPGeolocation: function(geoOptions, forceIP) {
- if(ALC.common.geolocationDebug.settings.enabled && ALC.applicationProperties.enableDebugging == 'true'){
- //Override is only availble in specific environments
- return Q.when(JSON.stringify(ALC.common.geolocationDebug.settings.geoData));
- }
- if(typeof NativeApp === 'object'){
- return ALC.common.getIP(true).then(function(ipAddress){
- var nativeGeoIP = {
- Latitude: 45.2597798,
- Longitude: -66.1090706,
- IpAddress: ipAddress
- };
- return JSON.stringify(nativeGeoIP);
- });
- }
- var options = geoOptions || {};
- var geoPromises = [ALC.common.getGeolocation(options), ALC.common.getIP(forceIP)];
- return Q.all(geoPromises).spread(function(geoData, ipData){
- var geoIPData = {
- IpAddress: ipData
- };
- if (options.enableHighAccuracy) {
- geoIPData.latitude = geoData.Latitude;
- geoIPData.longitude = geoData.Longitude;
- } else {
- geoIPData.Latitude = geoData.Latitude;
- geoIPData.Longitude = geoData.Longitude;
- }
- return JSON.stringify(geoIPData);
- });
- },
- getGameName: function(gameId){
- switch(gameId){
- case 'Lotto649' :
- return Granite.I18n.get('LOTTO 6/49');
- case 'Atlantic49' :
- return Granite.I18n.get('Atlantic 49');
- case 'DailyGrand' :
- return Granite.I18n.get('DAILY GRAND');
- case 'KenoAtlantic' :
- return Granite.I18n.get('Keno Atlantic');
- case 'LottoMax' :
- return Granite.I18n.get('LOTTO MAX');
- case 'SalsaBingo' :
- return Granite.I18n.get('Salsa Bingo');
- case 'AllLotto' :
- return Granite.I18n.get('All Lotto Games');
- case 'ScratchNWin' :
- return Granite.I18n.get('All Scratch N\' Win Games');
- case "Lotto4":
- return Granite.I18n.get('LOTTO 4');
- case 'PokerLotto' :
- return Granite.I18n.get('POKER LOTTO');
- default :
- return Granite.I18n.get(gameId);
- }
- },
- getCustomTranslation: function(key){
- switch(key){
- case 'All Lotto649 Winners' :
- return Granite.I18n.get('All LOTTO 6/49 Winners');
- case 'All Atlantic49 Winners' :
- return Granite.I18n.get('All Atlantic 49 Winners');
- case 'All DailyGrand Winners' :
- return Granite.I18n.get('All DAILY GRAND Winners');
- case 'All KenoAtlantic Winners' :
- return Granite.I18n.get('All Keno Atlantic Winners');
- case 'All LottoMax Winners' :
- return Granite.I18n.get('All LOTTO MAX Winners');
- case 'All SalsaBingo Winners' :
- return Granite.I18n.get('All Salsa Bingo Winners');
- case 'All Lotto4 Winners' :
- return Granite.I18n.get('All LOTTO 4 Winners');
- case 'All PokerLotto Winners' :
- return Granite.I18n.get('All POKER LOTTO Winners');
- default :
- return Granite.I18n.get(key);
- }
- },
- sessionStorageSupported: undefined,
- sessionStorage: {
- setItem: function(key, value, forceCookie){
- if(!forceCookie && ALC.common.sessionStorage.checkSessionStorage()) {
- window.sessionStorage.setItem(key, value);
- } else {
- Cookies.set(key, value, {path: '/', domain: 'alc.ca'});
- }
- },
- getItem: function(key, forceCookie){
- var keyValue;
- if(!forceCookie && ALC.common.sessionStorage.checkSessionStorage()) {
- keyValue = window.sessionStorage.getItem(key);
- } else {
- keyValue = Cookies.get(key);
- keyValue = (keyValue !== undefined) ? keyValue : null;
- }
- return keyValue;
- },
- removeItem: function(key, forceCookie){
- if(!forceCookie && ALC.common.sessionStorage.checkSessionStorage()) {
- window.sessionStorage.removeItem(key);
- } else {
- Cookies.remove(key, { path: '/', domain: '.alc.ca'});
- }
- },
- clear: function(keys, forceCookie){
- if(!forceCookie && ALC.common.sessionStorage.checkSessionStorage()) {
- if(keys instanceof Array){
- keys.forEach(function(key){
- ALC.common.sessionStorage.removeItem(key);
- });
- } else {
- window.sessionStorage.clear();
- }
- } else {
- if(keys instanceof Array){
- keys.forEach(function(key){
- Cookies.remove(key, { path: '/', domain: '.alc.ca'});
- });
- }
- }
- },
- checkSessionStorage: function(){
- var testKey = 'test',
- storage = window.sessionStorage;
- if(ALC.common.sessionStorageSupported === undefined){
- try {
- storage.setItem(testKey, '1');
- storage.removeItem(testKey);
- ALC.common.sessionStorageSupported = true;
- } catch (error) {
- ALC.common.sessionStorageSupported = false;
- }
- }
- return ALC.common.sessionStorageSupported;
- }
- },
- createAbsoluteURL: function(path) {
- var a = document.createElement('a');
- a.href = path;
- return a.href;
- },
- detectKeyInObject: function(obj, key) {
- var type = typeof key,
- keyParts;
- if(!obj || !key) return null;
- if (type === 'string' || type === 'number') {
- keyParts = String(key).replace(/\[(.*?)\]/g, function (m, keyPart) {
- return '.' + keyPart.replace(/^['']|['']$/g, '');
- }).split('.');
- } else {
- return null;
- }
- for (var i = 0; i < keyParts.length; i++) {
- if (obj.hasOwnProperty(keyParts[i])) obj = obj[keyParts[i]];
- else return null;
- }
- return obj;
- }
- }; //end of ALC.common
- ALC.AjaxLoader = (function() {
- /* CONSTANTS */
- var initialTheta = 0; // The initial rotation angle, in degrees.
- var thetaDelta = 5; // The amount to rotate the square about every 16.7 milliseconds, in degrees.
- var defaultDelayTime = 750; // default time delay to initializing spinner after AJAX call is made.
- var requestAnimationFrameID;
- var ajaxLoader;
- var doAnimation = function() {
- if (ajaxLoader) {
- ajaxLoader.setAttribute("transform", "rotate(" + ajaxLoader.currentTheta + ")"); // Rotate the widget by a small amount.
- ajaxLoader.currentTheta += thetaDelta; // Increase the angle that the widget will be rotated to, by a small amount.
- requestAnimationFrameID = requestAnimationFrame(doAnimation); // Call the doAnimation() function about 60 times per second (60 FPS), or about once every 16.7 milliseconds until cancelAnimationFrame() is called.
- }
- };
- var initLoaderDimensions = function() {
- var scrollPosition = window.scrollY || window.pageYOffset;
- var viewportHeight = window.innerHeight;
- var documentHeight = document.body.clientHeight + "px";
- $("#ajaxLoaderContainer")
- .css("height", documentHeight)
- .find("svg");
- };
- var initLoader = function() {
- var ajaxLoaderContainer = $("#ajaxLoaderContainer");
- if (ajaxLoaderContainer.length > 0) {
- ajaxLoaderContainer.show();
- }
- else {
- var svgLoaderHtml = '<div id="ajaxLoaderContainer"><svg width="80px" height="80px" xmlns="http://www.w3.org/2000/svg" viewBox="-50 -50 100 100" preserveAspectRatio="xMidYMid"><rect id="ajaxLoaderBG" x="-50" y="-50" width="100" height="100" fill="none"></rect><circle id="ajaxLoader" cx="0" cy="0" r="30" stroke-dasharray="143.36281798666926 87.9645943005142" stroke="#d9534f" fill="none" stroke-width="10"><animateTransform attributeName="transform" type="rotate" values="0 0 0;180 0 0;360 0 0;" keyTimes="0;0.5;1" dur="1s" repeatCount="indefinite" begin="0s"></animateTransform></circle></svg></div>';
- $(document.body).append(svgLoaderHtml);
- }
- initLoaderDimensions();
- };
- return {
- /**
- * @param {object}: options - loader config options
- * options.noBlock: loader will not spawn the translucent gray bg to block the page if set to true
- * options.size: pixel size of the loader (i.e. "100px")
- * options.color: spinner color (i.e. "#FFFFFF")
- * options.bgColor: background color of the loader (i.e. "#000000")
- */
- setOptions : function(options) {
- if (!options) { return; }
- if (options.noBlock) {
- $("#ajaxLoaderContainer").css("height", 0);
- }
- if (options.size) {
- var ajaxLoaderSVG = $("#ajaxLoaderContainer svg")[0];
- if (ajaxLoaderSVG) {
- ajaxLoaderSVG.setAttribute("width", options.size);
- ajaxLoaderSVG.setAttribute("height", options.size);
- }
- }
- if (options.color) {
- ajaxLoader = ajaxLoader || document.getElementById("ajaxLoader");
- ajaxLoader.setAttribute("stroke", options.color);
- }
- if (options.bgColor) {
- var ajaxLoaderBG = document.getElementById("ajaxLoaderBG");
- if (ajaxLoaderBG) {
- ajaxLoaderBG.setAttribute("fill", options.bgColor);
- }
- }
- },
- ajaxRequestCount: 0,
- start : function(options) {
- var self = this;
- var delayTime = (options && options.delayTime !== null) ? options.delayTime : defaultDelayTime;
- self.delayTimer = setTimeout((function() {
- initLoader();
- if (options) {
- self.setOptions(options);
- }
- if (!Modernizr.smil) {
- // only do JS animation for IE
- ajaxLoader = document.getElementById("ajaxLoader");
- ajaxLoader.currentTheta = initialTheta; // The initial rotation angle to use when the animation starts, stored in a custom property.
- requestAnimationFrameID = requestAnimationFrame(doAnimation); // Start the loop.
- }
- }), delayTime);
- },
- stop : function() {
- clearTimeout(this.delayTimer);
- var ajaxLoaderContainer = $("#ajaxLoaderContainer");
- if (ajaxLoaderContainer.length > 0) {
- ajaxLoaderContainer.hide();
- }
- if (requestAnimationFrameID) {
- cancelAnimationFrame(requestAnimationFrameID);
- }
- }
- };
- })();
- /**
- * Global AJAX defaults
- * Unless the they are specifically defined in 'local' $.ajax() calls,
- * the options below will replace the AJAX defaults for ALL AJAX calls
- */
- (function($){
- $.ajaxSetup({
- cache: false,
- error: function(response){
- var responseData;
- try{
- responseData = JSON.parse(response);
- }catch(err){
- responseData = response;
- }
- if(response.readyState == 0 && response.status == 0){
- window.location = ALC.constants.CONTENT_ROOT + ALC.common.getShortLang() + ALC.constants.AEM_DISPATCHER_FAILOVER_PATH;
- return;
- }
- },
- success: function(response){
- if(response.error_code === 401 && response.MessageCode === "SessionExpired"){
- ALC.common.sessionStorage.setItem('sessionExpires', true, true);
- ALC.common.sessionStorage.setItem('sessionReturnURL', window.location.href);
- ALC.common.alcLogout(ALC.constants.CONTENT_ROOT + ALC.common.getShortLang() + '.html');
- }
- }
- });
- })(jQuery);
- // AJAX Loader
- (function($){
- var clearAjaxLoader = function(){
- ALC.AjaxLoader.stop();
- if (ALC.activityTimer) {
- ALC.activityTimer.refreshActivityCookie();
- }
- };
- $(document).ajaxSend(function() {
- if (ALC.AjaxLoader.ajaxRequestCount < 1) {
- ALC.AjaxLoader.start();
- }
- ALC.AjaxLoader.ajaxRequestCount++;
- });
- $(document).ajaxComplete(function() {
- ALC.AjaxLoader.ajaxRequestCount--;
- if (ALC.AjaxLoader.ajaxRequestCount <= 0) {
- clearAjaxLoader();
- }
- });
- })(jQuery);
- -------------------------------------------
- LOGIN MODAL Mobile
- -------------------------------------------
- $(window).resize(function(){
- $("#page-en").css(“width”,“100vh”);
- $("#page-en").css(“height”,“100vh”);
- });
- SIGN IN link (button, uggh...)
- body > header.visible-xs.navbar-fixed-top.mobile.header-en > div.nav-right-side.clearfix > div.account-holder
- //*[@id="page-en"]/header[2]/div[2]/div[2]
- <div class="account-holder">
- <button class="account-login dropdown-toggle sign-in-circle link-button" data-toggle="dropdown" type="button" data-bind="visible : !isLoggedIn()" aria-expanded="false"><span class="button-text-underline">Sign In</span> <span class="material-icons md-18">lock</span>
- </button>
- </div>
- Login Modal body > div.parbase.modal-base.section.modal-login
- <div class="parbase modal-base section modal-login" style="width:100%"><div id="modal-login" class="alc-modal modal-login login modal fade in" tabindex="-1" role="dialog" aria-hidden="false" style="z-index: 1040; display: block; width: 100%; padding-left: 0px;">
- <div class="modal-dialog" style="width:100%; height:100%">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close close-modal" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
- </div>
- <div class="modal-body state-login">
- <div class="container-fluid">
- <div class="row">
- <div class="col-xs-12 col-sm-6 signin-form">
- <div class="modal-title">
- <h2>Sign In</h2>
- </div>
- <div class="account-timeout error-message hidden">
- <p><strong>Sorry your session has timed out.</strong></p>
- <p>Please sign in and try again.</p>
- </div>
- <div class="session-error error-message hidden">
- <p><strong>Sorry, there was an error with your session</strong></p>
- </div>
- <div class="wrong-credentials hidden error-message"></div>
- <form id="login-submit-form" novalidate="">
- <div class="form-group">
- <label for="exampleInputEmail1">Email</label>
- <input type="text" class="form-control" id="exampleInputEmail1" placeholder="Email" required="" data-parsley-required-message="Enter Email address (myname@emaildomain.ca)">
- </div>
- <div class="form-group">
- <label for="exampleInputPassword1">Password</label>
- <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password" required="" data-parsley-required-message="Enter Password">
- </div>
- <div class="modal-actions">
- <a href="/content/alc/en/registration/password-reset.html" class="forgot-password chevron-link">Forgot Password?</a>
- <button type="submit" id="login-submit-btn" class="button arrow-button orange btn-default btn-primary login-submit">Sign In</button>
- </div>
- <div class="help-block">
- <p>By signing in you confirm that you are 19 years of age or older, a resident of and physically located in Atlantic Canada.</p>
- </div>
- </form>
- </div>
- <div class="col-xs-12 col-sm-6 register-today">
- <div class="modal-title">
- <h3>Create an Account</h3>
- </div>
- <div class="account-benefits">
- <h4>Register today to start playing</h4>
- <ul>
- <li>Buy lottery tickets on the go</li>
- <li>Play the all new iBingo and Instant Win games</li>
- <li>Subscribe to your favourite draw games</li>
- <li>It’s fast, safe and secure<br>
- </li>
- </ul>
- </div>
- <div class="modal-actions">
- <a href="/content/alc/en/registration/create-account.html" class="button arrow-button gray btn-primary">Create an Account</a>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="modal-body account-error">
- <h3>We are sorry, there is a problem with your account</h3>
- <div class="account-error-container">
- <div class="account-error-info self-exclusion">
- <h4>Self Exclusion Period</h4>
- <p>You've indicated you do not want us to let you in for a little while...</p>
- <p>For help with Self Exclusion settings, please contact our <a href="">Customer Care Centre</a> at <a href="tel:1-877-252-3287">1-877-252-3287</a>.</p>
- </div>
- <div class="account-error-info locked-account">
- <h4>Locked Account</h4>
- <p>We're sorry, but your account has been temporarily locked for security reasons. This means you will need to reset your password to continue.</p>
- <button>Reset Password</button>
- <p>Contact the <a href="">Customer Care Centre</a> at <a href="tel:1-877-252-3287">1-877-252-3287</a>.</p>
- </div>
- <div class="account-error-info customer-suspended">
- <h4>Customer Suspended</h4>
- <p>You could not be signed in. Please contact our <a href="">Customer Care Centre</a> at <a href="tel:1-877-252-3287">1-877-252-3287</a>.</p>
- </div>
- <div class="account-error-info geoip">
- <h4>GEOIP</h4>
- <p>Sorry your IP address has been identified as being located outside Atlantic Canada. As per the alc.ca terms and conditions you are not permitted to play or purchase on our site. You have still have access to your account but you will not be able play/purchase any games or add any funds. If you have questions, please contact our <a href="">Customer Care Centre</a> at <a href="tel:1-877-252-3287">1-877-252-3287</a>.</p>
- </div>
- <div class="account-error-info connection-issues1">
- <h4>Connection Issues</h4>
- <p>Network Unavailable</p>
- </div>
- <div class="account-error-info connection-issues2">
- <h4>Connection Issues</h4>
- <p>No network connection available. Please check your settings.</p>
- </div>
- <div class="account-error-info connection-issues3">
- <h4>Connection Issues</h4>
- <p>Session Expired</p>
- </div>
- <div class="account-error-info connection-issues4">
- <h4>Connection Issues</h4>
- <p>Please sign in again.</p>
- </div>
- <div class="account-error-info connection-issues5">
- <h4>Connection Issues</h4>
- <p>We're sorry but the request could not be completed at this time.</p>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <div><section>
- <footer>
- <div><div class="parsys"><div class="parbase section text">
- <div class="clearfix"><div class="need-help"><h2>Need help?</h2>
- <p>Contact our Customer Care</p>
- </div>
- <div class="contact"><p><a href="#" class="link-phone">1-877-252-3287</a> <a href="mailto:info@alc.ca" class="link-email">Email Us</a></p>
- </div>
- </div>
- </div>
- </div>
- </div>
- </footer>
- </section></div>
- </div>
- <div id="promote-anonymous-cart-alert" class="hidden">
- <div class="container-fluid">
- <div class="row">
- <div class="col-xs-12 error-body">
- <h3>Error transferring guest cart</h3>
- <p>We were unable to transfer items in your cart. You are successfully signed in, but your cart will be empty.</p>
- <button class="button arrow-button orange btn-default login-anon-cart-error">OK</button>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script>
- ;(function($, ALC) {
- "use strict";
- var loginModal = $("#modal-login");
- loginModal.find("[data-action='action']").click(function(){
- var successCallback = loginModal.data("successCallback");
- if (typeof successCallback === "function") {
- successCallback(loginModal);
- }
- });
- var validationOptions = {
- modalPopover: true,
- popoverOptions: {
- container: '#modal-login'
- }
- }
- ALC.common.parsleyValidation.init($('#login-submit-form'), validationOptions);
- $('#login-submit-form').submit( function (event) {
- if($('#login-submit-form').parsley().validate()){
- ALC.common.alcLogin($('#exampleInputEmail1').val(), $('#exampleInputPassword1').val(), '.modal-body', true, false);
- }
- event.preventDefault();
- });
- $('.modal-login').on('hide.bs.modal', function(ev){
- ALC.common.sessionStorage.removeItem('sessionReturnURL');
- $(ev.target).find('.account-timeout').addClass('hidden');
- });
- })(jQuery, (ALC || (ALC = {})));
- </script>
- </div>
- -------------------------------------------
- ADD FUNDS Mobile
- -------------------------------------------
- {"locale":"en_CA","Amount":1000,"RedirectUrl":"https://www.alc.ca/content/alc-mobile/en/my-account/add-withdraw-funds.html","CancelUrl":"https://www.alc.ca/content/alc-mobile/en/my-account/add-withdraw-funds.html?cancelled=true","TimeoutUrl":"https://www.alc.ca/content/alc-mobile/en/my-account/add-withdraw-funds.html?timeout=true","HostedPageType":2,"ClientIpAddress":""}
- Cookie: _ga=GA1.2.2116113668.1510940598; _gid=GA1.2.1623536659.1510940598; userId=481933; TS012e1e73=0183e022d95e631a6a7a03a215e3b58e6325f7b35aee2c978998199514b02ebd0767a5c4c828c94908a04a3a2e3f0d83bea6ce0c16; LastActivity=1510940597; __qca=P0-900281888-1510940598474; _gat_UA-49662628-7=1; ALC-browser-check=checked; SciplayAuthToken=dmdDV2JlTjh5K7uhFF1wKna+OlbTKUbJ5TZX4J4n3G5SZusDu9JFqXy6LloFYafgDBxzRql2mtHSaJrEMJ4eieriTziQvgIYHsfauMRCGYTCpyjcPUeJPaULJjCvqHFZizg1ctB9b/oHnpMbEPAWlQs61be/TAl0m3GL4tflrqbr8oxLH0wItrcjZDKjaHgZJRAA+pU+Acb/TyFM2ud9KZPckxftfLZhytV79+4ZhZ9pXzfGjhTlxtPscHFK7vwC/Nx3NIyrotLYZX+tswr0Td3GM/cskOdz7Pca+8R+JNluS8r9vn7z+o11jC+Tp4yyIz5/78AZrix2IS7BzJOVn+J8pAoJI39fo+kH4Gt0/2e29d4szq7ujmkHS0pnROogpnbQTjZYzsfvIcWDZyC/d1PE4iQDK19uvpEWvgyxXPv8YqVg1jmE8X5xnwl8H4yaMbkrpQTkjFdVnc0WcV9Nvrhp0UvWo71MWRcApcBaYahdnQIFu1dLkX1YtNuD7sAbPF9ljHWQ4w0=; TS01d84674=0183e022d9dc15ccee30fe1f625c86b06d88f38a92ee2c978998199514b02ebd0767a5c4c8e37c5dc289d269768a04ddaa7dc0406afc907302ea2e24545b495f55a9f10bf75400e3235c5ed42406832e5618fd343f10416e0d9d8f44fa7e21646bda968c56; locale=en-ca; AuthSignature=2372C620258A42B6AB1C435180A2A74EA305FDBC2A225ACC2DE3C4731B847BCC; AuthTokenExpires=1510944184.0; CartHandle=3ad9d3e5-778f-4060-8d6f-402ba7f178a2; LoginTime=1510940584.0; NickName=bcmoney; PlayerCardId=481933; Province=NB; WalletId=481933; cust_xl=en
- Accept: application/json, text/javascript; */*; q=0.01
- Keep-Alive: timeout=30, max=100
- {"locale":"en_CA","Amount":1000,"RedirectUrl":"https://www.alc.ca/content/alc-mobile/en/my-account/add-withdraw-funds.html","CancelUrl":"https://www.alc.ca/content/alc-mobile/en/my-account/add-withdraw-funds.html?cancelled=true","TimeoutUrl":"https://www.alc.ca/content/alc-mobile/en/my-account/add-withdraw-funds.html?timeout=true","HostedPageType":2,"ClientIpAddress":""}
- FUNDS ERROR
- "{
- \"error_code\": 408,
- \"message\": \"\"
- }"
- FUNDS ERROR
- Object
- abort: function(i)
- always: function()
- complete: function()
- done: function()
- error: function()
- fail: function()
- getAllResponseHeaders: function()
- getResponseHeader: function(i)
- overrideMimeType: function(e)
- pipe: function()
- progress: function()
- promise: function(b8)
- readyState: 4
- responseText: ""
- setRequestHeader: function(i,cs)
- state: function()
- status: 200
- statusCode: function(i)
- statusText: "OK"
- success: function()
- then: function()
- arguments: null
- caller: null
- length: 0
- name: "then"
- prototype: then {}
- Function Prototype
- apply(thisObject, [argumentsArray])
- arguments
- bind(thisObject, ...arguments)
- call(thisObject, ...arguments)
- caller
- constructor: function()
- arguments: TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in this context.
- caller: TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in this context.
- length: 1
- name: "Function"
- prototype()
- Function Prototype
- apply(thisObject, [argumentsArray])
- arguments
- bind(thisObject, ...arguments)
- call(thisObject, ...arguments)
- caller
- constructor: function()
- length: 0
- name: ""
- toString()
- Symbol(Symbol.hasInstance)()
- Object Prototype
- length: 0
- name: ""
- toString()
- Symbol(Symbol.hasInstance)()
- Object Prototype
- * Using the browser console: https://www.wickedlysmart.com/hfjsconsole/
- * Log to Safari JavaScript Console: https://stackoverflow.com/questions/3748809/log-to-safari-javascript-console
- * Save Safari javascript console to file?: https://stackoverflow.com/questions/15507059/save-safari-javascript-console-to-file
- * JavaScript Debugging Tips You Probably Didn’t Know: https://raygun.com/blog/javascript-debugging/
- * Copy JSON from console.log in developer tool to clipboard?: https://superuser.com/questions/777213/copy-json-from-console-log-in-developer-tool-to-clipboard
- * How to save the output of a console.log(object) to a file?: https://stackoverflow.com/questions/11849562/how-to-save-the-output-of-a-console-logobject-to-a-file
- * Javascript / Chrome - How to copy an object from the webkit inspector as code: https://stackoverflow.com/questions/10305365/javascript-chrome-how-to-copy-an-object-from-the-webkit-inspector-as-code
- * JS files under clientlibs are not getting loaded: https://stackoverflow.com/questions/12281311/js-files-under-clientlibs-are-not-getting-loaded
Add Comment
Please, Sign In to add comment