forked from sent/waves
423 lines
20 KiB
HTML
423 lines
20 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head><meta name='robots' content='noindex'><link rel='canonical' href='https://www.coolmathgames.com/0-last-horizon' />
|
|
|
|
|
|
<!-- Generated by GameMaker:Studio http://www.yoyogames.com/gamemaker/studio -->
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
<meta http-equiv="pragma" content="no-cache"/>
|
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
<meta name ="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
|
<meta charset="utf-8"/>
|
|
|
|
<!-- Set the title bar of the page -->
|
|
<title>Last Horizon</title>
|
|
|
|
<!-- Set the background colour of the document -->
|
|
<style>
|
|
body {
|
|
background: #000000;
|
|
color:#cccccc;
|
|
margin: 0px;
|
|
padding: 0px;
|
|
border: 0px;
|
|
}
|
|
canvas {
|
|
image-rendering: optimizeSpeed;
|
|
-webkit-interpolation-mode: nearest-neighbor;
|
|
-ms-touch-action: none;
|
|
margin: 0px;
|
|
padding: 0px;
|
|
border: 0px;
|
|
}
|
|
:-webkit-full-screen #canvas {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
div.gm4html5_div_class
|
|
{
|
|
margin: 0px;
|
|
padding: 0px;
|
|
border: 0px;
|
|
}
|
|
/* START - Login Dialog Box */
|
|
div.gm4html5_login
|
|
{
|
|
padding: 20px;
|
|
position: absolute;
|
|
border: solid 2px #000000;
|
|
background-color: #404040;
|
|
color:#00ff00;
|
|
border-radius: 15px;
|
|
box-shadow: #101010 20px 20px 40px;
|
|
}
|
|
div.gm4html5_cancel_button
|
|
{
|
|
float: right;
|
|
}
|
|
div.gm4html5_login_button
|
|
{
|
|
float: left;
|
|
}
|
|
div.gm4html5_login_header
|
|
{
|
|
text-align: center;
|
|
}
|
|
/* END - Login Dialog Box */
|
|
:-webkit-full-screen {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
</style>
|
|
|
|
<style type="text/css">
|
|
.no-select {
|
|
-webkit-touch-callout: none; /* iOS Safari */
|
|
-webkit-user-select: none; /* Safari */
|
|
-khtml-user-select: none; /* Konqueror HTML */
|
|
-moz-user-select: none; /* Old versions of Firefox */
|
|
-ms-user-select: none; /* Internet Explorer/Edge */
|
|
user-select: none; /* Non-prefixed version, currently supported by Chrome, Edge, Opera and Firefox */
|
|
}
|
|
</style>
|
|
|
|
<script type="text/javascript">
|
|
setTimeout(function(){
|
|
if(document.getElementsByTagName("canvas").length) {
|
|
document.getElementsByTagName("body")[0].classList.add("no-select")
|
|
}
|
|
}, 2000);
|
|
</script>
|
|
<script src="cmg-h5gameads.js"></script>
|
|
<script type="text/javascript">
|
|
function receiveMessage(e) {
|
|
if(e.data == "invokeCMGAdBreak") {
|
|
cmgGoogleAdBreak("next",function cmgAdBreakCompleted() {
|
|
console.log("cmgAdBreakCompleted is invoked in the iframe. invoke the next game functionality like resume or play next level etc" );
|
|
});
|
|
}
|
|
}
|
|
addEventListener("message", receiveMessage, true);
|
|
function setUserAgent(window, userAgent) {
|
|
// Works on Firefox, Chrome, Opera and IE9+
|
|
if (navigator.__defineGetter__) {
|
|
navigator.__defineGetter__("userAgent", function () {
|
|
return userAgent;
|
|
});
|
|
} else if (Object.defineProperty) {
|
|
Object.defineProperty(navigator, "userAgent", {
|
|
get: function () {
|
|
return userAgent;
|
|
}
|
|
});
|
|
}
|
|
// Works on Safari
|
|
if (window.navigator.userAgent !== userAgent) {
|
|
var userAgentProp = {
|
|
get: function () {
|
|
return userAgent;
|
|
}
|
|
};
|
|
try {
|
|
Object.defineProperty(window.navigator, "userAgent", userAgentProp);
|
|
} catch (e) {
|
|
window.navigator = Object.create(navigator, {
|
|
userAgent: userAgentProp
|
|
});
|
|
}
|
|
}
|
|
}
|
|
if(window.navigator.userAgent.indexOf("Safari")>=0 && "ontouchstart" in window && !/iPhone|Android/.test(window.navigator.userAgent)) {
|
|
//var userAgent = window.navigator.userAgent.replace("Macintosh", "iPad");
|
|
var userAgent = "Mozilla/5.0 (iPad; CPU OS 13_1_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.1 Mobile/15E148 Safari/604.1";
|
|
setUserAgent(window,userAgent);
|
|
}
|
|
//GA event helper functions
|
|
function getCookie(key) {
|
|
var keyValue = document.cookie.match("(^|;) ?" + key + "=([^;]*)(;|$)");
|
|
return keyValue ? keyValue[2] : null;
|
|
}
|
|
function setCookie2(key, value, exptime, domain) {
|
|
//document.cookie = key + "=" + value + ";";
|
|
var d = new Date();
|
|
d.setTime(d.getTime() + exptime);
|
|
var expires = "expires=" + d.toUTCString();
|
|
document.cookie = key + "=" + value + "; " + expires + "; path=/; domain=" +domain;
|
|
}
|
|
function cmg_is_mobile_device() {
|
|
var sUsrAg = navigator.userAgent;
|
|
//if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(sUsrAg)){
|
|
if(/Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(sUsrAg)){
|
|
return true;
|
|
}
|
|
else {
|
|
if(navigator.maxTouchPoints == 5) {
|
|
return true;
|
|
}
|
|
else if (sUsrAg.indexOf("Safari")>=0 && "ontouchstart" in window && sUsrAg.indexOf("iPhone")== -1) {
|
|
return true;
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|
|
var enableDebug=false;
|
|
function debugOut(msg){
|
|
if (typeof getParameterByName === "function" && getParameterByName("debug") !== "") { enableDebug = getParameterByName("debug");}
|
|
if(enableDebug){console.log(msg);}
|
|
}
|
|
function getParameterByName(name) {
|
|
var regexS = "[\?&]" + name + "=([^&#]*)";
|
|
var regex = new RegExp(regexS);
|
|
var results = regex.exec(location.href);
|
|
if (results !== null) {
|
|
return decodeURIComponent(results[1].replace(/\+/g, " "));
|
|
}
|
|
//Check the parent window
|
|
var results = regex.exec(window.top.location.href);
|
|
if (results === null) {
|
|
return "";
|
|
}
|
|
return decodeURIComponent(results[1].replace(/\+/g, " "));
|
|
}
|
|
function getBrowserNameVer() {
|
|
var sBrowser, sUsrAg = navigator.userAgent;
|
|
// The order matters here, and this may report false positives for unlisted browsers.
|
|
if (sUsrAg.indexOf("Firefox") > -1) {
|
|
sBrowser = "Mozilla Firefox";
|
|
// "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0"
|
|
} else if (sUsrAg.indexOf("SamsungBrowser") > -1) {
|
|
sBrowser = "Samsung Internet";
|
|
// "Mozilla/5.0 (Linux; Android 9; SAMSUNG SM-G955F Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/9.4 Chrome/67.0.3396.87 Mobile Safari/537.36
|
|
} else if (sUsrAg.indexOf("Opera") > -1 || sUsrAg.indexOf("OPR") > -1) {
|
|
sBrowser = "Opera";
|
|
// "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 OPR/57.0.3098.106"
|
|
} else if (sUsrAg.indexOf("Trident") > -1) {
|
|
sBrowser = "Microsoft Internet Explorer";
|
|
// "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; Zoom 3.6.0; wbx 1.0.0; rv:11.0) like Gecko"
|
|
} else if (sUsrAg.indexOf("Edge") > -1) {
|
|
sBrowser = "Microsoft Edge (Legacy)";
|
|
// "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299"
|
|
} else if (sUsrAg.indexOf("Edg") > -1) {
|
|
sBrowser = "Microsoft Edge (Chromium)";
|
|
// Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.64
|
|
} else if (sUsrAg.indexOf("Chrome") > -1) {
|
|
sBrowser = "Google Chrome or Chromium";
|
|
// "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36"
|
|
} else if (sUsrAg.indexOf("Safari") > -1) {
|
|
sBrowser = "Apple Safari";
|
|
// "Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1 980x1306"
|
|
} else if (!/Safari|CriOS/.test(sUsrAg) && /iPhone|iPad\iPod/.test(sUsrAg) ) {
|
|
//( /iPhone|iPad\iPod/.test(sUsrAg) && /Safari/.test(sUsrAg) )
|
|
sBrowser = "iPhone Safari WebView";
|
|
} else {
|
|
sBrowser = "unknown";
|
|
}
|
|
sUsrAgArr = navigator.userAgent.split(" ")
|
|
sBrowser = sBrowser + " " + sUsrAgArr[0] + " " + sUsrAgArr[sUsrAgArr.length -1]
|
|
debugOut("You are using: " + sBrowser);
|
|
return sBrowser;
|
|
}
|
|
|
|
function trackEvent(category, action, label, value) {
|
|
if(typeof value === "undefined" || value === null) { value = 0; }
|
|
if(typeof __gaTracker !== "undefined") {
|
|
__gaTracker("send", {hitType: "event", eventCategory: category, eventAction: action, eventLabel: label, eventValue: value});
|
|
}
|
|
}
|
|
//Category: GamePlayPage, Action: DesktopiFrame / DesktopToplevel / DesktopImmersive / MobileToplevel / MobileImmersive, Label: Game title
|
|
var pCategory = "GamePlayPageRedirect";
|
|
var pAction = "Mobile "+ getBrowserNameVer();
|
|
var pLabel = location.pathname;
|
|
if(pLabel.startsWith("/")) {
|
|
pLabel = pLabel.substr(1);
|
|
}
|
|
|
|
debugOut("cmgplaypage: debug redirect check - pCategory="+pCategory +", pAction="+pAction + " " +new Date());
|
|
|
|
if(window.top == window.self && document.referrer == "" ) {
|
|
(function(w,d,s,l,i){
|
|
w[l]=w[l]||[];w[l].push({"gtm.start":
|
|
new Date().getTime(),event:"gtm.js"});var f=d.getElementsByTagName(s)[0],
|
|
j=d.createElement(s),dl=l!="dataLayer"?"&l="+l:"";j.async=true;j.src=
|
|
"https://www.googletagmanager.com/gtm.js?id="+i+dl;f.parentNode.insertBefore(j,f);
|
|
})(window,document,"script","dataLayer","GTM-WKRSNN8");
|
|
|
|
function ga4ObjInit(event) {
|
|
ga4Obj = {};
|
|
var ckeEn = navigator.cookieEnabled;
|
|
//Required
|
|
var event = (typeof event === "undefined" || event === null || event === "") ? "page_load" : event;
|
|
var userType = (!ckeEn || getCookie("cmg_l") == null) ? "AnonymousUser" : "FreeUser";
|
|
if (ckeEn && getCookie("cmg_sx") != null) {
|
|
userType = "PremiumUser";
|
|
}
|
|
var timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
var adBlock = (typeof ad_blocker_detected !== "undefined") ? ad_blocker_detected : false;
|
|
if (typeof gamePage != "undefined" && gamePage && typeof hide_preroll_ads != "undefined" && !hide_preroll_ads && (document.getElementById("randomAdBlockDiv") == null || typeof google == "undefined" || typeof cmgpbjs == "undefined")) {
|
|
adBlock = true;
|
|
}
|
|
|
|
//DeviceType
|
|
var deviceType = "Desktop"; //Default
|
|
var ua = navigator.userAgent;
|
|
if (/Android|webOS|iPhone|BlackBerry|IEMobile|Opera Mini/i.test(ua) || navigator.maxTouchPoints == 5) {
|
|
deviceType = "Mobile";
|
|
}
|
|
if (/Android/.test(ua) && /Chrome\/[.0-9]* Mobile/.test(ua)) { //Phone pattern: "Android" + "Chrome/[.0-9]* Mobile"
|
|
deviceType = "Mobile";
|
|
} else if (/Android/.test(ua) && /Chrome\/[.0-9]* (?!Mobile)/.test(ua)) { //Tablet pattern: "Android" + "Chrome/[.0-9]* (?!Mobile)"
|
|
deviceType = "Tablet";
|
|
} else if (/iPad/.test(ua) && /Mobile\/[0-9A-Z]* Safari\/[.0-9]*/.test(ua)) {
|
|
deviceType = "Tablet";
|
|
} else if (/iPhone|iPod/.test(ua) && /Mobile\/[0-9A-Z]* Safari\/[.0-9]*/.test(ua)) {
|
|
deviceType = "Mobile";
|
|
}
|
|
|
|
//dataLayer obj with required params
|
|
var ga4Obj = {
|
|
"event": event,
|
|
"user_type": userType,
|
|
"device_type": deviceType,
|
|
"timezone": timeZone,
|
|
"ad_blocker_detected": adBlock
|
|
};
|
|
|
|
//Optional - dataLayer params
|
|
if (typeof gameType != "undefined" && gameType != null) {
|
|
gameType = gameType.replace("game_", "");
|
|
ga4Obj.game_type = gameType;
|
|
} else if (typeof quizPage != "undefined" && quizPage != null && typeof quizTitle != "undefined") {
|
|
ga4Obj.game_type = "trivia";
|
|
if (typeof result_page != "undefined" && result_page == "true" && event == "page_load") {
|
|
ga4Obj.game_type = "trivia_result";
|
|
}
|
|
ga4Obj.game_name = quizTitle;
|
|
}
|
|
if (typeof gameId != "undefined" && gameId != null && typeof window.getGameName == "function") {
|
|
ga4Obj.game_name = formatGameName(window.getGameName());
|
|
}
|
|
const options = {
|
|
month: "short",
|
|
day: "numeric",
|
|
year: "numeric"
|
|
};
|
|
|
|
var cmgL = ckeEn && getCookie("cmg_l") != null ? getCookie("cmg_l") : "";
|
|
if (cmgL != "") {
|
|
ga4Obj.coolmath_user_id = cmgL;
|
|
}
|
|
|
|
return ga4Obj;
|
|
}
|
|
function ga4_trackEvent(event, pArr, vArr) {
|
|
if (typeof dataLayer !== "undefined" && typeof dataLayer.push === "function") {
|
|
ga4Obj = ga4ObjInit(event);
|
|
if (typeof pArr != "undefined" && typeof vArr != "undefined") {
|
|
var aLen = pArr.length;
|
|
for (var i = 0; i < aLen; i++) {
|
|
ga4Obj[pArr[i]] = vArr[i];
|
|
}
|
|
}
|
|
debugOut("CMGga4: track :" + event + " " + JSON.stringify(ga4Obj) + " " + new Date());
|
|
var ga4Response = dataLayer.push(ga4Obj);
|
|
debugOut("CMGga4: track :" + event + " dataLayer.push response = " + JSON.stringify(ga4Response) + " " + new Date());
|
|
} else {
|
|
debugOut("CMGga4: dataLayer does not exist : " + new Date());
|
|
}
|
|
}
|
|
|
|
//GA Trackevent and then Redirect the user to game landing page
|
|
//Check if we can use GA
|
|
|
|
//GA Loading
|
|
|
|
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
|
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
})(window,document,"script","//www.google-analytics.com/analytics.js","__gaTracker");
|
|
var ga_dev_host = /(stage|stage2|dev|dev2|dev3|d9\-test)(\-edit)?\.coolmathgames\.(com|local)/.test(window.location.host);
|
|
if(ga_dev_host || window.location.host == "d9-test-coolmathgames.local") {
|
|
__gaTracker("create", "UA-1192998-21", "auto");
|
|
} else {
|
|
__gaTracker("create", "UA-1192998-2", "auto");
|
|
}
|
|
|
|
//End of GA loading
|
|
if(cmg_is_mobile_device()){
|
|
setTimeout(function () {
|
|
//Load and fire GA event
|
|
trackEvent(pCategory, pAction, pLabel);
|
|
var sUsrAg = navigator.userAgent;
|
|
//Exclude iPads, iphone/iPod App and Android App
|
|
if(document.querySelector("link[rel='canonical']").href && !/iPad/.test(sUsrAg) && ( (/iPhone|iPod/.test(sUsrAg) && /Safari/.test(sUsrAg) ) || ( /Android/.test(sUsrAg) && !/wv/.test(sUsrAg) ) ) ) {
|
|
window.location.href = document.querySelector("link[rel='canonical']").href;
|
|
}
|
|
}, 100);
|
|
}
|
|
var isValidDevice = true;
|
|
var browserInfo = navigator.userAgent;
|
|
if((browserInfo.includes === "iPhone" && browserInfo.includes === "mobile") && (browserInfo.includes === "Chrome" || browserInfo.includes ==="Safari")){
|
|
isValidDevice = false;
|
|
}
|
|
if(isValidDevice){
|
|
trackEvent("gamePlayPage", "userVisit", location.pathname);
|
|
ga4_trackEvent("gamePlayPage", ["action","path"],["userVisit",location.pathname]);
|
|
}
|
|
}
|
|
//GA4 AEG
|
|
setInterval(function() {
|
|
if(!document.hidden) {
|
|
if(typeof window.parent.postMessage == "function") {
|
|
debugOut(new Date()+ " cmgGameHeartbeat: Active tab. parent postMsg");
|
|
window.parent.postMessage({"cmgGameHeartbeat" : document.hasFocus()}, "*");
|
|
} else if(typeof window.top.postMessage == "function" && window.top != window.self) {
|
|
debugOut(new Date()+ " cmgGameHeartbeat: Active tab. top postMsg");
|
|
window.top.postMessage({"cmgGameHeartbeat" : document.hasFocus()}, "*");
|
|
}
|
|
} else {
|
|
debugOut(new Date()+ " cmgGameHeartbeat: Inactive tab. No event");
|
|
}
|
|
}, 60000);
|
|
</script>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="gm4html5_div_class" id="gm4html5_div_id">
|
|
<!-- Create the canvas element the game draws to -->
|
|
<canvas id="canvas" width="740" height="620">
|
|
<p>Your browser doesn't support HTML5 canvas.</p>
|
|
</canvas>
|
|
</div>
|
|
|
|
<!-- Run the game code -->
|
|
<script type="text/javascript" src="LastHorizonCoolMath.js"></script>
|
|
<script>function fnSendMsg(evt){
|
|
if(typeof window.parent.postMessage == 'function') {
|
|
window.parent.postMessage('keypress-from-game', '*');
|
|
} else if(typeof window.top.postMessage == 'function' && window.top != window.self) {
|
|
window.top.postMessage('keypress-from-game', '*');
|
|
}
|
|
}
|
|
document.body.addEventListener('click', function(event) {
|
|
fnSendMsg(event);
|
|
});
|
|
document.addEventListener('keypress', function(event) {
|
|
fnSendMsg(event);
|
|
});
|
|
document.addEventListener('keydown', function (e) {
|
|
fnSendMsg(event);
|
|
});
|
|
document.addEventListener('keyup', function (e) {
|
|
fnSendMsg(event);
|
|
});
|
|
|
|
function cmgGameEvent(a) {
|
|
console.log(a)
|
|
}
|
|
</script></body>
|
|
</html>
|