var flimmerkisteMothership = new function() { var libLoadState = "uninitialized"; var api = null; var userid = ""; var g = "m"; var b = ""; var lastCheck = 0; var offerState = 0; // 0 = init; 1 = offer; 2 = no offer var videoID = 0; var isPlaying = false; var getCookie = function(name){ var i, n, v, cookies=document.cookie.split(";"); for (i=0;i flimmerkistePoll * 1000) { lastCheck = new Date().getTime(); setCookie("to_flimmerkiste", lastCheck); } else { return; } var path = ""; if (window.location.pathname.match(/\/(beta|flash)/)) { path = "../"; } loadJs(path + "payment/mosh.php", "?rnd=" + Math.floor(Math.random()*99999999999), { "onComplete": function (){ if (moshid == "") { return false } var moshvideoid = moshid + "&uid=" + instance.userid + "_" + getUniqueId(5) + "&gen" + "der=" + instance.g + "&a" + "ge=" + instance.b ; api.video_request({ onAvailable: function(id) { videoID = id; offerState = 1; }, onNotAvailable: function(){ offerState = 2; } }, moshvideoid); } }, true); } this.initialize = function(userid, g, b){ if (!api){ if (typeof b === 'string') { if (b.match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}/)) { d1 = new Date(b.substr(0,4), b.substr(5,2), b.substr(8,2)); d2 = new Date(); b = Math.floor((d2.getTime() - d1.getTime()) / (1000 * 60 * 60 * 24 * 365.25)); } else { b = parseInt(b) } } let gameid = 1; if (typeof userid === 'string') { let a = userid.match(/^[0-9]+_[0-9]+_[0-9]+_([0-9]+)/); if (a && a.length == 2 ) { gameid = Number(a[1]); } } this.userid = userid; this.g = (g==2)?"f":"m"; this.b = b; loadLibs(gameid); } else { backgroundLoad() } }; this.isAvailable = function(){ if (offerState == 1 && !isPlaying){ return 1; } return 0; }; this.setUserId = function(userid) { if (userid != "" && instance.userid != userid) { this.userid = userid; } }; this.show = function () { if (offerState != 1 && !isPlaying){ return; } isPlaying = true; api.video_play({ onVideoEnd: function() { videoID = 0; offerState = 0; isPlaying = false; } }, videoID); }; var instance = this; } function paymentFlimmerkiste2(mode, playerid, g, b) { switch (mode){ case "requesttv": flimmerkisteMothership.initialize(playerid, g, b); if (flimmerkisteMothership.isAvailable()){ return 1; } break; case "showtv": flimmerkisteMothership.setUserId(playerid); if (flimmerkisteMothership.isAvailable()){ flimmerkisteMothership.show(); } break; } return 0; } function paymentMothership(playerid){ flimmerkisteMothership.initialize(playerid, "m"); if (flimmerkisteMothership.isAvailable()){ flimmerkisteMothership.show(); } else { var text = "Sorry, no offer available"; if (strings["brandengage.no_offers"]){ text = strings["brandengage.no_offers"]; } createTextPopup("brandengageNoOffers", text, 200, 40, 1); } return 0; }