Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Kongregate = Kongregate || {};
- Kongregate.Utils = Kongregate.Utils || {};
- Kongregate.Utils.catchErrors = function(a, c) {
- return function() {
- try {
- return a.apply(c, arguments)
- } catch (b) {
- Kongregate.Log.error("catchErrors caught unhandled exception", b)
- }
- }
- };
- (function() {
- function a(a, b, e) {
- Kongregate.Log[a] = function() {
- try {
- "undefined" !== typeof active_user && void 0 === Kongregate.Log.debugLevel && (Kongregate.Log.debugLevel = active_user.debugLevel()), Kongregate.Log.debugLevel >= b && (console[e] ? Function.prototype.apply.call(console[e], console, arguments) : console.log(arguments))
- } catch (a) {}
- }
- }
- Kongregate.Log = {};
- a("spam", 5, "log");
- a("debug", 4, "log");
- a("info", 3, "info");
- a("warn", 2, "warn");
- a("error", 1, "error")
- })();
- KonduitEvent = {
- INIT: "init",
- CONNECT: "connect",
- CONNECTED: "connected",
- DISCONNECT: "disconnect",
- LOGIN: "login",
- SWITCH_USER: "switch_user",
- JOIN_ROOM: "join_room",
- LEAVE_ROOM: "leave_room",
- USER_JOIN: "user_join",
- USER_DEPARTURE: "user_departure",
- USER_CHANGED: "user_changed",
- ROOM_MESSAGE: "room_message",
- SYSTEM_MESSAGE: "system_message",
- PRIVATE_MESSAGE: "private_message",
- ADMIN_MESSAGE: "admin_message",
- MESSAGE_ERROR: "message_error",
- SET_PRESENCE: "set_presence",
- GUEST_COUNT: "guest_count",
- ROOM_NOT_FOUND: "room_not_found",
- ROOM_FULL: "room_full",
- REQUEST_CHAT_ROOM: "request_chat_room",
- CREATE_PRIVATE_ROOM: "create_private_room",
- DESTROY_PRIVATE_ROOM: "destroy_private_room",
- PRIVATE_ROOM_INVITATION: "private_room_invitation",
- PRIVATE_ROOM_KICK: "private_room_kick",
- PRIVATE_ROOM_INVITATION_SENT: "private_room_invitation_sent",
- JOIN_GUILD_ROOM: "join_guild_room",
- SILENCED: "silenced",
- PARTICIPATE: "participate",
- AMNESTY: "amnesty",
- API_INITIALIZED: "api_initialized",
- ADD_STATISTICS: "add_statistics",
- STATISTIC_UPDATED: "statistic_updated",
- STATISTIC_SUBMISSION: "statistic_submission",
- STATISTICS_FLUSH: "statistics_flush",
- SET_ACCOMPLISHMENT_PROGRESS: "set_accomplishment_progress",
- NEW_HIGH_SCORE: "new_high_score",
- DISPLAY_SHOUT_BOX: "display_shout_box",
- DISPLAY_INVITATION_BOX: "display_invitation_box",
- SEND_PRIVATE_MESSAGE: "send_private_message",
- DISPLAY_FEED_POST_BOX: "display_feed_post_box",
- DISPLAY_SIGN_IN_LIGHTBOX: "display_sign_in_lightbox",
- DISPLAY_REGISTRATION_LIGHTBOX: "display_registration_lightbox",
- RESIZE_GAME: "resize_game",
- HANDLE_ITEM_CHECKOUT_REQUEST: "handle_item_checkout_request",
- KONDUIT_MESSAGE: "konduit_message",
- ANALYTICS_PAYLOAD: "analytics_payload",
- OP_EXTERNAL_MESSAGE: "ext.msg",
- OP_CONNECTED: "connected",
- OP_HELLO: "hello",
- OP_USER_INFO: "user.info",
- OP_SIGN_IN: "sign_in",
- PARAM_USER: "user",
- PARAM_USER_ID: "user_id",
- PARAM_GAME_AUTH_TOKEN: "auth_token",
- PURCHASE_RESULT: "purchase_result",
- CUSTOM_TAB_MESSAGE: "custom_tab_message",
- CUSTOM_TAB_SHOW: "custom_tab_show",
- CUSTOM_TAB_CLOSE: "custom_tab_close",
- CUSTOM_TAB_SHOWN: "custom_tab_shown",
- CUSTOM_TAB_CLEAR_MESSAGES: "custom_tab_clear_messages",
- OP_CHAT_TAB: "chat.tab",
- OP_CHAT_CLEAR_DIALOG: "chat.dlg.clear",
- OP_CHAT_DISPLAY: "chat.disp",
- OP_CHAT_MSG: "chat.msg",
- OP_CHAT_CANVAS_ELEMENT: "chat.elm",
- OP_CHAT_PRIVATE_MESSAGE: "chat.privateMessage",
- OP_CHAT_RESIZE_GAME: "chat.resizeGame",
- OP_CHAT_DISPLAY_INVITATION_BOX: "chat.invite",
- OP_CHAT_DISPLAY_FEED_POST_BOX: "chat.feedpost",
- OP_CHAT_DISPLAY_REGISTRATION: "chat.registration",
- OP_CHAT_DISPLAY_SHOUT_BOX: "chat.shoutbox",
- PARAM_SHOUT_MESSAGE: "shout_message",
- PARAM_CANVAS_SIZE: "chat.canvas.size",
- PARAM_RESIZE_GAME_WIDTH: "chat.resizeGame.width",
- PARAM_RESIZE_GAME_HEIGHT: "chat.resizeGame.height",
- PARAM_INVITATION_MESSAGE: "invitation_message",
- PARAM_FRIEND_FILTER: "filter",
- PARAM_IMAGE_URI: "image_uri",
- PARAM_KV_PARAMS: "kv_params",
- PARAM_NAME: "name",
- PARAM_DESCRIPTION: "desc",
- PARAM_DATA: "data",
- OP_SHOUT_CALLBACK: "ext.shout_callback",
- PARAM_MESSAGE_TYPE: "ext.message_type",
- PARAM_MESSAGE_RECIPIENTS: "ext.message_recipients",
- PARAM_ERROR: "error",
- PARAM_SUCCESS: "success",
- PARAM_REQUEST_ID: "req.id",
- OP_STATS_SUBMIT: "stat.submit",
- ITEM_LIST: "mtx.item_list",
- ITEM_CHECKOUT: "mtx.checkout",
- PURCHASE_KREDS: "mtx.kred_purchase",
- ITEM_INSTANCES: "mtx.item_instances",
- USE_ITEM_INSTANCE: "mtx.use_item_instance",
- PARAM_PURCHASE_METHOD: "purchase_method",
- PARAM_ITEM_TAGS: "item_tags",
- PARAM_ITEMS: "items",
- PARAM_ORDER_INFO: "order_info",
- PARAM_ID: "id",
- ADS_INITIALIZE: "ads.initialize",
- ADS_AVAILABLE: "ads.available",
- ADS_UNAVAILABLE: "ads.unavailable",
- ADS_SHOW_INCENTIVIZED: "ads.show_incentivized",
- AD_OPENED: "ads.ad_opened",
- AD_COMPLETED: "ads.ad_completed",
- AD_ABANDONED: "ads.ad_abandoned",
- PROCESSING_SAVE_SHARED_CONTENT: "processing_save_shared_content",
- SAVE_SHARED_CONTENT: "save_shared_content",
- SAVE_SHARED_CONTENT_COMPLETE: "shared_content_save_complete",
- LOAD_SHARED_CONTENT: "load_shared_content",
- BROWSE_SHARED_CONTENT: "browse_shared_content",
- OP_SAVE_SHARED_CONTENT: "save_shared_content",
- OP_BROWSE_SHARED_CONTENT: "browse_shared_content",
- OP_LOAD_SHARED_CONTENT: "load_shared_content",
- OP_SHARED_CONTENT_SAVE_COMPLETE: "shared_content_save_complete",
- PARAM_CONTENT_TYPE: "content_type",
- PARAM_LABEL: "label",
- PARAM_IMAGE: "image",
- OP_IMAGE_AVATAR_SUBMIT: "avatar.submit",
- OP_IMAGE_AVATAR_FINISHED: "avatar.finished",
- IMAGE_AVATAR_SUBMIT: "image_avatar_submit",
- IMAGE_AVATAR_COMPLETE: "image_avatar_complete",
- OP_ANALYTICS_PAYLOAD: "analytics.payload",
- HOLODECK_DATA: "holodeck_data",
- PARAM_HOLODECK_TYPE: "holodeck_type",
- FETCH_HISTORY: "fetch_history",
- HISTORY_RECEIVED: "history_received",
- FAYE_DISCONNECT: "faye_disconnect"
- };
- KonduitChatErrorMessage = {
- MESSAGE_TOO_LONG: "error_msg_too_long",
- RATE_LIMITED: "error_msg_rate_limit"
- };
- KonduitPresenceType = {
- CHAT: "chat",
- AWAY: "away"
- };
- function FABridge(a, c) {
- this.target = a;
- this.remoteTypeCache = {};
- this.remoteInstanceCache = {};
- this.remoteFunctionCache = {};
- this.localFunctionCache = {};
- this.bridgeID = FABridge.nextBridgeID++;
- this.name = c;
- this.nextLocalFuncID = 0;
- FABridge.instances[this.name] = this;
- FABridge.idMap[this.bridgeID] = this;
- return this
- }
- FABridge.TYPE_ASINSTANCE = 1;
- FABridge.TYPE_ASFUNCTION = 2;
- FABridge.TYPE_JSFUNCTION = 3;
- FABridge.TYPE_ANONYMOUS = 4;
- FABridge.initCallbacks = {};
- FABridge.userTypes = {};
- FABridge.addToUserTypes = function() {
- for (var a = 0; a < arguments.length; a++) FABridge.userTypes[arguments[a]] = {
- typeName: arguments[a],
- enriched: !1
- }
- };
- FABridge.argsToArray = function(a) {
- for (var c = [], b = 0; b < a.length; b++) c[b] = a[b];
- return c
- };
- FABridge.isArray = function(a) {
- return !!a && (a instanceof Array || "[object Array]" === Object.prototype.toString.call(a))
- };
- FABridge.isASProxy = function(a) {
- return !!a && (a instanceof ASProxy || !!a.bridgeName && !!a.typeName && "ASProxy" === a.className)
- };
- function instanceFactory(a) {
- this.fb_instance_id = a;
- return this
- }
- function FABridge__invokeJSFunction(a) {
- var c = a[0];
- a = a.concat();
- a.shift();
- return FABridge.extractBridgeFromID(c).invokeLocalFunction(c, a)
- }
- FABridge.addInitializationCallback = function(a, c) {
- var b = FABridge.instances[a];
- void 0 != b ? c.call(b) : (b = FABridge.initCallbacks[a], null == b && (FABridge.initCallbacks[a] = b = []), b.push(c))
- };
- function FABridge__bridgeInitialized(a) {
- var c = document.getElementsByTagName("object"),
- b = c.length,
- e = [];
- if (0 < b)
- for (var d = 0; d < b; d++) "undefined" != typeof c[d].SetVariable && (e[e.length] = c[d]);
- b = document.getElementsByTagName("embed");
- d = b.length;
- c = [];
- if (0 < d)
- for (var k = 0; k < d; k++) "undefined" != typeof b[k].SetVariable && (c[c.length] = b[k]);
- k = e.length;
- b = c.length;
- d = "bridgeName=" + a;
- if (1 == k && !b || 1 == k && 1 == b) FABridge.attachBridge(e[0], a);
- else if (1 == b && !k) FABridge.attachBridge(c[0], a);
- else {
- var g = !1;
- if (1 < k)
- for (var f = 0; f <
- k; f++) {
- for (var n = e[f].childNodes, v = 0; v < n.length; v++) {
- var l = n[v];
- if (1 == l.nodeType && "param" == l.tagName.toLowerCase() && "flashvars" == l.name.toLowerCase() && 0 <= l.value.indexOf(d)) {
- FABridge.attachBridge(e[f], a);
- g = !0;
- break
- }
- }
- if (g) break
- }
- if (!g && 1 < b)
- for (e = 0; e < b; e++)
- if (0 <= c[e].attributes.getNamedItem("flashVars").nodeValue.indexOf(d)) {
- FABridge.attachBridge(c[e], a);
- break
- }
- }
- return !0
- }
- FABridge.nextBridgeID = 0;
- FABridge.instances = {};
- FABridge.idMap = {};
- FABridge.refCount = 0;
- FABridge.extractBridgeFromID = function(a) {
- return FABridge.idMap[a >> 16]
- };
- FABridge.attachBridge = function(a, c) {
- var b = new FABridge(a, c);
- FABridge[c] = b;
- var e = FABridge.initCallbacks[c];
- if (null != e) {
- for (var d = 0; d < e.length; d++) e[d].call(b);
- delete FABridge.initCallbacks[c]
- }
- };
- FABridge.blockedMethods = {
- toString: !0,
- get: !0,
- set: !0,
- call: !0
- };
- FABridge.prototype = {
- root: function() {
- return this.deserialize(this.target.getRoot())
- },
- releaseASObjects: function() {
- return this.target.releaseASObjects()
- },
- releaseNamedASObject: function(a) {
- return "object" != typeof a ? !1 : this.target.releaseNamedASObject(a.fb_instance_id)
- },
- create: function(a) {
- return this.deserialize(this.target.create(a))
- },
- makeID: function(a) {
- return (this.bridgeID << 16) + a
- },
- getPropertyFromAS: function(a, c) {
- if (0 < FABridge.refCount) throw Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.");
- FABridge.refCount++;
- retVal = this.target.getPropFromAS(a, c);
- retVal = this.handleError(retVal);
- FABridge.refCount--;
- return retVal
- },
- setPropertyInAS: function(a, c, b) {
- if (0 < FABridge.refCount) throw Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.");
- FABridge.refCount++;
- retVal = this.target.setPropInAS(a, c, this.serialize(b));
- retVal = this.handleError(retVal);
- FABridge.refCount--;
- return retVal
- },
- callASFunction: function(a,
- c) {
- if (0 < FABridge.refCount) throw Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.");
- FABridge.refCount++;
- retVal = this.target.invokeASFunction(a, this.serialize(c));
- retVal = this.handleError(retVal);
- FABridge.refCount--;
- return retVal
- },
- callASMethod: function(a, c, b) {
- if (0 < FABridge.refCount) throw Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.");
- FABridge.refCount++;
- b = this.encodeJSON(this.serialize(b));
- retVal = this.target.invokeASMethod(a, c, b);
- retVal = this.handleError(retVal);
- FABridge.refCount--;
- return retVal
- },
- invokeLocalFunction: function(a, c) {
- var b, e = this.localFunctionCache[a];
- void 0 != e && (b = this.serialize(e.apply(null, this.deserialize(c))));
- return b
- },
- getTypeFromName: function(a) {
- return this.remoteTypeCache[a]
- },
- createProxy: function(a, c) {
- var b = this.getTypeFromName(c);
- instanceFactory.prototype = b;
- b = new instanceFactory(a);
- return this.remoteInstanceCache[a] =
- b
- },
- getProxy: function(a) {
- return this.remoteInstanceCache[a]
- },
- addTypeDataToCache: function(a) {
- newType = new ASProxy(this, a.name);
- for (var c = a.accessors, b = 0; b < c.length; b++) this.addPropertyToType(newType, c[b]);
- a = a.methods;
- for (b = 0; b < a.length; b++) void 0 == FABridge.blockedMethods[a[b]] && this.addMethodToType(newType, a[b]);
- return this.remoteTypeCache[newType.typeName] = newType
- },
- addPropertyToType: function(a, c) {
- var b = c.charAt(0),
- e;
- "a" <= b && "z" >= b ? (e = "get" + b.toUpperCase() + c.substr(1), b = "set" + b.toUpperCase() + c.substr(1)) :
- (e = "get" + c, b = "set" + c);
- a[b] = function(a) {
- this.bridge.setPropertyInAS(this.fb_instance_id, c, a)
- };
- a[e] = function() {
- return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id, c))
- }
- },
- addMethodToType: function(a, c) {
- a[c] = function() {
- return this.bridge.deserialize(this.bridge.callASMethod(this.fb_instance_id, c, FABridge.argsToArray(arguments)))
- }
- },
- getFunctionProxy: function(a) {
- var c = this;
- null == this.remoteFunctionCache[a] && (this.remoteFunctionCache[a] = function() {
- c.callASFunction(a, FABridge.argsToArray(arguments))
- });
- return this.remoteFunctionCache[a]
- },
- getFunctionID: function(a) {
- void 0 == a.__bridge_id__ && (a.__bridge_id__ = this.makeID(this.nextLocalFuncID++), this.localFunctionCache[a.__bridge_id__] = a);
- return a.__bridge_id__
- },
- serialize: function(a) {
- var c = {},
- b = typeof a;
- if ("number" == b || "string" == b || "boolean" == b || null == b || "undefined" == b) c = a;
- else if (FABridge.isArray(a)) {
- c = [];
- for (b = 0; b < a.length; b++) c[b] = this.serialize(a[b])
- } else "function" == b ? (c.type = FABridge.TYPE_JSFUNCTION, c.value = this.getFunctionID(a)) : FABridge.isASProxy(a) ?
- (c.type = FABridge.TYPE_ASINSTANCE, c.value = a.fb_instance_id) : (c.type = FABridge.TYPE_ANONYMOUS, c.value = a);
- return c
- },
- deserialize: function(a) {
- var c, b = typeof a;
- if ("number" == b || "string" == b || "boolean" == b || null == a || void 0 == a) c = this.handleError(a);
- else if (FABridge.isArray(a)) {
- c = [];
- for (b = 0; b < a.length; b++) c[b] = this.deserialize(a[b])
- } else if ("object" == b) {
- for (b = 0; b < a.newTypes.length; b++) this.addTypeDataToCache(a.newTypes[b]);
- for (var e in a.newRefs) this.createProxy(e, a.newRefs[e]);
- a.type == FABridge.TYPE_PRIMITIVE ?
- c = a.value : a.type == FABridge.TYPE_ASFUNCTION ? c = this.getFunctionProxy(a.value) : a.type == FABridge.TYPE_ASINSTANCE ? c = this.getProxy(a.value) : a.type == FABridge.TYPE_ANONYMOUS && (c = a.value)
- }
- return c
- },
- encodeJSON: function(a) {
- var c, b, e, d = "";
- switch (typeof a) {
- case "object":
- if (a) {
- if (FABridge.isArray(a)) {
- for (b = 0; b < a.length; ++b) c = this.encodeJSON(a[b]), d && (d += ","), d += c;
- return "[" + d + "]"
- }
- if ("undefined" != typeof a.toString) {
- for (b in a) c = a[b], "undefined" != typeof c && "function" != typeof c && (c = this.encodeJSON(c), d && (d += ","), d +=
- this.encodeJSON(b) + ":" + c);
- return "{" + d + "}"
- }
- }
- return "null";
- case "number":
- return isFinite(a) ? "" + a : "null";
- case "string":
- e = a.length;
- d = '"';
- for (b = 0; b < e; b += 1)
- if (c = a.charAt(b), " " <= c) {
- if ("\\" == c || '"' == c) d += "\\";
- d += c
- } else switch (c) {
- case "\b":
- d += "\\b";
- break;
- case "\f":
- d += "\\f";
- break;
- case "\n":
- d += "\\n";
- break;
- case "\r":
- d += "\\r";
- break;
- case "\t":
- d += "\\t";
- break;
- default:
- c = c.charCodeAt(), d += "\\u00" + Math.floor(c / 16).toString(16) + (c % 16).toString(16)
- }
- return d + '"';
- case "boolean":
- return "" + a;
- default:
- return "null"
- }
- },
- addRef: function(a) {
- this.target.incRef(a.fb_instance_id)
- },
- release: function(a) {
- this.target.releaseRef(a.fb_instance_id)
- },
- handleError: function(a) {
- if ("string" == typeof a && 0 == a.indexOf("__FLASHERROR")) throw a = a.split("||"), 0 < FABridge.refCount && FABridge.refCount--, Error(a[1]);
- return a
- }
- };
- ASProxy = function(a, c) {
- this.bridge = a;
- this.typeName = c;
- this.className = "ASProxy";
- return this
- };
- ASProxy.prototype = {
- get: function(a) {
- return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id, a))
- },
- set: function(a, c) {
- this.bridge.setPropertyInAS(this.fb_instance_id, a, c)
- },
- call: function(a, c) {
- this.bridge.callASMethod(this.fb_instance_id, a, c)
- },
- addRef: function() {
- this.bridge.addRef(this)
- },
- release: function() {
- this.bridge.release(this)
- }
- };
- (function() {
- var a;
- Kongregate.MessageConnection = function(a) {
- this.initialize(a)
- };
- Kongregate.MessageConnection.MESSAGE_EVENT = "kongregate:api:message";
- Kongregate.MessageConnection.prototype = {
- initialize: function(c) {
- a = c.channel_id;
- this._window = c.window || window;
- this._targetOrigin = c.target_origin;
- this._targetWindows = c.target_window ? [c.target_window] : [];
- this._retryConnection = c.retry_connection || !1;
- this._messageListeners = [];
- this._supportsObjects = this.detectObjectSupport();
- this._client = "string" === typeof this._targetOrigin;
- this._connected = this._handleMessages = !1
- },
- addMessageListener: function(a) {
- this._messageListeners.push(a)
- },
- isSupported: function() {
- return !this.supportsObjects() && "undefined" === typeof this._window.JSON ? !1 : "undefined" !== typeof(this._targetWindows[0] || window).postMessage
- },
- connected: function() {
- return this._connected
- },
- isClient: function() {
- return this._client
- },
- supportsObjects: function() {
- return this._supportsObjects
- },
- logPrefix: function() {
- return this._client ? "[Game]" : "[Konduit]"
- },
- detectObjectSupport: function() {
- var a =
- document.createElement("iframe"),
- b = !0;
- a.src = "about:blank";
- document.body.appendChild(a);
- try {
- a.contentWindow.postMessage({
- toString: function() {
- b = !1;
- return ""
- }
- }, "*")
- } catch (e) {}
- document.body.removeChild(a);
- return b
- },
- listen: function() {
- if (this.isSupported() && !this._listening) {
- this._listening = !0;
- var a = this,
- b = function(b) {
- a.onMessageReceived.call(a, b)
- };
- this._window.addEventListener ? this._window.addEventListener("message", b, !1) : this._window.attachEvent && this._window.attachEvent("onmessage", b)
- }
- },
- parseMessage: function(a) {
- var b;
- try {
- if ("string" === typeof a && "{" === a[0] ? b = JSON.parse(a) : "object" === typeof a && (b = a), b && b.kongregate_type === Kongregate.MessageConnection.MESSAGE_EVENT) return {
- opcode: b.opcode,
- params: b.params
- }
- } catch (e) {
- Kongregate.Log.warn(this.logPrefix(), "Error parsing message", a, e)
- }
- return null
- },
- onMessageReceived: function(a) {
- var b = a.origin || a.originalEvent.origin;
- this._targetOrigin && b !== this._targetOrigin ? Kongregate.Log.debug(this.logPrefix(), "Ignoring message from " + b) : (b = this.parseMessage(a.data)) && this.processMessage(b,
- a)
- },
- processMessage: function(a, b) {
- Kongregate.Log.debug(this.logPrefix(), "Message received:", a);
- switch (a.opcode) {
- case KonduitEvent.CONNECT:
- this.onClientConnected(a.params, b.source);
- break;
- case KonduitEvent.CONNECTED:
- this.onConnectedToServer()
- }
- for (var e = 0; e < this._messageListeners.length; e++) this._messageListeners[e](a.opcode, a.params)
- },
- sendMessage: function(a, b) {
- this.removeMissingWindows();
- if (!this.connected() && a !== KonduitEvent.CONNECT && a !== KonduitEvent.CONNECTED) Kongregate.Log.debug(this.logPrefix(),
- "Not sending " + a + ", not connected");
- else {
- var e = {
- kongregate_type: Kongregate.MessageConnection.MESSAGE_EVENT,
- opcode: a,
- params: "string" === typeof b ? JSON.parse(b) : b
- };
- this.supportsObjects() || (e = JSON.stringify(e));
- for (var d = this._targetOrigin || "*", k = 0; k < this._targetWindows.length; k++) this._targetWindows[k].postMessage(e, d)
- }
- },
- connect: function() {
- this.connected() || (this.listen(), Kongregate.Log.debug("Attempting to connect to Kongregate API"), this.sendMessage(KonduitEvent.CONNECT, {
- chnl: a
- }), this._retryConnection &&
- this.retryConnection())
- },
- retryConnection: function() {
- var a = this;
- setTimeout(function() {
- a.connect()
- }, 5E3)
- },
- onClientConnected: function(c, b) {
- c.chnl !== a ? Kongregate.Log.warn(this.logPrefix(), "Channel ID mismatch, ignoring connect") : (Kongregate.Log.debug(this.logPrefix(), "API connection established!"), this.acceptClientConnection(b))
- },
- onConnectedToServer: function() {
- this.connected() || (Kongregate.Log.debug(this.logPrefix(), "API connection established!"), this._connected = !0)
- },
- acceptClientConnection: function(a) {
- for (var b =
- this._targetWindows, e = 0; e < this._targetWindows.length; e++)
- if (this._targetWindows[e] === a) {
- Kongregate.Log.debug("Not adding duplicate connection");
- return
- }
- this._targetWindows = [a];
- this.sendMessage(KonduitEvent.CONNECTED, {});
- this._targetWindows = b;
- this._targetWindows.push(a);
- this.removeMissingWindows()
- },
- removeMissingWindows: function(a) {
- if (!this._client) {
- for (i = this._targetWindows.length - 1; 0 <= i; i--) this._targetWindows[i].top || this._targetWindows.splice(i, 1);
- this._connected = 0 < this._targetWindows.length
- }
- }
- }
- })();
- (function() {
- Kongregate.AnalyticsServices = function(a) {
- this.initialize(a)
- };
- Kongregate.AnalyticsServices.prototype = {
- initialize: function(a) {
- var b = this;
- this._heartbeatInterval = a.heartbeat_interval || 15E3;
- this._services = a.services;
- this._legacyAnalytics = a.legacy_analytics;
- this._swrveClient = a.swrve_client;
- this._mtx = a.mtx;
- this._kongVars = a.kongregate_variables;
- this._staticVars = {};
- this._persistentStore = {};
- this._heartbeatCount = 0;
- this._enablePersistence = a.enable_persistence;
- this._services.addEventListener(KonduitEvent.KONDUIT_MESSAGE,
- function(a) {
- b._onIncomingMessage(a.opcode, a.params)
- });
- a.start && this._setup()
- },
- addEvent: function(a, b) {
- this._enabled && (!this._autoAnalyticsDisabled() && 0 <= ja.indexOf(a) ? Kongregate.Log.warn("Ignoring analytics event: " + a + " since it is a kong-automatic event.") : this._addEventInternal(a, this._objectify(b)))
- },
- addFilterType: function(a) {
- if (this._enabled && a) {
- var b = /^[a-zA-Z0-9_]+$/;
- !a || !b.test(a) ? Kongregate.Log.warn("Invalid filterType: " + a + ", must be alpha_numeric") : (b = (b = this._savedData[s]) ? b.split(",") : [], 0 > b.indexOf(a) && (b.push(a), b.sort(), this._savedData[s] = b.join(","), this._flushPersistentStore(), Kongregate.Log.info("Filter type added: " + a)))
- }
- },
- setCommonPropsCallback: function(a) {
- this._enabled && (this._commonPropsCallback = a, this.updateCommonProperties())
- },
- setCommonProperties: function(a) {
- a = this._objectify(a);
- this.setCommonPropsCallback(function() {
- return a
- })
- },
- updateCommonProperties: function() {
- try {
- "function" === typeof this._commonPropsCallback && (this._commonProperties = this._objectify(this._commonPropsCallback()),
- this._savedData[ka] = this._commonProperties, this._commonProperties[S] && !this._savedData[x] && (this._savedData[x] = this._commonProperties[S]))
- } catch (a) {
- Kongregate.Log.error("Error updating common properties: " + a)
- }
- },
- getAutoLongProperty: function(a) {
- return this.getAutoIntProperty(a)
- },
- getAutoLongLongProperty: function(a) {
- return this.getAutoLongProperty(a)
- },
- getAutoStringProperty: function(a) {
- if (!this._enabled) return null;
- var b = this._getKongAutomaticVariables();
- if ("string" === typeof b[a]) return b[a];
- Kongregate.Log.warn("Property is not a string: " +
- a);
- return null
- },
- getAutoBoolProperty: function(a) {
- return !this._enabled ? !1 : !!this._getKongAutomaticVariables()[a]
- },
- getAutoDoubleProperty: function(a) {
- if (!this._enabled) return NaN;
- var b = this._getKongAutomaticVariables();
- return Number(b[a])
- },
- getAutoIntProperty: function(a) {
- return !this._enabled ? NaN : Math.floor(this.getAutoDoubleProperty(a))
- },
- getAutoUTCProperty: function(a) {
- return this.getAutoStringProperty(a)
- },
- getAutoPropertiesJSON: function() {
- if (!this._enabled) return "{}";
- this._buildKongAutomaticVariables();
- return "function" === typeof JSON.stringify ? JSON.stringify(this._automaticVars) : "{}"
- },
- startPurchase: function(a, b) {
- if (!this._autoAnalyticsDisabled()) {
- var c = this._getProductId(a);
- c ? (this._priceUSD = this._getUSDPrice(c, b), this._iapID && Kongregate.Log.warn("startPurchase: invoked before active transaction finished. iap_ids may mismatch."), Kongregate.Log.debug("IAP FLOW STEP: startPurchase(): " + c), this._iapID = this._uuid(), this._productId = c, this._addIAPEvent(null, this._objectify(b), I)) : Kongregate.Log.warn("startPurchase: Can't start purchase with null productId, param was: " +
- a)
- }
- },
- finishPurchase: function(a, b, c) {
- this._autoAnalyticsDisabled() || (Kongregate.Log.debug("IAP FLOW STEP: finishPurchase(): " + this._productId + ", transactionId: " + b + ", resultCode: " + a), la === a ? (this._numPurchases++, this._totalSpentUSD += this._priceUSD, this._addIAPEvent(b, this._objectify(c), J)) : this._addIAPFailEvent(b, this._objectify(c)))
- },
- setAutomaticVariablesListener: function(a) {
- this._enabled && (this._automaticVarsListener = a, this._getKongAutomaticVariables())
- },
- start: function() {},
- _setup: function() {
- if (!this._savedData) {
- Kongregate.Log.debug("Initializing Analytics API");
- var b = this._services.isKongregate();
- this._mode = b ? this._kongVars.kongregate_analytics_mode : null;
- if (this._enabled = null !== this._mode) {
- this._enablePersistence && this._hasLocalStorage() && this._loadPersistentStore();
- this._clientVersion = b ? this._kongVars.kongregate_game_version : "1";
- this._pendingEvents = this._persistentStore.pending_events || [];
- this._persistentStore.event_queues = this._persistentStore.event_queues || {
- swrve: []
- };
- this._eventQueue = this._persistentStore.event_queues.swrve;
- this._savedData = this._persistentStore.saved_data =
- this._persistentStore.saved_data || {};
- this._items = this._persistentStore.items || [];
- this._savedData.common_properties || (this._savedData.common_properties = {});
- this._commonProperties = this._savedData.common_properties;
- this._bundleId = this._savedData[g];
- this._autoAnalyticsDisabled() ? Kongregate.Log.debug("Auto analytics disabled") : this._autoAnalyticsExcludesServer() ? Kongregate.Log.debug("Game has a server, only tracking a subset of analytics automatically") : Kongregate.Log.debug("Automatic analytics enabled");
- b && this._requestItems();
- var b = this._getDate(),
- c = !this._savedData[t];
- this._setInitialSavedData(t, this._toW3CDTF(b));
- this._setInitialSavedData(E, a);
- this._setInitialSavedData(y, this._clientVersion);
- this._setInitialSavedData(B, this._timeZoneOffset());
- c && (Kongregate.Log.debug("Analytics: First play"), this._installEvent());
- this._startSession();
- this._buildKongStaticVars()
- } else Kongregate.Log.debug("Analytics API not enabled")
- }
- },
- _enqueueEvent: function(a, b) {
- if (!this._initialized) {
- if (!this._autoAnalyticsDisabled() ||
- !b[K]) Kongregate.Log.debug("Queueing pending event: " + a), this._pendingEvents.push({
- name: a,
- event: b
- });
- return !0
- }
- return !1
- },
- _addEventInternal: function(a, b, c) {
- var h = 0 === a.indexOf("swrve.");
- !h && !b[T] && (b = this._merge(this._buildEventSpecificVariables(), b));
- if (!this._enqueueEvent(a, b) && this._enabled) {
- U === a && this._refreshPlayerInfoFields(b);
- var m = this._getKongAutomaticVariables(),
- e = {};
- h ? e = b : (this._merge(e, this._objectify(this._commonProperties)), b[K] ? (this._merge(e, m), this._merge(e, b)) : (this._merge(e, b), this._merge(e,
- m)));
- Kongregate.SwrveClient.SWRVE_SESSION_START_IDENTIFIER === a && (c = !0);
- Kongregate.Log.debug("Adding event: " + a + ", flush=" + c);
- this._eventQueue.push({
- name: a,
- event: e
- });
- this._flushQueue();
- c && this._flushPersistentStore()
- }
- },
- _flushQueue: function() {
- if (this._swrveClient) {
- var a = this;
- this._eventQueue.length && !this._submitLock && (Kongregate.Log.debug("Flushing swrve event queue"), this._submitLock = !0, this._swrveClient.sendEvents(this._eventQueue, function(b) {
- a._submitLock = !1;
- a._flushPersistentStore();
- a._flushQueueDelayed(b.success ?
- 1E3 : 1E4)
- }))
- }
- },
- _flushQueueDelayed: function(a) {
- var b = this;
- setTimeout(function() {
- b._flushQueue()
- }, a)
- },
- _persistentStoreName: function() {
- return Kongregate.AnalyticsServices.persistentStoreName(this._kongVars.kongregate_game_id)
- },
- _getLegacyPersistentStore: function() {
- if (this._legacyAnalytics) try {
- var a = this._legacyAnalytics.getPersistentDataJSON();
- if (a) return Kongregate.Log.debug("Importing legacy persistent store"), a
- } catch (b) {
- Kongregate.Log.warn("Error importing persistent store: " + b)
- }
- return null
- },
- _loadPersistentStore: function() {
- var a;
- try {
- var b = localStorage.getItem(this._persistentStoreName()) || this._getLegacyPersistentStore(!0) || "{}";
- a = JSON.parse(b)
- } catch (c) {
- Kongregate.Log.warn("Error loading persistent store: " + c)
- }
- this._persistentStore = a || {}
- },
- _flushPersistentStore: function() {
- try {
- var a = JSON.stringify(this._persistentStore);
- localStorage.setItem(this._persistentStoreName(), a)
- } catch (b) {
- Kongregate.Log.warn("Error flushing persistent store: " + b)
- }
- },
- _destroyPersistentStore: function() {
- localStorage.removeItem(this._persistentStoreName())
- },
- _buildEventSpecificVariables: function() {
- var a = {};
- a[T] = 0;
- if (this._autoAnalyticsDisabled()) return a;
- a[h] = this._uuid();
- a[u] = this._toW3CDTF(this._getDate());
- a[ma] = this._timeZoneOffset();
- return a
- },
- _refreshPlayerInfoFields: function(a) {
- a[L] = this._savedData[L];
- a[M] = this._savedData[M];
- for (var b = 0; b < V.length; b++) {
- var c = V[b];
- a[c] ? this._savedData[c] = a[c] : a[c] = this._savedData[c] ? this._savedData[c] : null
- }
- },
- _addAutoEvent: function(a, b) {
- this._autoAnalyticsDisabled() || (b = this._objectify(b), b[K] = !0, this._addEventInternal(a,
- b))
- },
- _addIAPEvent: function(a, b, c) {
- var h = {};
- this._merge(h, this._objectify(b));
- h[N] = this._priceUSD;
- h[na] = this._productId;
- h[W] = this._iapID;
- I != c && (h[X] = a || Y);
- this._services.isKongregate() ? (h[O] = this._getKredPrice(this._productId), h[P] = "KRED") : (h[O] = b[O] || this._priceUSD, h[P] = b[P] || "USD");
- J === c && (this._sendSwrveIAPEvent(this._productId, this._priceUSD, b), this._productId = this._iapID = null, this._priceUSD = 0);
- this._addEventInternal(c, h)
- },
- _addIAPFailEvent: function(a, b) {
- var c = {};
- this._merge(c, this._objectify(b));
- c[oa] = "SKErrorPaymentCancelled";
- c[X] = a || Y;
- c[W] = this._iapID;
- this._productId = this._iapID = null;
- this._priceUSD = 0;
- this._addEventInternal(Z, c)
- },
- _sendSwrveUserEvent: function() {
- if (!this._autoAnalyticsDisabled()) {
- for (var a = this._getKongAutomaticVariables(), b = {}, c = 0; c < aa.length; c++) {
- var h = aa[c];
- b["kong." + h] = a[h]
- }
- this._addAutoEvent(Kongregate.SwrveClient.SWRVE_USER_IDENTIFIER, b)
- }
- },
- _sendSwrveIAPEvent: function(a, b, c) {
- b = {
- product_id: a,
- quantity: 1,
- local_cost: b,
- local_currency: "USD",
- app_store: "unknown_store"
- };
- var h = {};
- h[a] = {
- type: "item",
- amount: 1
- };
- c.soft_currency_change && (h.soft_currency_change = {
- type: "currency",
- amount: c.soft_currency_change
- });
- c.hard_currency_change && (h.hard_currency_change = {
- type: "currency",
- amount: c.hard_currency_change
- });
- c.type && (h[c.type] = {
- type: "item",
- amount: 1
- });
- b.rewards = h;
- this.addEvent(Kongregate.SwrveClient.SWRVE_IAP_IDENTIFIER, b)
- },
- _onIncomingMessage: function(a, b) {
- a === KonduitEvent.OP_ANALYTICS_PAYLOAD && this._processAnalyticsPayload(b.data.info, b.data.payload)
- },
- _setInitialSavedData: function(a,
- b) {
- this._savedData[a] || (this._savedData[a] = b)
- },
- _autoAnalyticsDisabled: function() {
- return !this._enabled || this._mode === b
- },
- _autoAnalyticsAllEnabled: function() {
- return this._enabled && this._mode === e
- },
- _autoAnalyticsExcludesServer: function() {
- return this._enabled && this._mode === d
- },
- _getProductId: function(a) {
- try {
- if ("string" === typeof a) return a;
- if (Number(parseFloat(a)) == a) return a.toString();
- if ("[object Array]" === Object.prototype.toString.call(a)) {
- if (0 < a.length) return this._getProductId(a[0])
- } else if ("string" ===
- typeof a.identifier) return a.identifier
- } catch (b) {
- Kongregate.Log.error("Error calculating product ID:", b)
- }
- Kongregate.Log.warn("Couldn't get product ID from: " + a + ", type=" + typeof a);
- return null
- },
- _getUSDPrice: function(a, b) {
- if (this._services.isKongregate()) {
- var c = this._getKredPrice(a);
- if (0 !== c) return Math.floor(100 * c * this._kredExchangeRate) / 100
- } else if (b && b[N]) return b[N];
- if ((c = a.match(/^.*t([0-9][0-9])_.*$/)) && 2 === c.length)
- if (c = parseInt(c[1], 10), 0 < c && c <= ba.length) return ba[c - 1];
- Kongregate.Log.warn("Couldn't calculate USD price for identifier: " +
- a);
- return 0
- },
- _getKredPrice: function(a) {
- for (var b = 0; b < this._items.length; b++) {
- var c = this._items[b];
- if (a === c.identifier) return c.price
- }
- Kongregate.Log.warn("Couldn't get kred price for identifier: " + a);
- return 0
- },
- _requestItems: function(a) {
- a = a || 0;
- if (5 < a) Kongregate.Log.error("Giving up on retrieving item list");
- else {
- var b = this;
- this._mtx.requestItemList(null, function(c) {
- c.success ? b._items = b._persistentStore.items = c.data : b._retryRequestItems(a + 1)
- })
- }
- },
- _retryRequestItems: function(a) {
- var b = this;
- Kongregate.Log.warn("Retrying item list request, retry #" +
- a);
- setTimeout(function() {
- b.requestItems(a)
- }, 15E3 * a)
- },
- _processAnalyticsPayload: function(a, b) {
- Kongregate.Log.info("Analytics payload received");
- if (this._enabled)
- if (this._checkBrowserSupport(b)) {
- this._config = a;
- var c = this._config.swrve;
- this._svid = b.site_visitor_uid;
- b.kger && (this._kredExchangeRate = b.kger);
- this._updateKongStaticVars(b);
- this._initialized || (this._initialized = !0, !this._swrveClient && (c && c.application_id && c.key) && (Kongregate.Log.debug("Swrve initialized"), this._swrveClient = new Kongregate.SwrveClient({
- application_id: c.application_id,
- api_key: c.key,
- player_id: this._services.isKongregate() ? this._svid : this._savedData[Q],
- client_version: this._clientVersion
- })), this._swrveClient ? (this._submitLock = !1, this._startHeartbeatTimer(), this._flushPendingEvents(), this._sendSwrveUserEvent(), this.addEvent(U, {}), this._flushQueue()) : (Kongregate.Log.debug("Analytics not initialized, no services configured"), this._enabled = !1))
- } else this._enabled = !1
- },
- _checkBrowserSupport: function(a) {
- try {
- if ("safari" === a.browser.browser.toLowerCase()) Kongregate.Log.warn("Analytics disabled on Safari");
- else {
- if (window.XMLHttpRequest && "withCredentials" in new XMLHttpRequest) return !0;
- Kongregate.Log.warn("Analytics disabled due to lack of XHR/CORS support")
- }
- } catch (b) {
- Kongregate.Log.warn("Error while checking browser support: " + b)
- }
- return !1
- },
- _hasLocalStorage: function() {
- try {
- var a = "kong-" + this._getDate().getTime();
- localStorage.setItem(a, a);
- localStorage.removeItem(a);
- return !0
- } catch (b) {
- return !1
- }
- },
- _startHeartbeatTimer: function() {
- if (this._heartbeatInterval) {
- var a = this;
- setInterval(function() {
- a._onHeartbeatInterval()
- },
- this._heartbeatInterval)
- }
- },
- _onHeartbeatInterval: function() {
- this._heartbeatCount += 1;
- this._session.active = this._getDate().getTime();
- 4 == this._heartbeatCount && (this._heartbeatCount = 0, this.addEvent(pa, {}))
- },
- _flushPendingEvents: function() {
- if (0 < this._pendingEvents.length) {
- Kongregate.Log.debug("Flushing " + this._pendingEvents.length + " pending event(s)");
- for (var a = 0; a < this._pendingEvents.length; a++) {
- var b = this._pendingEvents[a];
- this._addEventInternal(b.name, b.event, !1)
- }
- this._pendingEvents.length = 0
- }
- },
- _buildKongStaticVars: function() {
- if (!this._autoAnalyticsDisabled()) {
- var b =
- this._services.isKongregate();
- this._staticVars[g] = this._bundleId;
- this._staticVars[ca] = this._services.getUsername();
- this._staticVars[qa] = this._services.getUserId();
- this._staticVars[ra] = b ? this._svid : "";
- this._staticVars[z] = this._session.id;
- this._staticVars[sa] = a;
- this._staticVars[G] = this._numSessions();
- this._staticVars[q] = this._clientVersion;
- this._staticVars[r] = this._clientVersion;
- this._staticVars[y] = this._savedData[y];
- this._staticVars[x] = this._savedData[x] || null;
- this._staticVars[ta] = "kongregate_web";
- this._autoAnalyticsExcludesServer() || (this._staticVars[Q] = b ? this._svid : this._savedData[Q]);
- this._staticVars[m] = "browser";
- this._staticVars[ua] = null;
- this._staticVars[t] = this._savedData[t];
- this._staticVars[E] = this._savedData[E];
- this._staticVars[B] = this._savedData[B];
- this._staticVars[va] = this._kongVars.kongregate_language || (window.navigator.userLanguage || window.navigator.language).split("-")[0];
- this._staticVars[da] = null;
- this._staticVars[ea] = null;
- this._staticVars[wa] = null;
- this._staticVars[xa] = null;
- this._staticVars[k] = !1;
- this._staticVars[w] = "wifi";
- this._staticVars[v] = null;
- this._staticVars[H] = null;
- this._staticVars[R] = null;
- this._staticVars[ya] = !0;
- this._staticVars[za] = "web"
- }
- },
- _buildKongAutomaticVariables: function() {
- if (this._autoAnalyticsDisabled()) this._automaticVars = {};
- else {
- var a = {};
- a[s] = this._savedData[s] || "";
- a[Aa] = this._numPurchases;
- a[A] = this._daysRetained();
- this._autoAnalyticsExcludesServer() || (a[fa] = this._totalSpentUSD);
- this._automaticVars = this._merge(a, this._staticVars)
- }
- },
- _updateKongStaticVars: function(a) {
- if (!this._autoAnalyticsDisabled()) {
- this._bundleId =
- "com.kongregate.web." + a.game_permalink;
- this._services.isExternal() && (this._bundleId += ".external");
- this._savedData[g] = this._bundleId;
- this._buildKongStaticVars();
- var b = this._parseOS(a.browser.os);
- this._staticVars[l] = b.type;
- this._staticVars[D] = b.version;
- this._staticVars[Ba] = a.premium;
- this._staticVars[p] = a.powerup_rewards_tier;
- this._savedData[L] = a.pur_link_date || null;
- this._savedData[M] = a.join_date || null;
- this._staticVars[Ca] = Number(a.spent_on_kreds);
- this._totalSpentUSD = a.spent_usd;
- this._numPurchases = a.num_purchases;
- this._staticVars[f] = a.browser.browser;
- this._staticVars[n] = a.browser.version;
- this._staticVars[Da] = a.ip_address;
- this._staticVars[F] = a.ip_address;
- b = this._getDate();
- b = Math.abs(b.getTime() - this._parseW3CDTF(a.server_time, b).getTime()) / 1E3;
- this._staticVars[Ea] = Math.floor(b);
- this._savedData[Fa] = a.server_time;
- this._staticVars[C] = a.country_code;
- this._getKongAutomaticVariables()
- }
- },
- _getKongAutomaticVariables: function() {
- if (!this._enabled) return {};
- this.updateCommonProperties();
- this._buildKongAutomaticVariables();
- this._automaticVarsListener && this._automaticVarsListener(this._automaticVars);
- return this._automaticVars
- },
- _startSession: function() {
- var a = this._getDate(),
- b = (this._previousSession = this._savedData.current_session) ? (a.getTime() - this._previousSession.active) / 1E3 : 0,
- h = this._previousSession ? (a.getTime() - this._previousSession.start) / 1E3 : 0;
- b > c ? (Kongregate.Log.debug("Terminating previous session (" + this._previousSession.id + "), inactiveFor=" + b + ", length=" + h), b = {}, b[z] = this._previousSession.id, b[G] = this._numSessions(),
- b[Ga] = this._toW3CDTF(this._previousSession.active), b[Ha] = h, b[Ia] = !1, this._addAutoEvent(ga, b)) : this._previousSession && (this._session = this._previousSession, Kongregate.Log.debug("Reopening previous session (" + this._previousSession.id + "), inactiveFor=" + b + ", length=" + h));
- this._session || (this._session = {
- id: this._uuid(),
- start: a.getTime(),
- active: a.getTime()
- }, this._savedData.current_session = this._session, a = this._savedData[G] ? this._numSessions() + 1 : 1, this._savedData[G] = a, Kongregate.Log.debug("Created new session: " +
- this._session.id));
- this._session != this._previousSession && (this.addEvent(Kongregate.SwrveClient.SWRVE_SESSION_START_IDENTIFIER, {}), a = {}, a[Ja] = !1, this._addAutoEvent(ha, a))
- },
- _installEvent: function() {
- if (this._autoAnalyticsAllEnabled()) {
- var a = {};
- a[Ka] = null;
- a[La] = null;
- a[Ma] = null;
- a[Na] = null;
- a[Oa] = null;
- a[Pa] = null;
- this._addAutoEvent(ia, a)
- } else Kongregate.Log.debug("Not firing installs event since analytics mode is not all")
- },
- _parseOS: function(a) {
- var b = "Unknown",
- c = "Unknown";
- try {
- var h = a.split(" ");
- if (2 > h.length) throw Error("Not enough segments in OS string");
- b = h.shift();
- "OS" === b && (b = "MacOS", h.shift());
- c = h.join(" ")
- } catch (m) {
- Kongregate.Log.error("Error parsing OS version (" + a + "): " + m.toString())
- }
- return {
- type: b,
- version: c
- }
- },
- _numSessions: function() {
- return this._savedData[G] || 1
- },
- _timeZoneOffset: function() {
- return this._getDate().getTimezoneOffset() / -60
- },
- _daysRetained: function() {
- var a = this._getDate(),
- b = this._timeZoneOffset(),
- c = this._staticVars[t];
- c && (a = this._parseW3CDTF(c, null), null === a && (Kongregate.Log.warn("Failed to parse first play date: " + c + ", resetting"),
- a = this._getDate(), this._savedData[t] = this._toW3CDTF(a), this._flushPersistentStore()));
- this._staticVars[B] && (b = this._staticVars[B]);
- return this._daysSince(a, b)
- },
- _dayOfEra: function(a, b) {
- return Math.floor((a + 3600 * b) / 86400)
- },
- _daysSince: function(a, b) {
- var c = Math.floor(this._getDate() / 1E3),
- h = Math.floor(a.getTime() / 1E3);
- return this._dayOfEra(c, this._timeZoneOffset()) - this._dayOfEra(h, b)
- },
- _objectify: function(a) {
- if ("string" === typeof a) {
- if (0 === a.length || "function" !== typeof JSON.parse) return {};
- try {
- return JSON.parse(a) || {}
- } catch (b) {
- return Kongregate.Log.warn("Failed to parse JSON: " + a + ", error: " + b), {}
- }
- }
- return a
- },
- _toW3CDTF: function(a) {
- return Kongregate.Utils.toW3CDTF(a)
- },
- _parseW3CDTF: function(a, b) {
- return Kongregate.Utils.parseW3CDTF(a, b)
- },
- _uuid: function() {
- var a = this._getDate().getTime();
- window.performance && "function" === typeof window.performance.now && (a += performance.now());
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(b) {
- var c = (a + 16 * Math.random()) % 16 | 0;
- a = Math.floor(a / 16);
- return ("x" == b ? c : c &
- 3 | 8).toString(16)
- })
- },
- _merge: function(a, b) {
- return Kongregate.Utils.merge(a, b)
- },
- _getDate: function() {
- return new Date
- }
- };
- var a = "2.0.0",
- c = 300,
- b = "none",
- e = "all",
- d = "cloud",
- k = "ad_tracking",
- g = "bundle_id",
- f = "browser",
- n = "browser_version",
- v = "carrier",
- l = "client_os_type",
- D = "client_os_version",
- q = "client_version",
- C = "country_code",
- w = "data_connection_type",
- A = "days_retained",
- r = "dev_client_version",
- h = "device_event_id",
- m = "device_type",
- u = "event_time",
- F = "external_ip_address",
- s = "filter_type",
- y = "first_client_version",
- B = "first_play_time_offset",
- t = "first_play_time",
- E = "first_sdk_version",
- x = "first_server_version",
- H = "gamecenter_id",
- R = "gamecenter_alias",
- p = "pur_tier",
- da = "idfa",
- ea = "idfv",
- xa = "imei",
- wa = "android_id",
- Da = "ip_address",
- ya = "is_valid",
- qa = "kong_user_id",
- ca = "kong_username",
- Ba = "kong_plus",
- va = "lang_code",
- Fa = "last_skew_refresh_time",
- Aa = "num_purchases",
- G = "num_sessions",
- ua = "mac_address",
- Q = "player_id",
- sa = "sdk_version",
- S = "server_version",
- z = "session_id",
- Ea = "time_skew",
- fa = "total_spent_in_usd",
- ma = "event_time_offset",
- ra = "site_visitor_id",
- Ca = "usd_spent_on_kreds",
- ta = "platform",
- za = "pkg_src",
- T = "retry_count",
- K = "auto_event",
- ha = "session_starts",
- Ja = "is_from_background",
- ga = "session_ends",
- Ha = "session_length_seconds",
- Ga = "session_end_time",
- Ia = "did_crash",
- ia = "installs",
- Ka = "stub_field",
- La = "utm_source",
- Ma = "utm_medium",
- Na = "utm_term",
- Oa = "utm_content",
- Pa = "utm_campaign",
- I = "iap_attempts",
- J = "iap_transactions",
- Z = "iap_fails",
- N = "usd_cost",
- na = "product_id",
- W = "iap_id",
- oa = "fail_reason",
- X = "receipt_id",
- P = "local_currency_type",
- O = "local_currency_cost",
- la = "SUCCESS",
- Y = "none",
- U = "player_info",
- M = "kong_join_date",
- L = "pur_link_date",
- ja = [ia, ha, ga, "foreground_visits", "background_visits", I, Z, J, "invalid_states"],
- V = ["twitter_id", "fb_user_id", "fb_username", "fb_email", "email"],
- aa = [fa, t, G, A, m, l, D, C, ca, z, da, ea, q],
- pa = "swrve.heartbeat",
- ba = [0.99, 1.99, 2.99, 3.99, 4.99, 5.99, 6.99, 7.99, 8.99, 9.99, 10.99, 11.99, 12.99, 13.99, 14.99, 15.99, 16.99, 17.99, 18.99, 19.99, 20.99, 21.99, 22.99, 23.99, 24.99, 25.99, 26.99, 27.99, 28.99, 29.99, 30.99, 31.99, 32.99, 33.99, 34.99, 35.99, 36.99, 37.99, 38.99, 39.99, 40.99, 41.99, 42.99, 43.99, 44.99, 45.99,
- 46.99, 47.99, 48.99, 49.99, 54.99, 59.99, 64.99, 69.99, 74.99, 79.99, 84.99, 89.99, 94.99, 99.99, 109.99, 119.99, 124.99, 129.99, 139.99, 149.99, 159.99, 169.99, 174.99, 179.99, 189.99, 199.99, 209.99, 219.99, 229.99, 239.99, 249.99, 299.99, 349.99, 399.99, 449.99, 499.99, 599.99, 699.99, 799.99, 899.99, 999.99
- ],
- ka = "common_properties";
- Kongregate.AnalyticsServices.KONG_ANALYTICS_EVENT_TIME = u;
- Kongregate.AnalyticsServices.persistentStoreName = function(a) {
- return "kong-game-analytics-" + a
- }
- })();
- Kongregate.ApiServices = function(a) {
- this.initialize(a)
- };
- Kongregate.ApiServices.prototype = {
- initialize: function(a) {
- this._kongVars = a.kongregate_variables || {};
- this._messageConnection = a.message_connection;
- this._eventListeners = {};
- this._requestHandlers = {};
- this._messageQueue = [];
- this._requestId = 0;
- this._initializeKongVars(this._kongVars);
- this.initializeEventListeners()
- },
- initializeEventListeners: function() {
- var a = this;
- this._messageConnection.addMessageListener(function(c, b) {
- a._onIncomingMessage(c, b)
- })
- },
- _initializeKongVars: function(a) {
- a = a || {};
- this._kongregate = "true" ===
- String(a.kongregate);
- this._username = a.kongregate_username || "Guest";
- this._authToken = a.kongregate_game_auth_token;
- this._userId = parseInt(a.kongregate_user_id, 10) || 0;
- this._gameId = parseInt(a.kongregate_game_id, 10) || 0
- },
- addEventListener: function(a, c) {
- this._eventListeners[a] || (this._eventListeners[a] = []);
- this._eventListeners[a].push(c)
- },
- _dispatchEvent: function(a, c) {
- for (var b = this._eventListeners[a] || [], e = 0; e < b.length; e++) b[e](c || {})
- },
- connect: function() {},
- connectExternal: function() {
- Kongregate.Log.warn("The Kongregate externally hosted API is not available")
- },
- isExternal: function() {
- return !this.isKongregate()
- },
- isKongregate: function() {
- return this._kongregate
- },
- getUsername: function() {
- return this._username
- },
- getGameAuthToken: function() {
- return this._authToken
- },
- getUserId: function() {
- return this._userId
- },
- getUserID: function() {
- return this.getUserId()
- },
- getGameId: function() {
- return this._gameId
- },
- getGameID: function() {
- return this.getGameId()
- },
- isGuest: function() {
- return 0 === this.getUserId()
- },
- isConnected: function() {
- return this._messageConnection.connected() && !this._messageQueue
- },
- sendMessage: function(a) {
- this.isConnected() ? this._messageConnection.sendMessage(a.opcode, a.params) : (Kongregate.Log.debug("Queueing message " + a.opcode + " since API is not yet connected!"), this._messageQueue.push(a))
- },
- _flushMessageQueue: function() {
- if (this._messageQueue) {
- var a = this._messageQueue;
- this._messageQueue = null;
- Kongregate.Log.debug("Flushing message queue", a);
- for (var c = 0; c < a.length; c++) this.sendMessage(a[c])
- }
- },
- _onIncomingMessage: function(a, c) {
- switch (a) {
- case KonduitEvent.OP_CONNECTED:
- this.sendMessage({
- opcode: KonduitEvent.OP_HELLO,
- params: {}
- });
- this._flushMessageQueue();
- break;
- case KonduitEvent.OP_EXTERNAL_MESSAGE:
- this._onIncomingMessage(c.opcode, c.data);
- break;
- case KonduitEvent.OP_SHOUT_CALLBACK:
- this._onShoutResponse(c);
- break;
- case KonduitEvent.OP_USER_INFO:
- this._onUserInfo(c)
- }
- this._dispatchEvent(KonduitEvent.KONDUIT_MESSAGE, {
- opcode: a,
- params: c
- })
- },
- _onShoutResponse: function(a) {
- this._completeRequest(a, {
- type: a[KonduitEvent.PARAM_MESSAGE_TYPE],
- recipients: a[KonduitEvent.PARAM_MESSAGE_RECIPIENTS],
- success: a.success,
- error: a.error
- })
- },
- _onUserInfo: function(a) {
- var c =
- a[KonduitEvent.PARAM_USER_ID];
- if (0 !== c) {
- var b = this.isGuest();
- this._username = a[KonduitEvent.PARAM_USER];
- this._authToken = a[KonduitEvent.PARAM_GAME_AUTH_TOKEN];
- this._userId = c;
- b && this._dispatchEvent(KonduitEvent.LOGIN)
- }
- },
- privateMessage: function(a, c) {
- if (this._ensureKongregate(c)) {
- var b = {
- shout_message: ("string" === typeof a ? a : a.content) || ""
- };
- this._enqueueRequest(b, c);
- this.sendMessage({
- opcode: KonduitEvent.OP_CHAT_PRIVATE_MESSAGE,
- params: b
- })
- }
- },
- resizeGame: function(a, c) {
- if (this._ensureKongregate()) {
- var b = {};
- b[KonduitEvent.PARAM_RESIZE_GAME_WIDTH] =
- a;
- b[KonduitEvent.PARAM_RESIZE_GAME_HEIGHT] = c;
- this.sendMessage({
- opcode: KonduitEvent.OP_CHAT_RESIZE_GAME,
- params: b
- })
- }
- },
- showInvitationBox: function(a, c) {
- if (this._ensureKongregate()) {
- var b = {};
- a = "string" === typeof a ? {
- content: a
- } : a;
- b[KonduitEvent.PARAM_INVITATION_MESSAGE] = a.content || "";
- b[KonduitEvent.PARAM_FRIEND_FILTER] = a.filter || "";
- b[KonduitEvent.PARAM_KV_PARAMS] = a.kv_params || {};
- this._enqueueRequest(b, c);
- this.sendMessage({
- opcode: KonduitEvent.OP_CHAT_DISPLAY_INVITATION_BOX,
- params: b
- })
- }
- },
- showFeedPostBox: function(a,
- c) {
- if (this._ensureKongregate()) {
- var b = {};
- a = "string" === typeof a ? {
- content: a
- } : a;
- b[KonduitEvent.PARAM_SHOUT_MESSAGE] = a.content || "";
- b[KonduitEvent.PARAM_KV_PARAMS] = a.kv_params || {};
- a.image_uri && (b[KonduitEvent.PARAM_IMAGE_URI] = a.image_uri);
- this._enqueueRequest(b, c);
- this.sendMessage({
- opcode: KonduitEvent.OP_CHAT_DISPLAY_FEED_POST_BOX,
- params: b
- })
- }
- },
- showSignInBox: function() {
- this.showRegistrationBox()
- },
- showRegistrationBox: function() {
- this._ensureKongregate() && this.isGuest() && this.sendMessage({
- opcode: KonduitEvent.OP_CHAT_DISPLAY_REGISTRATION,
- params: {}
- })
- },
- showShoutBox: function(a, c) {
- if (this._ensureKongregate()) {
- var b = {};
- b[KonduitEvent.PARAM_SHOUT_MESSAGE] = ("string" === typeof a ? a : a.content) || "";
- this._enqueueRequest(b, c);
- this.sendMessage({
- opcode: KonduitEvent.OP_CHAT_DISPLAY_SHOUT_BOX,
- params: b
- })
- }
- },
- _ensureKongregate: function(a) {
- return !this.isKongregate() ? (a && a({
- success: !1
- }), !1) : !0
- },
- _enqueueRequest: function(a, c) {
- var b = this._nextRequestId();
- a[KonduitEvent.PARAM_REQUEST_ID] = b;
- "function" === typeof c && (this._requestHandlers[b] = c)
- },
- _completeRequest: function(a,
- c) {
- var b = a[KonduitEvent.PARAM_REQUEST_ID],
- e = this._requestHandlers[b];
- "function" === typeof e && (e(c || a), delete this._requestHandlers[b])
- },
- _nextRequestId: function() {
- return this._requestId += 1
- }
- };
- Kongregate.ChatServices = function(a) {
- this.initialize(a)
- };
- Kongregate.ChatServices.DEFAULT_TAB = "Default";
- Kongregate.ChatServices.prototype = {
- initialize: function(a) {
- var c = this;
- this._services = a.services;
- this._eventCallbacks = [];
- this._services.addEventListener(KonduitEvent.KONDUIT_MESSAGE, function(a) {
- c._onIncomingMessage(a.opcode, a.params)
- })
- },
- showTab: function(a, c, b) {
- var e = {};
- e[KonduitEvent.PARAM_NAME] = a;
- e[KonduitEvent.PARAM_DESCRIPTION] = c;
- b && b.size && (e[KonduitEvent.PARAM_CANVAS_SIZE] = b.size);
- this._services.sendMessage({
- opcode: KonduitEvent.OP_CHAT_TAB,
- params: e
- })
- },
- closeTab: function() {
- this.showTab(Kongregate.ChatServices.DEFAULT_TAB)
- },
- displayMessage: function(a, c) {
- var b = {};
- b[KonduitEvent.PARAM_DATA] = a;
- b[KonduitEvent.PARAM_USER] = c;
- this._services.sendMessage({
- opcode: KonduitEvent.OP_CHAT_DISPLAY,
- params: b
- })
- },
- clearMessages: function() {
- this._services.sendMessage({
- opcode: KonduitEvent.OP_CHAT_CLEAR_DIALOG
- })
- },
- displayCanvasImage: function(a, c, b) {
- var e = {};
- e[KonduitEvent.PARAM_DATA] = {
- type: "image",
- name: a,
- url: c,
- position: b
- };
- this._services.sendMessage({
- opcode: KonduitEvent.OP_CHAT_CANVAS_ELEMENT,
- params: e
- })
- },
- displayCanvasText: function(a, c, b, e) {
- var d = {};
- d[KonduitEvent.PARAM_DATA] = {
- type: "text",
- name: a,
- text: c,
- position: b,
- options: e
- };
- this._services.sendMessage({
- opcode: KonduitEvent.OP_CHAT_CANVAS_ELEMENT,
- params: d
- })
- },
- drawCanvasObject: function(a, c) {
- var b = {};
- b[KonduitEvent.PARAM_DATA] = {
- type: "draw",
- name: a,
- commands: c
- };
- this._services.sendMessage({
- opcode: KonduitEvent.OP_CHAT_CANVAS_ELEMENT,
- params: b
- })
- },
- removeCanvasObject: function(a) {
- var c = {};
- c[KonduitEvent.PARAM_DATA] = {
- type: "remove",
- name: a
- };
- this._services.sendMessage({
- opcode: KonduitEvent.OP_CHAT_CANVAS_ELEMENT,
- params: c
- })
- },
- _onIncomingMessage: function(a, c) {
- switch (a) {
- case KonduitEvent.OP_CHAT_MSG:
- this._handleChatEvent("message", c);
- break;
- case KonduitEvent.OP_CHAT_ROOM_MESSAGE:
- this._handleChatEvent("room.message", c);
- break;
- case KonduitEvent.OP_CHAT_TAB:
- this._handleChatEvent("tab_visible", c)
- }
- },
- addEventListener: function(a, c) {
- "function" !== typeof c ? Kongregate.Log.error("addEventListener requires a callback function") : (this._eventCallbacks[a] || (this._eventCallbacks[a] = []), this._eventCallbacks[a].push(c))
- },
- _handleChatEvent: function(a,
- c) {
- var b = this._eventCallbacks[a];
- if (b)
- for (var e = 0; e < b.length; e++) b[e](c)
- }
- };
- Kongregate.ImageServices = function(a) {
- this.initialize(a)
- };
- Kongregate.ImageServices.prototype = {
- initialize: function(a) {
- var c = this;
- this._services = a.services;
- this._submitting = !1;
- this._callback = null;
- this._services.addEventListener(KonduitEvent.KONDUIT_MESSAGE, function(a) {
- c._onIncomingMessage(a.opcode, a.params)
- })
- },
- submitAvatar: function(a, c) {
- this._submitting ? (Kongregate.Log.warn("Another avatar submission is active, ignoring"), c && c({
- success: !1
- })) : (this._submitting = !0, this._callback = c, this._services.sendMessage({
- opcode: KonduitEvent.OP_IMAGE_AVATAR_SUBMIT,
- params: {
- image: a
- }
- }))
- },
- _onIncomingMessage: function(a, c) {
- KonduitEvent.OP_IMAGE_AVATAR_FINISHED === a && (this._submitting = !1, this._callback && this._callback(c.success))
- }
- };
- function KongregateAPI() {
- this._initialize()
- }
- KongregateAPI.prototype = {
- unityElementId: null,
- _initialize: function() {
- this._flashVarsString = "";
- this._flashVarsObject = {};
- this._services = {};
- this._postMessageParams = void 0;
- this._loading = this._loaded = this._paramsReceived = !1;
- this._queuedMessages = [];
- this._swfTimeout = window.chrome ? 0 : 1250;
- this._loadCallbacks = [];
- var a = location.search.split("?")[1];
- if (a)
- for (var a = a.split("&"), c = 0; c < a.length; c++) {
- var b = a[c].split("=");
- b && 2 == b.length && this._processParam(b[0], b[1])
- }
- if (this._postMessageParams = !this.flashVarsObject().kongregate_ansible_path &&
- top != window) {
- var e = this;
- window.addEventListener("message", function(a) {
- e._messageOriginIsKongregate(a) && (a = a.data, "params" == a.type && e._handleParamsMessage(a.data))
- });
- top.postMessage("kongregate_request_params", "*")
- } else this._paramsReceived = !0
- },
- flashVarsString: function() {
- return this._flashVarsString
- },
- flashVarsObject: function() {
- return this._flashVarsObject
- },
- getVariable: function(a) {
- return this._flashVarsObject[a]
- },
- loadAPI: function(a) {
- !this._postMessageParams || this._paramsReceived ? this._doLoadAPI(a) :
- this._loadCallbacks.push(a)
- },
- getAPI: function() {
- return this._services
- },
- embedFrame: function(a, c) {
- var b = document.getElementById(c ? c : "contentdiv"),
- e;
- e = "<iframe id='content' frameborder='0' style='position:relative;top:0px;left:0px;" + ("border:0px none;padding:0px;width:" + b.offsetWidth + "px;height:" + b.offsetHeight + "px;'");
- e += "src='" + a + "'></iframe>";
- b.innerHTML = e
- },
- _handleParamsMessage: function(a) {
- if (!this._paramsReceived) {
- for (var c in a) this._processParam(c, a[c]);
- this._paramsReceived = !0;
- 0 < this._loadCallbacks.length &&
- this._doLoadAPI()
- }
- },
- _fireLoadCallbacks: function() {
- var a = this._loadCallbacks.length;
- Kongregate.Log.debug("Kongregate API: Firing " + a + " load callback(s)");
- for (var c = 0; c < a; c++) {
- var b = this._loadCallbacks[c];
- "function" === typeof b && b()
- }
- this._loadCallbacks = []
- },
- _checkAlreadyLoaded: function() {
- this._loaded && this._fireLoadCallbacks();
- return this._loaded
- },
- _doLoadAPI: function(a) {
- this._loadCallbacks.push(a);
- if (!this._checkAlreadyLoaded() && !this._loading) {
- this._loading = !0;
- var c = this,
- b = function() {
- if (!c._checkAlreadyLoaded()) {
- c._loaded = !0;
- var a = c.messageConnection && c.messageConnection.isSupported(),
- b = "services stats mtx chat sharedContent analytics images".split(" ");
- try {
- if (c._hasFlash)
- for (var k = FABridge.ansible.root(), g = 0; g < b.length; g++) {
- var f = b[g];
- c._services[f] = k.getServices(f)
- }
- } catch (n) {
- Kongregate.Log.info("Error creating Flash Ansible object, which is probably fine: " + n)
- }
- a && c._createJavascriptApi();
- c._fireLoadCallbacks()
- }
- };
- kswfobject.addDomLoadEvent(function() {
- c._createAnsible(b)
- })
- }
- },
- _processParam: function(a, c) {
- 0 === a.indexOf("kongregate") &&
- (this._flashVarsObject[a] = c, this._flashVarsString += a + "=" + c + "&")
- },
- _messageOriginIsKongregate: function(a) {
- var c = this._flashVarsObject.kongregate_host;
- return c && a.origin == "http://" + c || a.origin == "https://" + c
- },
- _createJavascriptApi: function() {
- var a = this;
- this._services.services = new Kongregate.ApiServices({
- kongregate_variables: this.flashVarsObject(),
- message_connection: this.messageConnection
- });
- this._services.stats = new Kongregate.StatisticServices({
- services: this._services.services
- });
- this._services.sharedContent =
- new Kongregate.SharedContentServices({
- services: this._services.services
- });
- this._services.images = new Kongregate.ImageServices({
- services: this._services.services
- });
- this._services.mtx = new Kongregate.MicrotransactionServices({
- services: this._services.services
- });
- this._services.chat = new Kongregate.ChatServices({
- services: this._services.services
- });
- this._services.analytics = new Kongregate.AnalyticsServices({
- services: this._services.services,
- legacy_analytics: this._services.analytics,
- mtx: this._services.mtx,
- kongregate_variables: this.flashVarsObject(),
- enable_persistence: !0,
- start: !0
- });
- setTimeout(function() {
- a.messageConnection.connect()
- }, 0)
- },
- _analyticsImportRequired: function() {
- var a = this.flashVarsObject(),
- c = a.kongregate_analytics_mode,
- a = Kongregate.AnalyticsServices.persistentStoreName(a.kongregate_game_id);
- if (!c || "none" === c || navigator.userAgent.match(/Version\/[\d\.]+.*Safari/)) return !1;
- try {
- return !localStorage.getItem(a)
- } catch (b) {
- return !1
- }
- },
- _onAnsibleEmbeded: function(a, c) {
- this._hasFlash = (this._ansibleSWF = a.ref) && a.success;
- Kongregate.Log.debug("Ansible embed callback, success: " +
- this._hasFlash);
- this._jsApiEnabled ? this._hasFlash ? this._analyticsImportRequired() ? (Kongregate.Log.debug("Analytics import required, attempting to wait for Flash"), this._waitForAnsible(c)) : (Kongregate.Log.debug("Flash not required for analytics import, calling ansible embed callback"), c()) : (Kongregate.Log.debug("Flash not detected, calling ansible embed callback"), c()) : Kongregate.Log.debug("JS API disabled, waiting for Flash indefinitely")
- },
- _ansibleReady: function() {
- return this._ansibleSWF && "undefined" !==
- typeof this._ansibleSWF.Play
- },
- _waitForAnsible: function(a) {
- var c = (new Date).getTime(),
- b = this,
- e = this._requestAnimationFrame(),
- d = function() {
- b._ansibleSWF && "undefined" !== typeof b._ansibleSWF.Play ? Kongregate.Log.debug("Ansible SWF loading, no longer polling") : Math.abs((new Date).getTime() - c) >= b._swfTimeout ? (Kongregate.Log.debug("Ansible SWF did not start loading in time, giving up"), a()) : e(d)
- };
- d()
- },
- _requestAnimationFrame: function() {
- if (window.requestAnimationFrame) return window.requestAnimationFrame;
- for (var a = ["ms", "moz", "webkit", "o"], c = 0; c < a.length; c++) {
- var b = window[a[c] + "RequestAnimationFrame"];
- if (b) return b
- }
- return function(a) {
- setTimeout(a, 0)
- }
- },
- _createAnsible: function(a) {
- try {
- kongregateUnitySupport.hijackUnityErrorHandler()
- } catch (c) {}
- FABridge.addInitializationCallback("ansible", a);
- var b = this.flashVarsObject(),
- e = this;
- this._jsApiEnabled = "true" === String(b.kongregate_js_api);
- Kongregate.Log.debugLevel = b.kongregate_debug_level || 2;
- var d = document.createElement("div");
- d.id = "kongregate-ansible-container";
- d.style.position =
- "absolute";
- d.style.width = d.style.height = "1px";
- d.style.left = d.style.top = "-1000px";
- document.body.appendChild(d);
- var k = document.createElement("div");
- k.id = "kongregate-ansible";
- d.appendChild(k);
- d = {
- bridgeName: "ansible",
- json_encode: "true"
- };
- this._jsApiEnabled && (this.messageConnection = new Kongregate.MessageConnection({
- target_window: top,
- target_origin: decodeURIComponent(b.kongregate_host),
- channel_id: b.kongregate_channel_id,
- retry_connection: !0
- }), this.messageConnection.isSupported() && (d.message_connection_object =
- "kongregateAPI.messageConnection", this.messageConnection.addMessageListener(function(a, b) {
- var c = e._ansibleSWF;
- c && "function" === typeof c.handleMessageConnectionEvent && c.handleMessageConnectionEvent(JSON.stringify({
- opcode: a,
- params: b
- }))
- })));
- for (var g in b) d[g] = this.flashVarsObject()[g];
- b = decodeURIComponent(this.getVariable("kongregate_ansible_path"));
- kswfobject.embedSWF(b, "kongregate-ansible", "1", "1", "9.0.0", null, d, {
- allowScriptaccess: "always"
- }, null, function(b) {
- e._onAnsibleEmbeded(b, a)
- })
- }
- };
- kongregateAPI = new KongregateAPI;
- var kswfobject = function() {
- function a() {
- if (!E) {
- try {
- var a = m.getElementsByTagName("body")[0].appendChild(m.createElement("span"));
- a.parentNode.removeChild(a)
- } catch (b) {
- return
- }
- E = !0;
- for (var a = s.length, c = 0; c < a; c++) s[c]()
- }
- }
- function c(a) {
- E ? a() : s[s.length] = a
- }
- function b(a) {
- if (typeof h.addEventListener != w) h.addEventListener("load", a, !1);
- else if (typeof m.addEventListener != w) m.addEventListener("load", a, !1);
- else if (typeof h.attachEvent != w) l(h, "onload", a);
- else if ("function" == typeof h.onload) {
- var b = h.onload;
- h.onload =
- function() {
- b();
- a()
- }
- } else h.onload = a
- }
- function e() {
- var a = window.onerror;
- window.onerror = function() {
- return !0
- };
- try {
- var b = m.getElementsByTagName("body")[0],
- c = m.createElement(A);
- c.setAttribute("type", r);
- var h = b.appendChild(c);
- if (h) {
- var e = 0;
- (function() {
- if (typeof h.GetVariable != w) {
- var a = h.GetVariable("$version");
- a && (a = a.split(" ")[1].split(","), p.pv = [parseInt(a[0], 10), parseInt(a[1], 10), parseInt(a[2], 10)])
- } else if (10 > e) {
- e++;
- setTimeout(arguments.callee, 10);
- return
- }
- b.removeChild(c);
- h = null;
- d()
- })()
- } else d()
- } finally {
- window.onerror =
- a
- }
- }
- function d() {
- var a = y.length;
- if (0 < a)
- for (var b = 0; b < a; b++) {
- var c = y[b].id,
- h = y[b].callbackFn,
- m = {
- success: !1,
- id: c
- };
- if (0 < p.pv[0]) {
- var e = v(c);
- e && (D(y[b].swfVersion) && !(p.wk && 312 > p.wk) ? (C(c, !0), h && (m.success = !0, m.ref = k(c), h(m))) : (g(e), h && h(m)))
- } else if (C(c, !0), h) {
- if ((c = k(c)) && typeof c.SetVariable != w) m.success = !0, m.ref = c;
- h(m)
- }
- }
- }
- function k(a) {
- var b = null;
- if ((a = v(a)) && "OBJECT" == a.nodeName) typeof a.SetVariable != w ? b = a : (a = a.getElementsByTagName(A)[0]) && (b = a);
- return b
- }
- function g(a) {
- if (p.ie && p.win && 4 != a.readyState) {
- var b =
- m.createElement("div");
- a.parentNode.insertBefore(b, a);
- b.parentNode.replaceChild(f(a), b);
- a.style.display = "none";
- (function() {
- 4 == a.readyState ? a.parentNode.removeChild(a) : setTimeout(arguments.callee, 10)
- })()
- } else a.parentNode.replaceChild(f(a), a)
- }
- function f(a) {
- var b = m.createElement("div");
- if (p.win && p.ie) b.innerHTML = a.innerHTML;
- else if (a = a.getElementsByTagName(A)[0])
- if (a = a.childNodes)
- for (var c = a.length, h = 0; h < c; h++) !(1 == a[h].nodeType && "PARAM" == a[h].nodeName) && 8 != a[h].nodeType && b.appendChild(a[h].cloneNode(!0));
- return b
- }
- function n(a) {
- var b = v(a);
- b && "OBJECT" == b.nodeName && (p.ie && p.win ? (b.style.display = "none", function() {
- if (4 == b.readyState) {
- var c = v(a);
- if (c) {
- for (var h in c) "function" == typeof c[h] && (c[h] = null);
- c.parentNode.removeChild(c)
- }
- } else setTimeout(arguments.callee, 10)
- }()) : b.parentNode.removeChild(b))
- }
- function v(a) {
- var b = null;
- try {
- b = m.getElementById(a)
- } catch (c) {}
- return b
- }
- function l(a, b, c) {
- a.attachEvent(b, c);
- t[t.length] = [a, b, c]
- }
- function D(a) {
- var b = p.pv;
- a = a.split(".");
- a[0] = parseInt(a[0], 10);
- a[1] = parseInt(a[1],
- 10) || 0;
- a[2] = parseInt(a[2], 10) || 0;
- return b[0] > a[0] || b[0] == a[0] && b[1] > a[1] || b[0] == a[0] && b[1] == a[1] && b[2] >= a[2] ? !0 : !1
- }
- function q(a, b, c, h) {
- if (!p.ie || !p.mac) {
- var e = m.getElementsByTagName("head")[0];
- if (e) {
- c = c && "string" == typeof c ? c : "screen";
- h && (H = x = null);
- if (!x || H != c) h = m.createElement("style"), h.setAttribute("type", "text/css"), h.setAttribute("media", c), x = e.appendChild(h), p.ie && (p.win && typeof m.styleSheets != w && 0 < m.styleSheets.length) && (x = m.styleSheets[m.styleSheets.length - 1]), H = c;
- p.ie && p.win ? x && typeof x.addRule ==
- A && x.addRule(a, b) : x && typeof m.createTextNode != w && x.appendChild(m.createTextNode(a + " {" + b + "}"))
- }
- }
- }
- function C(a, b) {
- if (R) {
- var c = b ? "visible" : "hidden";
- E && v(a) ? v(a).style.visibility = c : q("#" + a, "visibility:" + c)
- }
- }
- var w = "undefined",
- A = "object",
- r = "application/x-shockwave-flash",
- h = window,
- m = document,
- u = navigator,
- F = !1,
- s = [function() {
- F ? e() : d()
- }],
- y = [],
- B = [],
- t = [],
- E = !1,
- x, H, R = !0,
- p = function() {
- var a = typeof m.getElementById != w && typeof m.getElementsByTagName != w && typeof m.createElement != w,
- b = u.userAgent.toLowerCase(),
- c = u.platform.toLowerCase(),
- e = c ? /win/.test(c) : /win/.test(b),
- c = c ? /mac/.test(c) : /mac/.test(b),
- b = /webkit/.test(b) ? parseFloat(b.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : !1,
- d = !+"\v1",
- s = [0, 0, 0],
- f = null;
- if (typeof u.plugins != w && typeof u.plugins["Shockwave Flash"] == A) {
- if ((f = u.plugins["Shockwave Flash"].description) && !(typeof u.mimeTypes != w && u.mimeTypes[r] && !u.mimeTypes[r].enabledPlugin)) F = !0, d = !1, f = f.replace(/^.*\s+(\S+\s+\S+$)/, "$1"), s[0] = parseInt(f.replace(/^(.*)\..*$/, "$1"), 10), s[1] = parseInt(f.replace(/^.*\.(.*)\s.*$/, "$1"), 10),
- s[2] = /[a-zA-Z]/.test(f) ? parseInt(f.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0
- } else if (typeof h.ActiveXObject != w) try {
- var g = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
- if (g && (f = g.GetVariable("$version"))) d = !0, f = f.split(" ")[1].split(","), s = [parseInt(f[0], 10), parseInt(f[1], 10), parseInt(f[2], 10)]
- } catch (k) {}
- return {
- w3: a,
- pv: s,
- wk: b,
- ie: d,
- win: e,
- mac: c
- }
- }();
- (function() {
- p.w3 && ((typeof m.readyState != w && "complete" == m.readyState || typeof m.readyState == w && (m.getElementsByTagName("body")[0] || m.body)) && a(), E || (typeof m.addEventListener !=
- w && m.addEventListener("DOMContentLoaded", a, !1), p.ie && p.win && (m.attachEvent("onreadystatechange", function() {
- "complete" == m.readyState && (m.detachEvent("onreadystatechange", arguments.callee), a())
- }), h == top && function() {
- if (!E) {
- try {
- m.documentElement.doScroll("left")
- } catch (b) {
- setTimeout(arguments.callee, 0);
- return
- }
- a()
- }
- }()), p.wk && function() {
- E || (/loaded|complete/.test(m.readyState) ? a() : setTimeout(arguments.callee, 0))
- }(), b(a)))
- })();
- (function() {
- p.ie && p.win && window.attachEvent("onunload", function() {
- for (var a = t.length,
- b = 0; b < a; b++) t[b][0].detachEvent(t[b][1], t[b][2]);
- a = B.length;
- for (b = 0; b < a; b++) n(B[b]);
- for (var c in p) p[c] = null;
- p = null;
- for (var h in kswfobject) kswfobject[h] = null;
- kswfobject = null
- })
- })();
- return {
- embedSWF: function(a, b, h, e, d, u, F, f, s, g) {
- var k = {
- success: !1,
- id: b
- };
- p.w3 && !(p.wk && 312 > p.wk) && a && b && h && e && d ? (C(b, !1), c(function() {
- h += "";
- e += "";
- var c = {};
- if (s && typeof s === A)
- for (var u in s) c[u] = s[u];
- c.data = a;
- c.width = h;
- c.height = e;
- u = {};
- if (f && typeof f === A)
- for (var l in f) u[l] = f[l];
- if (F && typeof F === A)
- for (var y in F) u.flashvars =
- typeof u.flashvars != w ? u.flashvars + ("&" + y + "=" + F[y]) : y + "=" + F[y];
- if (D(d)) {
- var q;
- l = v(b);
- if (!(p.wk && 312 > p.wk) && l)
- if (typeof c.id == w && (c.id = b), p.ie && p.win) {
- var n = "",
- z;
- for (z in c) c[z] != Object.prototype[z] && ("data" == z.toLowerCase() ? u.movie = c[z] : "styleclass" == z.toLowerCase() ? n += ' class="' + c[z] + '"' : "classid" != z.toLowerCase() && (n += " " + z + '="' + c[z] + '"'));
- z = "";
- for (var t in u) u[t] != Object.prototype[t] && (z += '<param name="' + t + '" value="' + u[t] + '" />');
- l.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' +
- n + ">" + z + "</object>";
- B[B.length] = c.id;
- q = v(c.id)
- } else {
- t = m.createElement(A);
- t.setAttribute("type", r);
- for (var x in c) c[x] != Object.prototype[x] && ("styleclass" == x.toLowerCase() ? t.setAttribute("class", c[x]) : "classid" != x.toLowerCase() && t.setAttribute(x, c[x]));
- for (n in u) u[n] != Object.prototype[n] && "movie" != n.toLowerCase() && (z = t, x = n, q = u[n], y = m.createElement("param"), y.setAttribute("name", x), y.setAttribute("value", q), z.appendChild(y));
- l.parentNode.replaceChild(t, l);
- q = t
- }
- u = q;
- c.id == b && C(b, !0);
- k.success = !0;
- k.ref =
- u
- } else C(b, !0);
- g && g(k)
- })) : g && g(k)
- },
- ua: p,
- removeSWF: function(a) {
- p.w3 && n(a)
- },
- createCSS: function(a, b, c, h) {
- p.w3 && q(a, b, c, h)
- },
- addDomLoadEvent: c,
- addLoadEvent: b
- }
- }();
- ! function(a) {
- function c(a) {
- for (var b = 16; b--;) {
- var c = b << 2;
- n[b] = a.charCodeAt(c) + (a.charCodeAt(c + 1) << 8) + (a.charCodeAt(c + 2) << 16) + (a.charCodeAt(c + 3) << 24)
- }
- }
- function b(a, b, c, e, d, f, g) {
- b += a + e + g;
- return (b << d | b >>> f) + c << 0
- }
- function e(a) {
- k(0, 0, 0, 0, a);
- q[0] = r[0] + 1732584193 << 0;
- q[1] = r[1] - 271733879 << 0;
- q[2] = r[2] - 1732584194 << 0;
- q[3] = r[3] + 271733878 << 0
- }
- function d(a) {
- k(q[0], q[1], q[2], q[3], a);
- q[0] = r[0] + q[0] << 0;
- q[1] = r[1] + q[1] << 0;
- q[2] = r[2] + q[2] << 0;
- q[3] = r[3] + q[3] << 0
- }
- function k(a, c, e, d, f) {
- var g;
- C ? (a = b((e ^ d) & c ^ d, a, c, f[0], 7, 25, -680876936),
- d = b((c ^ e) & a ^ e, d, a, f[1], 12, 20, -389564586), e = b((a ^ c) & d ^ c, e, d, f[2], 17, 15, 606105819), c = b((d ^ a) & e ^ a, c, e, f[3], 22, 10, -1044525330)) : (a = f[0] - 680876937, a = (a << 7 | a >>> 25) - 271733879 << 0, d = f[1] - 117830708 + (2004318071 & a ^ -1732584194), d = (d << 12 | d >>> 20) + a << 0, e = f[2] - 1126478375 + ((a ^ -271733879) & d ^ -271733879), e = (e << 17 | e >>> 15) + d << 0, c = f[3] - 1316259209 + ((d ^ a) & e ^ a), c = (c << 22 | c >>> 10) + e << 0);
- a = b((e ^ d) & c ^ d, a, c, f[4], 7, 25, -176418897);
- d = b((c ^ e) & a ^ e, d, a, f[5], 12, 20, 1200080426);
- e = b((a ^ c) & d ^ c, e, d, f[6], 17, 15, -1473231341);
- c = b((d ^ a) & e ^ a, c, e,
- f[7], 22, 10, -45705983);
- a = b((e ^ d) & c ^ d, a, c, f[8], 7, 25, 1770035416);
- d = b((c ^ e) & a ^ e, d, a, f[9], 12, 20, -1958414417);
- e = b((a ^ c) & d ^ c, e, d, f[10], 17, 15, -42063);
- c = b((d ^ a) & e ^ a, c, e, f[11], 22, 10, -1990404162);
- a = b((e ^ d) & c ^ d, a, c, f[12], 7, 25, 1804603682);
- d = b((c ^ e) & a ^ e, d, a, f[13], 12, 20, -40341101);
- e = b((a ^ c) & d ^ c, e, d, f[14], 17, 15, -1502002290);
- c = b((d ^ a) & e ^ a, c, e, f[15], 22, 10, 1236535329);
- a = b((c ^ e) & d ^ e, a, c, f[1], 5, 27, -165796510);
- d = b((a ^ c) & e ^ c, d, a, f[6], 9, 23, -1069501632);
- e = b((d ^ a) & c ^ a, e, d, f[11], 14, 18, 643717713);
- c = b((e ^ d) & a ^ d, c, e, f[0], 20, 12, -373897302);
- a = b((c ^ e) & d ^ e, a, c, f[5], 5, 27, -701558691);
- d = b((a ^ c) & e ^ c, d, a, f[10], 9, 23, 38016083);
- e = b((d ^ a) & c ^ a, e, d, f[15], 14, 18, -660478335);
- c = b((e ^ d) & a ^ d, c, e, f[4], 20, 12, -405537848);
- a = b((c ^ e) & d ^ e, a, c, f[9], 5, 27, 568446438);
- d = b((a ^ c) & e ^ c, d, a, f[14], 9, 23, -1019803690);
- e = b((d ^ a) & c ^ a, e, d, f[3], 14, 18, -187363961);
- c = b((e ^ d) & a ^ d, c, e, f[8], 20, 12, 1163531501);
- a = b((c ^ e) & d ^ e, a, c, f[13], 5, 27, -1444681467);
- d = b((a ^ c) & e ^ c, d, a, f[2], 9, 23, -51403784);
- e = b((d ^ a) & c ^ a, e, d, f[7], 14, 18, 1735328473);
- c = b((e ^ d) & a ^ d, c, e, f[12], 20, 12, -1926607734);
- g = c ^ e;
- a = b(g ^ d, a, c, f[5], 4, 28, -378558);
- d = b(g ^ a, d, a, f[8], 11, 21, -2022574463);
- g = d ^ a;
- e = b(g ^ c, e, d, f[11], 16, 16, 1839030562);
- c = b(g ^ e, c, e, f[14], 23, 9, -35309556);
- g = c ^ e;
- a = b(g ^ d, a, c, f[1], 4, 28, -1530992060);
- d = b(g ^ a, d, a, f[4], 11, 21, 1272893353);
- g = d ^ a;
- e = b(g ^ c, e, d, f[7], 16, 16, -155497632);
- c = b(g ^ e, c, e, f[10], 23, 9, -1094730640);
- g = c ^ e;
- a = b(g ^ d, a, c, f[13], 4, 28, 681279174);
- d = b(g ^ a, d, a, f[0], 11, 21, -358537222);
- g = d ^ a;
- e = b(g ^ c, e, d, f[3], 16, 16, -722521979);
- c = b(g ^ e, c, e, f[6], 23, 9, 76029189);
- g = c ^ e;
- a = b(g ^ d, a, c, f[9], 4, 28, -640364487);
- d = b(g ^ a, d, a,
- f[12], 11, 21, -421815835);
- g = d ^ a;
- e = b(g ^ c, e, d, f[15], 16, 16, 530742520);
- c = b(g ^ e, c, e, f[2], 23, 9, -995338651);
- a = b(e ^ (c | ~d), a, c, f[0], 6, 26, -198630844);
- d = b(c ^ (a | ~e), d, a, f[7], 10, 22, 1126891415);
- e = b(a ^ (d | ~c), e, d, f[14], 15, 17, -1416354905);
- c = b(d ^ (e | ~a), c, e, f[5], 21, 11, -57434055);
- a = b(e ^ (c | ~d), a, c, f[12], 6, 26, 1700485571);
- d = b(c ^ (a | ~e), d, a, f[3], 10, 22, -1894986606);
- e = b(a ^ (d | ~c), e, d, f[10], 15, 17, -1051523);
- c = b(d ^ (e | ~a), c, e, f[1], 21, 11, -2054922799);
- a = b(e ^ (c | ~d), a, c, f[8], 6, 26, 1873313359);
- d = b(c ^ (a | ~e), d, a, f[15], 10, 22, -30611744);
- e =
- b(a ^ (d | ~c), e, d, f[6], 15, 17, -1560198380);
- c = b(d ^ (e | ~a), c, e, f[13], 21, 11, 1309151649);
- a = b(e ^ (c | ~d), a, c, f[4], 6, 26, -145523070);
- d = b(c ^ (a | ~e), d, a, f[11], 10, 22, -1120210379);
- e = b(a ^ (d | ~c), e, d, f[2], 15, 17, 718787259);
- c = b(d ^ (e | ~a), c, e, f[9], 21, 11, -343485551);
- r[0] = a;
- r[1] = c;
- r[2] = e;
- r[3] = d
- }
- var g = [],
- f = [],
- n = [],
- v = [],
- l = "0123456789abcdef".split(""),
- D = [],
- q = [],
- C = !1,
- w = 0,
- A = 0,
- r = [];
- if (a.Int32Array) f = new Int32Array(16), n = new Int32Array(16), v = new Int32Array(4), D = new Int32Array(4), q = new Int32Array(4), r = new Int32Array(4);
- else {
- for (a = 0; 16 >
- a; a++) f[a] = n[a] = 0;
- for (a = 0; 4 > a; a++) v[a] = D[a] = q[a] = r[a] = 0
- }
- v[0] = 128;
- v[1] = 32768;
- v[2] = 8388608;
- v[3] = -2147483648;
- D[0] = 0;
- D[1] = 8;
- D[2] = 16;
- D[3] = 24;
- Kongregate.Utils.md5 = function(a, b, k) {
- if (!b) {
- for (var r = b = "", s = 0, y = 0, B = 0, t = a.length; B < t; B++) r = a.charCodeAt(B), 128 > r ? y++ : (r = 2048 > r ? String.fromCharCode(r >> 6 | 192, r & 63 | 128) : String.fromCharCode(r >> 12 | 224, r >> 6 & 63 | 128, r & 63 | 128), y > s && (b += a.slice(s, y)), b += r, s = y = B + 1);
- y > s && (b += a.slice(s, t));
- a = b
- }
- a += "";
- C = !1;
- w = A = a.length;
- if (63 < A) {
- c(a.substring(0, 64));
- e(n);
- C = !0;
- for (b = 128; b <= A; b +=
- 64) c(a.substring(b - 64, b)), d(n);
- a = a.substring(b - 64);
- A = a.length
- }
- for (b = f[0] = f[1] = f[2] = f[3] = f[4] = f[5] = f[6] = f[7] = f[8] = f[9] = f[10] = f[11] = f[12] = f[13] = f[14] = f[15] = 0; b < A; b++) s = b & 3, f[b >> 2] = 0 === s ? a.charCodeAt(b) : f[b >> 2] | a.charCodeAt(b) << D[s];
- f[b >> 2] |= v[b & 3];
- 55 < b ? (C ? d(f) : (e(f), C = !0), d([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, w << 3, 0])) : (f[14] = w << 3, C ? d(f) : e(f));
- a = q[0];
- g[1] = l[a & 15];
- g[0] = l[(a >>= 4) & 15];
- g[3] = l[(a >>= 4) & 15];
- g[2] = l[(a >>= 4) & 15];
- g[5] = l[(a >>= 4) & 15];
- g[4] = l[(a >>= 4) & 15];
- g[7] = l[(a >>= 4) & 15];
- g[6] = l[a >> 4 & 15];
- a = q[1];
- g[9] = l[a &
- 15];
- g[8] = l[(a >>= 4) & 15];
- g[11] = l[(a >>= 4) & 15];
- g[10] = l[(a >>= 4) & 15];
- g[13] = l[(a >>= 4) & 15];
- g[12] = l[(a >>= 4) & 15];
- g[15] = l[(a >>= 4) & 15];
- g[14] = l[a >> 4 & 15];
- a = q[2];
- g[17] = l[a & 15];
- g[16] = l[(a >>= 4) & 15];
- g[19] = l[(a >>= 4) & 15];
- g[18] = l[(a >>= 4) & 15];
- g[21] = l[(a >>= 4) & 15];
- g[20] = l[(a >>= 4) & 15];
- g[23] = l[(a >>= 4) & 15];
- g[22] = l[a >> 4 & 15];
- a = q[3];
- g[25] = l[a & 15];
- g[24] = l[(a >>= 4) & 15];
- g[27] = l[(a >>= 4) & 15];
- g[26] = l[(a >>= 4) & 15];
- g[29] = l[(a >>= 4) & 15];
- g[28] = l[(a >>= 4) & 15];
- g[31] = l[(a >>= 4) & 15];
- g[30] = l[a >> 4 & 15];
- return k ? g : g.join("")
- }
- }("undefined" === typeof global ?
- window : global);
- Kongregate.MicrotransactionServices = function(a) {
- this.initialize(a)
- };
- Kongregate.MicrotransactionServices.prototype = {
- initialize: function(a) {
- var c = this;
- this._services = a.services;
- this._services.addEventListener(KonduitEvent.KONDUIT_MESSAGE, function(a) {
- c._onIncomingMessage(a.opcode, a.params)
- });
- this._adCallbacks = []
- },
- requestItemList: function(a, c) {
- Kongregate.Log.info("MicrotransactionServices.requestItemList(" + a + ")");
- params = {};
- a && 0 < a.length && (params[KonduitEvent.PARAM_ITEM_TAGS] = a);
- this._services._enqueueRequest(params, c);
- this._services.sendMessage({
- opcode: KonduitEvent.ITEM_LIST,
- params: params
- })
- },
- requestUserItemList: function(a, c) {
- Kongregate.Log.info("MicrotransactionServices.requestUserItemList(" + a + ")");
- params = {};
- params[KonduitEvent.PARAM_USER] = a || this._services.getUsername();
- this._services._enqueueRequest(params, c);
- this._services.sendMessage({
- opcode: KonduitEvent.ITEM_INSTANCES,
- params: params
- })
- },
- purchaseItems: function(a, c) {
- Kongregate.Log.info("MicrotransactionServices.purchaseItems(" + a + ")");
- params = {};
- a && 0 < a.length ? (this._purchaseItemsCallback = c, params[KonduitEvent.PARAM_ITEMS] =
- a, this._services.sendMessage({
- opcode: KonduitEvent.ITEM_CHECKOUT,
- params: params
- })) : (Kongregate.Log.error("purchaseItems requires a non-empty item identifier array"), c && c({
- success: !1
- }))
- },
- purchaseItemsRemote: function(a, c) {
- Kongregate.Log.info("MicrotransactionServices.purchaseItemsRemote(" + a + ")");
- params = {};
- a && 0 < a.length ? (this._purchaseItemsCallback = c, params[KonduitEvent.PARAM_ORDER_INFO] = a, this._services.sendMessage({
- opcode: KonduitEvent.ITEM_CHECKOUT,
- params: params
- })) : (Kongregate.Log.error("purchaseItemsRemote requires an orderInformation string"),
- c && c({
- success: !1
- }))
- },
- useItemInstance: function(a, c) {
- Kongregate.Log.info("MicrotransactionServices.useItemInstance(" + a + ")");
- params = {};
- a ? (params[KonduitEvent.PARAM_ID] = a, this._services._enqueueRequest(params, c), this._services.sendMessage({
- opcode: KonduitEvent.USE_ITEM_INSTANCE,
- params: params
- })) : (Kongregate.Log.error("useItemInstance requires an itemInstanceId"), c && c({
- success: !1
- }))
- },
- showKredPurchaseDialog: function(a) {
- params = {};
- params[KonduitEvent.PARAM_PURCHASE_METHOD] = a;
- this._services.sendMessage({
- opcode: KonduitEvent.PURCHASE_KREDS,
- params: params
- })
- },
- initializeIncentivizedAds: function() {
- this._services.sendMessage({
- opcode: KonduitEvent.ADS_INITIALIZE
- })
- },
- showIncentivizedAd: function() {
- this._services.sendMessage({
- opcode: KonduitEvent.ADS_SHOW_INCENTIVIZED
- })
- },
- addEventListener: function(a, c) {
- "function" !== typeof c ? Kongregate.Log.error("addEventListener requires a callback function") : (this._adCallbacks[a] || (this._adCallbacks[a] = []), this._adCallbacks[a].push(c))
- },
- _onIncomingMessage: function(a, c) {
- switch (a) {
- case KonduitEvent.ITEM_INSTANCES:
- case KonduitEvent.ITEM_LIST:
- case KonduitEvent.USE_ITEM_INSTANCE:
- this._services._completeRequest(c);
- break;
- case KonduitEvent.PURCHASE_RESULT:
- this._onPurchaseResultResponse(c);
- break;
- case KonduitEvent.ADS_AVAILABLE:
- this._handleAdEvent("adsAvailable", c);
- break;
- case KonduitEvent.ADS_UNAVAILABLE:
- this._handleAdEvent("adsUnavailable", c);
- break;
- case KonduitEvent.AD_OPENED:
- this._handleAdEvent("adOpened", c);
- break;
- case KonduitEvent.AD_COMPLETED:
- this._handleAdEvent("adCompleted", c);
- break;
- case KonduitEvent.AD_ABANDONED:
- this._handleAdEvent("adAbandoned", c)
- }
- },
- _onPurchaseResultResponse: function(a) {
- this._purchaseItemsCallback &&
- (this._purchaseItemsCallback(a), this._purchaseItemsCallback = null)
- },
- _handleAdEvent: function(a, c) {
- var b = this._adCallbacks[a];
- if (b)
- for (var e = 0; e < b.length; e++) b[e](c)
- }
- };
- Kongregate.SharedContentServices = function(a) {
- this.initialize(a)
- };
- Kongregate.SharedContentServices.CONTENT_TYPE_LIMIT = 12;
- Kongregate.SharedContentServices.prototype = {
- initialize: function(a) {
- var c = this;
- this._services = a.services;
- this._loadListeners = {};
- this._services.addEventListener(KonduitEvent.KONDUIT_MESSAGE, function(a) {
- c._onIncomingMessage(a.opcode, a.params)
- })
- },
- browse: function(a, c, b) {
- var e = {};
- e[KonduitEvent.PARAM_CONTENT_TYPE] = a;
- b && (e[KonduitEvent.PARAM_LABEL] = b);
- c && (e[KonduitEvent.PARAM_SORT] = c);
- this._services.sendMessage({
- opcode: KonduitEvent.OP_BROWSE_SHARED_CONTENT,
- params: e
- })
- },
- save: function(a, c, b, e, d) {
- if (this._saving ||
- a.length > Kongregate.SharedContentServices.CONTENT_TYPE_LIMIT) b && b({
- success: !1
- });
- else {
- var k = {};
- k[KonduitEvent.PARAM_CONTENT_TYPE] = a;
- k[KonduitEvent.PARAM_LABEL] = d;
- k[KonduitEvent.PARAM_DATA] = c;
- k[KonduitEvent.PARAM_IMAGE] = e;
- this._services.sendMessage({
- opcode: KonduitEvent.OP_SAVE_SHARED_CONTENT,
- params: k
- });
- this._saving = !0;
- this._saveCallback = b
- }
- },
- addLoadListener: function(a, c) {
- this._loadListeners[a] || (this._loadListeners[a] = []);
- this._loadListeners[a].push(c)
- },
- _onIncomingMessage: function(a, c) {
- switch (a) {
- case KonduitEvent.OP_SHARED_CONTENT_SAVE_COMPLETE:
- this._onSaveContentComplete(c);
- break;
- case KonduitEvent.OP_LOAD_SHARED_CONTENT:
- this._onLoadSharedContent(c)
- }
- },
- _onSaveContentComplete: function(a) {
- this._saving = !1;
- this._saveCallback && (this._saveCallback(a), this._saveCallback = null)
- },
- _onLoadSharedContent: function(a) {
- var c = a.contentType;
- a = {
- id: a.id,
- name: a.name,
- permalink: a.permalink,
- content: a.content,
- label: a.label
- };
- Kongregate.Log.info({
- loadContent: a
- });
- for (var c = this._loadListeners[c] || [], b = 0; b < c.length; b++) c[b](a)
- }
- };
- Kongregate.StatisticServices = function(a) {
- this.initialize(a)
- };
- Kongregate.StatisticServices.prototype = {
- initialize: function(a) {
- this._services = a.services
- },
- submit: function(a, c) {
- Kongregate.Log.info("StatServices.submit(" + a + "," + c + ")");
- !a || null === c || void 0 === c || isNaN(c) ? Kongregate.Log.warn("Invalid stat name or value:", a, c) : this._services.sendMessage({
- opcode: KonduitEvent.OP_STATS_SUBMIT,
- params: {
- stats: [{
- name: a,
- value: c
- }]
- }
- })
- },
- submitArray: function(a) {
- if (a && a.length)
- for (var c = 0; c < a.length; c++) this.submit(a[c].name, a[c].value)
- }
- };
- (function() {
- Kongregate.SwrveClient = function(a) {
- this.initialize(a)
- };
- var a = Kongregate.SwrveClient;
- Kongregate.SwrveClient.prototype = {
- initialize: function(a) {
- this._applicationId = a.application_id;
- this._apiKey = a.api_key;
- this._playerId = a.player_id;
- this._clientVersion = a.client_version
- },
- sendEvents: function(a, c) {
- var d = new XMLHttpRequest,
- k = a.length,
- g = this,
- f = function(d) {
- g._onError(a, k, d, c)
- };
- d.open("POST", "//" + this._applicationId + ".api.swrve.com/1/batch");
- d.setRequestHeader("Content-Type", "application/json; charset=utf-8");
- d.onerror = d.onabort = f;
- d.onload = function() {
- g._onBatchResponse(d, a, k, c, f)
- };
- "undefined" !== typeof d.timeout && (d.timeout = 3E4, d.ontimeout = f);
- d.send(JSON.stringify(this._createPayload(a)))
- },
- _onBatchResponse: function(a, c, d, k, g) {
- var f = !1;
- if (200 === a.status) {
- var n = a.responseText;
- (f = 0 === n.length) || (f = 200 === JSON.parse(n).code)
- }
- f ? (Kongregate.Log.debug("SWRVE submission complete, " + d + " event(s)"), c.splice(0, d), k && k({
- success: !0
- })) : (Kongregate.Log.error("Error while parsing swrve result: " + a.status + ", removing " +
- d + " event(s)"), g(!0))
- },
- _onError: function(a, c, d, k) {
- for (var g = 0; g < c && g < a.length; g++) {
- var f = a[g];
- if (f) {
- var n = (f.event.retry_count || 0) + (d ? this._maxRetries() + 1 : 1);
- f.event.retry_count = n
- }
- }
- this._pruneEvents(a);
- k && k({
- success: !1
- })
- },
- _createPayload: function(b) {
- for (var c = {
- app_version: this._clientVersion,
- session_token: this._createSessionToken(),
- user: this._playerId
- }, d = [], k = 0; k < b.length; k++) {
- var g = b[k],
- f = g.name,
- n = this._getTime(g),
- g = Kongregate.Utils.merge({}, g.event);
- this._removeTransientProperties(g);
- a.SWRVE_SESSION_START_IDENTIFIER ===
- f ? d.push({
- type: "session_start",
- time: n
- }) : a.SWRVE_USER_IDENTIFIER === f ? d.push({
- type: "user",
- time: n,
- attributes: g
- }) : a.SWRVE_IAP_IDENTIFIER === f ? d.push(Kongregate.Utils.merge({
- type: "iap",
- time: n
- }, g)) : 0 === f.indexOf("swrve.") ? (f = f.replace("swrve.", "Kongregate."), d.push({
- type: "event",
- name: f,
- time: n,
- payload: g
- })) : (f = "Kongregate.RawData." + f, d.push({
- type: "event",
- name: f,
- time: n,
- payload: {
- data: JSON.stringify(g)
- }
- }))
- }
- c.data = d;
- return c
- },
- _pruneEvents: function(a) {
- for (var c = a.length - 1; 0 <= c; c--) a[c].event && a[c].event.retry_count >
- this._maxRetries() && (Kongregate.Log.debug("Event " + a[c].name + " is over max retry count, deleting it"), a.splice(c, 1));
- c = this._maxBacklogSize();
- a && a.length > c && a.splice(0, a.length - c)
- },
- _removeTransientProperties: function(a) {
- for (var e = 0; e < c.length; e++) {
- var d = c[e];
- void 0 !== a[d] && delete a[d]
- }
- },
- _createSessionToken: function() {
- var a = Math.floor(this._getDate().getTime() / 1E3);
- return this._applicationId + "=" + this._playerId + "=" + String(a) + "=" + Kongregate.Utils.md5(this._playerId + String(a) + this._apiKey)
- },
- _maxRetries: function() {
- return 2
- },
- _maxBacklogSize: function() {
- return 100
- },
- _getDate: function() {
- return new Date
- },
- _getTime: function(a) {
- var c = this._getDate();
- a.event && a.event[Kongregate.AnalyticsServices.KONG_ANALYTICS_EVENT_TIME] && (c = Kongregate.Utils.parseW3CDTF(a.event[Kongregate.AnalyticsServices.KONG_ANALYTICS_EVENT_TIME], this._getDate()));
- return Math.floor(c.getTime() / 1E3)
- }
- };
- a.SWRVE_EVENT_IDENTIFIER = "swrve.";
- a.SWRVE_BARE_EVENT_IDENTIFIER = a.SWRVE_EVENT_IDENTIFIER + "__bare_";
- a.SWRVE_SESSION_START_IDENTIFIER = a.SWRVE_BARE_EVENT_IDENTIFIER +
- "session_start";
- a.SWRVE_USER_IDENTIFIER = a.SWRVE_BARE_EVENT_IDENTIFIER + "user";
- a.SWRVE_IAP_IDENTIFIER = a.SWRVE_BARE_EVENT_IDENTIFIER + "iap";
- var c = ["auto_event", "retry_count"]
- })();
- (function() {
- Kongregate.Utils.merge = function(a, b) {
- if (!a || !b) return a;
- for (var e in b) b.hasOwnProperty(e) && (a[e] = b[e]);
- return a
- };
- Kongregate.Utils.toW3CDTF = function(a) {
- function b(a) {
- return 10 > a ? "0" + a : a
- }
- return !(a instanceof Date) ? "" : a.getUTCFullYear() + "-" + b(a.getUTCMonth() + 1) + "-" + b(a.getUTCDate()) + "T" + b(a.getUTCHours()) + ":" + b(a.getUTCMinutes()) + ":" + b(a.getUTCSeconds()) + "." + (a.getUTCMilliseconds() / 1E3).toFixed(3).slice(2, 5) + "-00:00"
- };
- Kongregate.Utils.parseW3CDTF = function(c, b) {
- var e;
- try {
- var d, k = 0,
- g = [1, 4,
- 5, 6, 7, 10, 11
- ];
- if (d = a.exec(c)) {
- for (var f = 0, n; n = g[f]; ++f) d[n] = +d[n] || 0;
- d[2] = (+d[2] || 1) - 1;
- d[3] = +d[3] || 1;
- "Z" !== d[8] && void 0 !== d[9] && (k = 60 * d[10] + d[11], "+" === d[9] && (k = 0 - k));
- e = new Date(Date.UTC(d[1], d[2], d[3], d[4], d[5] + k, d[6], d[7]))
- }
- if (!e || "Invalid Date" === e.toString()) throw Error("This date does not conform to W3CDTF.");
- } catch (v) {
- return e = "Unable to parse the string [" + c + "] into a date. " + ("The internal error was: " + v.toString()), Kongregate.Log.error(e), b
- }
- return e
- };
- var a = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/
- })();
- "undefined" == typeof kongregateUnitySupport && (kongregateUnitySupport = function() {
- function a(a) {
- a = g.getElementById(a);
- if (!a) return null;
- var b;
- l.win && l.ie ? (a = a.getElementsByTagName("object")[0]) && "OBJECT" == a.nodeName && (b = a) : (a = a.getElementsByTagName("embed")[0]) && "EMBED" == a.nodeName && (b = a);
- return b && typeof b.GetPluginVersion == d ? null : b
- }
- function c() {
- if ("function" === typeof window.SendMessage) return window;
- var b = "kongregateUnityDiv";
- typeof kongregateAPI != d && kongregateAPI.unityElementId && (b = kongregateAPI.unityElementId);
- return a(b) || a("unityPlayer")
- }
- function b() {
- return [kongregate.services.getUserId(), kongregate.services.getUsername(), kongregate.services.getGameAuthToken()].join("|")
- }
- var e = [],
- d = "undefined",
- k = navigator,
- g = document,
- f = k.userAgent,
- k = k.platform,
- n = !1,
- v = /chrome/i.test(f);
- /msie/i.test(f) ? n = parseFloat(f.replace(/^.*msie ([0-9]+(\.[0-9]+)?).*$/i, "$1")) : /Trident/i.test(f) && (n = parseFloat(f.replace(/^.*rv:([0-9]+(\.[0-9]+)?).*$/i, "$1")));
- var l = {
- w3: typeof g.getElementById != d && typeof g.getElementsByTagName != d && typeof g.createElement !=
- d,
- win: k ? /win/i.test(k) : /win/i.test(f),
- mac: k ? /mac/i.test(k) : /mac/i.test(f),
- ie: n,
- ff: /firefox/i.test(f),
- op: /opera/i.test(f),
- ch: v,
- ch_v: /chrome/i.test(f) ? parseFloat(f.replace(/^.*chrome\/(\d+(\.\d+)?).*$/i, "$1")) : !1,
- sf: /safari/i.test(f) && !v,
- wk: /webkit/i.test(f) ? parseFloat(f.replace(/^.*webkit\/(\d+(\.\d+)?).*$/i, "$1")) : !1,
- x64: /win64/i.test(f) && /x64/i.test(f),
- moz: /mozilla/i.test(f) ? parseFloat(f.replace(/^.*mozilla\/([0-9]+(\.[0-9]+)?).*$/i, "$1")) : 0,
- mobile: /ipad/i.test(k) || /iphone/i.test(k) || /ipod/i.test(k) ||
- /android/i.test(f) || /windows phone/i.test(f)
- };
- l.clientBrand = l.ch ? "ch" : l.ff ? "ff" : l.sf ? "sf" : l.ie ? "ie" : l.op ? "op" : "??";
- l.clientPlatform = l.win ? "win" : l.mac ? "mac" : "???";
- return {
- onUnityEmbed: function(a) {
- $("unity_missing") && (a.success ? "missingUnityObject" == a.id ? ($("missingUnityObject").update(""), $("kongregateUnityDiv").update(""), top.location.replace(decodeURIComponent(kongregateAPI.getVariable("kongregate_game_url")))) : $("unity_missing").remove() : $("unity_missing").show())
- },
- initAPI: function(a, d) {
- e.push({
- object: a ||
- "KongregateAPI",
- callback: d || "OnKongregateAPILoaded"
- });
- kongregateAPI.loadAPI(function() {
- "undefined" === typeof kongregate && (kongregate = kongregateAPI.getAPI());
- for (var a = 0; a < e.length; a++) {
- var d = e[a];
- c().SendMessage(d.object, d.callback, b())
- }
- e = []
- })
- },
- getUnityObject: function() {
- return c()
- },
- getUserInfoString: function() {
- return b()
- },
- hijackUnityErrorHandler: function() {
- if (!kongregateAPI.disableUnityErrorHandler) {
- var a = window.Module;
- if (a && a.TOTAL_MEMORY && a.codeUrl) {
- var b = a.errorhandler;
- a.errorhandler = function(a,
- c, d) {
- if (a.match(/Permission denied to access property/)) {
- try {
- console.error("Caught error: " + a)
- } catch (e) {}
- return !0
- }
- return "function" === typeof b && b(a, c, d)
- }
- }
- }
- }
- }
- }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement