1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711 |
- (function (t) {
- "use strict";
- function e() { }
- function n(t) {
- if (t = t || {}, this.IS_MASTER = t.isMaster || !1, !this.IS_MASTER) throw Error("The DataStore can only be instantiated by the Master");
- this.dataStore = {}
- }
- function r(t, e) {
- if (this.IS_MASTER = t && t.isMaster ? t.isMaster : !1, this.IS_SLAVE = !this.IS_MASTER, this.messenger = null, this.subscribers = {}, this.moduleReady = e ? e : !1, this.gameState = "resume", !t || !t.messenger) throw Error("No messenger passed to the Game module instance");
- this.messenger = t.messenger, window.addEventListener ? window.addEventListener("message", this._performAction.bind(this), !1) : window.attachEvent && window.attachEvent("onmessage", this._performAction.bind(this))
- }
- function i(t, e) {
- t = t || {}, this.IS_MASTER = t.isMaster, this.IS_SLAVE = !this.IS_MASTER, this.moduleReady = e ? e : !1, this.messenger = t.messenger, this.data = t.data || null, this._setupMasterEvent()
- }
- function o(t, e) {
- t = t || {}, this.isMaster = t.isMaster, this.isStandalone = t.isStandalone, this.messenger = t.messenger, this.moduleReady = e ? e : !1, this.timeoutAfter = 500, this.timeout = !1, this._callbacks = {
- pause: !1,
- resume: !1
- }
- }
- function a(t, e) {
- t = t || {}, this.IS_MASTER = t.isMaster, this.isStandalone = t.isStandalone, this.messenger = t.messenger, this.eventTracking = t.eventTracking, this.moduleReady = e ? e : !1, this.events = {
- GAME_START: "GAME_START",
- GAME_END: "GAME_END",
- GAME_PAUSE: "GAME_PAUSE",
- GAME_CONTINUE: "GAME_CONTINUE",
- GAME_MUTE: "GAME_MUTE",
- LEVEL_FAIL: "LEVEL_FAIL",
- LEVEL_COMPLETE: "LEVEL_COMPLETE"
- }, this._setupEvents()
- }
- function s(t, e) {
- t = t || {}, this.IS_MASTER = t.isMaster, this.IS_SLAVE = !this.IS_MASTER, this.data = t.data, this.messenger = t.messenger, this.moduleReady = e ? e : !1, this.gamePlayTracking = {
- started: !1,
- appid: null,
- host: null,
- timestamp: null
- }, this.timeInGameTracking = {
- started: !1,
- appid: null,
- timestamp: null
- }
- }
- function u(t, e) {
- t = t || {}, this.IS_MASTER = t.isMaster, this.IS_SLAVE = !this.IS_MASTER, this.moduleReady = e ? e : !1, this.messenger = t.messenger, this.components = t.components, this.data = t.data || null
- }
- function c(t) {
- var e = "string" == typeof t ? p(t) : t;
- e && (this.type = e.type, this.callbackId = e.callbackId, this.data = e.data)
- }
- function p(t) {
- var e, n, r, i = !1,
- o = [];
- if ("string" == typeof t && (o = t.split("|"), "gameapi" === o[0])) {
- o.shift(), e = o.shift(), r = parseInt(o.shift(), 10), n = o.join("|");
- try {
- i = {
- type: e,
- callbackId: r,
- data: "" !== n ? JSON.parse(n) : ""
- }
- } catch (a) { }
- }
- return i
- }
- // ih5game.setShare({
- // desc: "圣诞节来啦!圣诞老人快起床!!~~~~"
- // });
- function l(t) {
- t = t || {}, this.IS_MASTER = "boolean" == typeof t.isMaster ? t.isMaster : !1, this.IS_SLAVE = !this.IS_MASTER, this.api = t.api ? t.api : {}, this._target = t.target ? t.target : {}, this._callbacks = [], this._channels = [], this.IS_MASTER && t.dataStore && (this.dataStore = t.dataStore), this._setupEventListener()
- }
- function d(t, n, o, s, u) {
- this.version = "0.13.7", this.isReady = !1, this._setRole(), this.__ = {}, this.__.dataStore = this.IS_MASTER ? new t({
- isMaster: !0
- }) : null, this.__.messenger = new n({
- isMaster: this.IS_MASTER,
- api: this,
- target: this._getTarget(),
- dataStore: this.__.dataStore
- }), this.__.components = new e, this.Branding = new o({
- isMaster: this.IS_MASTER,
- messenger: this.__.messenger,
- components: this.__.components
- }, !1), this.__.EventTracking = new s({
- isMaster: this.IS_MASTER,
- data: null,
- messenger: this.__.messenger
- }, !1), this.GameBreak = new u({
- isMaster: this.IS_MASTER,
- isStandalone: this.IS_STANDALONE,
- messenger: this.__.messenger
- }, !1), this.Game = new r({
- isMaster: this.IS_MASTER,
- messenger: this.__.messenger
- }, !1), this.Score = new i({
- isMaster: this.IS_MASTER,
- messenger: this.__.messenger
- }, !1), this.GameEvent = new a({
- isMaster: this.IS_MASTER,
- messenger: this.__.messenger,
- eventTracking: this.__.EventTracking
- }, !1)
- }
- var h;
- (function (t) {
- if ("function" == typeof bootstrap) bootstrap("promise", t);
- else if ("object" == typeof exports) module.exports = t();
- else if ("function" == typeof define && define.amd) define(t);
- else if ("undefined" != typeof ses) {
- if (!ses.ok()) return;
- ses.makeQ = t
- } else h = t()
- })(function () {
- function t(t) {
- return function () {
- return X.apply(t, arguments)
- }
- }
- function e(t) {
- return t === Object(t)
- }
- function n(t) {
- return "[object StopIteration]" === ee(t) || t instanceof W
- }
- function r(t, e) {
- if (q && e.stack && "object" == typeof t && null !== t && t.stack && -1 === t.stack.indexOf(ne)) {
- for (var n = [], r = e; r; r = r.source) r.stack && n.unshift(r.stack);
- n.unshift(t.stack);
- var o = n.join("\n" + ne + "\n");
- t.stack = i(o)
- }
- }
- function i(t) {
- for (var e = t.split("\n"), n = [], r = 0; e.length > r; ++r) {
- var i = e[r];
- s(i) || o(i) || !i || n.push(i)
- }
- return n.join("\n")
- }
- function o(t) {
- return -1 !== t.indexOf("(module.js:") || -1 !== t.indexOf("(node.js:")
- }
- function a(t) {
- var e = /at .+ \((.+):(\d+):(?:\d+)\)$/.exec(t);
- if (e) return [e[1], Number(e[2])];
- var n = /at ([^ ]+):(\d+):(?:\d+)$/.exec(t);
- if (n) return [n[1], Number(n[2])];
- var r = /.*@(.+):(\d+)$/.exec(t);
- return r ? [r[1], Number(r[2])] : void 0
- }
- function s(t) {
- var e = a(t);
- if (!e) return !1;
- var n = e[0],
- r = e[1];
- return n === F && r >= J && ae >= r
- }
- function u() {
- if (q) try {
- throw Error()
- } catch (t) {
- var e = t.stack.split("\n"),
- n = e[0].indexOf("@") > 0 ? e[1] : e[2],
- r = a(n);
- if (!r) return;
- return F = r[0], r[1]
- }
- }
- function c(t, e, n) {
- return function () {
- return "undefined" != typeof console && "function" == typeof console.warn && console.warn(e + " is deprecated, use " + n + " instead.", Error("").stack), t.apply(t, arguments)
- }
- }
- function p(t) {
- return y(t) ? t : v(t) ? I(t) : k(t)
- }
- function l() {
- function t(t) {
- e = t, o.source = t, Q(n, function (e, n) {
- H(function () {
- t.promiseDispatch.apply(t, n)
- })
- }, void 0), n = void 0, r = void 0
- }
- var e, n = [],
- r = [],
- i = Y(l.prototype),
- o = Y(f.prototype);
- if (o.promiseDispatch = function (t, i, o) {
- var a = K(arguments);
- n ? (n.push(a), "when" === i && o[1] && r.push(o[1])) : H(function () {
- e.promiseDispatch.apply(e, a)
- })
- }, o.valueOf = function () {
- if (n) return o;
- var t = m(e);
- return y(t) && (e = t), t
- }, o.inspect = function () {
- return e ? e.inspect() : {
- state: "pending"
- }
- }, p.longStackSupport && q) try {
- throw Error()
- } catch (a) {
- o.stack = a.stack.substring(a.stack.indexOf("\n") + 1)
- }
- return i.promise = o, i.resolve = function (n) {
- e || t(p(n))
- }, i.fulfill = function (n) {
- e || t(k(n))
- }, i.reject = function (n) {
- e || t(T(n))
- }, i.notify = function (t) {
- e || Q(r, function (e, n) {
- H(function () {
- n(t)
- })
- }, void 0)
- }, i
- }
- function d(t) {
- if ("function" != typeof t) throw new TypeError("resolver must be a function.");
- var e = l();
- try {
- t(e.resolve, e.reject, e.notify)
- } catch (n) {
- e.reject(n)
- }
- return e.promise
- }
- function h(t) {
- return d(function (e, n) {
- for (var r = 0, i = t.length; i > r; r++) p(t[r]).then(e, n)
- })
- }
- function f(t, e, n) {
- void 0 === e && (e = function (t) {
- return T(Error("Promise does not support operation: " + t))
- }), void 0 === n && (n = function () {
- return {
- state: "unknown"
- }
- });
- var r = Y(f.prototype);
- if (r.promiseDispatch = function (n, i, o) {
- var a;
- try {
- a = t[i] ? t[i].apply(r, o) : e.call(r, i, o)
- } catch (s) {
- a = T(s)
- }
- n && n(a)
- }, r.inspect = n, n) {
- var i = n();
- "rejected" === i.state && (r.exception = i.reason), r.valueOf = function () {
- var t = n();
- return "pending" === t.state || "rejected" === t.state ? r : t.value
- }
- }
- return r
- }
- function g(t, e, n, r) {
- return p(t).then(e, n, r)
- }
- function m(t) {
- if (y(t)) {
- var e = t.inspect();
- if ("fulfilled" === e.state) return e.value
- }
- return t
- }
- function y(t) {
- return e(t) && "function" == typeof t.promiseDispatch && "function" == typeof t.inspect
- }
- function v(t) {
- return e(t) && "function" == typeof t.then
- }
- function _(t) {
- return y(t) && "pending" === t.inspect().state
- }
- function S(t) {
- return !y(t) || "fulfilled" === t.inspect().state
- }
- function w(t) {
- return y(t) && "rejected" === t.inspect().state
- }
- function b() {
- re.length = 0, ie.length = 0, oe || (oe = !0)
- }
- function A(t, e) {
- oe && (ie.push(t), e && e.stack !== void 0 ? re.push(e.stack) : re.push("(no stack) " + e))
- }
- function E(t) {
- if (oe) {
- var e = $(ie, t); -1 !== e && (ie.splice(e, 1), re.splice(e, 1))
- }
- }
- function T(t) {
- var e = f({
- when: function (e) {
- return e && E(this), e ? e(t) : this
- }
- }, function () {
- return this
- }, function () {
- return {
- state: "rejected",
- reason: t
- }
- });
- return A(e, t), e
- }
- function k(t) {
- return f({
- when: function () {
- return t
- },
- get: function (e) {
- return t[e]
- },
- set: function (e, n) {
- t[e] = n
- },
- "delete": function (e) {
- delete t[e]
- },
- post: function (e, n) {
- return null === e || void 0 === e ? t.apply(void 0, n) : t[e].apply(t, n)
- },
- apply: function (e, n) {
- return t.apply(e, n)
- },
- keys: function () {
- return te(t)
- }
- }, void 0, function () {
- return {
- state: "fulfilled",
- value: t
- }
- })
- }
- function I(t) {
- var e = l();
- return H(function () {
- try {
- t.then(e.resolve, e.reject, e.notify)
- } catch (n) {
- e.reject(n)
- }
- }), e.promise
- }
- function M(t) {
- return f({
- isDef: function () { }
- }, function (e, n) {
- return L(t, e, n)
- }, function () {
- return p(t).inspect()
- })
- }
- function R(t, e, n) {
- return p(t).spread(e, n)
- }
- function C(t) {
- return function () {
- function e(t, e) {
- var a;
- if ("undefined" == typeof StopIteration) {
- try {
- a = r[t](e)
- } catch (s) {
- return T(s)
- }
- return a.done ? a.value : g(a.value, i, o)
- }
- try {
- a = r[t](e)
- } catch (s) {
- return n(s) ? s.value : T(s)
- }
- return g(a, i, o)
- }
- var r = t.apply(this, arguments),
- i = e.bind(e, "next"),
- o = e.bind(e, "throw");
- return i()
- }
- }
- function P(t) {
- p.done(p.async(t)())
- }
- function O(t) {
- throw new W(t)
- }
- function x(t) {
- return function () {
- return R([this, G(arguments)], function (e, n) {
- return t.apply(e, n)
- })
- }
- }
- function L(t, e, n) {
- return p(t).dispatch(e, n)
- }
- function G(t) {
- return g(t, function (t) {
- var e = 0,
- n = l();
- return Q(t, function (r, i, o) {
- var a;
- y(i) && "fulfilled" === (a = i.inspect()).state ? t[o] = a.value : (++e, g(i, function (r) {
- t[o] = r, 0 === --e && n.resolve(t)
- }, n.reject, function (t) {
- n.notify({
- index: o,
- value: t
- })
- }))
- }, void 0), 0 === e && n.resolve(t), n.promise
- })
- }
- function N(t) {
- return g(t, function (t) {
- return t = z(t, p), g(G(z(t, function (t) {
- return g(t, U, U)
- })), function () {
- return t
- })
- })
- }
- function j(t) {
- return p(t).allSettled()
- }
- function D(t, e) {
- return p(t).then(void 0, void 0, e)
- }
- function B(t, e) {
- return p(t).nodeify(e)
- }
- var q = !1;
- try {
- throw Error()
- } catch (V) {
- q = !!V.stack
- }
- var F, W, J = u(),
- U = function () { },
- H = function () {
- function t() {
- for (; e.next;) {
- e = e.next;
- var n = e.task;
- e.task = void 0;
- var i = e.domain;
- i && (e.domain = void 0, i.enter());
- try {
- n()
- } catch (a) {
- if (o) throw i && i.exit(), setTimeout(t, 0), i && i.enter(), a;
- setTimeout(function () {
- throw a
- }, 0)
- }
- i && i.exit()
- }
- r = !1
- }
- var e = {
- task: void 0,
- next: null
- },
- n = e,
- r = !1,
- i = void 0,
- o = !1;
- if (H = function (t) {
- n = n.next = {
- task: t,
- domain: o && process.domain,
- next: null
- }, r || (r = !0, i())
- }, "undefined" != typeof process && process.nextTick) o = !0, i = function () {
- process.nextTick(t)
- };
- else if ("function" == typeof setImmediate) i = "undefined" != typeof window ? setImmediate.bind(window, t) : function () {
- setImmediate(t)
- };
- else if ("undefined" != typeof MessageChannel) {
- var a = new MessageChannel;
- a.port1.onmessage = function () {
- i = s, a.port1.onmessage = t, t()
- };
- var s = function () {
- a.port2.postMessage(0)
- };
- i = function () {
- setTimeout(t, 0), s()
- }
- } else i = function () {
- setTimeout(t, 0)
- };
- return H
- }(),
- X = Function.call,
- K = t(Array.prototype.slice),
- Q = t(Array.prototype.reduce || function (t, e) {
- var n = 0,
- r = this.length;
- if (1 === arguments.length)
- for (; ;) {
- if (n in this) {
- e = this[n++];
- break
- }
- if (++n >= r) throw new TypeError
- }
- for (; r > n; n++) n in this && (e = t(e, this[n], n));
- return e
- }),
- $ = t(Array.prototype.indexOf || function (t) {
- for (var e = 0; this.length > e; e++)
- if (this[e] === t) return e;
- return -1
- }),
- z = t(Array.prototype.map || function (t, e) {
- var n = this,
- r = [];
- return Q(n, function (i, o, a) {
- r.push(t.call(e, o, a, n))
- }, void 0), r
- }),
- Y = Object.create || function (t) {
- function e() { }
- return e.prototype = t, new e
- },
- Z = t(Object.prototype.hasOwnProperty),
- te = Object.keys || function (t) {
- var e = [];
- for (var n in t) Z(t, n) && e.push(n);
- return e
- },
- ee = t(Object.prototype.toString);
- W = "undefined" != typeof ReturnValue ? ReturnValue : function (t) {
- this.value = t
- };
- var ne = "From previous event:";
- p.resolve = p, p.nextTick = H, p.longStackSupport = !1, p.defer = l, l.prototype.makeNodeResolver = function () {
- var t = this;
- return function (e, n) {
- e ? t.reject(e) : arguments.length > 2 ? t.resolve(K(arguments, 1)) : t.resolve(n)
- }
- }, p.Promise = d, p.promise = d, d.race = h, d.all = G, d.reject = T, d.resolve = p, p.passByCopy = function (t) {
- return t
- }, f.prototype.passByCopy = function () {
- return this
- }, p.join = function (t, e) {
- return p(t).join(e)
- }, f.prototype.join = function (t) {
- return p([this, t]).spread(function (t, e) {
- if (t === e) return t;
- throw Error("Can't join: not the same: " + t + " " + e)
- })
- }, p.race = h, f.prototype.race = function () {
- return this.then(p.race)
- }, p.makePromise = f, f.prototype.toString = function () {
- return "[object Promise]"
- }, f.prototype.then = function (t, e, n) {
- function i(e) {
- try {
- return "function" == typeof t ? t(e) : e
- } catch (n) {
- return T(n)
- }
- }
- function o(t) {
- if ("function" == typeof e) {
- r(t, s);
- try {
- return e(t)
- } catch (n) {
- return T(n)
- }
- }
- return T(t)
- }
- function a(t) {
- return "function" == typeof n ? n(t) : t
- }
- var s = this,
- u = l(),
- c = !1;
- return H(function () {
- s.promiseDispatch(function (t) {
- c || (c = !0, u.resolve(i(t)))
- }, "when", [
- function (t) {
- c || (c = !0, u.resolve(o(t)))
- }
- ])
- }), s.promiseDispatch(void 0, "when", [void 0,
- function (t) {
- var e, n = !1;
- try {
- e = a(t)
- } catch (r) {
- if (n = !0, !p.onerror) throw r;
- p.onerror(r)
- }
- n || u.notify(e)
- }
- ]), u.promise
- }, p.when = g, f.prototype.thenResolve = function (t) {
- return this.then(function () {
- return t
- })
- }, p.thenResolve = function (t, e) {
- return p(t).thenResolve(e)
- }, f.prototype.thenReject = function (t) {
- return this.then(function () {
- throw t
- })
- }, p.thenReject = function (t, e) {
- return p(t).thenReject(e)
- }, p.nearer = m, p.isPromise = y, p.isPromiseAlike = v, p.isPending = _, f.prototype.isPending = function () {
- return "pending" === this.inspect().state
- }, p.isFulfilled = S, f.prototype.isFulfilled = function () {
- return "fulfilled" === this.inspect().state
- }, p.isRejected = w, f.prototype.isRejected = function () {
- return "rejected" === this.inspect().state
- };
- var re = [],
- ie = [],
- oe = !0;
- p.resetUnhandledRejections = b, p.getUnhandledReasons = function () {
- return re.slice()
- }, p.stopUnhandledRejectionTracking = function () {
- b(), oe = !1
- }, b(), p.reject = T, p.fulfill = k, p.master = M, p.spread = R, f.prototype.spread = function (t, e) {
- return this.all().then(function (e) {
- return t.apply(void 0, e)
- }, e)
- }, p.async = C, p.spawn = P, p["return"] = O, p.promised = x, p.dispatch = L, f.prototype.dispatch = function (t, e) {
- var n = this,
- r = l();
- return H(function () {
- n.promiseDispatch(r.resolve, t, e)
- }), r.promise
- }, p.get = function (t, e) {
- return p(t).dispatch("get", [e])
- }, f.prototype.get = function (t) {
- return this.dispatch("get", [t])
- }, p.set = function (t, e, n) {
- return p(t).dispatch("set", [e, n])
- }, f.prototype.set = function (t, e) {
- return this.dispatch("set", [t, e])
- }, p.del = p["delete"] = function (t, e) {
- return p(t).dispatch("delete", [e])
- }, f.prototype.del = f.prototype["delete"] = function (t) {
- return this.dispatch("delete", [t])
- }, p.mapply = p.post = function (t, e, n) {
- return p(t).dispatch("post", [e, n])
- }, f.prototype.mapply = f.prototype.post = function (t, e) {
- return this.dispatch("post", [t, e])
- }, p.send = p.mcall = p.invoke = function (t, e) {
- return p(t).dispatch("post", [e, K(arguments, 2)])
- }, f.prototype.send = f.prototype.mcall = f.prototype.invoke = function (t) {
- return this.dispatch("post", [t, K(arguments, 1)])
- }, p.fapply = function (t, e) {
- return p(t).dispatch("apply", [void 0, e])
- }, f.prototype.fapply = function (t) {
- return this.dispatch("apply", [void 0, t])
- }, p["try"] = p.fcall = function (t) {
- return p(t).dispatch("apply", [void 0, K(arguments, 1)])
- }, f.prototype.fcall = function () {
- return this.dispatch("apply", [void 0, K(arguments)])
- }, p.fbind = function (t) {
- var e = p(t),
- n = K(arguments, 1);
- return function () {
- return e.dispatch("apply", [this, n.concat(K(arguments))])
- }
- }, f.prototype.fbind = function () {
- var t = this,
- e = K(arguments);
- return function () {
- return t.dispatch("apply", [this, e.concat(K(arguments))])
- }
- }, p.keys = function (t) {
- return p(t).dispatch("keys", [])
- }, f.prototype.keys = function () {
- return this.dispatch("keys", [])
- }, p.all = G, f.prototype.all = function () {
- return G(this)
- }, p.allResolved = c(N, "allResolved", "allSettled"), f.prototype.allResolved = function () {
- return N(this)
- }, p.allSettled = j, f.prototype.allSettled = function () {
- return this.then(function (t) {
- return G(z(t, function (t) {
- function e() {
- return t.inspect()
- }
- return t = p(t), t.then(e, e)
- }))
- })
- }, p.fail = p["catch"] = function (t, e) {
- return p(t).then(void 0, e)
- }, f.prototype.fail = f.prototype["catch"] = function (t) {
- return this.then(void 0, t)
- }, p.progress = D, f.prototype.progress = function (t) {
- return this.then(void 0, void 0, t)
- }, p.fin = p["finally"] = function (t, e) {
- return p(t)["finally"](e)
- }, f.prototype.fin = f.prototype["finally"] = function (t) {
- return t = p(t), this.then(function (e) {
- return t.fcall().then(function () {
- return e
- })
- }, function (e) {
- return t.fcall().then(function () {
- throw e
- })
- })
- }, p.done = function (t, e, n, r) {
- return p(t).done(e, n, r)
- }, f.prototype.done = function (t, e, n) {
- var i = function (t) {
- H(function () {
- if (r(t, o), !p.onerror) throw t;
- p.onerror(t)
- })
- },
- o = t || e || n ? this.then(t, e, n) : this;
- "object" == typeof process && process && process.domain && (i = process.domain.bind(i)), o.then(void 0, i)
- }, p.timeout = function (t, e, n) {
- return p(t).timeout(e, n)
- }, f.prototype.timeout = function (t, e) {
- var n = l(),
- r = setTimeout(function () {
- n.reject(Error(e || "Timed out after " + t + " ms"))
- }, t);
- return this.then(function (t) {
- clearTimeout(r), n.resolve(t)
- }, function (t) {
- clearTimeout(r), n.reject(t)
- }, n.notify), n.promise
- }, p.delay = function (t, e) {
- return void 0 === e && (e = t, t = void 0), p(t).delay(e)
- }, f.prototype.delay = function (t) {
- return this.then(function (e) {
- var n = l();
- return setTimeout(function () {
- n.resolve(e)
- }, t), n.promise
- })
- }, p.nfapply = function (t, e) {
- return p(t).nfapply(e)
- }, f.prototype.nfapply = function (t) {
- var e = l(),
- n = K(t);
- return n.push(e.makeNodeResolver()), this.fapply(n).fail(e.reject), e.promise
- }, p.nfcall = function (t) {
- var e = K(arguments, 1);
- return p(t).nfapply(e)
- }, f.prototype.nfcall = function () {
- var t = K(arguments),
- e = l();
- return t.push(e.makeNodeResolver()), this.fapply(t).fail(e.reject), e.promise
- }, p.nfbind = p.denodeify = function (t) {
- var e = K(arguments, 1);
- return function () {
- var n = e.concat(K(arguments)),
- r = l();
- return n.push(r.makeNodeResolver()), p(t).fapply(n).fail(r.reject), r.promise
- }
- }, f.prototype.nfbind = f.prototype.denodeify = function () {
- var t = K(arguments);
- return t.unshift(this), p.denodeify.apply(void 0, t)
- }, p.nbind = function (t, e) {
- var n = K(arguments, 2);
- return function () {
- function r() {
- return t.apply(e, arguments)
- }
- var i = n.concat(K(arguments)),
- o = l();
- return i.push(o.makeNodeResolver()), p(r).fapply(i).fail(o.reject), o.promise
- }
- }, f.prototype.nbind = function () {
- var t = K(arguments, 0);
- return t.unshift(this), p.nbind.apply(void 0, t)
- }, p.nmapply = p.npost = function (t, e, n) {
- return p(t).npost(e, n)
- }, f.prototype.nmapply = f.prototype.npost = function (t, e) {
- var n = K(e || []),
- r = l();
- return n.push(r.makeNodeResolver()), this.dispatch("post", [t, n]).fail(r.reject), r.promise
- }, p.nsend = p.nmcall = p.ninvoke = function (t, e) {
- var n = K(arguments, 2),
- r = l();
- return n.push(r.makeNodeResolver()), p(t).dispatch("post", [e, n]).fail(r.reject), r.promise
- }, f.prototype.nsend = f.prototype.nmcall = f.prototype.ninvoke = function (t) {
- var e = K(arguments, 1),
- n = l();
- return e.push(n.makeNodeResolver()), this.dispatch("post", [t, e]).fail(n.reject), n.promise
- }, p.nodeify = B, f.prototype.nodeify = function (t) {
- return t ? (this.then(function (e) {
- H(function () {
- t(null, e)
- })
- }, function (e) {
- H(function () {
- t(e)
- })
- }), void 0) : this
- };
- var ae = u();
- return p
- }),
- function (t) {
- var e = "Promise" in t && "cast" in t.Promise && "resolve" in t.Promise && "reject" in t.Promise && "all" in t.Promise && "race" in t.Promise && "spread" in t.Promise;
- e || (t.Promise = h.promise, t.Promise.all = h.all, t.Promise.timeout = h.timeout, h.stopUnhandledRejectionTracking())
- }(t !== void 0 ? t : this);
- var f = {
- timeout: 3e3
- };
- f.getGameConfig = function () {
- var t = h.defer();
- return SpilGames(["JSLib"], function (e) {
- var n = e.get("current.game.integration.info");
- n ? t.resolve(n) : t.reject(Error("No data retrieved from JSLib"))
- }), t.promise.timeout(this.timeout)
- }, f.getBrandingConfig = function (t) {
- var e = h.defer(),
- n = "configs",
- r = t.portal.siteId,
- i = t.portal.channelId,
- o = t.portal.applicationId;
- return SpilGames(["Net", "JSLib"], function (t, a) {
- t.send({
- url: [n, i, r, o].join("/"),
- type: "GET",
- dataType: "JSON"
- }, function (t) {
- if (t && t.configar) window.postMessage(new c({
- type: "success",
- callbackId: null,
- data: "log.configar.getBranding.success"
- }), "*"), e.resolve(t.configar);
- else {
- var n = {};
- try {
- n = a.get("configar.data.cached") || n
- } catch (r) { }
- e.reject(n)
- }
- })
- }), e.promise.timeout(this.timeout)
- };
- var g = {};
- g.argsToArray = function (t) {
- return t ? Array.prototype.slice.apply(t) : []
- }, g.isA10 = function () {
- return /4399.com/.test(window.location.host)
- }, g.disableKeys = function (t) {
- var e = t.keyCode;
- (8 === e || 9 === e || e >= 32 && 40 >= e || 46 === e) && t.preventDefault()
- }, g.trackGA = function () { }, g.getRole = function () {
- var t = "function" == typeof window.SpilGames,
- e = window.self !== window.top,
- n = null;
- if (g.isA10()) return window.onkeydown = this.disableKeys, {
- IS_MASTER: !0,
- IS_SLAVE: !0,
- IS_STANDALONE: !0
- };
- if (t) {
- var r = document.getElementById("#iframegame");
- switch (r) {
- case "null":
- n = {
- IS_MASTER: !0,
- IS_SLAVE: !0,
- IS_STANDALONE: !1
- };
- break;
- default:
- n = {
- IS_MASTER: !0,
- IS_SLAVE: !1,
- IS_STANDALONE: !1
- }
- }
- } else e ? (window.onkeydown = this.disableKeys, this.trackGA(), n = {
- IS_MASTER: !1,
- IS_SLAVE: !0,
- IS_STANDALONE: !1
- }) : (window.onkeydown = this.disableKeys, this.trackGA(), n = {
- IS_MASTER: !0,
- IS_SLAVE: !0,
- IS_STANDALONE: !0
- });
- return n
- }, g.callConfigar = function (t, e) {
- var n, r, i = t.site || 500,
- o = t.channel || 100,
- a = t.id || null;
- window.XDomainRequest ? (n = new XDomainRequest, n.onload = function () {
- e(200, n.responseText)
- }, n.onerror = function () {
- e(404, null)
- }, n.onprogress = function () { }) : window.XMLHttpRequest ? (n = new XMLHttpRequest, n.onreadystatechange = function () {
- 4 === n.readyState && e(n.status, n.responseText)
- }) : window.ActiveXObject && (n = new ActiveXObject("Microsoft.XMLHTTP"), n.onreadystatechange = function () {
- 4 === n.readyState && e(n.status, n.responseText)
- }), a && (r = ["configs", o, i, a].join("/"), n.open("GET", r, !0), n.timeout = 3e3, n.ontimeout = function () {
- e(404, null)
- }, n.send())
- }, g.isWrapped = function () {
- return void 0 !== (window.PhoneGap || window.cordova || window.Cordova)
- }, g.isArray = Array.isArray || function (t) {
- return "[object Array]" === Object.prototype.toString.call(t)
- }, g._getQueryString = function () {
- return window.location.search
- }, g._getPortalHost = function () {
- return window && window.location && window.location.hostname ? window.location.hostname : "unknown"
- }, g.validateSchema = function (t, e) {
- for (var n in e)
- if (e.hasOwnProperty(n)) {
- if (!t.hasOwnProperty(n)) return {
- error: "Wrong argument passed: " + n
- };
- if (t.hasOwnProperty(n)) {
- var r = "object" == typeof t[n] ? t[n].type : t[n];
- if (e[n].constructor.name !== r) return {
- error: "Wrong value type for " + n + ": expected " + t[n] + ", got " + e[n].constructor.name
- };
- var i = t[n] && t[n].values || [];
- if (-1 === i.indexOf(e[n])) return {
- error: "Wrong value for " + n + ": expected " + i.join(" or ") + ", got " + e[n]
- }
- }
- }
- return {
- error: !1
- }
- };
- var m = {};
- m.getGameConfig = function () {
- return f.getGameConfig().catch(function () {
- return m.getLocalConfig()
- })
- }, m.getBrandingConfig = function (t) {
- return new Promise(function (e) {
- return f.getBrandingConfig(t).then(e, function (t) {
- e(t), window.postMessage(new c({
- type: "warning",
- callbackId: null,
- data: "log.configar.getBranding.failure"
- }), "*")
- })
- })
- }, m.getLocalConfig = function (t) {
- t = t && Object.keys(t).length ? t : {
- portal: {},
- game: {},
- branding: {}
- };
- var e = {
- game: {
- applicationId: t.portal.applicationId || "0",
- contentarId: t.portal.contentarId || "0",
- info: t.game.info || {},
- settings: t.game.objectSettings || {},
- features: {
- achievements: t.game.achievements || !1,
- gameSidePanel: t.game.gameSidePanel || !1,
- highscores: t.game.highscores || !1,
- recommendedGames: t.game.recommendedGames || !1
- }
- },
- user: {
- authenticated: t.portal.authenticated || !1,
- username: t.portal.username || ""
- },
- portal: {
- host: g._getPortalHost(),
- siteId: t.portal.siteId || 0,
- channelId: t.portal.channelId || 0,
- applicationId: t.portal.applicationId || "0"
- },
- branding: t.branding || {}
- };
- return e.branding.logo = e.branding.logo || {}, e.branding.logo.url = e.branding.logo.url || !1, e.branding.logo.image = e.branding.logo.image || !1, e
- }, m.setupStandaloneMode = function (t, e) {
- var n = {},
- r = {
- configar: {
- branding: {
- main: {
- label: "main",
- image: "space.png",
- url: "#",
- style: "",
- width: "202",
- height: "50",
- mime: "image/png",
- type: "png",
- handler: "newTab",
- blacklisted: !0
- },
- logo: {
- label: "logo",
- image: "space.png",
- url: "#",
- style: "",
- width: "202",
- height: "50",
- mime: "image/png",
- type: "png",
- handler: "newTab",
- blacklisted: !1
- },
- more_games: {
- label: "more_games",
- image: null,
- url: "#",
- style: "",
- width: null,
- height: null,
- mime: null,
- type: null,
- handler: "newTab",
- blacklisted: !1
- },
- splash_screen: {
- label: "splash_screen",
- image: "place_holder_string",
- url: "#",
- style: "",
- width: "0",
- height: "0",
- mime: "image/png",
- type: "png",
- handler: "newTab",
- blacklisted: !1
- }
- }
- }
- };
- n.JSLib = {
- memory: {},
- _channels: {},
- get: function (t) {
- return this.memory[t] ? this.memory[t] : !1
- },
- set: function (t, e) {
- return this.memory[t] = e, e
- },
- publish: function (t, e) {
- this._channels[t] && this._channels[t].forEach(function (t) {
- try {
- t.fn.call(this, e)
- } catch (n) { }
- })
- },
- subscribe: function (t, e) {
- if ("function" != typeof e) throw Error("Callback has to be a function");
- if ("string" != typeof t) throw Error("Channel name has to be a string");
- this._channels[t] || (this._channels[t] = []), this._channels[t].push({
- fn: e
- })
- }
- }, n.Net = {
- send: function (t, e) {
- e.call(this, {})
- }
- }, window.SpilGamesBootstrap = [], window.SpilGames = function () {
- var t = arguments;
- if (t[0] && "string" == typeof t[0]) n.JSLib.publish(t[0], t[1] || null);
- else if (t[0] && t[0] instanceof Array) {
- var e, r, i = [];
- for (e = 0, r = t[0].length; r > e; e++) i.push(n[t[0][e]]);
- t[1].apply(this, i)
- }
- }, t && t.id ? e.call(this, {
- branding: r.configar.branding
- }) : e.call(this, {
- branding: r.configar.branding
- })
- }, m.getCachedConfig = function () { }, e.prototype.newTab = function (t) {
- try { /*ih5game.more();*/ parent.moregame(); } catch (e) { }
- }, e.prototype.displayOnTop = function (t) {
- if (t === void 0 || t.url === void 0 || "string" != typeof t.url || t.action === void 0 || "function" != typeof t.action) return t.callback !== void 0 || "function" == typeof t.callback ? (t.callback(), void 0) : void 0;
- var e = document.createElement("div"),
- n = t.url,
- r = t.action,
- i = t.callback;
- return e.setAttribute("id", "spilgames-splash-screen-sample"), document.body.appendChild(e), e.style.left = "0", e.style.top = "0", e.style.width = "100%", e.style.height = "100%", e.style.position = "absolute", e.style.zIndex = "10000", e.onclick = r, n && (e.style.background = "url('" + n + "') center center no-repeat #FFF"), window.setTimeout(function () {
- var t = document.getElementById("spilgames-splash-screen-sample");
- t.parentNode.removeChild(t), i && i()
- }, 2e3), e
- }, n.prototype.get = function (t) {
- for (var e = this.dataStore, n = t.split("."), r = n.length, i = 0; r - 1 > i; i++) {
- if (!e[n[i]]) return null;
- e = e[n[i]]
- }
- return e[n[r - 1]] || null
- }, n.prototype.put = function (t, e) {
- for (var n = this.dataStore, r = t.split("."), i = r.length, o = 0; i - 1 > o; o++) {
- var a = r[o];
- n[a] || (n[a] = {}), n = n[a]
- }
- n[r[i - 1]] = e
- }, n.prototype.set = function (t, e) {
- this.put(t, e);
- var n = Date.parse(new Date);
- return this.notify({
- type: "new",
- key: t,
- current: e,
- previous: null,
- timestamp: n
- }), e
- }, n.prototype.update = function (t, e) {
- var n, r, i = null;
- return this.get(t) ? (n = "update", i = this.get(t)) : n = "new", this.put(t, e), r = Date.parse(new Date), this.notify({
- type: n,
- key: t,
- current: e,
- previous: i,
- timestamp: r
- }), e
- }, n.prototype.remove = function (t) {
- if (this.get(t)) {
- var e, n = this.get(t);
- return this.put(t, null), e = Date.parse(new Date), this.notify({
- type: "remove",
- key: t,
- current: null,
- previous: n,
- timestamp: e
- }), !0
- }
- return !1
- }, n.prototype._setCache = function (t) {
- this.dataStore = t
- }, n.prototype._getCache = function () {
- return this.dataStore
- }, n.prototype.notify = function (t) {
- if (this.IS_MASTER) {
- var e = new c({
- type: "datachange",
- callbackId: null,
- data: t
- }).encode();
- return window.postMessage(e, "*"), e
- }
- }, r.prototype._performAction = function (t) {
- var e = new c(t.data || {}),
- n = this.messenger,
- r = this.subscribers || {};
- if (e && e.type && e.data) switch (e.type) {
- case "gameEvent":
- e.data[0] && r[e.data[0]] && r[e.data[0]].length > 0 ? r[e.data[0]].forEach(function (t) {
- t.call(this), n._postMessage([e.data[0], {
- origin: "slave"
- },
- null
- ], null, "gameState")
- }) : e.data[0] && e.data[1] && "slave" === e.data[1].origin && "function" == typeof SWFtoJS && SWFtoJS({
- call: e.data[0],
- params: {}
- });
- break;
- case "gameState":
- e.data[0] && e.data[1] && "slave" === e.data[1].origin && (this.gameState = e.data[0])
- }
- }, r.prototype.on = function (t, e) {
- this.IS_SLAVE && (this.subscribers[t] || (this.subscribers[t] = []), this.subscribers[t].push(e))
- }, r.prototype.emit = function (t) {
- if (!this.IS_MASTER) throw Error("Only the master environment can emit game events");
- if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
- if (t === this.gameState) throw Error("The game is already in state: `" + t + "`");
- this.messenger._postMessage([t, {
- origin: "master"
- },
- null
- ], null, "gameEvent")
- }, i.prototype._setupMasterEvent = function () {
- this.IS_MASTER && this.messenger.subscribe("gameapi.score", this.submit, this)
- }, i.prototype.submit = function (t) {
- if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
- return this.IS_MASTER ? "function" == typeof SWFtoJS && SWFtoJS({
- call: "UPDATE_HIGHSCORE",
- params: {
- score: t
- }
- }) : (this.messenger._postMessage(t, void 0, "gameapi.score"), this.messenger._postMessage(["log.gameapi.score.submit", {
- origin: "slave",
- score: t
- },
- null
- ], null, "log")), {
- success: !0,
- value: t
- }
- }, o.prototype.init = function () {
- this._setupEvents()
- }, o.prototype._setupEvents = function () {
- var t = this.messenger;
- this.isMaster ? (SpilGames(["JSLib"], function (e) {
- e.subscribe("ad.request.accepted", function (e) {
- !0 === e && (SpilGames("game.ad.accepted", !0), t._postMessage(!0, void 0, "ad.request.accepted"))
- }), e.subscribe("ad.complete", function () {
- t._postMessage("", "", "ad.complete")
- })
- }), this.messenger.subscribe("game.ad.request", this._triggerAd, this)) : (this.messenger.subscribe("ad.request.accepted", this._onAdAccepted, this), this.messenger.subscribe("ad.complete", this._onAdCompleted, this))
- }, o.prototype._triggerAd = function () {
- SpilGames("game.ad.request")
- }, o.prototype._runCallback = function (t) {
- this._callbacks[t] && (this._callbacks[t](), this._callbacks[t] = !1)
- }, o.prototype.request = function (t, e) {
- var n = this;
- if ("function" != typeof t) throw Error("pauseGame argument should be a function");
- if ("function" != typeof e) throw Error("resumeGame argument should be a function");
- if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
- this._callbacks.pause = t, this._callbacks.resume = e, this.messenger._postMessage(void 0, void 0, "game.ad.request"), this.isMaster || this.messenger._postMessage(["log.gameapi.ad.requested", {
- origin: "slave"
- },
- null
- ], null, "log"), this.timeout = setTimeout(function () {
- n._requestTimeout()
- }, this.timeoutAfter)
- }, o.prototype._onAdAccepted = function (t) {
- var e = this.messenger;
- this.timeout && clearTimeout(this.timeout), !this.isMaster && t && (e._postMessage(["log.gameapi.ad.start", {
- origin: "slave"
- },
- null
- ], null, "log"), this._runCallback("pause"))
- }, o.prototype._onAdCompleted = function () {
- var t = this.messenger;
- this.isMaster || t._postMessage(["log.gameapi.ad.complete", {
- origin: "slave"
- },
- null
- ], null, "log"), this._runCallback("resume")
- }, o.prototype._requestTimeout = function () {
- this._onAdCompleted()
- }, a.prototype._setupEvents = function () {
- this.IS_MASTER && this.messenger.subscribe("gameapi.gameevent", this.emit, this)
- }, a.prototype._validateEvent = function (t) {
- var e = !1;
- return this.events[t] && this.events[t] !== void 0 && (e = !0), e
- }, a.prototype.emit = function (t, e) {
- if (!this.moduleReady) throw Error("This method cannot be called before the API is loaded");
- this._validateEvent(t) ? this.IS_MASTER ? "function" == typeof SWFtoJS && SWFtoJS({
- call: t
- }) : (this.messenger._postMessage(t, void 0, "gameapi.gameevent"), this.messenger._postMessage(["log.gameapi.gameevent.emit", {
- origin: "slave",
- evt: t
- },
- null
- ], null, "log")) : this.IS_MASTER || this.messenger._postMessage(["log.gameapi.gameevent.emit", {
- origin: "slave"
- },
- null
- ], null, "log")
- }, s.prototype.init = function (t) {
- t = t || {}, this.data = t.data || this.data;
- var e = this.data && this.data.game && this.data.game.applicationId ? this.data.game.applicationId : null,
- n = new Date,
- r = window.location.hostname;
- (this.IS_SLAVE || g.isWrapped()) && this.startInternalTracking(e, n, r)
- }, s.prototype._createEventObject = function (t, e, n) {
- return {
- eventCategory: t,
- eventAction: e,
- properties: n
- }
- }, s.prototype._sendSETEvent = function (t, e, n) {
- return this.messenger && (this.IS_SLAVE || g.isWrapped()) && this.messenger.post("tracker.event." + t, e, n), e
- }, s.prototype.trackGamePlay = function (t) {
- if (!this.gamePlayTracking.started) return !1;
- var e = this.gamePlayTracking.gid,
- n = this.gamePlayTracking.timestamp,
- r = this.gamePlayTracking.host,
- i = this._createEventObject("game", "gameplay", {
- applicationId: e,
- start: n,
- host: r
- });
- return this._sendSETEvent("express", i, t), i
- }, s.prototype.trackTimeInGame = function (t) {
- if (!this.timeInGameTracking.started) return !1;
- var e = this.timeInGameTracking.gid,
- n = this.timeInGameTracking.timestamp,
- r = this._createEventObject("game", "heartbeat", {
- applicationId: e,
- start: n
- });
- return this._sendSETEvent("express", r, t), r
- }, s.prototype.startInternalTracking = function (t, e, n) {
- var r = this,
- i = 6e4,
- o = function (t) {
- if (!t) throw "Could not save the time in game"
- };
- return this.moduleReady ? t ? (this.gamePlayTracking.gid = t, this.gamePlayTracking.timestamp = Date.parse(e), this.gamePlayTracking.host = n, this.gamePlayTracking.started = !0, this.timeInGameTracking.gid = t, this.timeInGameTracking.timestamp = Date.parse(e), this.timeInGameTracking.started = !0, this.trackGamePlay(function (t) {
- if (!t) throw "Could not save the game play"
- }), this.trackTimeInGame(o), setInterval(function () {
- r.trackTimeInGame(o)
- }, i), this.gamePlayTracking.started && this.timeInGameTracking.started) : {
- error: "No application ID defined for this game"
- } : {
- error: "This method cannot be called before the API is loaded"
- }
- }, u.prototype.init = function (t) {
- t = t || {}, this.data = t.data || this.data
- }, u.prototype.getLogo = function (t) {
- if (!this.moduleReady) return {
- error: "This method cannot be called before the API is loaded"
- };
- var e = this.IS_MASTER ? "master" : "slave";
- this.messenger._postMessage(["log.branding.getlogo", {
- origin: e
- },
- null
- ], null, "log");
- var n, r, i = {
- type: {
- type: "String",
- values: ["png"]
- },
- width: "Number",
- height: "Number"
- };
- return n = this._getLink("logo"), t && "object" == typeof t && (r = g.validateSchema(i, t), r.error && (n.error = r.error)), n
- }, u.prototype.getLink = function (t) {
- if (!t) return {
- error: "No link identifier provided"
- };
- var e = this.listLinks();
- if (-1 !== e.indexOf(t)) {
- var n = this.IS_MASTER ? "master" : "slave";
- return this.messenger._postMessage(["log.branding.getlink", {
- origin: n,
- linkName: t
- },
- null
- ], null, "log"), this._getLink(t)
- }
- return {
- error: "Invalid option: '" + t + "'",
- action: function () { }
- }
- }, u.prototype._getLink = function (t) {
- if (!t) return {
- error: "No link identifier provided"
- };
- var e = this.data && this.data.branding ? this.data.branding : {};
- return e && e[t] ? {
- linkName: t,
- image: e[t].image || !1,
- action: this._executeHandler.bind(this, t)
- } : {
- error: "Invalid option: '" + t + "'",
- action: function () { }
- }
- }, u.prototype._getGMLink = function (t) {
- var e = null;
- if (!t) return {
- error: "No link identifier provided"
- };
- var n = this.data && this.data.branding ? this.data.branding : {};
- return n && n[t] ? (e = this._tagUrl(n[t].url, t), {
- linkName: t,
- url: e
- }) : {
- error: "Invalid option: '" + t + "'",
- url: null
- }
- }, u.prototype.getLinks = function () {
- var t = {},
- e = this.listLinks();
- if (0 === e.length) t = {
- more_games: {
- action: function () { }
- }
- };
- else
- for (var n = 0; e.length > n; n++) {
- var r = e[n];
- t[r] = this._getLink(r)
- }
- return t
- }, u.prototype._executeHandler = function (t) {
- var e = this.data && this.data.branding ? this.data.branding : {},
- n = e[t],
- r = n.handler,
- i = this._tagUrl(n.url, t);
- if (n.url && n.url.length > 0 && r && this.components[r]) {
- var o = this.IS_MASTER ? "master" : "slave";
- return this.messenger._postMessage(["log.branding.linkAction", {
- origin: o,
- linkName: t
- },
- null
- ], null, "log"), this.components[r]({
- url: i
- })
- }
- return function () { }
- }, u.prototype.listLinks = function () {
- var t = [],
- e = this.data && this.data.branding ? this.data.branding : {},
- n = Object.keys(e);
- return t = n.filter(function (t) {
- return !e[t].blacklisted
- })
- }, u.prototype.getSplashScreen = function () {
- var t, e = this.IS_MASTER ? "master" : "slave";
- if (this.data && this.data.branding && this.data.branding.splash_screen) {
- var n = !0;
- this.data.branding.splash_screen.image || this.data.branding.splash_screen.url || (n = !1), t = {
- show: n,
- action: this._getLink("splash_screen").action || function () { }
- }
- } else t = {
- show: !0,
- action: function () { }
- };
- return this.messenger._postMessage(["log.branding.splashScreen", {
- origin: e
- },
- null
- ], null, "log"), t
- }, u.prototype.displaySplashScreen = function (t) {
- if ("function" != typeof t) throw Error("argument passed to displaySplashScreen method should be a function");
- var e = this.IS_MASTER ? "master" : "slave",
- n = this._getLink("logo").image;
- n && this.getSplashScreen().show ? ("master" !== e && this.messenger._postMessage(["log.branding.displaySplashScreen", {
- origin: e
- },
- null
- ], null, "log"), this.components.displayOnTop({
- url: n,
- action: this.getSplashScreen().action,
- callback: t
- })) : t()
- }, u.prototype._tagUrl = function (t, e) {
- var n, r, i, o = this.data && this.data.portal ? this.data.portal : {},
- a = this.data && this.data.game ? this.data.game : {},
- s = parseInt(o.siteId, 10);
- if ("string" != typeof t) throw Error("No url specified");
- return n = "string" == typeof e ? e : "logo", r = "brandedgames_" + (s > 0 && 500 > s ? "internal" : "external"), i = ["utm_medium=" + r, "utm_campaign=" + a.applicationId, "utm_source=" + o.host, "utm_content=" + n].join("&"), t += t.indexOf("?") > -1 ? "&" : "?", t + i
- }, c.prototype.encode = function () {
- var t = ["gameapi", this.type, this.callbackId, this.data ? JSON.stringify(this.data) : ""].join("|");
- return t
- }, l.prototype._postMessage = function (t, e, n) {
- var r, i;
- r = g.isArray(t) && "function" == typeof t[t.length - 1] ? this._callbacks.push(t.pop()) - 1 : e, i = new c({
- type: n || "jslib",
- callbackId: r,
- data: t
- }).encode(), this._target.postMessage(i, "*")
- }, l.prototype._callJSLib = function () {
- SpilGames.apply(SpilGames, g.argsToArray(arguments))
- }, l.prototype._setupEventListener = function () {
- window.addEventListener ? window.addEventListener("message", this._handleMessage.bind(this), !1) : window.attachEvent && window.attachEvent("onmessage", this._handleMessage.bind(this))
- }, l.prototype._handleMessage = function (t) {
- var e, n, r, i, o = this,
- a = new c(t.data);
- if (a)
- if (e = a.type, n = a.callbackId, r = a.data, i = this._callbacks[n] || !1, this.IS_MASTER) switch (e) {
- case "jslib":
- "Array" === r.constructor.name && r.push(function (t) {
- o._postMessage(t, n)
- }), this._callJSLib.apply(this, r);
- break;
- case "ugapi":
- this._handleUGARequest(t);
- break;
- case "datachange":
- this._postMessage(r, null, "datachange");
- break;
- default:
- this.publish(e, r)
- } else this.IS_SLAVE && ("function" == typeof i ? (delete this._callbacks[n], i(r)) : "datachange" === e || "jslib" !== e && this.publish(e, r));
- return !1
- }, l.prototype._handleUGARequest = function (t) {
- var e, n, r, i = this,
- o = new c(t.data);
- if (o) switch (e = o.data[0], n = o.callbackId, r = o.data[1] ? o.data[1] : null, e) {
- case "GameAPI.data":
- i._postMessage(this.dataStore._getCache(), n, "ugapi");
- break;
- case "GameAPI.isReady":
- i._postMessage({
- isready: this.api.isReady
- }, n, "ugapi")
- }
- }, l.prototype.post = function () {
- var t = g.argsToArray(arguments);
- return this.IS_SLAVE ? this._postMessage(t) : this._callJSLib.apply(this, t), this
- }, l.prototype.publish = function (t, e) {
- return this._channels[t] && this._channels[t].forEach(function (t) {
- try {
- t.fn.call(t.ctx, e)
- } catch (n) { }
- }), this
- }, l.prototype.subscribe = function (t, e, n) {
- if ("function" != typeof e) throw Error("Callback has to be a function");
- if ("string" != typeof t) throw Error("Channel name has to be a string");
- return this._channels[t] || (this._channels[t] = []), this._channels[t].push({
- fn: e,
- ctx: n
- }), this
- }, l.prototype.unsubscribe = function (t, e) {
- return this._channels[t] && "function" == typeof e && (this._channels[t] = this._channels[t].filter(function (t) {
- return t.fn !== e
- })), this
- }, l.prototype.subscribeOnce = function (t, e, n) {
- function r(n) {
- i.unsubscribe(t, r), e.call(this, n)
- }
- var i = this;
- return this.subscribe(t, r, n)
- }, l.prototype.requestFromParent = function (t, e, n) {
- if (!this.IS_SLAVE) throw "You are the parent, stop talking to yourself";
- e = e || {}, this._postMessage([t, e, n], null, "ugapi")
- }, d.prototype._setRole = function () {
- var t = g.getRole();
- this.IS_MASTER = t.IS_MASTER, this.IS_SLAVE = t.IS_SLAVE, this.IS_STANDALONE = t.IS_STANDALONE
- }, d.prototype._getTarget = function () {
- if (this.IS_STANDALONE) return window;
- var t = document.getElementById("iframegame"),
- e = t && t.contentWindow ? t.contentWindow : window.parent;
- return this.IS_MASTER ? e : window.parent
- }, d.prototype.loadAPI = function (t, e) {
- function r(e) {
- return c.IS_MASTER && (e = i(e)), c.isReady = !0, c.Branding.moduleReady = !0, c.__.EventTracking.moduleReady = !0, c.GameBreak.moduleReady = !0, c.Game.moduleReady = !0, c.Score.moduleReady = !0, c.GameEvent.moduleReady = !0, c.Branding.init({
- data: e
- }), c.__.EventTracking.init({
- data: e
- }), c.GameBreak.init(), c.__.messenger._postMessage(["log.gameapi.loadapi.finish", {
- origin: p,
- version: c.version
- },
- null
- ], null, "log"), t(c)
- }
- function i(t) {
- var e = t.game || {},
- n = t.user || {},
- r = t.portal || {},
- i = t.branding || {};
- return m.getLocalConfig({
- game: e,
- user: n,
- portal: r,
- branding: i
- })
- }
- function o() {
- c.__.messenger.requestFromParent("GameAPI.data", {}, function (t) {
- r(t)
- })
- }
- function a() {
- c.IS_STANDALONE = !0, c.IS_MASTER = !0, c.IS_SLAVE = !0, c.__.dataStore = new n({
- isMaster: !0
- }), e = e || null, m.setupStandaloneMode(e, function (t) {
- c.__.dataStore._setCache(i(t)), r(t)
- })
- }
- function s() {
- c.__.messenger.requestFromParent("GameAPI.isReady", {}, function (t) {
- u && clearTimeout(u), t.isready ? o() : 5 > l ? (l++, setTimeout(s, 500)) : o()
- })
- }
- var u, c = this,
- p = this.IS_MASTER ? "master" : "slave",
- l = 0;
- if ("function" != typeof t) throw Error("argument passed to loadAPI method should be a function");
- return !0 === this.isReady ? (window.console && window.console.log && console.log("WARNING: Detected multiple executions of GameAPI.loadAPI(). This method should only be executed once per page load!"), t(c)) : (this.__.messenger._postMessage(["log.gameapi.loadapi.start", {
- origin: p,
- version: c.version,
- spildata: e
- },
- null
- ], null, "log"), this.IS_STANDALONE ? a() : this.IS_MASTER ? m.getGameConfig().then(function (t) {
- m.getBrandingConfig(t).then(function (e) {
- t && !t.isError && (t.branding = e.branding, c.__.dataStore._setCache(i(t))), r(t)
- })
- }) : (u = setTimeout(a, 600), s()), void 0)
- };
- var y = new d(n, l, u, s, o);
- "function" == typeof define && define.amd && define("GameAPI", y), t.GameAPI = y
- })(window),
- function () {
- "use strict";
- function t(t) {
- t && (t.setTargetValueAtTime || (t.setTargetValueAtTime = t.setTargetAtTime))
- }
- window.hasOwnProperty("AudioContext") && (window.webkitAudioContext = AudioContext, AudioContext.prototype.hasOwnProperty("internal_createGain") || (AudioContext.prototype.internal_createGain = AudioContext.prototype.createGain, AudioContext.prototype.createGain = function () {
- var e = this.internal_createGain();
- return t(e.gain), e
- }), AudioContext.prototype.hasOwnProperty("internal_createDelay") || (AudioContext.prototype.internal_createDelay = AudioContext.prototype.createDelay, AudioContext.prototype.createDelay = function () {
- var e = this.internal_createDelay();
- return t(e.delayTime), e
- }), AudioContext.prototype.hasOwnProperty("internal_createBufferSource") || (AudioContext.prototype.internal_createBufferSource = AudioContext.prototype.createBufferSource, AudioContext.prototype.createBufferSource = function () {
- var e = this.internal_createBufferSource();
- return e.noteOn || (e.noteOn = e.start), e.noteGrainOn || (e.noteGrainOn = e.start), e.noteOff || (e.noteOff = e.stop), t(e.playbackRate), e
- }), AudioContext.prototype.hasOwnProperty("internal_createDynamicsCompressor") || (AudioContext.prototype.internal_createDynamicsCompressor = AudioContext.prototype.createDynamicsCompressor, AudioContext.prototype.createDynamicsCompressor = function () {
- var e = this.internal_createDynamicsCompressor();
- return t(e.threshold), t(e.knee), t(e.ratio), t(e.reduction), t(e.attack), t(e.release), e
- }), AudioContext.prototype.hasOwnProperty("internal_createBiquadFilter") || (AudioContext.prototype.internal_createBiquadFilter = AudioContext.prototype.createBiquadFilter, AudioContext.prototype.createBiquadFilter = function () {
- var e = this.internal_createBiquadFilter();
- t(e.frequency), t(e.detune), t(e.Q), t(e.gain);
- for (var n = ["LOWPASS", "HIGHPASS", "BANDPASS", "LOWSHELF", "HIGHSHELF", "PEAKING", "NOTCH", "ALLPASS"], r = 0; n.length > r; ++r) {
- var i = n[r],
- o = i.toLowerCase();
- e.hasOwnProperty(i) || (e[i] = o)
- }
- return e
- }), AudioContext.prototype.hasOwnProperty("internal_createOscillator") || AudioContext.prototype.hasOwnProperty("createOscillator") && (AudioContext.prototype.internal_createOscillator = AudioContext.prototype.createOscillator, AudioContext.prototype.createOscillator = function () {
- var e = this.internal_createOscillator();
- e.noteOn || (e.noteOn = e.start), e.noteOff || (e.noteOff = e.stop), t(e.frequency), t(e.detune);
- for (var n = ["SINE", "SQUARE", "SAWTOOTH", "TRIANGLE", "CUSTOM"], r = 0; n.length > r; ++r) {
- var i = n[r],
- o = i.toLowerCase();
- e.hasOwnProperty(i) || (e[i] = o)
- }
- return e.hasOwnProperty("setWaveTable") || (e.setWaveTable = e.setPeriodicTable), e
- }), AudioContext.prototype.hasOwnProperty("internal_createPanner") || (AudioContext.prototype.internal_createPanner = AudioContext.prototype.createPanner, AudioContext.prototype.createPanner = function () {
- var t = this.internal_createPanner(),
- e = {
- EQUALPOWER: "equalpower",
- HRTF: "HRTF",
- LINEAR_DISTANCE: "linear",
- INVERSE_DISTANCE: "inverse",
- EXPONENTIAL_DISTANCE: "exponential"
- };
- for (var n in e) {
- var r = e[n];
- t.hasOwnProperty(n) || (t[n] = r)
- }
- return t
- }), AudioContext.prototype.hasOwnProperty("createGainNode") || (AudioContext.prototype.createGainNode = AudioContext.prototype.createGain), AudioContext.prototype.hasOwnProperty("createDelayNode") || (AudioContext.prototype.createDelayNode = AudioContext.prototype.createDelay), AudioContext.prototype.hasOwnProperty("createJavaScriptNode") || (AudioContext.prototype.createJavaScriptNode = AudioContext.prototype.createScriptProcessor), AudioContext.prototype.hasOwnProperty("createWaveTable") || (AudioContext.prototype.createWaveTable = AudioContext.prototype.createPeriodicWave))
- }(window);
|