(function (window) { // API window.ex = { config: { fbAppId: null, // required fbAppPageId: null, fbPricesUrl: null, // "https://d2fmgmkly4bg9q.cloudfront.net/rs/public/facebook/prices/" fbVersion: "v3.1", fbIsCanvas: (window.name != null && self !== top && document.location.href.indexOf("nofb=1") == -1), fbPermissions: "email", // user_friends,publish_actions fbStandalone: true, // false to disable FB api outside of Facebook playstoreId: null, appstoreId: null, serverId: null, // required title: null, // required namespace: null, // required staticUrl: null, // required versionUrl: null, // required flashUrl: null, // required flashVersion: "11.8", flashWidth: 755, flashHeight: 650, flashObject: null, flashInstall: "./public/script/expressInstall.swf", // declare in index.html for deploy script to add version number! lang: "en", languages: {}, // override to extend lang DB query: "{query}", onFlashReady: null, onConnected: $.noop, onInstall: null, onRegistration: null, onNAU: null, onNAPU: null, onShowBanners: null, trialPayVendorId: null, trialPayCurrencyUrl: null, fyberAppId: null, fyberWidth: 1000, fyberHeight: 1000, affizAppId: null, woobiAppId: null, woobiColorSide: null, woobiColorBack: null, kongIsIframe: false, kongInstance: null }, init: init, flash: { show: flashShow, hide: flashHide, setup: flashSetup }, facebook: { login: facebookLogin, request: facebookRequest, share: facebookShare, permissions: facebookPermissions, like: { show: facebookLike, hide: facebookLikeHide }, hideFlashCallback: facebookHideFlashCallback }, twitter: { tweet: twitterTweet }, payment: { show: paymentShow, facebook: paymentFacebook, kongregate: paymentKongregate }, banners: { insert: bannersInsert, remove: bannersRemove }, offerwall: { trialPay: { show: offerwallTrialPayShow, onTransaction: offerwallTrialPayOnTransaction } }, videos: { fyber: { getVideos: fyberGetVideos, showVideo: fyberShowVideo }, affiz: { getVideos: affizGetVideos, showVideo: affizShowVideo }, woobi: { getVideos: woobiGetVideos, showVideo: woobiShowVideo } }, analytics: { view: analyticsView, click: analyticsClick, event: analyticsEvent, load: analyticsTime, error: analyticsError }, lang: { getLanguage: langGetLanguage, t: langGetTranslation }, support: { ticket: supportTicket, forum: supportForum }, track: { visit: trackVisit, pixel: trackPixel }, chromestore: { install: chromestoreInstall }, log: log, scrolling: { enable: scrollingEnable, disable: scrollingDisable }, utils: { setCookie: utilsSetCookie, getCookie: utilsGetCookie, addParameter: utilsAddParameter, getParameter: utilsGetParameter, forward: utilsForward, openWindow: utilsOpenWindow, loadScript: utilsLoadScript, loadStyle: utilsLoadStyle, dialogs: { create: dialogCreate, showOnce: dialogShowOnce, showWebView: dialogShowWebView } }, languages: { "en": { "close": "Close", "skip": "Skip", "like": "Like {title} and win awesome gifts on our Facebook page!", "support": "Support", "noflash": "In less than a month the game won't be available on web anymore, please select one of the 3 solutions", "facebookPage": "Facebook page", "init": "Initializing...", "paused": "Game paused. Close all chat windows to resume.", "flashRequired": "The Flash Player plugin is required to play this game. Please click below to enable the Flash Player.", "adPlaceholder": "Advertisements assist us in the development of {title} so please keep advertising enabled and not use an ad blocker.

Any purchase will, of course, make the game completely advertisement free!", "adRemove": "Remove Ad", "offerwall": "Free credits", "forum": "Forum" }, "de": { "close": "Schließen", "skip": "Überspringen", "like": "Like {title} und gewinne fantastische Geschenke auf unserer Facebook-Seite!", "support": "Support", "facebookPage": "Facebook-Seite", "init": "Initialisiere…", "paused": "Spiel pausiert", "flashRequired": "The Flash Player plugin is required to play this game. Please click below to enable the Flash Player.", "adPlaceholder": "Advertisements assist us in the development of {title} so please keep advertising enabled and not use an ad blocker.

Any purchase will, of course, make the game completely advertisement free!", "adRemove": "Remove Ad", "offerwall": "Free credits", "forum": "Forum" }, "fr": { "close": "Fermer", "skip": "Passer", "like": "Aimez {title} et gagnez des cadeaux sur notre page Facebook !", "support": "Support", "noflash": "Dans moins d'un mois le jeu ne sera plus disponible sur le web, merci de choisir une des 3 solutions", "facebookPage": "Page Facebook", "init": "Initialisation...", "paused": "Jeu en pause. Fermer toutes les fenêtres de chat pour reprendre.", "flashRequired": "Le plugin Flash Player est requis pour jouer. Veuillez autoriser le Flash Player en cliquant ci-dessous.", "adPlaceholder": "Les publicités nous aident dans le développement de {title}, c'est pourquoi nous t'incitons à ne pas les bloquer.

Bien entendu, tout achat retire les publicités de façon permanente !", "adRemove": "Retirer Pub", "offerwall": "Credits gratuits", "forum": "Forum" }, "ko": { "close": "닫기", "skip": "넘어가기", "like": "{title}의 페이스북 페이지에 '좋아요'를 눌러주세요!", "support": "고객문의", "facebookPage": "페이스북 페이지", "init": "재료 준비중...", "paused": "대기 중", "flashRequired": "The Flash Player plugin is required to play this game. Please install the Flash Player to continue.", "adPlaceholder": "Advertisements assist us in the development of {title} so please keep advertising enabled and not use an ad blocker.

Any purchase will, of course, make the game completely advertisement free!", "adRemove": "Remove Ad", "offerwall": "Free credits", "forum": "Forum" }, "pt": { "close": "Fechar", "skip": "Pular", "like": "Curta {title} e ganhe presentes incríveis em sua página do Facebook!", "support": "Ajuda", "facebookPage": "Página do Facebook", "init": "Iniciando…", "paused": "Jogo pausado", "flashRequired": "The Flash Player plugin is required to play this game. Please install the Flash Player to continue.", "adPlaceholder": "Advertisements assist us in the development of {title} so please keep advertising enabled and not use an ad blocker.

Any purchase will, of course, make the game completely advertisement free!", "adRemove": "Remove Ad", "offerwall": "Free credits", "forum": "Forum" }, "es": { "close": "Cerrar", "skip": "Omitir", "like": "¡Pon \"Me gusta\" en {title} y gana increíbles premios en nuestra página en Facebook page!", "support": "Ayuda", "facebookPage": "Página en Facebook", "init": "Inicializando...", "paused": "Pausa de juego", "flashRequired": "Se necesita el plugin de Flash Player para jugar este juego. Por favor, instale el Flash Player para continuar.", "adPlaceholder": "Los avisos nos sirven en el desarrollo de {title}, de modo que rogamos mantener habilitados los avisos y no usar un bloqueador de avisos.

¡Después de la compra, el juego quedará por supuesto completamente liberado de avisos!", "adRemove": "Eliminar anuncio", "offerwall": "Free credits", "forum": "Forum" } } }; // INIT function init(cfg) { ex.config = $.extend(true, ex.config, cfg); ex.config.lang = (ex.lang.getLanguage() in ex.languages ? ex.lang.getLanguage() : "en"); ex.languages = $.extend(true, ex.languages, ex.config.languages); ex.log("init:", cfg, ex.config); // Redirect mobile var ua = navigator.userAgent; if (ex.config.playstoreId && /Android/.test(ua)) { document.location.href = "market://details?id=" + ex.config.playstoreId; return; } if (ex.config.appstoreId && /iPhone|iPad|iPod/.test(ua)) { document.location.href = "https://itunes.apple.com/app/id" + ex.config.appstoreId; return; } // Handle session ?c= if (ex.config.query == "{query}") { ex.config.query = window.location.search.substring(1); if (window.location.hash) { var hash = window.location.hash.substring(1); ex.config.query += (ex.config.query.length ? "&" : "") + hash; window.location.hash = window.location.hash.replace(/(^[\#|\&]?)c\=[^\&]+[\&]?/, "$1"); // remove c=xxxx } } window.fbAsyncInit = function() { var fbOptions = { appId: ex.config.fbAppId, status: true, cookie: true, xfbml: true, frictionlessRequests: true, hideFlashCallback: ex.facebook.hideFlashCallback }; if (ex.config.fbVersion) { fbOptions.version = ex.config.fbVersion; } FB.init(fbOptions); FB.Canvas.setUrlHandler(facebookUrlHandler); }; window.fbAsyncLoaded = function() { var isChromium = document.location.href.indexOf("chromium=") >= 0; var popupUrl = "https://www2.sweetnitro.com/popups/noflash.php?server=" + ex.config.serverId; if (isChromium) { popupUrl += "&chromium=1"; } setTimeout(function() { ex.utils.dialogs.showWebView(getPortalUrl(popupUrl), 800, 600); ex.flash.setup(); var styles = "@keyframes MoveUpDown { \n 0%, 100% { \n bottom: 0; \n } \n 50% { \n bottom: 150px; \n } \n}"; var styleSheet = document.createElement("style"); styleSheet.type = "text/css"; styleSheet.innerText = styles; document.head.appendChild(styleSheet); if (!String.prototype.startsWith) { String.prototype.startsWith = function(searchString, position) { position = position || 0; return this.indexOf(searchString, position) === position; }; } window.addEventListener('message', function (event) { if (event.data == 'show-arrow' && event.origin.startsWith('https://www2.sweetnitro.com')) { $("#dialog_overlay").remove(); window.Arrow=function(window,document){"use strict";function _increaseOpacity(milliseconds){var arrow=document.getElementById("arrow-"+browser);arrow.style.display="block";var i=0,ieI=0,x=setInterval(function(){i+=.1,ieI+=10,"msie"===browser&&8>=browserVersion?arrow.filters&&(arrow.filters.item("DXImageTransform.Microsoft.Alpha").opacity=ieI):arrow.style.opacity=i},50);setTimeout(function(){clearInterval(x)},600),setTimeout(function(){_hide()},milliseconds||6e3)}function _decreaseOpacity(){var arrow=document.getElementById("arrow-"+browser),i=1,ieI=100,x=setInterval(function(){i-=.1,ieI-=10,"msie"===browser&&8>=browserVersion?arrow.filters&&(arrow.filters.item("DXImageTransform.Microsoft.Alpha").opacity=ieI):arrow.style.opacity=i},50);setTimeout(function(){clearInterval(x),arrow.style.display="none"},600)}function _applyStyleModern(node){node.style.position="fixed",node.style.zIndex=999,node.style.display="none",node.style.height="309px",node.style.width="186px",node.style.opacity=0,node.style.animation="MoveUpDown 1s linear infinite",node.style.backgroundImage="url(https://i.imgur.com/aMwoyfN.png)",node.style.backgroundRepeat="no-repeat",node.style.backgroundPositionX="0",node.style.backgroundPositionY="0"}function _applyStyleIE8(node){node.style.top="10px",node.style.left="20px";var opacity="progid:DXImageTransform.Microsoft.Alpha(opacity=0) ",imgSrc='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="https://i.imgur.com/aMwoyfN.png", sizingMethod="scale") ',rotation='progid:DXImageTransform.Microsoft.Matrix(M11=1, M12=1.2246063538223773e-16, M21=-1.2246063538223773e-16, M22=-1, SizingMethod="auto expand") ';node.style.filter=opacity+imgSrc+rotation}function _applyStyleMs(node){node.style.bottom="50px",node.style.left="67%"}function _applyStyleMoz(node){node.style.top="0px",node.style.right="37px",node.style.transform="rotateX(180deg) rotateY(180deg)",node.style.MozTransform="rotateX(180deg) rotateY(180deg)"}function _applyStyleWebkit(node){node.style.bottom="50px",node.style.left="20px"}function _applyStyleSafari(node){node.style.top="0px",node.style.right="80px",node.style.transform="rotateX(180deg) rotateY(180deg)",node.style.webkitTransform="rotateX(180deg) rotateY(180deg)"}function _setStyleType(node){_applyStyleModern(node),"msie"===browser?8===browserVersion?_applyStyleIE8(node):(9===browserVersion||10===browserVersion)&&_applyStyleMs(node):"chrome"===browser||"opera"===browser?_applyStyleWebkit(node):"safari"===browser?_applyStyleSafari(node):"IE11"===browser||"edge"===browser?_applyStyleMs(node):"firefox"===browser&&browserVersion>=20&&_applyStyleMoz(node)}function _buildArrow(){var div=document.createElement("div");return div.setAttribute("id","arrow-"+browser),arrowNode=div,div}function _injectNode(node){document.body.appendChild(node)}function _isExist(){return!!document.getElementById("arrow-"+browser)}function _initArrow(){var arrow=_buildArrow();_setStyleType(arrow),_calculateArrowPosition(),_injectNode(arrow),_addWindowEvent("resize",_calculateArrowPosition),_addWindowEvent("scroll",_calculateArrowPosition)}function _addWindowEvent(event,functionReference){window.addEventListener?window.addEventListener(event,functionReference,!1):window.attachEvent&&window.attachEvent(event,functionReference)}function _calculateArrowPosition(){"number"==typeof window.innerWidth?(visibleWidth=window.innerWidth,visibleHeight=window.innerHeight):document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)&&(visibleWidth=document.documentElement.clientWidth,visibleHeight=document.documentElement.clientHeight),"msie"===browser&&9===browserVersion&&(1005>visibleWidth?arrowNode.style.bottom="85px":visibleWidth>1006&&(arrowNode.style.bottom="50px"))}function _hide(){if(!_isExist())throw"Invalid usage: There are no arrows on the page.";_decreaseOpacity()}function show(seconds){if(!_isExist())throw"Invalid usage: arrow does not exist";_increaseOpacity(seconds)}var arrowNode,version="0.1.9",Arrow={},browser="",browserVersion=0,visibleHeight=0,visibleWidth=0;return function(){var tem,N=navigator.appName,ua=navigator.userAgent,M=ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);M&&null!=(tem=ua.match(/version\/([\.\d]+)/i))&&(M[2]=tem[1]),M=M?[M[1],M[2]]:[N,navigator.appVersion,"-?"],browser="netscape"==M[0].toLowerCase()?"IE11":-1!=ua.toLowerCase().indexOf("edge")?"edge":M[0].toLowerCase(),browserVersion=parseInt(M[1],10)}(),_initArrow(),Arrow._version=version,Arrow._browser=browser,Arrow._browserVersion=browserVersion,Arrow.show=show,Arrow}(window,window.document); Arrow.show(15000); } }); }, 200); } window.URLSearchParams = window.URLSearchParams || function (searchString) { var self = this; self.searchString = searchString; self.get = function (name) { var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(self.searchString); if (results == null) { return null; } else { return decodeURI(results[1]) || 0; } }; } if (ex.config.fbIsCanvas || ex.config.fbStandalone) { ex.log("init: with FB login"); facebookInject(function () { FB.getLoginStatus(function(response) { if (response.status === "connected") { window.fbAuthResponse = response.authResponse; } if (window.fbAuthResponse || !ex.config.fbIsCanvas) { //ex.flash.setup(); window.fbAsyncLoaded(); } else { FB.login(function(response) { if (response.authResponse) { window.fbAuthResponse = response.authResponse; } window.fbAsyncLoaded(); }, { scope: ex.config.fbPermissions, return_scopes: true } ); } }); }); } else if (!ex.config.fbIsCanvas && !ex.config.fbStandalone) { ex.log("init: without FB login"); //ex.flash.setup(); window.fbAsyncLoaded(); if (ex.config.fbAppId) { facebookInject(); } else { ex.log("init: without FB API, no appId"); } } else { ex.log("init: error"); } if (ex.config.kongIsIframe) { ex.utils.loadScript("https://cdn1.kongregate.com/javascripts/kongregate_api.js", false, false, function () { log("kongregateAPI: loading", kongregateAPI); kongregateAPI.loadAPI(function onComplete() { ex.config.kongInstance = kongregateAPI.getAPI(); log("kongregateAPI: loaded", ex.config.kongInstance); }); }); } $(function () { $("body").addClass("lang-" + ex.config.lang); if (ex.utils.getParameter(window.location.href, "nostores") !== undefined) { $("body").addClass("hide-stores"); } $("#support-button").on("click", function (event) { event.preventDefault(); ex.support.ticket(); }); $("#forum-button").on("click", function (event) { event.preventDefault(); ex.support.forum(); }); $("a").on("mousedown", function(event) { var link = $(this); var url = link.attr("href"); try { if (url.match(/^https?:\/\/(www\.)?(sublinet|sweetnitro)\.com\/(support|forum)\/((?![\?&]c=).)*$/)) { var data = ex.config.flashObject.getSessionData(0); if (data && data.c) { link.attr("href", ex.utils.addParameter(url, "c", data.c)); } } } catch (e) {} }); ex.track.visit(); langInject(); }); } // LOG function log() { var args = Array.prototype.slice.call(arguments); try { window.console.log.apply(window.console, args); } catch (error) {} } // LANG function langInject() { $("*[data-lang]").each(function (index, el) { var e = $(el); var key = e.data("lang"); if (key && key.length > 0) { e.html(ex.lang.t(key)); } }); } function langGetTranslation(key, useLang) { useLang = useLang || ex.config.lang; try { var l = ex.languages[useLang][key]; return l.replace("{title}", ex.config.title); } catch (e) { if (useLang == "en") { return "{!" + key + "}"; } else { return langGetTranslation(key, "en"); } }; } function langGetLanguage() { try { if (navigator.browserLanguage) { return navigator.browserLanguage.substring(0, 2); } else { return navigator.language.substring(0, 2); } } catch (e) { ex.log("ERROR getLanguage:", e); return "en"; } } // BANNERS function bannersInsert() { $(".banner-close").unbind().show().bind("click", function (event) { event.preventDefault(); var t = $(this); var p = t.parents(".banner"); p.find(".banner-content").hide().empty(); p.find(".banner-text").fadeIn(); t.css("visibility", "hidden"); }); if (ex.config.onInsertBanners) { ex.config.onInsertBanners(); } } function bannersRemove() { $(".banner-content").empty(); $(".banner").hide(); } // avoid flash issues function bannersShowFlash() { $(".banner-inner").show(); } function bannersHideFlash() { $(".banner-inner").hide(); } // OFFERWALL function offerwallTrialPayShow(serverId, memberId) { try { TRIALPAY.fb.show_overlay( ex.config.fbAppId, "fbdirect", { tp_vendor_id: ex.config.trialPayVendorId, callback_url: "https://www.sweetnitro.com/en/payment2/return/callback.php?p=offers_trialpay", currency_url: ex.config.trialPayCurrencyUrl, sid: serverId + "-" + memberId, onOpen: "ex.flash.hide", onClose: "ex.flash.show", onTransact: "ex.offerwall.trialPay.onTransaction", zIndex: 1000 } ); } catch (e) { ex.log("offerwallTrialPayShow: failed", e); } } function offerwallTrialPayOnTransaction(response) { ex.log("offerwallTrialPayOnTransaction:", response); try { ex.config.flashObject.offerwallTransactionCallback(response); } catch (e) { ex.log("offerwallTrialPayOnTransaction: failed", e); } } // VIDEOS // FYBER var fyberVideo = null; function fyberGetVideos(userId, claimText) { var options = { appid: ex.config.fyberAppId, width: ex.config.fyberWidth, height: ex.config.fyberHeight, uid: userId, display_format: "bare_player", callback_on_start: function (offer) { ex.log("fyberGetVideo: start", offer); try { ex.config.flashObject.videosFyberSearchCallback(true); } catch (e) { ex.log("fyberGetVideo: start failed", e); } }, callback_no_offers: function () { ex.log("fyberGetVideo: no offers"); try { ex.config.flashObject.videosFyberSearchCallback(false); } catch (e) { ex.log("fyberGetVideo: no offers failed", e); } }, callback_on_close: function () { ex.log("fyberGetVideo: closed"); ex.flash.show(); }, callback_on_conversion: function () { ex.log("fyberGetVideo: conversion"); try { ex.config.flashObject.videosFyberCompletedCallback(); } catch (e) { ex.log("fyberGetVideo: conversion failed", e); } } }; if (claimText) { options.text_claim_button = claimText; } fyberVideo = new SPONSORPAY.Video.Iframe(options); fyberVideo.backgroundLoad(); } function fyberShowVideo() { if (fyberVideo) { ex.flash.hide(); fyberVideo.showVideo(); } } // AFFIZ var affizVideo = null; function affizGetVideos(userId, claimText) { var options = { site_id: ex.config.affizAppId, clientid: userId, modal: true, load_callback: function () { ex.log("affizGetVideos: load"); try { ex.config.flashObject.videosAffizSearchCallback(true); } catch (e) { ex.log("affizGetVideos: load failed", e); } }, noads_callback: function () { ex.log("affizGetVideos: no offers"); try { ex.config.flashObject.videosAffizSearchCallback(false); } catch (e) { ex.log("affizGetVideos: no offers failed", e); } }, close_callback: function () { ex.log("affizGetVideos: closed"); ex.flash.show(); }, complete_callback: function () { ex.log("affizGetVideos: complete"); try { ex.flash.show(); ex.config.flashObject.videosAffizCompletedCallback(); } catch (e) { ex.log("affizGetVideos: complete failed", e); } } }; if (claimText) { options.text_claim_btn = claimText; } AFFIZVIDEO.init(options); } function affizShowVideo() { if (AFFIZVIDEO && AFFIZVIDEO.show) { ex.flash.hide(); AFFIZVIDEO.show(); } } // WOOBI function woobiGetVideos(userId) { try { tokenads.config.appId = ex.config.woobiAppId; tokenads.config.clientId = userId; if (ex.config.woobiColorSide) { tokenads.settings.view.colorTheme = ex.config.woobiColorSide; } if (ex.config.woobiColorBack) { tokenads.settings.view.backColor = ex.config.woobiColorBack; } tokenads.config.listener.onClose = function () { ex.log("woobiGetVideos: onClose"); ex.flash.show(); }; tokenads.config.listener.onCredit = function (credits) { ex.log("woobiGetVideos: onCredit", credits); try { ex.config.flashObject.videosWoobiCompletedCallback(); } catch (e) { ex.log("woobiGetVideos: onCredit failed", e); } }; tokenads.config.listener.onError = function (error) { ex.log("woobiGetVideos: onError", error); try { ex.config.flashObject.videosWoobiSearchCallback(false); } catch (e) { ex.log("woobiGetVideos: onError callback failed", e); } }; tokenads.checkInventory(function (nbOffers) { ex.log("woobiGetVideos: checkInventory", nbOffers); try { nbOffers = nbOffers || 0; ex.config.flashObject.videosWoobiSearchCallback(nbOffers > 0); } catch (e) { ex.log("woobiGetVideos: checkInventory callback failed", e); } }); } catch (e) { ex.log("woobiGetVideos: failed", e); } } function woobiShowVideo() { try { ex.flash.hide(); tokenads.showPlayer(); } catch (e) { ex.log("woobiShowVideo: failed", e); } } // ANALYTICS function analytics() { var args = Array.prototype.slice.call(arguments); try { window.ga.apply(window, args); } catch (error) { ex.log("ERROR analytics:", error, "arguments:", args); } } function analyticsTrigger(fnName) { if (ex.config[fnName]) { try { var source = ex.utils.getCookie("source"); ex.config[fnName](source); } catch (e) { ex.log("ERROR: analyticsTrigger:", fnName, e); } } } function analyticsView(name) { analytics("send", "pageview", name); } function analyticsEvent(category, action, label, value) { if (category == "install" && action == "install") { analyticsTrigger("onInstall"); } if (category == "conversion" && action == "NAU") { analyticsTrigger("onNAU"); } if (category == "conversion" && action == "Registration") { analyticsTrigger("onRegistration"); } if (category == "conversion" && action == "NAPU") { analyticsTrigger("onNAPU"); } analytics("send", "event", category, action, label, value); } function analyticsClick(action, label, value) { analytics("send", "event", "click", action, label, value); } function analyticsTime(category, action, label, value) { analytics("send", "timing", category, action, value, label); // value & label inverted in web api } function analyticsError(fatal, description) { analytics("send", "event", "exception", description, "fatal", fatal ? 1 : 0); // no exception } // SUPPORT function supportTicket() { var dump; try { dump = ex.config.flashObject.getSessionData(); } catch (e) { ex.log("goToSupport: dump failed", e); dump = { logs: "Dump failed.." }; } var form = $('
'); form.appendTo("body"); if (dump) { var url = "https://www.sweetnitro.com/" + ex.config.lang + "/support/new_ticket.php?server=" + ex.config.serverId; if (dump.c) { url += "&c=" + dump.c; } form.attr("action", url); form.find("input:first").val(dump.logs); } form.submit(); form.remove(); } function supportForum() { goToPortal("https://www.sweetnitro.com/forum/index.php?server=" + ex.config.serverId); } function getPortalUrl(url) { var data; try { data = ex.config.flashObject.getSessionData(0); if (data && data.memberId) { url = ex.utils.addParameter(url, "memberId", data.memberId); } if (data && data.c) { url = ex.utils.addParameter(url, "c", data.c); } } catch (e) { ex.log("getPortalUrl: failed", e, url, data); if (window.fbAuthResponse) { url = ex.utils.addParameter(url, "facebookId", window.fbAuthResponse.userID); url = ex.utils.addParameter(url, "facebookAuth", window.fbAuthResponse.accessToken); } else { var urlParams = new URLSearchParams(window.location.search); var c = urlParams.get('c'); if (c) { url = ex.utils.addParameter(url, "c", c); } var memberId = urlParams.get('memberId'); if (memberId) { url = ex.utils.addParameter(url, "memberId", memberId); } } } ex.log("getPortalUrl:", url); return url; } function goToPortal(url) { window.open(getPortalUrl(url), "_blank"); } // FLASH var flashHideCounter = 0; /* WARNING: using relative/absolute to hide #flash-frame, don't use visibility: hidden. Include #flash-frame { visibility: visible !important; } in CSS for IE */ function flashShow() { ex.log("flashShow:", flashHideCounter); flashHideCounter--; if (flashHideCounter <= 0) { ex.log("flashShow: showing"); flashHideCounter = 0; $("#flash-frame").removeClass("flash-hidden"); bannersShowFlash(); } ex.config.flashObject.focus(); } function flashHide() { flashHideCounter++; ex.log("flashHide:", flashHideCounter, "hiding"); $("#flash-spoiler-text").html(ex.lang.t("paused")); $("#flash-frame").addClass("flash-hidden"); bannersHideFlash(); } function flashSetup() { ex.log("flashSetup:", swfobject.getFlashPlayerVersion().major + "." + swfobject.getFlashPlayerVersion().minor); if (document.location.href.indexOf("?debug=1") >= 0) { ex.config.flashUrl = ex.config.flashUrlDebug; } ex.config.query = ex.config.query.replace('?', '&'); var options = { staticUrl: ex.config.staticUrl + "assets/", configUrl: ex.config.staticUrl + "config/", versionUrl: ex.config.versionUrl, inFacebook: ex.config.fbIsCanvas ? "true" : "false", graphPrefix: ex.config.fbVersion ? "/" + ex.config.fbVersion : "", query: encodeURIComponent(ex.config.query), serverId: ex.config.serverId, embedded: "true" }; if (ex.config.kongIsIframe) { options.kongregate = "true"; } swfobject.embedSWF( ex.config.flashUrl, "flash-embed", ex.config.flashWidth, ex.config.flashHeight, ex.config.flashVersion, ex.config.flashInstall, options, { swLiveConnect: "true", allowFullScreen: "true", allowScriptAccess: "always", allowFullScreenInteractive: "true", wmode: "direct", allowNetworking: "all" }, {}, function (event) { ex.log("flashSetup event:", event); if (event.success) { ex.config.flashObject = event.ref; if (ex.config.onFlashReady) { ex.config.onFlashReady(); } setTimeout(ex.flash.show, 2000); // try and avoid users blocked on init } else { ex.log("flashSetup failed:", event); flashInstall(); } } ); } function flashInstall() { $("#flash-spoiler").css("display", "block"); $("#flash-spoiler-text").html(ex.lang.t("flashRequired")); $("#flash-install").css("display", "block"); } // FLASH PREVENT scroll var scrollingEnabled; function scrollingEnable() { scrollingEnabled = true; } function scrollingDisable() { scrollingEnabled = false; } function scrollingOnWheel(event) { if (!event) { event = window.event; } if (!scrollingEnabled) { if (event.preventDefault) { event.preventDefault(); } event.returnValue = false; } } function scrollListen() { if (window.addEventListener) { window.addEventListener('DOMMouseScroll', scrollingOnWheel, false); } window.onmousewheel = document.onmousewheel = scrollingOnWheel; scrollingEnable(); } // BANK function paymentShow(serverId, memberId, credits) { ex.log("paymentShow:", serverId, memberId, credits); var url = "https://www.sweetnitro.com/payment2/?ssl=1&serverId=" + serverId + "&memberId=" + memberId + "&credits=" + credits; if (ex.config.fbIsCanvas) { url += "&provider=fb"; } var iframe = $(''); var dialog = ex.utils.dialogs.create({ content: iframe, onClose: function () { ex.log("paymentShow: close"); try { ex.config.flashObject.purchaseErrorCallback(); } catch (e) { ex.log("paymentShow: close failed", e); } } }); dialog.show(); } // KONGREGATE function paymentKongregate(item) { log("paymentKongregate:", item); try { ex.config.kongInstance.mtx.purchaseItemsRemote(item, function(result) { log("paymentKongregate: response", result); try { if (result.success) { ex.config.flashObject.kongregatePurchaseSuccessCallback(); } else { ex.config.flashObject.kongregatePurchaseErrorCallback(); } } catch (e) { log("paymentKongregate: callback failed", e); } }); } catch (e) { log("paymentKongregate: failed", e); ex.config.flashObject.kongregatePurchaseErrorCallback(); } } // FACEBOOK LOGIN / REQUESTS / OG function facebookInject(callback) { if (callback) { var fbAsyncInit = window.fbAsyncInit; window.fbAsyncInit = function () { fbAsyncInit(); callback(); }; } $("body").append($('
')); (function() { if (document.getElementById("facebook-jssdk")) {return;} var firstScriptElement = document.getElementsByTagName("script")[0]; var facebookJS = document.createElement("script"); facebookJS.id = "facebook-jssdk"; facebookJS.src = "https://connect.facebook.net/en_US/all.js"; firstScriptElement.parentNode.insertBefore(facebookJS, firstScriptElement); }()); } function facebookUrlHandler(data) { try { ex.config.flashObject.facebookUrlCallback(data); } catch (e) { ex.log("facebookUrlHandler: failed", e); } } function facebookLogin(force) { if (!force && window.fbAuthResponse) { try { ex.log("facebookLogin: using cache", window.fbAuthResponse); FB.api('/me', { fields: "id" }, function(response) { ex.log("facebookLogin cache: /me", response); if (response.error) { ex.facebook.login(true); } else { ex.config.flashObject.facebookLoginSuccessCallback(window.fbAuthResponse); } }); } catch (e) { ex.log("facebookLogin: failed direct auth", e, force, window.fbAuthResponse); } } else { var opt = { scope: ex.config.fbPermissions, return_scopes: true }; if (window.fbRetry) opt.scope = "email,user_age_range"; FB.login(function(response) { try { if (response.authResponse) { ex.log("facebookLogin: success", response); window.fbAuthResponse = response.authResponse; FB.api('/me', { fields: "id" }, function(response) { ex.log("facebookLogin cache: /me", response); if (response.error && !window.fbRetry) { window.fbRetry = true; ex.facebook.login(true); } else { ex.config.flashObject.facebookLoginSuccessCallback(window.fbAuthResponse); } }); } else { ex.config.flashObject.facebookLoginErrorCallback(response); } } catch (e) { ex.log("facebookLogin: failed login", e, response); } }, opt); } } function facebookShare(title, message, url, picture, to, reference) { ex.log("facebookShare:", title, message, url, picture, to, reference); if (!ex.config.fbIsCanvas) { ex.flash.hide(); } FB.ui({ method: 'feed', link: url, name: title, description: message, picture: picture, to: to, ref: reference }, function(response) { try { if (!ex.config.fbIsCanvas) { ex.flash.show(); } if (response) { ex.config.flashObject.facebookShareSuccessCallback(response); } else { ex.config.flashObject.facebookShareErrorCallback(null); } } catch (e) { ex.log("facebookShare: failed", e, response); } }); } function facebookRequest(message, data, ids) { if (!ex.config.fbIsCanvas) { ex.flash.hide(); } var data = { method: "apprequests", data: data, message: message, to: ids ? ids.toString() : null }; FB.ui(data, function (response) { try { if (!ex.config.fbIsCanvas) { ex.flash.show(); } if (response && !response.error_code) { ex.config.flashObject.facebookRequestSuccessCallback(response); } else { ex.config.flashObject.facebookRequestErrorCallback(response); } } catch (e) { ex.log("facebookRequest: error on response", e, response); } }); } function facebookPermissions(permissions) { if (!ex.config.fbIsCanvas) { ex.flash.hide(); } FB.login(function (response) { try { if (!ex.config.fbIsCanvas) { ex.flash.show(); } if (response.authResponse) { window.fbAuthResponse = response.authResponse; ex.config.flashObject.facebookLoginSuccessCallback(response.authResponse); } else { ex.config.flashObject.facebookLoginErrorCallback(response); } } catch (e) { ex.log("facebookLogin: failed login", e, response); } }, { scope: permissions, auth_type: "rerequest", return_scopes: true }); } // FACEBOOK PAGE function facebookLike() { var pageId = ex.config.fbAppPageId || ex.config.fbAppId; FB.api("me/likes/" + pageId, "get", {}, function (response) { if (response.data.length > 0) { ex.log("likePage: already liked"); } else { facebookLikeShow(); } }); } function facebookLikeShow() { ex.flash.hide(); $("#flash-frame").addClass("flash-like-visible"); FB.Event.subscribe("edge.create", facebookLikeHide); } function facebookLikeHide() { FB.Event.unsubscribe("edge.create", facebookLikeHide); $("#flash-frame").removeClass("flash-like-visible"); ex.flash.show(); } function facebookHideFlashCallback(info) { ex.log("facebookHideFlashCallback:", info); if (info.state == "opened") { ex.flash.hide(); } else { ex.flash.show(); } } // TWITTER function twitterTweet(text, url, hashtags, via) { ex.log("twitterTweet:", text, url, hashtags, via); var node = $("#tw-tweet"); if (!node) { ex.log("twitterTweet: dialog missing"); return; } var txt = text; if (url && url.length > 0) { txt += " " + url; } if (hashtags && hashtags.length > 0) { txt += " #" + hashtags.split(",").join(" #"); } if (via && via.length > 0) { txt += " via @" + via; } var textarea = node.find(".tweetbox-text"); var send = node.find(".tweetbox-send"); send.empty(); textarea.val(text); var button; function update() { twttr.widgets.createShareButton( url, send[0], { count: "none", text: textarea.val(), hashtags: hashtags, via: via } ).then(function (b) { ex.log("twitterTweet: updated tweet button", b); if (button) { $(button).remove(); } button = b; }); } textarea.off("keyup"); textarea.on("keyup", update); update(); function tweeted(event) { ex.log("twitterTweet: tweeted", event); dialog.hide(); try { ex.config.flashObject.twitterTweetCallback(true); } catch (e) { ex.log("twitterTweet: tweeted failed", e); } } twttr.events.bind("tweet", tweeted); var dialog = ex.utils.dialogs.create({ content: node, onClose: function () { ex.log("twitterTweet: cancelled"); try { ex.config.flashObject.twitterTweetCallback(false); } catch (e) { ex.log("twitterTweet: cancelled failed", e); } }, onHide: function () { textarea.off("keyup"); twttr.events.unbind("tweet", tweeted); } }); dialog.show(); } // CHROMESTORE function chromestoreInstall() { try { if (!chrome.app.isInstalled) { // is using app chrome.webstore.install(); } else { ex.log("chromestoreInstall: already installed"); } } catch (e) { ex.log("chromestoreInstall: failed", e); } } // TRACKING function trackVisit() { var visits = parseInt(ex.utils.getCookie("visits") || 0) + 1; var source = ex.utils.getCookie("source"); if (!source) { var refName = ex.config.fbIsCanvas ? "gameref" : "ref"; source = ex.utils.getParameter(document.location.search, refName); if (!source) { source = ex.utils.getParameter(document.location.search, "s"); } } ex.log("trackVisit:", visits, source); if (visits == 1) { ex.utils.setCookie("source", source, 365); } ex.utils.setCookie("visits", visits, 365); } function trackPixel(url) { ex.log("trackPixel:", url); var img = new Image(); img.src = url; img.onload = function () { ex.log("trackPixel: complete", url); }; img.onerror = function () { ex.log("trackPixel: failed", url); }; } function utilsSetCookie(name, value, days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); expires = "; expires=" + date.toGMTString(); } document.cookie = name + "=" + value + expires + "; path=/"; } function utilsGetCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function utilsAddParameter(url, name, value) { var ch = "?"; if (url.indexOf("?") > -1) { ch = "&"; } return url + ch + name + "=" + value; } function utilsRemoveParameter(url, name) { return url.replace(new RegExp("&"+name+"(=[^&#]*)?"), "").replace(new RegExp("\\?"+name+"(=[^&#]*)?&?"), "?"); } function utilsGetParameter(url, name) { var matches = url.match(new RegExp("[\?&]" + name + "=([^&#]*)")); return matches ? matches[1] : undefined; } function utilsForward(url) { document.location.href = url; } function utilsOpenWindow(url, width, height, name) { var top = (screen.height - height) >> 1; var left = (screen.width - width) >> 1; return window.open(url, name || "_blank", "scrollbars=yes,resizable=yes,toolbar=no,location=yes,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top); } function utilsLoadScript(url, async, defer, callback) { var script = document.createElement("script"); script.type = "text/javascript"; script.src = url; script.async = async || false; script.defer = defer || false; if (callback) { script.onload = callback; } document.getElementsByTagName("head")[0].appendChild(script); } function utilsLoadStyle(url) { var link = document.createElement("link"); link.type = "text/css"; link.href = url; link.rel = "stylesheet"; link.media = "all"; document.getElementsByTagName("head")[0].appendChild(link); } // DIALOGS var dialogIds = 0; var dialogDefaults = { closeText: "Close", destroyOnClose: true, onClose: $.noop, onShow: $.noop, onHide: $.noop }; function Dialog(options) { var self = this; this.id = ++dialogIds; this.options = $.extend({}, dialogDefaults, options); this.node = $( '
' + '
' + '
' + '
' + '
' + '' + '
' + '
' + '
' + '
' + '
' ); this.overlay = this.node.find('.dialog-overlay'); this.window = this.node.find('.dialog-window'); this.close = this.node.find('.dialog-close'); this.content = this.node.find('.dialog-content'); function onClick(event) { event.preventDefault(); if (self.options.onClose) { self.options.onClose(); } self.hide(); } this.close.html(this.options.closeText); this.close.on("click", onClick); this.overlay.on("click", onClick); this.node.css({display: "none"}); this.node.appendTo("body"); var restoredParent = null; this.removeContent = function () { if (restoredParent) { self.content.children().appendTo(restoredParent); } self.content.empty(); } this.setContent = function (content) { this.removeContent(); if (!content) return; if (!content.jquery && content.nodeType) { content = $(content); } if (content.jquery) { restoredParent = content.parent(); // save parent to restore later self.content.append(content); } else { self.content.html(content); } }; if (this.options.content) { this.setContent(this.options.content); } if (this.options.verticalAlign) { this.node.find(".dialog-vertical").css("vertical-align", this.options.verticalAlign); } this.show = function () { ex.flash.hide(); if (self.options.onShow) { self.options.onShow(); } var top = this.options.top || 0; self.node.fadeOut(0); self.node.show(); self.window .css({ top: top + 30 }) .animate({ top: top }, 100); self.node.fadeIn(100); }; this.hide = function () { var top = this.options.top || 0; self.window.animate({ top: top - 30 }, 100); self.node.fadeOut(100, function () { self.node.hide(); try { ex.flash.show(); } catch (e) {} if (self.options.onHide) { self.options.onHide(); } if (self.options.destroyOnClose) { self.destroy(); } }); }; this.destroy = function () { self.removeContent(); self.node.remove(); }; } function dialogCreate(options) { return new Dialog(options); } function dialogShowOnce(id, date, days, options) { var now = (new Date()).getTime(); var has = ex.utils.getCookie("dialog-once-" + id); if (!has && now > date && now < date + days * 24 * 3600 * 1000) { ex.utils.setCookie("dialog-once-" + id, true, 365); ex.utils.dialogs.create(options).show(); } } function dialogShowWebView(url, width, height) { width = width || 800; height = height || 600; var dialog = ex.utils.dialogs.create({ content: $(''), onHide: function () { if (confirm(ex.lang.t("noflash"))) { dialogShowWebView(url, width, height); } else { try { ex.config.flashObject.webViewCloseCallback(); } catch (e) { ex.log("dialogShowWebView: close callback failed", e); } } } }); dialog.show(); } }) (window); // FACEBOOK PAYMENTS : public for jsonp function paymentFacebook(serverId, memberId, itemId, hhAvailable, option) { ex.log("paymentFacebook:", serverId, memberId, itemId, hhAvailable, option); var priceUrl = ex.config.fbPricesUrl + itemId + (hhAvailable ? "-hh" : "") + ".html"; window.sweetnitroPaymentKey = serverId + "-" + memberId; window.sweetnitroPaymentItemId = itemId; window.sweetnitroPaymentOption = option || ""; FB.ui({ method: "pay", action: "purchaseitem", product: priceUrl, request_id: window.sweetnitroPaymentKey + "|" + window.sweetnitroPaymentItemId + "|" + window.sweetnitroPaymentOption + "|" + (new Date()).getTime(), quantity: 1 }, facebookPayCallback); } function facebookPayCallback(data) { ex.log("facebookPayCallback:", data); if (!data || data.error_code) { try { ex.config.flashObject.purchaseErrorCallback(data); } catch (e) { ex.log("facebookPayCallback: failed", e, data); } } else { data.p = "facebook"; data.provider = "fb"; data.key = window.sweetnitroPaymentKey; data.productId = window.sweetnitroPaymentItemId; if (window.sweetnitroPaymentOption != "") data.option = window.sweetnitroPaymentOption; data.method = "POST"; $.ajax({ url: "/rest/action/payment", data: data, dataType: "jsonp", jsonp: "facebookPayCallback2" }); } } function facebookPayCallback2(data) { ex.log("facebookPayCallback2:", data); try { if (data) { ex.config.flashObject.purchaseSuccessCallback(data); } else { ex.config.flashObject.purchaseErrorCallback("paymentRefusedByServer"); } } catch (e) { ex.log("facebookPayCallback2: failed", e, data); } }