You'll Also Like
'; } else { signupPromoTop = ''; signupContainerTop = '
' + signupPromoTop + '
'; } if (typeof signupPromoBottom !== 'undefined' && signupPromoBottom !== '') { signupContainerBottom = '
' + signupPromoBottom + '
'; } else { signupPromoBottom = ''; signupContainerBottom = '
' + signupPromoBottom + '
'; } function preroll_signup_top_handler() { trackEvent('Preroll Signup Clicked', 'Preroll Signup Top', document.title); } function preroll_signup_bottom_handler() { trackEvent('Preroll Signup Clicked', 'Preroll Signup Bottom', document.title);}
'); jQuery('#does-not-support-ie').show(); jQuery('#afg_preloader').css('display', 'none').html('
');; jQuery('#does-not-support-ie').html(' '); jQuery('.load-wrap').hide(); jQuery('#continue-container').hide(); jQuery('#afg_preloader').hide(); } function getGameName() { var url = window.location.href; var lastPart = url.split("/").pop(); return lastPart; } var coep_frame_type = 'crossorigin="use-credentials"'; if(/(Firefox)/.test(navigator.userAgent)) { coep_frame_type = 'allow="cross-origin-isolated"'; } function setIframeHeight(iframe) { if (iframe) { /* var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow; if (iframeWin.document.body) { iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight; } */ var gamename = getGameName(); if (gamename == "0-chess") { iframe.height = "620px"; } } }; jQuery(function(){ setIframeHeight(document.getElementById('html5game')); }); /** For big screen promo with list of games to appear */ function checkBigScreenPromoURL() { bigScreenPromoGame = false; if (bs_promo_pages.test(location.pathname)) { bigScreenPromoGame = true; jQuery(document).ready(function () { jQuery(".pane-bean-new-go-ad-free").html('Go Big Screen!'); jQuery('#right-rail-big-screen-promo').show(); }); } } checkBigScreenPromoURL(); /** ** check for marketing game promo for game page. check for specific games to make this popover appear. */ function checkAdfreeMktCmpgnURL() { AdfreeMktCmpGame = false; if ((typeof adfreeMktPages != 'undefined' && adfreeMktPages.test(location.pathname)) || (location.pathname == "/0-cannon-basketball") || (location.pathname == "/0-parking-fury")) { AdfreeMktCmpGame = true; jQuery(document).ready(function () { jQuery(".pane-bean-new-go-ad-free").html('Go Big Screen!'); jQuery('#right-rail-adfree-marketing-promo').show(); }); } } checkAdfreeMktCmpgnURL(); /** ** check for playlist marketing game promo for game page. check for specific games to make this popover appear. */ function checkPlaylistMktCmpgnURL() { playListMktCmpGame = false; if (playlistMktPages.test(location.pathname)) { playListMktCmpGame = true; jQuery(document).ready(function () { jQuery('.playlist-right-side-promo').show(); }); } } checkPlaylistMktCmpgnURL(); function checkPremiumAvatarURL() { premiumAvatarGame = false; if(typeof premiumAvatarMktPages != 'undefined' && premiumAvatarMktPages.test(location.pathname) || (location.pathname == "/0-moto-x3m-winter") || ( location.pathname == '/0-redline-pong')) { if (gamesPlayed == 2 || gamesPlayed == 8) { schoolHours = false;//display all the time premiumAvatarGame = true; } // setting the default premiumAvatarGameABTest if (getCookie('cmg_fx') !== null && getCookie('cmg_sx') == null) { var planToSubscription = '67361110'; } else { var planToSubscription = '553bdf22'; } // logged in free user jQuery(document).ready(function () { jQuery(".pane-bean-new-go-ad-free").html('Go Big Screen!'); jQuery('.premium-avatar-right-side-promo').show(); }); var gamePageBarPromo = 'GET THE AVATAR: GO PREMIUM'; gamePageBarPromoActionText = 'Get Premium '; var pathpromobarsubscriptionform = '/subscribe/' + planToSubscription; jQuery('.gamepage-signup-promo').hide(); jQuery('#block-cmatgame-cmatgame-system-main').append('
' + gamePageBarPromo + '
' + gamePageBarPromoActionText + '
'); } } function checkPlayedGames() { // this is for supportCMG A/B Test gamesPlayed = navigator.cookieEnabled ? parseInt(localStorage.getItem('gamesPlayed') || 0) : 0; sessionGamesPlayed = navigator.cookieEnabled ? parseInt(sessionStorage.getItem('sessionGamesPlayed') || 0) : 0; //localStorage.setItem('gamesPlayed', ++ gamesPlayed) if(navigator.cookieEnabled) { localStorage.setItem('gamesPlayed', 0); sessionStorage.setItem('sessionGamesPlayed', ++ sessionGamesPlayed); } checkPremiumAvatarURL(); } /** ** For CMG default screen promo with list of games to appear */ function checkCMGDefaultExceptionURL() { supportCMG = false; if(!cmgDefaultGameUrl.test(location.pathname) && (typeof gamesPlayed != "undefined" && (gamesPlayed == 2 || gamesPlayed == 8))) { supportCMG = true; schoolHours = false; // display all the time if (getCookie('cmg_fx') !== null && getCookie('cmg_sx') == null) { var planToSubscription = 'd61242ac'; } else { var planToSubscription = '0735a1f2'; } // logged in free user jQuery(document).ready(function () { jQuery(".pane-bean-new-go-ad-free").html('Go Big Screen!'); jQuery('.cmgdefault-right-side-promo').show(); }); var gamePageBarPromo = 'GO PREMIUM: THE BEST GAMING EXPERIENCE'; gamePageBarPromoActionText = 'Get Premium '; var pathpromobarsubscriptionform = '/subscribe/' + planToSubscription; jQuery('.gamepage-signup-promo').hide(); jQuery('#block-cmatgame-cmatgame-system-main').append('
' + gamePageBarPromo + '
' + gamePageBarPromoActionText + '
'); } } checkPlayedGames(); // need to comment this settimebased();function call to prevent it run on page load, it should start work on // game load. //settimebased(); checkCMGDefaultExceptionURL(); if (isUserValidFreeUserOrSubscriber()) { var userprofileData = JSON.parse(localStorage.getItem("userprofile")); var levelofcompletedgame = 1; for (var i = 0; i < userprofileData.mygameslist.length; i++) { if (userprofileData.mygameslist[i].id == gameId) { var levelbasedCompletedStatus = userprofileData.mygameslist[i].timebasedcompletedSt; var levelofcompletedgame = userprofileData.mygameslist[i].level; } } } var workerstatusvar = "no"; var count = 0; var myInterval; // Active function chkIdleOnpage() { var userActivityTime = Date.now(); // check if user activity is not there more than 55 min 60000*55 = 3300000 if (userActivityTime - lastKeyBoardorMouseActivityTime > 3300000) { if (typeof(w) != "undefined") { workerstatusvar = "terminated"; w.terminate(); w = undefined; } } else { // May be keyboard is active start new worker settimebased(); } } // Inactive if (!is_level_based) { // check idle time in every 5 min 60000 * 5 = 300000 idleOnPageCheckTimer = setInterval(function () { chkIdleOnpage() }, 300000); } function settimebased() { if (!is_level_based) { jQuery(document).ready(function () { if (isUserValidFreeUserOrSubscriber()) { window.addEventListener("beforeunload", function (e) { saveUserProgress(); }); if (typeof(Worker) !== "undefined") { if (typeof(w) == "undefined") { w = new Worker("/modules/custom/cmatgame_userprofile/js/userprogress_workers.js"); w.onmessage = function (event) { var userActivityTime = Date.now(); // save userprofile object back to localstorage // if(userActivityTime - lastKeyBoardorMouseActivityTime <= 60000) { userprofile = event.data; localStorage.setItem("userprofile", JSON.stringify(userprofile)); // display game progressbar on game pages if (typeof gameId != "undefined") { display_game_progressbar(gameId); } // display user progressbar display_user_profile_progressbar(); //adding save userprogress back to api server saveUserProgress(); // } }; var userprofile = localStorage.getItem("userprofile"); setTimeout(function () { var userprofile = localStorage.getItem("userprofile"); var currentGameData = searchGamesById(gameId); if(typeof drupalSettings.cmatgame != "undefined" && typeof drupalSettings.cmatgame.flash_emulation != "undefined" && drupalSettings.cmatgame.flash_emulation == 0 ) { //Do nothing here } else if (typeof w != 'undefined') { w.postMessage([ gameId, xp_per_level, userprofile, currentGameData, cmatgameSearchGames, userprofile_level_xpData ]); } }, 60000); // setInterval(function () { updateMyGamesTimeSpent1(gameId) }, 60000); } } } }); } } // Stop timer function stopTimer() { count = 0; if (workerstatusvar == "terminated") { settimebased(); workerstatusvar = "started"; } window.clearInterval(myInterval); } function checkKeyboardOrMouseActivity() { lastKeyBoardorMouseActivityTime = Date.now(); if (!is_level_based) { if (typeof isRemoveAdSwfJWPLayer === "undefined" || !isRemoveAdSwfJWPLayer) { // html 5 game } else { stopTimer(); } } } function startTimer() { // for flash based game check idle time in every 5 min 60000 * 5 = 300000 myInterval = window.setInterval(timerHandler, 30000); } function timerHandler() { count++; // count of flash based game will for 55 rounds if (count == 55) { workerstatusvar = "terminated"; if (typeof w !== 'undefined') { w.terminate(); w = undefined; } } } document.addEventListener("mousemove", checkKeyboardOrMouseActivity, false); document.addEventListener('keydown', checkKeyboardOrMouseActivity, false); document.addEventListener("keypress", checkKeyboardOrMouseActivity, false); document.addEventListener("touchmove", checkKeyboardOrMouseActivity, false); if(!is_level_based) { if (typeof isRemoveAdSwfJWPLayer === "undefined" || !isRemoveAdSwfJWPLayer) { // html 5 game document.addEventListener("visibilitychange", function() { if(document.visibilityState == 'hidden') { //startTimer(); if(typeof idleOnPageCheckTimer !== 'undefined') { clearInterval(idleOnPageCheckTimer); } /*** need to remove below workerstatusvar variable. position changed . it should be under if codition where worker undefine ***/ // workerstatusvar = "terminated"; if (typeof w !== 'undefined') { w.terminate(); w = undefined; workerstatusvar = "terminated"; } } else if (document.visibilityState == 'visible') { stopTimer(); // starts worker. } }, false); } else { // flash game window.addEventListener('focus', stopTimer); window.addEventListener('blur', startTimer); // Check browser minimize document.addEventListener("visibilitychange", function () { if (document.visibilityState == 'hidden') { startTimer(); } else if (document.visibilityState == 'visible') { stopTimer(); } }, false); startTimer(); } } // end of !is_level_based function putSharedObjectsInDB(syncData) { flashStorage = syncData; saveUserProgress(); } isRemoveAdSwfJWPLayer = false; prerollAdDisplayed = false; //use this when switching from mobile view to desktop view and preroll ad was not shown earlier prerollAdStart = ""; prerollAdEnd = ""; // Testing Overlay for Watch Ad To Unlock Games // var watchAdtoUnlockGame = true; // var schoolHours = false; // //console.log('supportCMG is true'); window.addEventListener("message", receiveMessage, false); function receiveMessage(event) { // console.log("message received2 from " + event.origin + " : " + event.data); var valid_domain_msg = false; if (/coolmathgames\.com|coolmathgames\.local|coolmathgames/.test(event.origin)) { valid_domain_msg = true; } if(valid_domain_msg && event.data == "cmgGameEventStatic") { ga4_trackEvent("cmgGameEventStatic", ); } else if (event.data == "continue-without-big-screen" && jQuery('#big-screen-overlay').length && valid_domain_msg) { // close overlay if (jQuery('#big-screen-overlay').length) { jQuery('#big-screen-overlay').hide(); if (jQuery('#big-screen-truex-overlay').length) { jQuery('#big-screen-truex-overlay').hide(); } cmg_bigscreen_trackevent('closesignup', cmg_bsft); } } else if (event.data == "continue-with-login-big-screen" && jQuery('#big-screen-overlay').length && valid_domain_msg) { // console.log("BIGSCREEN message received2 from " + event.origin + " : " + event.data); cmg_bigscreen_trackevent('closesignup2login', cmg_bsft); jQuery('#big-screen-overlay').hide(); if (jQuery('#big-screen-truex-overlay').length) { jQuery('#big-screen-truex-overlay').hide(); } window.location = "/login?destination=" + window.location.pathname; } else if (event.data == "continue-premium-big-screen" && (jQuery('#big-screen-overlay').length || jQuery('#pr-profile-screen-overlay').length) && valid_domain_msg) { // console.log("BIGSCREEN message received2 from " + event.origin + " : " + event.data); cmg_bigscreen_trackevent('playgame after signup', cmg_bsft); jQuery('#big-screen-overlay').hide(); jQuery('#pr-profile-screen-overlay').hide(); if (jQuery('#big-screen-truex-overlay').length) { jQuery('#big-screen-truex-overlay').hide(); } window.location.reload(); } else if (event.data == "big-screen-profile-customize" && (jQuery('#big-screen-overlay').length || jQuery('#pr-profile-screen-overlay').length) && valid_domain_msg) { // console.log("BIGSCREEN message received2 from " + event.origin + " : " + event.data); cmg_bigscreen_trackevent('profile customize after signup', cmg_bsft); jQuery('#big-screen-overlay').hide(); jQuery('#pr-profile-screen-overlay').hide(); if (jQuery('#big-screen-truex-overlay').length) { jQuery('#big-screen-truex-overlay').hide(); } if (getCookie('cmg_fx') !== null) { window.location = '/profile/' + getCookie('cmg_fx').toLowerCase() + '/edit'; } } else if (event.data == "big-screen-premium-benefits" && jQuery('#big-screen-overlay').length && valid_domain_msg) { // console.log("BIGSCREEN message received2 from " + event.origin + " : " + event.data); cmg_bigscreen_trackevent('see premium benefits after signup', cmg_bsft); jQuery('#big-screen-overlay').hide(); if (jQuery('#big-screen-truex-overlay').length) { jQuery('#big-screen-truex-overlay').hide(); } if (getCookie('cmg_fx') !== null) { window.location = '/premium-benefits'; } } else if (event.data == "keypress-from-game") { checkKeyboardOrMouseActivity(); } else if (event.origin === "https://copterroyale.coolmathgames.com" || event.origin === "https://copterroyale2.coolmathgames.com" || event.origin === "https://powerline.coolmathgames.com") { var eventObject = JSON.parse(event.data); if (eventObject.eventType == "gameEvent") { cmgGameEvent(eventObject.key, eventObject.value); } else if (eventObject.eventType == "dataEvent") { cmgDataEvent(eventObject.key, eventObject.value); } } else if (event.origin == 'https://hangman-backend.coolmathgames.com' || event.origin == 'https://hangman-frontend.coolmathgames.com' || event.origin == 'https://hangmanqa-frontend.coolmathgames.com' || event.origin == 'https://hangmanqa.coolmathgames.com') { var eventObject = JSON.parse(event.data); if (eventObject.eventType == "gameEvent") { cmgGameEvent("Hangman "+eventObject.key, eventObject.value); } else if (eventObject.eventType == "dataEvent") { cmgDataEvent("Hangman "+eventObject.key, eventObject.value); } } else if (event.origin == 'https://wordrace-4inrow-stage.coolmathgames.com' || event.origin == 'https://wordrace-4inrow.coolmathgames.com' ) { var eventObject = JSON.parse(event.data); var eventGame = "wordrace"; if(/0-four-in-a-row/.test(location.pathname)) { eventGame = "fourinarow"; } if (eventObject.eventType == "gameEvent") { cmgGameEvent(eventGame+" "+eventObject.key, eventObject.value); } else if (eventObject.eventType == "dataEvent") { cmgDataEvent(eventGame+" "+eventObject.key, eventObject.value); } } else if (event.origin == 'https://hexanaut.coolmathgames.com') { var eventObject = JSON.parse(event.data); var eventGame = "hexanaut"; if (eventObject.eventType == "gameEvent") { cmgGameEvent(eventGame+" "+eventObject.key, eventObject.value); } else if (eventObject.eventType == "dataEvent") { cmgDataEvent(eventGame+" "+eventObject.key, eventObject.value); } } else if (event.origin == 'https://cheerpx.coolmathgames.com' || event.origin == 'https://cheerpx-prod.coolmathgames.com') { console.log("cmg cheerpx: cmgHandleMessage "+event.data); //close loading screen closeCmgCheerpxLoadingScreen(); // Remove Narrow screen loading closeCmgCheerpxLoadingScreenResized(); } else if (event.origin == 'https://www.coolmath-games.com' || event.origin != 'https://d8-dev.coolmathgames.com') { if (event.data.eventType == "syncEventPut") { syncData = event.data.syncJSON; putSharedObjectsInDB(syncData); } if (event.data.eventType == "syncEventGet") { if (typeof flashStorageFromDB != "undefined") { // restoring flash shared objects from DB for (var i = 0; i < flashStorageFromDB.length; i++) { flashStorageFromDB[i].swfdata = decodeURI(flashStorageFromDB[i].swfdata); } document.getElementById('swfgame').contentWindow.postMessage({ 'eventType': 'syncEventGet', 'soData': flashStorageFromDB }, '*'); } else { document.getElementById('swfgame').contentWindow.postMessage({ 'eventType': 'gamePlay' }, '*'); } } } else { return; } } // var signupPromoTop = 'Join to Play Ad-Free'; var signupPromoBottom = 'Join to Skip All Ads'; if (typeof signupPromoTop !== 'undefined' && signupPromoTop !== '') { signupContainerTop = '
' + signupPromoTop + '
'; } else { signupPromoTop = ''; signupContainerTop = '
' + signupPromoTop + '
'; } if (typeof signupPromoBottom !== 'undefined' && signupPromoBottom !== '') { signupContainerBottom = '
' + signupPromoBottom + '
'; } else { signupPromoBottom = ''; signupContainerBottom = '
' + signupPromoBottom + '
'; } function preroll_signup_top_handler() { trackEvent('Preroll Signup Clicked', 'Preroll Signup Top', document.title); } function preroll_signup_bottom_handler() { trackEvent('Preroll Signup Clicked', 'Preroll Signup Bottom', document.title); } // we will define this varialbe signUpURLABTest in experiments.js var cmg_upg_days_limit = 180; var user_dst = window.location.pathname; user_dst = user_dst.replace("\/", ""); if (window.location.host !== 'cmatgame.local') { if (typeof signUpURL === 'undefined' || signUpURL === '') { signUpURL = '/premium-access/ b2df5a33?origin=' + user_dst; } else { signUpURL = signUpURL + '?origin=' + user_dst; } } else if (typeof signUpURLABTest === "undefined" || signUpURLABTest === null) { signUpURL = 'https://' + window.location.hostname + '/premium-access/ b2df5a33?origin=' + user_dst; } else { signUpURL = signUpURLABTest; } function subscription_promo_handler() { if (typeof freeTrialUser !== 'undefined' && freeTrialUser) { trackEvent('Premium Subscription ' + subscriberLeg, 'Subscription overlay clicked', userPlayedGames); trackGoalVirtualPV('/virtual/subscription-overlay-click'); } return; } function subscriptionSignUpUrl() { var user_played_games = ''; var zeroFreeGamesLeftUsers = localStorage.getItem("zeroFreeGamesLeftUsers"); if (typeof userPlayedGames !== 'undefined' && userPlayedGames) { user_played_games = "upg=" + userPlayedGames; } else { user_played_games = "upg=0"; } if (zeroFreeGamesLeftUsers !== null && user_played_games !== '') { user_played_games = user_played_games + '&zfg=' + zeroFreeGamesLeftUsers; } else if (zeroFreeGamesLeftUsers !== null) { user_played_games = 'zfg=' + zeroFreeGamesLeftUsers; } if (typeof signUpURL !== 'undefined' && signUpURL !== null && signUpURL.indexOf('upg') === -1) { if (signUpURL.indexOf('?random_true') > -1) { signUpURL = signUpURL.replace('?random_true', ''); } if (signUpURL.indexOf('?') > -1) { signUpURL = signUpURL + '&' + user_played_games; } else { signUpURL = signUpURL + '?' + user_played_games; } } } function updateMyGamesTimeSpent(gameId) { var userActivityTime = Date.now(); // if(userActivityTime - lastKeyBoardorMouseActivityTime <= 60000) { //user is active on page for last 60 seconds, so we can add this as his XP if (currentTimeInterval >= 2) { currentTimeInterval = 0; if (isUserValidFreeUserOrSubscriber()) { // save MyGames only for subscribers saveMyGames(gameId, 0, 1); currentTime = userActivityTime; } } else { currentTimeInterval = currentTimeInterval + 1; saveUserProgress(); // save user progress every 20 sec } // } } function updateMyGamesTimeSpent1(gameId) { if (isUserValidFreeUserOrSubscriber()) { // save MyGames only for subscribers if (userActivityTime - lastKeyBoardorMouseActivityTime <= 60000) { saveMyGames(gameId, 0, 1); } } } function updateMyGamesTimeSpentLevelBase(gameId, level) { if (isUserValidFreeUserOrSubscriber()) { // save MyGames only for subscribers saveMyGames(gameId, 1, level); } } /* if(!is_level_based) { var objGameNode = {}; objGameNode[gameId] = "yes"; localStorage.setItem("runoncestarted", JSON.stringify(objGameNode)); setInterval(function () { updateMyGamesTimeSpent1(gameId) }, 60000); } */ if (is_level_based) { var userActivityTime = Date.now(); // for level based game. check if user activity is not there more than 55 min 60000*55 = 3300000 if (userActivityTime - lastKeyBoardorMouseActivityTime <= 3300000) { var objGameNode = {}; objGameNode[gameId] = "no"; var localgamestrate = "storagelocal-" + gameId + "-storagelocal"; localStorage.setItem("runoncestarted", JSON.stringify(objGameNode)); localStorage.setItem(localgamestrate, "no"); updateMyGamesTimeSpentLevelBase(gameId, levelofcompletedgame) } } function cmgGetCheerpxUrl() { var cheerpxUrl = 'https://cheerpx-prod.coolmathgames.com/cheerpx.html?f='; if(location.host != "www.coolmathgames.com" && !/(Firefox)/.test(navigator.userAgent)) { cheerpxUrl = 'https://cheerpx.coolmathgames.com/cheerpx.html?f='; } return cheerpxUrl; } function displayCmgCheerpxLoadingScreen() { //todo -- use the iframe widht and height //jQuery("#swfgame").parent().before("
Loading...
") jQuery("#swfgame").parent().before('
Your Flash game is loading
it may take longer than usual
'); } // Narrow Screen Loading Screen function displayCmgCheerpxLoadingScreenResized(){ jQuery("#swfgame").parent().before('
Your Flash game is loading
it may take longer than usual
'); } function closeCmgCheerpxLoadingScreen() { jQuery("#cmg-cheerpxloading-screen").remove(); } // Removing Narrow Screen Loading Screen function closeCmgCheerpxLoadingScreenResized(){ if($("#cmg-cheerpxloading-screen-resized").length > 0){ jQuery("#cmg-cheerpxloading-screen-resized").remove(); } } /* * Remove remove Preroll And Display Game. Old function name: removePrerollAndDisplayGame(). */ function cmg_remove_padg() { //homepage continue playing lastplayedgame - cmg_lpg if(gameId) { localStorage.setItem("cmg_lpg", gameId); } settimebased(); prerollAdDisplayed = true;//This is to be invoked after preroll ad is done; if(document.documentElement.clientWidth >= 960 - ( window.innerWidth-jQuery(document).width() )) { prerollAdEnd = "dtp"; } else { prerollAdEnd = "mob"; } if (isRemoveAdSwfJWPLayer) { // remove preroll only once } else { // record current time to calculate how much time user spent on playing the current game currentTime = Date.now(); currentTimeInterval = 0; // call this only for timebased games // TODO save game progress /*if(!is_level_based) { setInterval(function () { updateMyGamesTimeSpent(gameId) }, 20000); } */ jQuery("#my-content").css("opacity", "1"); if (typeof intervalId != "undefined") { clearInterval(intervalId); } jQuery("#afg_container").remove(); jQuery("#afg_preloader").remove(); jQuery("#continue-container").remove(); if (!drupalSettings.cmatgame.swfembed) { // html5 game game width, game height and game type game_width = jQuery("#html5game").attr("width"); game_height = jQuery("#html5game").attr("height"); game_type = "html5"; // IE Detection and Version grabbing ie = false; var html5_game_url = jQuery("#html5game").attr("src"); var swf_game_url = jQuery("#swfgame").attr("src"); if( (/hangman/.test(html5_game_url) || /85380/.test(gameId) ) && typeof getParameterByName != "undefined") { var qLobby = getParameterByName("private-lobby"); var qPlay = getParameterByName("play"); var qXid = getParameterByName("xid"); if(typeof qLobby != "undefined" && typeof qXid != "undefined" && qLobby !== "" && qXid !== "" && html5_game_url.indexOf("hangman") && html5_game_url.indexOf("/home") ) { html5_game_url = html5_game_url.replace("/home", "/private-lobby/" +qLobby + "/" +qXid); } else if(typeof qPlay != "undefined" && typeof qXid != "undefined" && qPlay !== "" && qXid !== "" && html5_game_url.indexOf("hangman") && html5_game_url.indexOf("/home")) { html5_game_url = html5_game_url.replace("/home", "/play/" + qPlay + "/" +qXid); } } else if( /bloobio|bloob\.io/.test(html5_game_url) && typeof getParameterByName != "undefined") { var qLobby = getParameterByName("private-lobby"); if(typeof qLobby != "undefined" && qLobby !== "") { html5_game_url = html5_game_url + '/'+qLobby; } if(typeof drupalSettings.language != "undefined" && drupalSettings.language != "en") { if(!/locale=/.test(html5_game_url)) { html5_game_url = html5_game_url + "?locale="+drupalSettings.language; } var isMobile = cmg_is_mobile_device(); if(isMobile && !/mobile=/.test(html5_game_url)) { html5_game_url = html5_game_url + "&mobile=true"; } } } if (typeof swf_game_url !== 'undefined') { if (!cmg_flash_emulated_game()) { // console.log('flash is undefined'); flashDetectionMessage(); } } if (typeof swf_game_url !== 'undefined' && swf_game_url.indexOf("//") === 0) { swf_game_url = window.location.protocol + swf_game_url; } else if (typeof swf_game_url !== 'undefined' && swf_game_url.indexOf("//") > 0) { swf_game_url = swf_game_url.replace("http:", window.location.protocol); } if (typeof html5_game_url !== 'undefined' && html5_game_url.indexOf("//") === 0) { html5_game_url = window.location.protocol + html5_game_url; } else if (typeof html5_game_url !== 'undefined' && html5_game_url.indexOf("//") > 0) { html5_game_url = html5_game_url.replace("http:", window.location.protocol); } if (navigator.appName == "Microsoft Internet Explorer") { ie = true; var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})"); if (re.exec(ua) != null) { ieVersion = parseInt(RegExp.$1) } } if (ie && ieVersion < 9) { nothtml5browser = '
Hey, you\'re using an older web browser that can\'t play HTML5 games like this one.
Please switch to another browser or just enjoy a different Coolmath game!' + 'div>
• Get a new Internet Explorer browser from Microsoft
'; jQuery("#html5game").replaceWith(nothtml5browser); jQuery("#swfgame").replaceWith(nothtml5browser); } else { sandbox = jQuery("#html5game").attr("sandbox"); if (sandbox !== undefined) { sandbox = ' sandbox=\"' + sandbox + '\"'; } else { sandbox = ''; } if(cmg_is_mobile_device() || document.documentElement.clientWidth < 960 - (window.innerWidth-jQuery(document).width()) ) { newiframe = '
'; newswfiframe = '
'; } else { newiframe = '
'; newswfiframe = '
'; } if (typeof isRemoveAdSwfJWPLayer === "undefined" || !isRemoveAdSwfJWPLayer) { jQuery("#html5game").replaceWith(newiframe); if (cmg_flash_emulated_game() || drupalSettings.cmatgame.flash_emulation === "1") { jQuery("#swfgame").replaceWith(newswfiframe); } else if(cmg_flash_emulated_game() && drupalSettings.cmatgame.flash_emulation === "2"){ //console.log("Cheerpx load 1"); game_width = drupalSettings.cmatgame.swfembed.swf.swf_1.width; game_height = drupalSettings.cmatgame.swfembed.swf.swf_1.height; game_type = "html5"; var swfURLObject = drupalSettings.cmatgame.swfembed.swf.u; var swfURLArray = swfURLObject.split("/"); //swf_1_game_url = "/sites/default/files/games/" + swfURLArray[swfURLArray.length-1]; swf_1_game_movie_param = swfURLArray[swfURLArray.length-1]; //cheerpx js var swf_game_url = cmgGetCheerpxUrl()+swfURLArray[swfURLArray.length-1]+'&w='+game_width+'&h='+game_height; //allow="cross-origin-isolated" --> origin trial use: crossorigin="use-credentials" newswfiframe = '
'; jQuery("#swfgame").replaceWith(newswfiframe); //console.log("Cheerpx replace iframe 3"); } } } } else { if (!cmg_flash_emulated_game() && (drupalSettings.cmatgame.flash_emulation !== "1" || drupalSettings.cmatgame.flash_emulation !== "2" )) { // console.log('flash is undefined'); /* CLSS-1614 to load html5 as backup - START */ var html5_game_url = jQuery("#html5game").attr("src"); if (typeof html5_game_url !== 'undefined') { game_width = jQuery("#html5game").attr("width"); game_height = jQuery("#html5game").attr("height"); game_type = "html5"; // IE Detection and Version grabbing ie = false; if (typeof html5_game_url !== 'undefined' && html5_game_url.indexOf("//") === 0) { html5_game_url = window.location.protocol + html5_game_url; } else if (typeof html5_game_url !== 'undefined' && html5_game_url.indexOf("//") > 0) { html5_game_url = html5_game_url.replace("http:", window.location.protocol); } if (navigator.appName == "Microsoft Internet Explorer") { ie = true; var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})"); if (re.exec(ua) != null) { ieVersion = parseInt(RegExp.$1) } } if (ie && ieVersion < 9) { nothtml5browser = '
Hey, you\'re using an older web browser that can\'t play HTML5 games like this one.
Please switch to another browser or just enjoy a different Coolmath game!' + 'div>
• Get a new Internet Explorer browser from Microsoft
'; jQuery("#html5game").replaceWith(nothtml5browser); } else { sandbox = jQuery("#html5game").attr("sandbox"); if (sandbox !== undefined) { sandbox = ' sandbox=\"' + sandbox + '\"'; } else { sandbox = ''; } newiframe = '
'; if (typeof isRemoveAdSwfJWPLayer === "undefined" || !isRemoveAdSwfJWPLayer) { jQuery("#html5game").replaceWith(newiframe); } } } else { /* CLSS-1614 to load html5 as backup - END */ flashDetectionMessage(); } } else { // flash game game width, game height and game type game_width = drupalSettings.cmatgame.swfembed.swf.swf_1.width; game_height = drupalSettings.cmatgame.swfembed.swf.swf_1.height; if(drupalSettings.cmatgame.flash_emulation === "1"){ //ruffle game_type = "html5"; var swfURLObject = drupalSettings.cmatgame.swfembed.swf.u; var swfURLArray = swfURLObject.split("/"); var swf_game_url = 'https://www.coolmath-games.com/sites/cmatgame/files/ruffle1/ruffle.html?f='+swfURLArray[swfURLArray.length-1]+'&w='+game_width+'&h='+game_height; newswfiframe = '
'; jQuery("#swfgame").replaceWith(newswfiframe); } else if(drupalSettings.cmatgame.flash_emulation === "2"){ //cheerpx game_type = "html5"; if (navigator.appName == "Microsoft Internet Explorer") { ie = true; var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})"); if (re.exec(ua) != null) { ieVersion = parseInt(RegExp.$1) } } if (ie && ieVersion <= 11) { notCheerpxBrowser = '
NO IE
'; //console.log("Cheerpx avoid load completely on IE"); jQuery("#html5game").replaceWith(notCheerpxBrowser); } //console.log("Cheerpx load 2"); game_width = drupalSettings.cmatgame.swfembed.swf.swf_1.width; game_height = drupalSettings.cmatgame.swfembed.swf.swf_1.height; var swfURLObject = drupalSettings.cmatgame.swfembed.swf.u; var swfURLArray = swfURLObject.split("/"); //swf_1_game_url = "/sites/default/files/games/" + swfURLArray[swfURLArray.length-1]; swf_1_game_movie_param = swfURLArray[swfURLArray.length-1]; //cheerpx js var swf_game_url = cmgGetCheerpxUrl()+swfURLArray[swfURLArray.length-1]+'&w='+game_width+'&h='+game_height; //allow="cross-origin-isolated" --> origin trial use: crossorigin="use-credentials" newswfiframe = '
'; jQuery("#swfgame").replaceWith(newswfiframe); console.log("Cheerpx replace iframe and loading screen"); displayCmgCheerpxLoadingScreen(); } else { game_type = "flash"; if (typeof isRemoveAdSwfJWPLayer === "undefined" || !isRemoveAdSwfJWPLayer) { var swf_game_url = jQuery("#swfgame").attr("src"); if (typeof swf_game_url !== 'undefined' && swf_game_url.indexOf("//") === 0) { swf_game_url = window.location.protocol + swf_game_url; } else if (typeof swf_game_url !== 'undefined' && swf_game_url.indexOf("//") > 0) { swf_game_url = swf_game_url.replace("http:", window.location.protocol); } newswfiframe = '
'; jQuery("#swfgame").replaceWith(newswfiframe); var gameInstructions = document.getElementById('game-instructions'); // insert fix flash div before game instructions field if (typeof gameInstructions !== 'undefined' && gameInstructions !== null && typeof gameInstructions.innerHTML !== 'undefined' && gameInstructions.innerHTML !== null) { gameInstructions.innerHTML = '
If this flash game doesn\'t work on your computer, go here for help.
' + gameInstructions.innerHTML; } } } isRemoveAdSwfJWPLayer = true; } } } jQuery('.game-xp-bar-immerse-button').addClass('enabled'); jQuery('.btn.btn-primary.btn-sm.requestfullscreen').css('display', 'inline-block'); //Deferred js is breaking the display of bigscreen button deferredbigscreenbtn = setTimeout(function () { if(jQuery('.btn.btn-primary.btn-sm.requestfullscreen').length && !jQuery('.btn.btn-primary.btn-sm.requestfullscreen').is(":visible")) { jQuery('.btn.btn-primary.btn-sm.requestfullscreen').css('display', 'inline-block'); } }, 2000); if(typeof display_game_progressbar === "function"){ display_game_progressbar(gameId); } } function cmatgame_premium_subscription_game_display() { var cmatgame_subscriber = getCookie('cmg_sx'); var validSubscriber = false; if (typeof cmatgame_subscriber !== 'undefined' && cmatgame_subscriber !== null) { validSubscriber = true; } if(getCookie("cmg_wl") !== null) { validSubscriber = true; } var cmatgame_free_user = getCookie('cmg_fx'); var validFreeUser = false; if (typeof cmatgame_free_user !== 'undefined' && cmatgame_free_user !== null) { validFreeUser = true; } if (typeof subscribeNowAlienClass === 'undefined' || subscribeNowAlienClass === null || subscribeNowAlienClass === '') { // if (drupalSettings.cmatgame.isSubscriptionActive == false) { // subscribeNowAlienClass = "subscribe-now-alien-subscribe"; // } else { // subscribeNowAlienClass = "subscribe-now-alien-signup"; // } } freeGamesExceeded = true; // Display Ads to anonymous users the time from 7am to 13pm, display ads to anonymous users from 13pm to 11:59pm and 00 to 7am only if the user is not from New York city // TODO --> Need to add day of the week for school hours logic, day < 6 do not display Ads when GDPR cookie is set abd GDPR_All cookie is not set // Remove preroll-ads for whitelist users if (validSubscriber || getCookie("cmg_wl") !== null) { // retrieve user progress retrieveUserProgress(); cmg_remove_padg(); jQuery(document).ready(function () { $('.game-xp-bar-immerse-button').addClass('enabled'); jQuery('.btn.btn-primary.btn-sm.requestfullscreen').css('display', 'inline-block'); display_game_progressbar(gameId); immersive_mode_display_controller(); }); } else if (getCookie('cmg_schwl') !== null || typeof cmg_no_ads !== 'undefined' || (! validSubscriber && schoolHours || (!schoolHours && !targetStateUser) || (!schoolHours && targetStateUser && getCookie('cmg_active_anonymous_user') !== null))) { // TODO Display Game cmg_remove_padg(); jQuery(document).ready(function () { $('.game-xp-bar-immerse-button').addClass('enabled'); jQuery('.btn.btn-primary.btn-sm.requestfullscreen').css('display', 'inline-block'); display_game_progressbar(gameId); }); if (!/0-chess/.test(window.location.pathname)) { // setCookie('cmg_active_anonymous_user', 'active', 30*60*1000); } } else if (! validSubscriber && !schoolHours && targetStateUser && getCookie('cmg_active_anonymous_user') === null && getCookie('cmg_editor') === null) { // if user comes from google dont show the subscription paywall var ref = document.referrer; // count number of games played by the user this month userPlayedGames = 0; var userFreeGameList = []; var freeGameNid = 12670; if (sessionStorage.getItem("userFreeGameList") !== null && navigator.cookieEnabled) { userFreeGameList = JSON.parse(sessionStorage.getItem("userFreeGameList")); } if ((localStorage.getItem("userPlayedGames") == null || getCookie('cmg_upg') === null) && freeGameLimit !== 0 && navigator.cookieEnabled) { userPlayedGames = 1; localStorage.setItem("userPlayedGames", userPlayedGames); // TODO monthly cookie setCookie('cmg_upg', 'true', cmg_upg_days_limit * 24 * 60 * 60 * 1000); userFreeGameList = [freeGameNid]; sessionStorage.setItem("userFreeGameList", JSON.stringify(userFreeGameList)); // TODO Display Game cmg_remove_padg(); jQuery(document).ready(function () { display_game_progressbar(gameId); }); } else { // userPlayedGames = parseInt(localStorage.getItem("userPlayedGames"+currentMonth+currentYear)); Monthly limit if (localStorage.getItem("userPlayedGames") !== null && getCookie('cmg_upg') !== null) { userPlayedGames = parseInt(localStorage.getItem("userPlayedGames")); } else { userPlayedGames = 0; setCookie('cmg_upg', 'true', cmg_upg_days_limit * 24 * 60 * 60 * 1000); } if (freeGameLimit != 0 && userPlayedGames < freeGameLimit && userFreeGameList.indexOf(freeGameNid) === -1) { userPlayedGames ++; freeGamesExceeded = false; if (userFreeGameList.length > 0) { userFreeGameList = userFreeGameList.concat(freeGameNid); } else { userFreeGameList = [freeGameNid]; } localStorage.setItem("userPlayedGames", userPlayedGames); sessionStorage.setItem("userFreeGameList", JSON.stringify(userFreeGameList)); } else { freeGamesExceeded = true; } // console.log("Number of games user has played "+ userPlayedGames ); var validReferer = false; var validGameSession = false; if (userFreeGameList.indexOf(freeGameNid) > -1) { validGameSession = true; } if (ref.match("google.com") !== null || ref.match("yahoo.com") !== null || ref.match("bing.com") !== null) { validReferer = true; } subscriptionSignUpUrl(); if (! validReferer && userPlayedGames >= freeGameLimit && ! validGameSession) { // subscription paywall // block anonymous users for New York City from 0-7am and 13pm to 11:59pm console.log("Free games limit exceeded and referer is not google"); clearInterval(intervalId); jQuery("#afg_container").remove(); jQuery(".game-instructions").remove(); var alreadySubscriberText = '
Already a Subscriber? Login
'; if (getCookie('cmg_l') != null) { alreadySubscriberText = ''; } var headLine = '
Please Sign up to keep playing
'; if (getCookie('cmg_l') != null && getCookie('cmg_sx') != null) { headLine = '
PLEASE SUBSCRIBE NOW TO KEEP PLAYING
'; } jQuery(".field-game").html('
' + headLine + '
The World\'s Best Collection of Games
For Logic, Reasoning & Fun. Subscribe Now' + alreadySubscriberText + '
'); jQuery("#videoplayer").remove(); } else { // console.log("User may have come from google or is within the free game limit "+ (freeGameLimit-userPlayedGames) ); // TODO Display Game cmg_remove_padg(); jQuery(document).ready(function () { display_game_progressbar(gameId); }); } } } } function unlockAllLevels() { trackEvent('Unlock All Levels category', 'unlock all levels button clicked', document.title); alllevels = '
levels-unlocked
'; jQuery("#subscriber-banner").replaceWith(alllevels); var cmgorigindomain = /coolmath-games/; var cmgtargetdomain = window.location.protocol + 'www.coolmath-games.com'; if (/edit-stage/.test(window.location.hostname)) { cmgtargetdomain = window.location.protocol + 'edit-stage.coolmath-games.com'; } else if (/d8-dev/.test(window.location.hostname)) { cmgtargetdomain = window.location.protocol + 'stage.coolmath-games.com'; } else if (/cmatgame.local|dev.coolmath.games.com/.test(window.location.hostname)) { cmgtargetdomain = window.location.protocol + 'stage.coolmath-games.com'; } if (game_type == "html5") { document.getElementById("html5game").contentWindow.unlockAllLevels(); } else { if (cmgorigindomain.test(window.location.hostname)) { document.getElementById("swfObjID").unlockAllLevels(); } else { var recievergameFrame = document.getElementById("swfgame"); gDate = new Date(); recievergameFrame.contentWindow.postMessage('unlockAllLevels', cmgtargetdomain); // TODO -- put target origin } } } function addSubToUnlockGAEvent() { trackEvent('Unlock All Levels category', 'subscribe to unlock button clicked', document.title); trackGoalVirtualPV('/virtual/unlock-button-click'); window.location.href = "https://www.coolmathgames.com/signup/ b2df5a33?origin= /0-idle-dice&stual=1" } var immersive_mode_enabled = false; // Rules for big screen free trial function valid_big_screen_ft() { validUserMode = false; cmg_bsft = getCookie('cmg_bsft') !== null ? parseInt(getCookie('cmg_bsft')) : 0; // Logged in user if (getCookie('cmg_fx') !== null && getCookie('cmg_uid') !== null) { cmg_uid_bsft = getCookie('cmg_bsft_' + getCookie('cmg_uid')); if (cmg_uid_bsft !== null) { cmg_bsft = parseInt(cmg_uid_bsft); } else { cmg_bsft = 0; } } if (cmg_bsft <= 3) { validUserMode = true; } return validUserMode; } function immersive_mode_display_controller() { var validUserMode = false; if (getCookie('cmg_sx') !== null || getCookie("cmg_wl") !== null) { // display xp bar for premium users $('.game-xp-bar-immerse-button').addClass('enabled'); jQuery('.btn.btn-primary.btn-sm.requestfullscreen').css('display', 'inline-block'); validUserMode = true; } else if (getCookie('cmg_fx') !== null) { // Is valid Freemium user free trial ? if (valid_big_screen_ft()) { validUserMode = true; } else { validUserMode = true; // console.log("User reached FT limit. Display Big screen button ?"); } } else { // Is valid Anonymous user free trial ? if (valid_big_screen_ft()) { validUserMode = true; } } if (validUserMode && ! immersive_mode_enabled) { immersive_mode_enabled = true; immersive_mode_display(); } } var bigScreenTimer = null; bigScreenActive = false; function cmg_bigscreen_trackevent(type, trial_num) { if (jQuery('#big-screen-truex-overlay').length) { jQuery('#big-screen-truex-overlay').hide(); } var tCat = 'BigScreen-Trial'; if (cmg_stop_truex_promo === '' || cmg_stop_truex_promo !== 'yes') { var tCat = 'BigScreen-TrueX-Promo'; } var tUsr = 'Anonymous user'; if (typeof getCookie === 'function' && (getCookie('cmg_sx') !== null || getCookie('cmg_wl') !== null)) { tUsr = 'Subscriber'; } else if (typeof getCookie === 'function' && getCookie('cmg_fx') !== null) { tUsr = 'Freemium user'; } var tEvt = tUsr + ' trial ' + trial_num + ' - ' + type; if (cmg_stop_truex_promo === '' || cmg_stop_truex_promo !== 'yes') { tEvt = tUsr + ' TrueX Promo' + ' - ' + type; } else { if (trial_num > 3) { tEvt = tUsr + ' no more trial ' + ' - ' + type; } } if (type === 'enter' || type === 'exit' || type === 'closesignup' || type == 'closepromo' || type == 'bigscreen-exit') { trackEvent(tCat, tEvt, document.title); } else if (type === 'exit2signup' || type === 'signup') { if (cmg_stop_truex_promo === '' || cmg_stop_truex_promo !== 'yes') { var sLeg = get_premium_access_leg_desc('849ef809'); if (typeof getCookie === 'function' && getCookie('cmg_fx') !== null && (getCookie('cmg_sx') === null && getCookie('cmg_wl') === null)) { sLeg = get_premium_access_leg_desc('e180e28d'); } trackEvent(tCat, tEvt + ' - Leg - ' + sLeg, document.title); } else { var sLeg = get_premium_access_leg_desc('1bb008bd'); if (typeof getCookie === 'function' && getCookie('cmg_fx') !== null && (getCookie('cmg_sx') === null && getCookie('cmg_wl') === null)) { sLeg = get_premium_access_leg_desc('7859e605'); } trackEvent(tCat, tEvt + ' - Leg - ' + sLeg, document.title); } } else { trackEvent(tCat, type, document.title); } } popover_login_click = false; function cmg_display_login_page() { //console.log("login link clicked in popup message"); popover_login_click = true; if (jQuery('#popover' + gameId).length) { jQuery('#popover' + gameId).remove(); immerse_hover_on = 0; } window.location = "/login?destination=" + window.location.pathname } function display_cmg_overlay_signupform(variant) { // console.log("BIG SCREEN display_cmg_overlay_signupform: "+new Date()); if (jQuery('#popover' + gameId).length) { jQuery('#popover' + gameId).remove(); immerse_hover_on = 0; } // track event of type 'signup' if (typeof cmg_bsft === 'undefined') { cmg_bsft = 0; if (getCookie('cmg_fx') === null) { cmg_bsft = getCookie('cmg_bsft') !== null ? parseInt(getCookie('cmg_bsft')) : 0; } else if (getCookie('cmg_uid') !== null && getCookie('cmg_bsft_' + getCookie('cmg_uid')) !== null) { cmg_bsft = getCookie('cmg_bsft_' + getCookie('cmg_uid')); } } cmg_bigscreen_trackevent('signup', cmg_bsft); if ((getCookie('cmg_sx') === null && getCookie('cmg_wl') === null)) { myStopFunction(); } // Check if A/B test is available if (typeof signup_abtest_cmg_bsft !== 'undefined') { //variant = signup_abtest_cmg_bsft; } if (typeof variant === 'undefined' || variant === '') { variant = '/16'; // 14b, 15c, 16 } if (cmg_stop_truex_promo !== '' && cmg_stop_truex_promo === 'yes' && jQuery('#big-screen-overlay').length) { jQuery('#big-screen-overlay').show(); } else if (cmg_stop_truex_promo !== '' && cmg_stop_truex_promo === 'yes') { var big_screen_url = ''; if (getCookie('cmg_fx') === null) { // big_screen_url = '/premium-access/1bb008bd' + variant + '?ts='+new Date().getTime();//Bigscreen trial plans // big_screen_url = '/premium-access/849ef809' + variant + '?ts=' + new Date().getTime(); // BSWOJ anon plan if(drupalSettings.language == 'en') { big_screen_url = '/premium-access/6ea95de6' + variant + '?ts='+new Date().getTime();//BSWOJ anon plan } else{ big_screen_url = '/'+drupalSettings.language+'/premium-access/6ea95de6' + variant + '?ts='+new Date().getTime();//BSWOJ anon plan } } else { // big_screen_url = '/premium-access/7859e605' + variant + '?ts='+new Date().getTime();//BSFT logged-in user plan if(drupalSettings.language == 'en') { big_screen_url = '/profile/premium-access/e180e28d' + variant + '?ts=' + new Date().getTime(); // BSWOJ logged-in user plan } else{ big_screen_url = '/'+drupalSettings.language+'/profile/premium-access/e180e28d' + variant + '?ts=' + new Date().getTime(); // BSWOJ logged-in user plan } } if (variant == 'thankyou') { if(drupalSettings.language == 'en') { big_screen_url = '/signup/thank-you/overlay?ts=1596827222&src=wc&origin=/premium-access/1bb008bd/14b&sp=0&cmgtypl=1bb008bd&cmgovly=1'; } else{ big_screen_url = '/'+drupalSettings.language+'/signup/thank-you/overlay?ts=1596827222&src=wc&origin=/premium-access/1bb008bd/14b&sp=0&cmgtypl=1bb008bd&cmgovly=1'; } } if (/coolmathgames/.test(location.host)) { // big_screen_url = "https://" + location.host + big_screen_url; } var ov_css = 'style="display:none; position: fixed; z-index: 100000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgb(0,0,0); background-color: rgba(0,0,0,0.4);" min-height="1040px"'; var ovc_css = 'style="margin: auto; padding: 10px; width: 850px;" min-height="540px"'; var iframe_overlay = '
'; // TODO Add this iframe at the correct place that it needs to go. jQuery('.global-wrapper').before(iframe_overlay); // TODO jQuery('#big_screen_iframe').css('height', '800px'); jQuery('#big-screen-overlay').fadeIn(1000); jQuery('.big-screen-signup-container .btn-close').on('click', function (e) { e.preventDefault(); jQuery('#big-screen-overlay').hide(); }); } else { var big_screen_url = ''; if (getCookie('cmg_fx') === null) { // big_screen_url = '/premium-access/1bb008bd' + variant + '?ts='+new Date().getTime(); if(drupalSettings.language == 'en') { big_screen_url = '/premium-access/849ef809' + variant + '?ts=' + new Date().getTime(); // BSWOJ anon plan } else{ big_screen_url = '/'+drupalSettings.language+'/premium-access/849ef809' + variant + '?ts=' + new Date().getTime(); // BSWOJ anon plan } } else { // big_screen_url = '/premium-access/7859e605' + variant + '?ts='+new Date().getTime(); if(drupalSettings.language == 'en') { big_screen_url = '/profile/premium-access/e180e28d' + variant + '?ts=' + new Date().getTime(); // BSWOJ logged-in user plan } else{ big_screen_url = '/'+drupalSettings.language+'/profile/premium-access/e180e28d' + variant + '?ts=' + new Date().getTime(); // BSWOJ logged-in user plan } } if (variant == 'thankyou') { if(drupalSettings.language == 'en') { big_screen_url = '/signup/thank-you/overlay?ts=1596827222&src=wc&origin=/premium-access/849ef809/14b&sp=0&cmgtypl=1bb008bd&cmgovly=1'; } else{ big_screen_url = '/'+drupalSettings.language+'/signup/thank-you/overlay?ts=1596827222&src=wc&origin=/premium-access/849ef809/14b&sp=0&cmgtypl=1bb008bd&cmgovly=1'; } } if (/coolmathgames/.test(location.host)) { // big_screen_url = "https://" + location.host + big_screen_url; } var ov_css = 'style="display:none; position: fixed; z-index: 100000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgb(0,0,0); background-color: rgba(0,0,0,0.4);" min-height="1040px"'; var ovc_css = 'style="margin: auto; padding: 10px; width: 850px;" min-height="540px"'; var iframe_overlay = '
'; // TODO Add this iframe at the correct place that it needs to go. jQuery('.global-wrapper').before(iframe_overlay); // TODO jQuery('#big_screen_iframe').css('height', '800px'); jQuery('#big-screen-overlay').fadeIn(1000); jQuery('.big-screen-signup-container .btn-close').on('click', function (e) { e.preventDefault(); jQuery('#big-screen-overlay').hide(); }); } } function immersive_mode_exit_handler(variant) { start_full_screen_without_ad = false;//clss-3207 no ad after 1st trial bigScreenActive = false; cmg_bsft = getCookie('cmg_bsft') !== null ? parseInt(getCookie('cmg_bsft')) : 0; // we do not increment in exit handler // Logged in user if (getCookie('cmg_fx') !== null && getCookie('cmg_uid') !== null) { cmg_uid_bsft = getCookie('cmg_bsft_' + getCookie('cmg_uid')); if (cmg_uid_bsft !== null) { cmg_bsft = parseInt(cmg_uid_bsft); } else { cmg_bsft = 0; } } if (cmg_bsft >= 3 && getCookie('cmg_sx') === null && getCookie('cmg_wl') === null) { // Redirect the user to signup page if (jQuery.fullscreen.isFullScreen()) { jQuery.fullscreen.exit(); } if (cmg_stop_truex_promo !== '' && cmg_stop_truex_promo === 'yes') { // track event of type 'exit2signup' cmg_bigscreen_trackevent('exit2signup', cmg_bsft); display_cmg_overlay_signupform(variant); } else { cmg_bigscreen_trackevent('bigscreen-exit', cmg_bsft); } } else if (getCookie('cmg_sx') === null && getCookie('cmg_wl') === null) { myTimerAction(); } if (bigScreenTimer) { clearTimeout(bigScreenTimer); bigScreenTimer = null; } if (cmg_bsft < 3) { // track event of type 'exit' cmg_bigscreen_trackevent('exit', cmg_bsft); } } function bigScreenTimerAction() { cmg_bsft = 3; if (typeof bigScreenActive !== 'undefined' && bigScreenActive) { if (getCookie('cmg_fx') !== null && getCookie('cmg_uid') !== null) { // Logged in user cmg_uid_bsft = getCookie('cmg_bsft_' + getCookie('cmg_uid')); if (cmg_uid_bsft !== null) { // cmg_bsft = parseInt(cmg_uid_bsft) + 1; cmg_bsft = 3; // 3011 } else { cmg_bsft = 3; // 3011 } // Ajax request to update user object url = "/ajax/cmgbsft/" + getCookie('cmg_uid') + '/' + cmg_bsft; // + '?' + new Date().getTime(); status = 0; jQuery.getJSON(url, function (data) { if (typeof data.uid !== 'undefined' && data.cmgbsft !== 'undefined') { status = 1; } }); // setCookie('cmg_bsft_'+getCookie('cmg_uid'), cmg_bsft, 365 * 24 * 60 * 60 * 1000); } else { // Anon user // cmg_bsft = getCookie('cmg_bsft') !== null ? parseInt(getCookie('cmg_bsft')) + 1 : 1; cmg_bsft = 3; // 3011 setCookie('cmg_bsft', cmg_bsft, 365 * 24 * 60 * 60 * 1000); } clearTimeout(bigScreenTimer); bigScreenTimer = null; } } var immerse_hover_on = 0; var immerse_hover_in = 0; var big_screen_msg_on = 0; function immersive_popover_msg() { var popover_msg = "New Premium Feature! Try it for FREE now"; if ((getCookie('cmg_sx') !== null || getCookie('cmg_wl') !== null)) { popover_msg = "New Premium Feature! Try it now!"; } else { cmg_bsft = getCookie('cmg_bsft') !== null ? parseInt(getCookie('cmg_bsft')) : 0; // Logged in user if (getCookie('cmg_fx') !== null && getCookie('cmg_uid') !== null) { cmg_uid_bsft = getCookie('cmg_bsft_' + getCookie('cmg_uid')); if (cmg_uid_bsft !== null) { cmg_bsft = parseInt(cmg_uid_bsft); } else { cmg_bsft = 0; } } // setCookie('cmg_bsft', cmg_bsft, 365*24*60*60*1000);todo in timer function after bigscreen is active for a minute if (cmg_bsft === 1) { popover_msg = "2 Free Trials Remaining"; } else if (cmg_bsft === 2) { popover_msg = "1 Free Trial Remaining"; } else if (cmg_bsft >= 3) { var variant = ''; if (typeof signup_abtest_2_variations_adfree_modular !== 'undefined') { variant = '/'.signup_abtest_2_variations_adfree_modular; } if (getCookie('cmg_fx') !== null) { popover_msg = 'BIG SCREEN is a Premium Feature.
Please Sign Up'; } else { popover_msg = 'BIG SCREEN is a Premium Feature.
Please Sign Up or Log In.'; } } } return popover_msg; } var cmg_bs_popover_prefix = '
PLAY BIG SCREEN AFTER THIS 30 SECOND AD
'); myStopFunction(); trueXTimer = setTimeout(function () { jQuery('#big-screen-truex-header-text').css('background-color', '#16202c').css('padding-top', '14px').html('
PLEASE INTERACT WITH THIS AD TO CONTINUE
'); // .css('margin-top', '150px'); }, 25 * 1000); }); truexAd.onCredit(function (engagement) { // user spent 30 seconds and interacted at least once log("Bigscreen Truex Ad credit"); trackEvent('BigScreen-TrueX-Promo', 'View a Sponsored Video: TrueX Ad Credited', document.title); //
text to write ▶
jQuery('#big-screen-truex-header-text').css('background-color', '#16202c').css('padding-top', '14px').html('
'); document.getElementById("truex-bigscreen-activate-id").onclick = function () { event.preventDefault(); if (typeof bigScreenActive === 'undefined' || typeof bigScreenActive !== 'undefined' && !bigScreenActive) { jQuery('#big-screen-signup-container-id').html(""); jQuery('#big-screen-truex-overlay').remove(); cmg_start_game_full_screen('truex'); } } // console.log(engagement); }); truexAd.onClose(function (activity) { // user closed the ad unit log("Bigscreen Truex Ad close"); trackEvent('BigScreen-TrueX-Promo', 'View a Sponsored Video: TrueX Ad Closed', document.title); containerClose(); requestTrueXAdsAndDisplay(client); }); truexAd.onFinish(function (activity) { // user got to end of ad log("Bigscreen Truex Ad finish"); trackEvent('BigScreen-TrueX-Promo', 'View a Sponsored Video: TrueX Ad Finished', document.title); jQuery('#big-screen-signup-container-id').html(""); jQuery('#big-screen-truex-overlay').remove(); // full screen cmg_start_game_full_screen("truex"); }); truexAd.onMessage(function (payload) { // log("onMessage = " + payload); }); // track TrueX Trigger Point Impression // client.trackTriggerPointImpression(truexAd); // handle opt-in click event // add TrueX Opt-in to DOM if (jQuery("#cmg-big-screen-truex-activity").length) { var truex_container = document.getElementById("cmg-big-screen-truex-activity"); document.getElementById("cmg-big-screen-truex-activity").onclick = function () { // truex_preroll_display_handler(); event.preventDefault(); trackEvent('BigScreen-TrueX-Promo', 'View a Sponsored Video: Button clicked', document.title); jQuery('.big-screen-options-container').hide(); if (truex_ad_available && typeof client !== 'undefined') { // BigScreen-TrueX-Promo log("Bigscreen Truex ad available. Show Truex activity"); trackEvent('BigScreen-TrueX-Promo', 'View a Sponsored Video: TrueX Ad Loading', document.title); client.loadActivityIntoContainer(truexAd, 'big-screen-signup-container-id', { width: "960px", height: "540px" }); // show_big_screen_preroll_ad();//test preroll } else { log("Bigscreen Truex ad not available. Instead show preroll video"); // TODO: Show preroll truex_overlay_preroll_ad_display = true; show_big_screen_preroll_ad(); trackEvent('BigScreen-TrueX-Promo', 'View a Sponsored Video: Preroll Ad Loading', document.title); } }; } // cmg-big-screen-truex-signup if (jQuery("#cmg-big-screen-truex-signup").length) { document.getElementById("cmg-big-screen-truex-signup").onclick = function () { log("Bigscreen button clicked"); event.preventDefault(); // jQuery('.big-screen-options-container').hide(); jQuery('#big-screen-truex-overlay').remove(); display_cmg_overlay_signupform(); }; } } function truex_preroll_display_handler() { // log("Truex ad is available. Show truex activity"); event.preventDefault(); trackEvent('BigScreen-TrueX-Promo', 'View a Sponsored Video: Button clicked', document.title); jQuery('.big-screen-options-container').hide(); if (truex_ad_available && (typeof client !== 'undefined' || cmg_truex_client != null) ) { // BigScreen-TrueX-Promo if(typeof client == "undefined") { client = cmg_truex_client; truexAd = cmg_truexAd; } trackEvent('BigScreen-TrueX-Promo', 'View a Sponsored Video: TrueX Ad Loading', document.title); client.loadActivityIntoContainer(truexAd, 'big-screen-signup-container-id', { width: "960px", height: "540px" }); // show_big_screen_preroll_ad();//test preroll } else { // log("Truex ad not available. Instead show preroll video"); // TODO: Show preroll truex_overlay_preroll_ad_display = true; show_big_screen_preroll_ad(); trackEvent('BigScreen-TrueX-Promo', 'View a Sponsored Video: Preroll Ad Loading', document.title); } } function containerClose() { // log("containerClose called."); } function log(msg) { console.log("CMG [%s] - %s", new Date().toLocaleTimeString(), msg); } cmg_truex_promo_events_added = 0; function display_big_screen_truex_options_overlay() { // initialize trueX ad client w/ options hash trackEvent('BigScreen-TrueX-Promo', 'Bigscreen button clicked', document.title); //console.log("big screen button click position 1 -"+ new Date()); if (getCookie('cmg_sx') !== null || getCookie('cmg_wl') !== null || getCookie('cmg_editor') !== null ) { event.preventDefault(); //console.log("big screen button click -"+ new Date()); cmg_start_game_full_screen('truex'); } else { network_user_id = getCookie('_ga'); if (typeof network_user_id !== 'undefined' && network_user_id !== '') { network_user_id = network_user_id.replace('GA', 'cmg').replaceAll("\.", ""); } // TRUEX Test Hash // truex_options = {'network_user_id': network_user_id, 'partner_config_hash': '83f879b26797c723882473d6435e6361c105d86b'}; // TRUEX Live Hash truex_options = { 'network_user_id': network_user_id, 'partner_config_hash': '375f2f2b728700cd991bb24601b3841c98375886' }; if (typeof truex !== 'undefined') { truex.client(truex_options, function (client) { requestTrueXAdsAndDisplay(client); }); } var ov_css = ' style="display:none; position: fixed; z-index: 100000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgb(0,0,0); background-color: rgba(0,0,0,0.7);" min-height="1040px" '; var ovc_css = ' style="margin: auto; margin-top: 200px; padding: 10px; width: 424px; height: initial; background-color: #1f4f77; border:3px solid #286aa1;" '; var ovc_css_id = ' style="margin: auto; margin-top: 150px; width: 960px; " '; var truex_css = ' '; var truex_options1 = "
"; // onclick="truex_preroll_display_handler(); return false; --> below" var truex_options2 = "
"; var truex_optionsOR = "
"; var truex_options3 = "
"; if(getCookie("cmg_sac") == "no"){ truex_optionsOR = ""; truex_options3 = ""; } var truex_options4 = "
"; var truex_options_prefix = '
'; var truex_options_suffix = '
'; truex_options = truex_options_prefix + truex_options1 + truex_options2 + truex_optionsOR + truex_options3 + truex_options4 + truex_options_suffix; var truex_options_heading = '
' + '
'; var preroll_container = '
' + // '
Continue in
'+ // '15'; '
'; var bs_truex_options = '
' + '
' + '
' + '' + truex_options + '
' + '
' + '
' + truex_options_heading + '
' + preroll_container + '
' + '
'; // TODO Add this iframe at the correct place that it needs to go. jQuery('.global-wrapper').before(bs_truex_options); // TODO jQuery('#big_screen_iframe').css('height', '800px'); jQuery('.big-screen-options-container').show(); jQuery('#big-screen-truex-overlay').fadeIn(1000); // if(!cmg_truex_promo_events_added) { // cmg_truex_promo_events_added = 1; jQuery('.big-screen-options-container .btn-close').on('click', function (e) { e.preventDefault(); jQuery('#big-screen-truex-overlay').hide(); }); jQuery('#cmg-big-screen-truex-promo-close').on('click', function (e) { e.preventDefault(); jQuery('#big-screen-truex-overlay').hide(); }); // } } } function show_big_screen_preroll_ad() { event.preventDefault(); jQuery('#big-screen-truex-header-text').css('padding-top', '14px').html("
PLAY BIG SCREEN AFTER THIS AD
"); jQuery('.big-screen-options-container').hide(); var cmatgame_subscriber = getCookie('cmg_sx'); var validSubscriber = false; if (typeof cmatgame_subscriber !== 'undefined' && cmatgame_subscriber !== null) { validSubscriber = true; } // preroll ads var prerollUrls = /0\-testing/; if (! validSubscriber) { // display preroll ads window.scrollTo(0, 0); var modal = document.getElementById('big-screen-preroll-container'); // modal.style.display = 'block'; // clear refresh timer if (typeof refreshTimer !== "undefined") { clearTimeout(refreshTimer); refreshTimer = null; } var adTagUrl = 'https://pubads.g.doubleclick.net/gampad/ads?iu=/137548614/1023174/71134/1023174-71134-video&description_url=https%3A%2F%2Fwww.coolmathgames.com%2F&env=vp&impl=s&correlator=&tfcd=0&npa=0&gdfp_req=1&output=vast&sz=640x480&unviewed_position_start=1'; if (typeof window.PW_CMG != "undefined") { var auctionCallback = function (displayAds, videoUrl) { application = new Application(displayAds, videoUrl); }; window.PW_CMG.startAuction(auctionCallback); } else { // adblock application = new Application(false, adTagUrl); } bs_preroll_timer = 15; bs_preroll_intervalId = setInterval(function () { bs_preroll_timer --; jQuery('#big-screen-truex-header-text').html('
PLAY BIG SCREEN AFTER THIS AD: ' + bs_preroll_timer + '
'); // document.getElementById("preroll_timer_id").innerHTML = seconds_left; if (bs_preroll_timer <= 0) { jQuery('#big-screen-truex-header-text').html('
PLAY BIG SCREEN NOW ▶
'); document.getElementById("truex-bigscreen-activate-id").onclick = function () { event.preventDefault(); $('a.requestfullscreen>span.big-screen-popover-span').html('Play Big Screen'); if (typeof bigScreenActive === 'undefined' || typeof bigScreenActive !== 'undefined' && !bigScreenActive) { jQuery('#big-screen-signup-container-id').html(""); jQuery('#big-screen-truex-overlay').remove(); start_full_screen_without_ad = false; cmg_start_game_full_screen('truex'); } } clearInterval(bs_preroll_intervalId); } }, 1000); } } // TRUEX end function cmg_start_game_full_screen(cmgsource) { myStopFunction(); // no ad refresh bigScreenActive = true; // console.log("Starting fullscreen"); if (cmg_stop_truex_promo !== '' && cmg_stop_truex_promo === 'yes') { // trackEvent('BigScreen-Trial', 'Bigscreen activated', document.title); cmg_bigscreen_trackevent('enter', cmg_bsft); bigScreenTimer = setTimeout(function () { bigScreenTimerAction(); }, 60 * 1000); } else { // trackEvent('BigScreen-TrueX-Promo', 'Bigscreen activated', document.title); cmg_bigscreen_trackevent('enter', 0); } var elem = document.getElementById('block-system-main'); if (jQuery('html').hasClass('mobile-device')) { requestFullscreenModal(elem, document.title); return false; } if (elem.requestFullscreen) { elem.requestFullscreen(); } else if (elem.mozRequestFullScreen) { /* Firefox */ elem.mozRequestFullScreen(); } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari & Opera */ elem.webkitRequestFullscreen(); } else if (elem.msRequestFullscreen) { /* IE/Edge */ elem.msRequestFullscreen(); } else { requestFullscreenModal(elem, document.title); return false; } adjustWidthHeightGame(); } function immersive_mode_display() { var popover_msg = immersive_popover_msg(); var immerse_prefix = ''; // do not add title var immerse_suffix = ''; var immerse_html = "Watch Ad To Play Big Screen"; var immerse_html_sub = "PLAY BIG SCREEN"; if (getCookie('cmg_sx') !== null || getCookie('cmg_wl') !== null) { $(".immerse-button").html(immerse_prefix + immerse_html_sub + immerse_suffix); } else { $(".immerse-button").html(immerse_prefix + immerse_html + immerse_suffix); } if (getCookie('cmg_fx') !== null) { jQuery('.node-type-game.logged-in .requestfullscreen').css('display', 'inline-block'); } // get game var elem = document.getElementById('block-system-main'); // open game in fullscreen $('.immerse-button .requestfullscreen').on('click', function (e) { e.preventDefault(); //console.log("function immerse button onclick handler" + new Date()); // If mobile view show full screen without any ads // if($("html").hasClass("mobile-device")) { // cmg_start_game_full_screen(); // } if(/\/test-game\//.test(window.location.pathname)){ //console.log("test page"); cmg_start_game_full_screen(); } if (cmg_stop_truex_promo === '' || cmg_stop_truex_promo !== 'yes') { // TODO: Return from here or not? if (start_full_screen_without_ad) { display_big_screen_truex_options_overlay(); } else { cmg_start_game_full_screen(); } } return; if (jQuery('#popover' + gameId).length) { jQuery('#popover' + gameId).remove(); immerse_hover_on = 0; } cmg_bsft = getCookie('cmg_bsft') !== null ? parseInt(getCookie('cmg_bsft')) : 0; // Logged in user if (getCookie('cmg_fx') !== null && getCookie('cmg_uid') !== null) { cmg_uid_bsft = getCookie('cmg_bsft_' + getCookie('cmg_uid')); if (cmg_uid_bsft !== null) { cmg_bsft = parseInt(cmg_uid_bsft); } else { cmg_bsft = 0; } } if (cmg_stop_truex_promo !== '' && cmg_stop_truex_promo === 'yes') { if (cmg_bsft < 3) { // track event of type 'enter' cmg_bigscreen_trackevent('enter', cmg_bsft + 1); } if (getCookie('cmg_sx') !== null || getCookie("cmg_wl") !== null || cmg_bsft < 3) { cmg_start_game_full_screen(); } else { //console.log("BIG SCREEN You have reached a FT limit"); //Display signup form if(getCookie('cmg_sx') === null && getCookie('cmg_wl') === null && !popover_login_click) { display_cmg_overlay_signupform(); } // track event of type 'signup' // cmg_bigscreen_trackevent('signup', cmg_bsft+1); } } else { //Big Screen - TrueX Integration //TODO conditions to check or when to display the overlay if (getCookie('cmg_sx') === null && getCookie('cmg_wl') === null) { //console.log("Big screen button clicked. display the overlay with options"); display_big_screen_truex_options_overlay(); } else { if (cmg_bsft < 3) { // track event of type 'enter' cmg_bigscreen_trackevent('enter', cmg_bsft + 1); } if (getCookie('cmg_sx') !== null || getCookie('cmg_wl') !== null || cmg_bsft < 3) { cmg_start_game_full_screen(); } else { //console.log("BIG SCREEN You have reached a FT limit"); //Display signup form if(getCookie('cmg_sx') === null && getCookie('cmg_wl') === null && !popover_login_click) { //display_cmg_overlay_signupform(); } // track event of type 'signup' // cmg_bigscreen_trackevent('signup', cmg_bsft+1); } } } }); if (cmg_stop_truex_promo !== '' && cmg_stop_truex_promo === 'yes') { $('.immerse-button .requestfullscreen').hover(function () { // hover in // console.log("Bigscreen button hover in "+new Date()); immerse_hover_in = 1; if (!immerse_hover_on) { popover_msg = immersive_popover_msg(); var popover_html = cmg_bs_popover_prefix + cmg_bs_popover_suffix1 + popover_msg + cmg_bs_popover_suffix2; $(".immerse-button .big-screen-popover-span").after(popover_html); var width = $(".immerse-button").find('.requestfullscreen').width(); var height = $(".immerse-button").find('.popover').height(); var xPos = '-' + (width/2); var yPos = '-' + (height + 5); $(".immerse-button").find('.popover').css("transform","translate3d("+ xPos +"px, "+ yPos + "px, 0)"); immerse_hover_on = 1; if (jQuery('#popover' + gameId).length) { jQuery('#popover' + gameId).hover(function () { //console.log("Popover message hover in "+ new Date()); big_screen_msg_on = 1 }, function () { //console.log("Popover message hover out "+ new Date()); big_screen_msg_on = 0; }); } } }, function () { // hover out // console.log("Bigscreen button hover out "+ new Date()); immerse_hover_in = 0; setTimeout(function () { if (immerse_hover_on && !immerse_hover_in && !big_screen_msg_on) { jQuery('#popover' + gameId).remove(); immerse_hover_on = 0; } }, 1 * 1000); }); } // close game fullscreen $('#block-system-main .close-full-screen').on('click', function (e) { e.preventDefault(); immersive_mode_exit_handler(); jQuery.fullscreen.exit(); }); $('body').keypress(function (e) { if (e.which == 27) { if ($('.immerse-button .requestfullscreen').length && typeof bigScreenActive !== 'undefined' && bigScreenActive) { immersive_mode_exit_handler(); // jQuery.fullscreen.exit(); } } }); var screen_change_events = "webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange"; // toggle full screen window class jQuery(document).on(screen_change_events, function () { if (jQuery.fullscreen.isFullScreen()) { /* elem.classList.add('full-screen-window'); var iframe = document.getElementById('html5game') ? document.getElementById('html5game') : document.getElementById('swfgame'); var iframeWidth = parseInt(iframe.width); var iframeHeight = parseInt(iframe.height); var windowWidth = parseInt(screen.width); var windowHeight = parseInt(screen.height) - 75; var xpbarPos = (windowHeight + 75 - iframeHeight) / 2 + iframeHeight + 10; $('.game-xp-bar-immerse-button').css('top', xpbarPos + "px"); if ($("body").hasClass("game-scalable")) { if (iframeHeight > windowHeight) { var ratio = iframeHeight / windowHeight; } else { var ratio = windowHeight / iframeHeight; } // Calculating game width based on window height var gameWidth = iframeWidth * ratio; // apply new width and height with iframe and xp bar iframe.style.width = gameWidth + "px"; iframe.style.height = windowHeight + "px"; var xpbarPos = windowHeight + 10; $('.game-xp-bar-immerse-button').css('top', xpbarPos + "px"); } else if ($("body").hasClass("game-full-screen")) { // apply new width and height with iframe and xp bar iframe.style.width = windowWidth + "px"; iframe.style.height = windowHeight + "px"; var xpbarPos = windowHeight + 10; $('.game-xp-bar-immerse-button').css('top', xpbarPos + "px"); } */ if (jQuery('html').hasClass('mobile-device')) { jQuery("#block-system-main #html5game").attr('src', jQuery('#playNowButton').attr('href')); } $("body").addClass('immersiveActive'); elem.classList.add('full-screen-window'); // add zoomed alert chkZoomValues(); // Adjusted width and height of iframe game adjustWidthHeightGame(); } else { if (jQuery('html').hasClass('mobile-device')) { jQuery("#block-system-main #html5game").removeAttr('src'); } immersive_mode_exit_handler(); $("body").removeClass('immersiveActive'); elem.classList.remove('full-screen-window'); // remove zoomed alert $('.zoomedalert').remove(); $('#html5game').removeAttr("style"); $('#swfgame').removeAttr("style"); $('.game-xp-bar-immerse-button').removeAttr("style"); } }); } function adjustWidthHeightGame() { var iframe = document.getElementById('html5game') ? document.getElementById('html5game') : document.getElementById('swfgame'); var iframeWidth = parseInt(iframe.width); var iframeHeight = parseInt(iframe.height); // var windowWidth = parseInt(screen.width); // var windowHeight = parseInt(screen.height) - 75; var windowWidth = parseInt($(window).width()); var windowHeight = parseInt($(window).height()); var xpbarPos = (windowHeight + 75 - iframeHeight) / 2 + iframeHeight + 10; $('.game-xp-bar-immerse-button').css('top', xpbarPos + "px"); if ($("body").hasClass("game-scalable")) { if (iframeHeight > windowHeight) { var ratio = iframeHeight / windowHeight; } else { var ratio = windowHeight / iframeHeight; } // Calculating game width based on window height var gameWidth = iframeWidth * ratio; // apply new width and height with iframe and xp bar iframe.style.width = gameWidth + "px"; iframe.style.height = windowHeight + "px"; var xpbarPos = windowHeight + 10; $('.game-xp-bar-immerse-button').css('top', xpbarPos + "px"); } else if ($("body").hasClass("game-full-screen")) { // apply new width and height with iframe and xp bar iframe.style.width = windowWidth + "px"; iframe.style.height = windowHeight + "px"; var xpbarPos = windowHeight + 10; $('.game-xp-bar-immerse-button').css('top', xpbarPos + "px"); } } function adjustWidthHeightModalGame(is_resize) { var iframe = $('#immersiveModal').find('#html5game'); var iframeWidth = parseInt(iframe.attr('width')); var iframeHeight = parseInt(iframe.attr('height')); var time_out = (is_resize === true) ? 500 : 0; // setTimeout(function(){ var wdWidth = parseInt($(window).width()); var wdHeight = parseInt($(window).height()); var oTwdWidth = parseInt($(window).outerWidth()); var oTwdHeight = parseInt($(window).outerHeight()); var windowWidth = (oTwdWidth > wdWidth) ? oTwdWidth : wdWidth; var windowHeight = (oTwdHeight > wdHeight) ? oTwdHeight : wdHeight; if ($("body").hasClass("game-scalable")) { if (iframeHeight > windowHeight) { var ratio = iframeHeight / windowHeight; } else { var ratio = windowHeight / iframeHeight; } // Calculating game width based on window height var gameWidth = iframeWidth * ratio; // apply new width and height with iframe iframe.css("width", windowWidth); iframe.css("height", windowHeight); } else if ($("body").hasClass("game-full-screen")) { iframe.css("width", windowWidth); iframe.css("height", windowHeight); } // }, time_out); } // adjust game width/height if screen rotate from portrait to landscape window.addEventListener("resize", function () { if ($("body").hasClass("immersiveActive")) { adjustWidthHeightGame(); } if ($("body").hasClass("isFullScreen")) { adjustWidthHeightGame(); } if ($("body").find("#immersiveModal").length) { adjustWidthHeightModalGame(true); } if($("#swfgamewrapper #html5game").prop("tagName") == "IFRAME1" && !cmg_is_mobile_device() && document.documentElement.clientWidth >= 960 - ( window.innerWidth-jQuery(document).width() ) ) { if(hide_preroll_ads == false && (prerollAdDisplayed == false || prerollAdEnd != "" && prerollAdStart != prerollAdEnd ) && prerollAdEnd != "mob") {//TODO: isRemoveAdSwfJWPLayer or prerollAdDisplayed //console.log("CMGResize: gamenode-inline resizeed from mobile to desktop and game not loaded. TODO - Display preroll ad and then game - "+new Date()); displayPrerollAd_Desktop(); //TODO: 06/21/2022 Ads not displaying and hence game after it //cmg_remove_padg(); } else if(hide_preroll_ads == true || prerollAdDisplayed == true) { //console.log("CMGResize: gamenode-inline resizeed from mobile to desktop and game not loaded. Preroll ad already displayed. Display game - "+new Date()); cmg_remove_padg(); } } }, false); var cmg_mmg_html = ''; var cmg_mmg_swf_html = ''; var cmg_game_modal_attached = false; function attachModalHtml(elem, title) { cmg_game_modal_attached = true; var elem = document.getElementById('block-system-main'); html = '
'; $('body').append(html); var gamewrapper = jQuery("#swfgamewrapper"); jQuery('#immersiveModal .modal-body').html(gamewrapper); if(cmg_is_mobile_device() || (jQuery(".game-page-mobile .playNow").length && jQuery(".game-page-mobile .playNow").is(':visible') ) ) { sandbox = jQuery("#html5game").attr("sandbox"); if (sandbox !== undefined) { sandbox = ' sandbox=\"' + sandbox + '\"'; } else { sandbox = ''; } newiframe = '
'; if(jQuery("#html5game").length) { cmg_mmg_html = '
'; } newswfiframe = '
'; if(jQuery("#swfgame").length) { cmg_mmg_swf_html = '
'; } if (cmg_flash_emulated_game()) { if(drupalSettings.cmatgame.flash_emulation === "1"){ //ruffle game_type = "html5"; var swfURLObject = drupalSettings.cmatgame.swfembed.swf.u; var swfURLArray = swfURLObject.split("/"); game_width = drupalSettings.cmatgame.swfembed.swf.swf_1.width; game_height = drupalSettings.cmatgame.swfembed.swf.swf_1.height; var swf_game_url = 'https://www.coolmath-games.com/sites/cmatgame/files/ruffle1/ruffle.html?f='+swfURLArray[swfURLArray.length-1]+'&w='+game_width+'&h='+game_height; cmg_mmg_swf_html = '
'; } else if(drupalSettings.cmatgame.flash_emulation === "2"){ //ruffle //console.log("Cheerpx load 3"); game_type = "html5"; game_width = drupalSettings.cmatgame.swfembed.swf.swf_1.width; game_height = drupalSettings.cmatgame.swfembed.swf.swf_1.height; game_type = "html5"; var swfURLObject = drupalSettings.cmatgame.swfembed.swf.u; var swfURLArray = swfURLObject.split("/"); //swf_1_game_url = "/sites/default/files/games/" + swfURLArray[swfURLArray.length-1]; swf_1_game_movie_param = swfURLArray[swfURLArray.length-1]; //cheerpx js var swf_game_url = cmgGetCheerpxUrl()+swfURLArray[swfURLArray.length-1]+'&w='+game_width+'&h='+game_height; newswfiframe = '
'; jQuery("#swfgame").replaceWith(newswfiframe); //console.log("Cheerpx replace iframe 2"); } } } } function requestFullscreenModal(elem, title) { $("#immersiveModal").addClass('modal fade show full-screen-modal').css({"display":"block", "z-index":10000000}); $('body').addClass('isModalPlay'); $('#immersiveModal').find('#swfgamewrapper').show(); if($('#html5game').length || cmg_mmg_html) { jQuery("#swfgamewrapper").html(cmg_mmg_html); if (cmg_flash_emulated_game()) { jQuery("#swfgamewrapper").html(cmg_mmg_swf_html); } } else if(jQuery('#swfgame').length) { if (cmg_flash_emulated_game()) { if(drupalSettings.cmatgame.flash_emulation === "2"){ jQuery("#swfgamewrapper").html(newswfiframe); } else { jQuery("#swfgamewrapper").html(cmg_mmg_swf_html); } } } if(drupalSettings.cmatgame.flash_emulation === "2"){ displayCmgCheerpxLoadingScreenResized(); } $('#immersiveModal').find('.close').click(function () { $("#immersiveModal").remove(); }); window.location.hash = "immersiveModal"; $(window).on('hashchange', function (event) { if (window.location.hash != "#immersiveModal") { $("#immersiveModal").hide(); if($('#html5game').length) { $('#html5game').remove(); } else if(jQuery('#swfgame').length) { jQuery('#swfgame').remove(); } $('body').removeClass('isModalPlay'); } }); adjustWidthHeightModalGame(false); if (typeof browser !== "undefined" && browser == "Microsoft Internet Explorer") { if ("function" === typeof checkVersionBrowser) { ieVersion = checkVersionBrowser(); if(ieVersion == "IE 11" && !jQuery('#html5game').length) { jQuery("#swfgamewrapper").html(cmg_mmg_html); //console.log("requestFullscreenModal immersiveModal ieVersion ? "+ieVersion.length); } } } }
' + signupContainerTop).prependTo('.load-wrap'); }
Skip All Ads: Go Premium Now
Continue in
15
Click the Ad Blocker extension icon in the upper
right area of your browser window.
' + '
2
Choose “Don\’t run on this domain” or similar
option to disable it for all Coolmath Pages.
' + '
3
Refresh the Page
Having problems or need more info? Click here
' + '' + '
' + '
' + '
FAQs
How do you play Idle dice on Coolmath? ›
Instructions. Press the roll button to earn points. Spend your points to upgrade your dice or buy new ones. More choices open up the longer you play.
Is Coolmath Games still alive? ›We've seen a crazy rumor flying around that Coolmath Games is shutting down, but don't worry: There's no truth to it.
Why did Coolmath Games get blocked? ›Like Newsweek said, Flash would be shutting down to begin with,after all, they've most likely used Flash so many times to play the games on Coolmath. The answer is simple, it was a risk. Back before all of this,Adobe Flash was starting to become a security risk.
How do you beat Idle dice? ›- Start with the 2's, so that you can gain cards much quicker.
- Go for 5's, Q's, and 3's next, to maximize point gain. ...
- If you want to test your luck, go for kings next. ...
- If you want to leave the game for long periods of time, J's are a helpful card to choose.
Bonus Points (BP) are the secondary, less common currency system in Idle Dice excluding duel dice cup points and casinos.
What idle game means? ›An idle game, also known as an incremental game, is a genre of games defined by the primary feature of its strategy: leaving the game running by itself with minimum or zero player interaction. Interaction with the game, while often useful for progression, is optional for extended periods of gameplay.
Why did Flash shut down? ›Adobe had decided it wasn't in their best interest to support Flash Player and “pivoted” to HTML5. This happened not long after it became clear that Apple was not going to allow Flash Player to run in the browser on iPhones or iPads.
Does Coolmath have virus? ›DO NOT LET STUDENTS USE THIS WEBSITE! Coolmath is an old website filled with malware and spyware. Students previously used this website on the school equipment and it caused 70 laptops to crash. Equipment invested with viruses must be completely wiped and reformatted.
What was the first Coolmath game? ›...
Cool Math Games.
View screenshot A screenshot of www.coolmathgames.com on September 5, 2020. | |
---|---|
Launched | 1997 |
Written in | PHP, HTML and Adobe Flash |
Why do schools block games? Schools want their students to be productive and focus on their studies during their time, which is why schools block gaming apps or gaming websites. Unfortunately, many scammers are on the gaming websites; therefore, schools prefer to block gaming websites.
What games can't be blocked? ›
- Armorgames.com. Armorgames.com is a website that specializes in flash-based, browser-based, and downloadable games. ...
- Unblocked Games 24h. ...
- Subway Surfers. ...
- Unblocked Games WTF. ...
- Unblocked Games Pod. ...
- Unblocked Games 66. ...
- Unblocked Games 77. ...
- HoodaMath.
Not only does Coolmath Games have some pretty fantastic games, but we also have one of the best coding tutorials out there, especially when it comes to Roblox.
Can you cheat in dice? ›The easiest way to cheat is to simply lie about the result. Rolling in an obscured location and the disturbing or scooping up the dice will prevent other players from being able to verify the number, but is bad practice whether you are cheating or not and other players may become suspicious.
Should I prestige in Idle dice? ›If you are having trouble gaining cards or points, it is suggested to prestige , even if you don't double your current multiplier. By doing this, you can start over with a new set of cards to draw.
What do diamonds do in Idle dice? ›The diamond card is the sixth item unlocked in the slot machine. It costs 3,500 diamonds to buy and increases by 3,500 every time you buy one. Hitting the diamond card gives you "1 DIAMOND CARD POINT!!" You can spend diamond card points to place diamonds on cards.
Why is the 1 on dice red? ›In China red is considered to be a very auspicious colour, and the symbol of luck and good fortune. Traditionally the 'one' on Chinese dice are also coloured red as the 'one' is the ace and often the highest throw in Chinese dice games.
Why is 4 red on dice? ›The Chinese custom of painting the 4-spot red is said to have originated when an Emperor playing sugoruku with his queen was about to lose and desperately needed fours to win the game. He cried out, threw the dice and they came up accordingly. He was so glad that he ordered that fours be painted red from then on.
What does DBL mean in dice? ›As the other answerers have pointed out, a double means that both dice show the same number. "Doublet" or "doublets" is a synonym, see the fifth definition here, or the third definition here. Hence the doubles are (in your notation) (1,1), (2,2), (3,3), (4,4), (5,5), (6,6).
What is the oldest idle game? ›Progress Quest (2002), considered the first idle game.
What is the first clicker game? ›Starting from the original clicker game, the very first one that started the whole genre of incremental games — Cookie Clicker. Designed by Julien Orwell, it's a really simple and innovative game, you click a cookie and get one cookie for each click. More clicks means more cookies.
What is being idle in Roblox? ›
After 20 minutes hit, you'll have a red bar above your screen saying,”You have be idle for 20 minutes. To continue playing the game, leave the server and rejoin.” Or something relative to that(I'm mostly full-time on Roblox, so it's only happened to me like 3–4 times).
Can iPhone run Flash? ›Apple doesn't support flash on the iPhone, iPad or any other iOS device. This has been a source of frustration for numerous users, who tried to play flash videos or games and other kinds of interactive content on their iDevices. But there is a workaround that allows you to use Adobe Flash Player on iPhone and iPad.
What is a Flash anime? ›Flash animation is animation made in the program formerly known as Adobe Flash, now Adobe Animate. The program is vector based, meaning that when you draw something you could make it infinitely bigger or smaller without losing quality, but it also disables your ability to use brushes like in photoshop.
Does Flash Player still exist? ›Adobe officially stopped supporting Flash in 2021 and has blocked Flash content from running in Flash Player. Web browsers have removed all Flash-related software.
Is Roblox is a virus? ›Roblox by itself is completely fine to download, but you should only download it from the official website on PC or Mac, on the Play Store on Android and the App Store on iOS. Other versions from other websites could have viruses in them and you shouldn't take the chance.
Did Roblox used to be a virus? ›The official website download of ROBLOX Player app is not a virus and has been proven safe by trustworthy anti-viruses. However, some antiviruses show ROBLOX as a virus. You may have downloaded a false version of ROBLOX or your antivirus flagged it due to a false positive for viruses.
What age group is Coolmath for? ›Coolmath.com offers "math learning for ages 13-100" -- lessons, tools and learning that are easy to grasp on topics like algebra, pre-calculus and more.
Is Coolmath actually math? ›The site is also linked to a math games site (Coolmath Games) where some of the games could be used to teach strategy or practice concepts. However, many of the games aren't really math-focused -- they're described as "brain-training" -- and may be more useful as a reward or break for students.
How old is ABCya? ›ABCya.com was founded in 2004 by Alan Tortolani. A public school teacher, Tortolani created his own activities for his students.
Why do schools not allow gum? ›Students should not chew gum in class because it acts as a distraction to others, it is a health issue, and it is a safety issue. If students continue to disregard the rules, consequences will need to become more severe. Chewing gum acts as an incredible distraction to students and teachers.
Why does school exist? ›
The primary purpose of schools is to provide students with the education they need to be successful in life. In addition to academic instruction, schools also offer social and emotional support to help children develop into well-rounded individuals.
Why do schools block Netflix? ›Unfortunately, many workplaces, schools, universities and colleges block Netflix on their WiFi networks. In fact, because Netflix is such a bandwidth hog, even public WiFi hotspots are beginning to restrict access to Netflix.
What blocks are illegal? ›In gridiron football, blocking below the waist is an illegal block, from any direction, below the waist by any defensive player or by an offensive player under certain situations, by any player after change of possession, with certain exceptions. It is sometimes incorrectly referred to as a "chop block".
How do you play banned games at school? ›- First, you'll need to sign up with a trusted VPN provider. ...
- Now you can download the VPN's app on your device. ...
- Install and then log in to the app. ...
- You should now be able to access your favorite online games without restriction!
Most school networks have a “Proxy Server” act like a middle man between your devices and server you are visiting. The Proxy Server was meant to kept your devices ip hidden and safe for Malware to directly enter your devices.
Can a 7 year play Roblox? ›The account controls are optional; kids of any age can create an account on Roblox with no parental restrictions. On accounts of kids under 13, Roblox automatically defaults to stricter settings, but a kid could change these if there's no parent PIN.
Can my 6 year old play Roblox? ›There is no official age that kids can play Roblox, but Common Sense Media rates the platform safe for users 13+ "based on continuing challenges with problematic content.
Can 7 year olds play Roblox? ›What age rating is Roblox? Roblox is rated suitable for 7 years and over in the UK by PEGI for "frequent scenes of mild violence and scenes that younger children may find frightening." The game is aimed at 7-to-18 year-olds, but anyone can use the platform.
How do you hack a dice? ›Trick Dice Hack! - YouTube
Is dice a skill or luck? ›Skilled dice controllers, because of their nonrandom rolls, have altered the nature of craps. Is it possible for an average player to learn how to control the dice? Yes, but it isn't easy. Unlike advantage play in blackjack, dice control is a physical skill rather than a purely mental talent.
Is dice setting illegal? ›
— Wade J. ANSWER: Setting dice on a craps game has been practiced forever and is typically not considered illegal. Dice-setting rules or decisions come under each individual casino's policy.
What is the max amount of dice in Idle dice? ›Dice is the main Idle Dice mechanic that is used to earn points and it is rolled between 1 to 6. By rolling the dice, you earn points. You start off with 1 dice but you can purchase 4 more dice.
What do chips do in Idle dice? ›Chips are used to upgrade the roulette or force it to land on specific spaces.
What happens if you prestige as a demon? ›After prestiging, you will lose everything except for your family, but you will get 3 family rerolls (These don't stack), and your prestige count will go up by 1. This means you will have to restart the game from the beginning (Demon you fought at the Start).
How do you progress faster in Idle dice? ›Tip: use the Buy 1, Buy 10, and the Buy 100 function to upgrade your dice faster instead of just clicking the upgrade button on the dice. If you use the Buy 100 function to upgrade a regular die, it will fully ascend the dice you clicked that was used to upgrade.
How do you get gold Idle dice? ›Golden Cards (aka Gilds) are the 2nd tier upgrade that do not reset like regular Cards but last throughout basic prestiging. They are unlocked after selecting the convert button in the cards tab in-game.
How do you get the too slow achievement in Idle dice? ›Too Slow Achievement (locked)
You can use the Prestiege button repeatedly as a short cut. Clicking Prestiege does not reset the dice roll timer, so just keep 0% prestieging until it's been at least a minute since your last roll :) > *Originally posted by **[Nine_of_Hearts](/forums/1032802/topics/1804253?
Idle dice game codes | Idle dice Wiki | Fandom
I ALMOST quit ... Idle dice
BEST OP HACK/CHEAT IN IDLE DICE!!
[Battle Pop Game Design]: Big pop fidget toys game rule - Roll 2 dices in turn & push the bubble according to the other side player rolled dices number. You will lose if you push all bubble on your side down first. Up to 11 rounds of battle can be played.
How do you play ceelo dice game? ›How To Play Cee-Lo - YouTube
How do you play pop up games with dice? ›
With Dice - A team throw dice first, and if throws 6 then B team push down 6 pops. Then B team throw dice and A team push down pops according to dice number. The player who presses down the last pop loses the round, and need to push the middle big pop, whoever win three games out of five rounds is winner.
How do you play Snake with dice? ›Snake Eyes - Fun Dice Game by Math Kit Tutor Games - YouTube
How do you use a pop it fidget toy? ›How to Play Pop It Fidget Toy Game - Easy and Fun! - YouTube
How do you pop a pop ball? ›The sensory fidget toy simply presses on the semi-circular bubbles protruding from the sphere, which will make a slight popping sound to relieve your pressure.
How do you make pop its? ›DIY POP ITS - super easy FIDGETS! - YouTube
What does 456 mean in dice? ›Some players rule that a 4-5-6 is an instant win for the first player who rolls it, and it cannot be tied. To see who picks the order, each person rolls a die and the person with the highest number chooses the order. If it is a tie, then those people roll again and again until one person has a higher number.
Is Street dice illegal? ›Unregulated gambling like street craps is illegal in every state in the US and in many places elsewhere.
Why is the 1 and 4 on a dice red? ›In China red is considered to be a very auspicious colour, and the symbol of luck and good fortune. Traditionally the 'one' on dice are also coloured red as the 'one' is the ace and often the highest throw in Chinese dice games.
Is there a fidget game? ›The Fidget Game is an interactive educational game created for kids in Pre-K to Grade 3.
How do you play pop up pig? ›How to Play Pop the Pig - YouTube
How do you play Pop It Butterfly game? ›
Press the pop-up bubbles in a line and the one who press the last one bubble will lose. Help you or your children to concentrate, reduce anxiety and pressure, build emotional stability They are not only for playing, but also can be used as a fly pan for your pets, a place mat or a coaster.
Is snake eyes good dice? ›Snake Eyes Means You've Crapped Out
For the majority of basic bets, rolling two ones or snake eyes will result in you losing your chips on the table.
The term snake eyes probably comes from the appearance of the single black dot in each die. Together, the two dice with one dot each can resemble the literal eyes of a snake. It is also possible that the animal snake was chosen due to the negative association of the low roll and the animal.
How big is a dice snake? ›Their typical size is 1.0–1.3 m (39–51 in) long. Their color may vary from greyish green to brownish or almost black, with dark spots on the back. The belly is sometimes vividly coloured in yellow or orange, with black spots, very similar to dice, hence the name.