From 83aa7b2da4bb86ecd3742555c2271865d7cffd35 Mon Sep 17 00:00:00 2001 From: dustinlarimer Date: Mon, 20 Jul 2015 17:41:36 -0700 Subject: [PATCH] Refactor tests, deps, and specs Remove sinon.js, calling the API direct now - no more mystery Update configs to remove sinon.js refs Update specs for IE8/9, bump OSX test version --- CHANGELOG.md | 12 ++- README.md | 11 ++- dist/keen-tracking.js | 2 +- dist/keen-tracking.js.map | 2 +- dist/keen-tracking.min.js | 2 +- gulpfile.js | 29 ++++--- karma.conf.js | 2 +- lib/index.js | 2 +- package.json | 4 +- test/unit/helpers/client-config.js | 2 +- .../modules/record-events-browser-spec.js | 87 +++++-------------- test/unit/modules/utils/listener-spec.js | 15 ++-- 12 files changed, 71 insertions(+), 99 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce309c9..65de669 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,19 @@ # Unreleased --> + +# 0.0.2 + +**NEW:** +* Synchronous XHR option (#28, ported from keen-js) + +**BREAKING:** +* `.recordEvent` XHR calls now use POST, mirroring previous keen-js functionality (#27). +* `client.url()`: The previous keen-js implementation of `client.url()` automatically included `https://api.keen.io/3.0/projects/PROJECT_ID` + a `path` argument ('/events/whatever'), which severely limited its value. It now only returns `https://api.keen.io` + the path argument. + + # 0.0.1 Hello, world! **NEW:** - * [Everything](./README.md) :) diff --git a/README.md b/README.md index 01cd96b..0a60cad 100644 --- a/README.md +++ b/README.md @@ -36,13 +36,22 @@ If you haven't done so already, login to Keen IO to create a project. The Projec **Upgrading from keen-js:** -There are several new methods and name changes from keen-js, but fear not! We have included shims and legacy methods to make this library fully backward-compatible with the core functionality of keen-js. Here are the methods and their replacement methods: +There are several new methods and name changes from keen-js, but fear not! We have included shims and legacy methods to make this library fully backward-compatible with the core functionality of keen-js, aside from one breaking change to the `client.url()` method (detailed below). Here are the methods and their replacement methods: * `addEvent` and `addEvents` are now [`recordEvent`](#record-a-single-event) and [`recordEvents`](#record-multiple-events) * `setGlobalProperties` is now handled by the [`extendEvents`](#extend-events) methods * `trackExternalLinks` is now handled by the [DOM listeners](#listeners) utility (browser-only) Please avoid using these deprecated methods, as they will eventually get axed. Deprecation messages will be visible in the developer console if [debugging](#debugging) is enabled. +**Breaking change from keen-js:** the previous implementation of `client.url()` automatically included `https://api.keen.io/3.0/projects/PROJECT_ID` + a `path` argument ('/events/whatever'), which severely limited its value. It now only returns `https://api.keen.io` + the path argument. + +You can also now pass in an object to append a serialized query string to the result, like so: + +```javascript +var url = client.url('/3.0/projects', { key: 'value'} ); +// https://api.keen.io/3.0/projects?key=value +``` + **Additional resources:** diff --git a/dist/keen-tracking.js b/dist/keen-tracking.js index 8e38bb8..5886950 100644 --- a/dist/keen-tracking.js +++ b/dist/keen-tracking.js @@ -478,7 +478,7 @@ extend(Keen, { loaded: false, helpers: {}, utils: {}, - version: '0.0.1' + version: '0.0.2' }); Keen.log = function(message) { if (Keen.debug && typeof console == 'object') { diff --git a/dist/keen-tracking.js.map b/dist/keen-tracking.js.map index 7fd0788..81273bd 100644 --- a/dist/keen-tracking.js.map +++ b/dist/keen-tracking.js.map @@ -1 +1 @@ -{"version":3,"names":[],"mappings":"","sources":["keen-tracking.js"],"sourcesContent":["(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o or
DOM element');\n }\n if (timeoutCallback) {\n callback = function(){\n if(!triggered){\n triggered = true;\n timeoutCallback();\n }\n };\n }\n this.recordEvent(eventCollection, payload, callback);\n setTimeout(callback, timer);\n if (!evt.metaKey) {\n return false;\n }\n }\n\n // IE-specific polyfills, yay!\n // -----------------------------\n if (!Array.prototype.indexOf){\n Array.prototype.indexOf = function(elt /*, from*/) {\n var len = this.length >>> 0;\n\n var from = Number(arguments[1]) || 0;\n from = (from < 0)\n ? Math.ceil(from)\n : Math.floor(from);\n if (from < 0)\n from += len;\n\n for (; from < len; from++) {\n if (from in this &&\n this[from] === elt)\n return from;\n }\n return -1;\n };\n }\n\n module.exports = Keen;\n return Keen;\n});\n\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{\"./\":10,\"./defer-events\":2,\"./extend-events\":3,\"./helpers/getBrowserProfile\":4,\"./helpers/getDatetimeIndex\":5,\"./helpers/getDomNodePath\":6,\"./helpers/getScreenProfile\":7,\"./helpers/getUniqueId\":8,\"./helpers/getWindowProfile\":9,\"./record-events-browser\":11,\"./utils/cookie\":13,\"./utils/deepExtend\":14,\"./utils/each\":15,\"./utils/extend\":16,\"./utils/listener\":17,\"./utils/parseParams\":18,\"./utils/timer\":20}],2:[function(require,module,exports){\nvar Keen = require('./index');\nvar each = require('./utils/each');\nvar queue = require('./utils/queue');\n\nmodule.exports = {\n 'deferEvent': deferEvent,\n 'deferEvents': deferEvents,\n 'queueCapacity': queueCapacity,\n 'queueInterval': queueInterval,\n 'recordDeferredEvents': recordDeferredEvents\n};\n\nfunction deferEvent(eventCollection, eventBody){\n\n if (arguments.length !== 2 || typeof eventCollection !== 'string') {\n handleValidationError.call(this, 'Incorrect arguments provided to #deferEvent method');\n return;\n }\n\n this.queue.events[eventCollection] = this.queue.events[eventCollection] || [];\n this.queue.events[eventCollection].push(eventBody);\n this.queue.capacity++;\n this.emit('deferEvent', eventCollection, eventBody);\n return this;\n}\n\nfunction deferEvents(eventsHash){\n var self = this;\n\n if (arguments.length !== 1 || typeof eventsHash !== 'object') {\n handleValidationError.call(this, 'Incorrect arguments provided to #deferEvents method');\n return;\n }\n\n each(eventsHash, function(eventList, eventCollection){\n self.queue.events[eventCollection] = self.queue.events[eventCollection] || [];\n self.queue.events[eventCollection] = self.queue.events[eventCollection].concat(eventList);\n self.queue.capacity = self.queue.capacity + eventList.length;\n });\n self.emit('deferEvents', eventsHash);\n return self;\n}\n\nfunction queueCapacity(num){\n if (!arguments.length) return this.queue.config.capacity;\n this.queue.config.capacity = num ? Number(num): 0;\n return this;\n}\n\nfunction queueInterval(num){\n if (!arguments.length) return this.queue.config.interval;\n this.queue.config.interval = num ? Number(num): 0;\n return this;\n}\n\nfunction recordDeferredEvents(){\n var self = this, currentQueue;\n if (self.queue.capacity > 0) {\n currentQueue = JSON.parse(JSON.stringify(self.queue));\n self.queue = queue();\n self.queue.options = currentQueue.options;\n\n self.emit('recordDeferredEvents', currentQueue.events);\n self.recordEvents(currentQueue.events, function(err, res){\n if (err) {\n // Retry once\n self.recordEvents(currentQueue.events);\n }\n else {\n currentQueue = void 0;\n }\n });\n }\n return self;\n}\n\nfunction handleValidationError(message){\n var err = 'Event(s) not deferred: ' + message;\n this.emit('error', err);\n}\n\n},{\"./index\":10,\"./utils/each\":15,\"./utils/queue\":19}],3:[function(require,module,exports){\nvar deepExtend = require('./utils/deepExtend');\nvar each = require('./utils/each');\n\nmodule.exports = {\n 'extendEvent': extendEvent,\n 'extendEvents': extendEvents,\n 'getExtendedEventBody': getExtendedEventBody\n};\n\nfunction extendEvent(eventCollection, eventModifier){\n if (arguments.length !== 2 || typeof eventCollection !== 'string'\n || ('object' !== typeof eventModifier && 'function' !== typeof eventModifier)) {\n handleValidationError.call(this, 'Incorrect arguments provided to #extendEvent method');\n return;\n }\n this.extensions.collections[eventCollection] = this.extensions.collections[eventCollection] || [];\n this.extensions.collections[eventCollection].push(eventModifier);\n this.emit('extendEvent', eventCollection, eventModifier);\n return this;\n}\n\nfunction extendEvents(eventsModifier){\n if (arguments.length !== 1 || ('object' !== typeof eventsModifier && 'function' !== typeof eventsModifier)) {\n handleValidationError.call(this, 'Incorrect arguments provided to #extendEvents method');\n return;\n }\n this.extensions.events.push(eventsModifier);\n this.emit('extendEvents', eventsModifier);\n return this;\n}\n\nfunction handleValidationError(message){\n var err = 'Event(s) not extended: ' + message;\n this.emit('error', err);\n}\n\nfunction getExtendedEventBody(result, queue){\n if (queue && queue.length > 0) {\n each(queue, function(eventModifier, i){\n var modifierResult = (typeof eventModifier === 'function') ? eventModifier() : eventModifier;\n deepExtend(result, modifierResult);\n });\n }\n return result;\n}\n\n},{\"./utils/deepExtend\":14,\"./utils/each\":15}],4:[function(require,module,exports){\nvar getScreenProfile = require('./getScreenProfile'),\n getWindowProfile = require('./getWindowProfile');\n\nfunction getBrowserProfile(){\n return {\n 'cookies' : ('undefined' !== typeof navigator.cookieEnabled) ? navigator.cookieEnabled : false,\n 'codeName' : navigator.appCodeName,\n 'language' : navigator.language,\n 'name' : navigator.appName,\n 'online' : navigator.onLine,\n 'platform' : navigator.platform,\n 'useragent': navigator.userAgent,\n 'version' : navigator.appVersion,\n 'screen' : getScreenProfile(),\n 'window' : getWindowProfile()\n }\n}\n\nmodule.exports = getBrowserProfile;\n\n},{\"./getScreenProfile\":7,\"./getWindowProfile\":9}],5:[function(require,module,exports){\nfunction getDateTimeIndex(input){\n var date = input || new Date();\n return {\n 'hour_of_day' : date.getHours(),\n 'day_of_week' : parseInt( 1 + date.getDay() ),\n 'day_of_month' : date.getDate(),\n 'month' : parseInt( 1 + date.getMonth() ),\n 'year' : date.getFullYear()\n };\n}\n\nmodule.exports = getDateTimeIndex;\n\n},{}],6:[function(require,module,exports){\nfunction getDomNodePath(el){\n if (!el.nodeName) return '';\n\n var stack = [];\n while ( el.parentNode != null ) {\n // console.log(el.nodeName);\n var sibCount = 0;\n var sibIndex = 0;\n for ( var i = 0; i < el.parentNode.childNodes.length; i++ ) {\n var sib = el.parentNode.childNodes[i];\n if ( sib.nodeName == el.nodeName ) {\n if ( sib === el ) {\n sibIndex = sibCount;\n }\n sibCount++;\n }\n }\n if ( el.hasAttribute('id') && el.id != '' ) {\n stack.unshift(el.nodeName.toLowerCase() + '#' + el.id);\n } else if ( sibCount > 1 ) {\n stack.unshift(el.nodeName.toLowerCase() + ':eq(' + sibIndex + ')');\n } else {\n stack.unshift(el.nodeName.toLowerCase());\n }\n el = el.parentNode;\n }\n\n return stack.slice(1).join(' > ');\n}\n\nmodule.exports = getDomNodePath;\n\n// via: http://stackoverflow.com/a/16742828/2511985\n\n},{}],7:[function(require,module,exports){\nfunction getScreenProfile(){\n var keys, output;\n\n if ('undefined' == typeof window || !window.screen) return {};\n\n keys = ['height', 'width', 'colorDepth', 'pixelDepth', 'availHeight', 'availWidth'];\n output = {};\n\n for (var i = 0; i < keys.length; i++) {\n output[keys[i]] = window.screen[keys[i]] ? window.screen[keys[i]] : null;\n }\n\n output.orientation = {\n 'angle' : window.screen.orientation ? window.screen.orientation['angle'] : 0,\n 'type' : window.innerWidth > window.innerHeight ? 'landscape': 'portrait'\n };\n\n return output;\n}\n\nmodule.exports = getScreenProfile;\n\n},{}],8:[function(require,module,exports){\n// via: http://stackoverflow.com/a/2117523/2511985\n\nfunction getUniqueId(){\n var str = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n return str.replace(/[xy]/g, function(c) {\n var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);\n return v.toString(16);\n });\n}\n\nmodule.exports = getUniqueId;\n\n},{}],9:[function(require,module,exports){\nfunction getWindowProfile(){\n var body, html, output;\n\n if ('undefined' == typeof document) return {};\n\n body = document.body;\n html = document.documentElement;\n\n output = {\n 'height': ('innerHeight' in window) ? window.innerHeight : document.documentElement.offsetHeight,\n 'width': ('innerWidth' in window) ? window.innerWidth : document.documentElement.offsetWidth,\n 'scrollHeight': Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight ) || null\n };\n\n if (window.screen) {\n output.ratio = {\n 'height': (window.screen.availHeight) ? parseFloat( (window.innerHeight/window.screen.availHeight).toFixed(2) ) : null,\n 'width': (window.screen.availWidth) ? parseFloat( (window.innerWidth/window.screen.availWidth).toFixed(2) ) : null\n };\n }\n\n return output;\n}\n\nmodule.exports = getWindowProfile;\n\n/*\n Notes:\n document.documentElement.offsetHeight/Width is a workaround for IE8 and below, where window.innerHeight/Width is undefined\n*/\n\n},{}],10:[function(require,module,exports){\nvar Emitter = require('component-emitter');\nvar JSON2 = require('JSON2');\n\nvar each = require('./utils/each');\nvar extend = require('./utils/extend');\nvar queue = require('./utils/queue');\n\nvar root = this;\nvar previousKeen = root.Keen;\n\nvar Keen = function(config){\n this.configure(config);\n Keen.emit('client', this);\n};\n\nKeen.prototype.configure = function(config){\n var self = this, defaultProtocol;\n\n if (config['host']) {\n config['host'].replace(/.*?:\\/\\//g, '');\n }\n\n defaultProtocol = 'https';\n // IE<10 request shim\n if ('undefined' !== typeof document && document.all) {\n config['protocol'] = (document.location.protocol !== 'https:') ? 'http' : defaultProtocol;\n }\n\n self.config = self.config || {\n // projectId\n // writeKey\n host: 'api.keen.io',\n protocol: defaultProtocol,\n requestType: 'jsonp'\n // writePath (generated)\n };\n\n extend(self.config, config || {});\n\n self.queue = queue();\n self.queue.on('flush', function(){\n self.recordDeferredEvents();\n });\n\n self.extensions = {\n events: [],\n collections: {}\n };\n\n if (Keen.debug) {\n self.on('error', Keen.log);\n }\n self.emit('ready');\n return self;\n};\n\nKeen.prototype.projectId = function(str){\n if (!arguments.length) return this.config.projectId;\n this.config.projectId = (str ? String(str) : null);\n return this;\n};\n\nKeen.prototype.writeKey = function(str){\n if (!arguments.length) return this.config.writeKey;\n this.config.writeKey = (str ? String(str) : null);\n return this;\n};\n\nKeen.prototype.writePath = function(str){\n if (!arguments.length) {\n if (!this.projectId()) {\n this.emit('error', 'Keen is missing a projectId property');\n return;\n }\n return this.config.writePath ? this.config.writePath : ('/3.0/projects/' + this.projectId() + '/events');\n }\n this.config.writePath = (str ? String(str) : null);\n return this;\n};\n\nKeen.prototype.url = function(path, data){\n var url;\n if (!this.projectId()) {\n this.emit('error', 'Keen is missing a projectId property');\n return;\n }\n url = this.config.protocol + '://' + this.config.host; // + this.writePath();\n if (path) {\n url += path;\n }\n if (data) {\n url += '?' + serialize(data);\n }\n return url;\n};\n\n// ----------------------\n// DEPRECATED\n// ----------------------\nKeen.prototype.setGlobalProperties = function(props){\n this.emit('error', 'This method has been deprecated. Check out #extendEvents: https://github.com/keen/keen-tracking.js#extend-events');\n if (!props || typeof props !== 'function') {\n this.emit('error', 'Invalid value for global properties: ' + props);\n return;\n }\n this.config.globalProperties = props;\n return this;\n};\n\nEmitter(Keen);\nEmitter(Keen.prototype);\n\nextend(Keen, {\n debug: false,\n enabled: true,\n loaded: false,\n helpers: {},\n utils: {},\n version: '__VERSION__'\n});\n\nKeen.log = function(message) {\n if (Keen.debug && typeof console == 'object') {\n console.log('[Keen IO]', message);\n }\n};\n\nfunction serialize(data){\n var query = [];\n each(data, function(value, key){\n if ('string' !== typeof value) {\n value = JSON2.stringify(value);\n }\n query.push(key + '=' + encodeURIComponent(value));\n });\n return query.join('&');\n}\n\nmodule.exports = Keen;\n\n},{\"./utils/each\":15,\"./utils/extend\":16,\"./utils/queue\":19,\"JSON2\":22,\"component-emitter\":24}],11:[function(require,module,exports){\nvar Keen = require('./index');\nvar base64 = require('./utils/base64');\nvar each = require('./utils/each');\nvar extend = require('./utils/extend');\nvar extendEvents = require('./extend-events');\nvar JSON2 = require('JSON2');\n\nmodule.exports = {\n 'recordEvent': recordEvent,\n 'recordEvents': recordEvents,\n\n // DEPRECATED\n 'addEvent': addEvent,\n 'addEvents': addEvents\n};\n\n// ------------------------------\n// .recordEvent\n// ------------------------------\n\nfunction recordEvent(eventCollection, eventBody, callback, async){\n var url, data, cb, getRequestUrl, getRequestUrlOkLength, extendedEventBody, isAsync;\n\n url = this.url(this.writePath() + '/' + encodeURIComponent(eventCollection));\n data = {};\n cb = callback;\n\n // Requests are asynchronous by default\n isAsync = ('boolean' === typeof async) ? async : true;\n\n if (!checkValidation.call(this, cb)) {\n return;\n }\n\n if (!eventCollection || typeof eventCollection !== 'string') {\n handleValidationError.call(this, 'Collection name must be a string.', cb);\n return;\n }\n\n // ------------------------------\n // DEPRECATED\n // Apply client.globalProperties\n // ------------------------------\n if (this.config.globalProperties) {\n data = this.config.globalProperties(eventCollection);\n }\n extend(data, eventBody);\n\n // ------------------------------\n // Run extendEvent(s) transforms\n // ------------------------------\n extendedEventBody = {};\n extendEvents.getExtendedEventBody(extendedEventBody, this.extensions.events);\n extendEvents.getExtendedEventBody(extendedEventBody, this.extensions.collections[eventCollection]);\n extendEvents.getExtendedEventBody(extendedEventBody, [data]);\n\n this.emit('recordEvent', eventCollection, extendedEventBody);\n\n if (!Keen.enabled) {\n handleValidationError.call(this, 'Keen.enabled is set to false.', cb);\n return false;\n }\n\n // ------------------------------\n // Send event\n // ------------------------------\n\n getRequestUrl = this.url(this.writePath() + '/' + encodeURIComponent(eventCollection), {\n api_key : this.writeKey(),\n data : base64.encode(JSON2.stringify(extendedEventBody)),\n modified : new Date().getTime()\n });\n getRequestUrlOkLength = getRequestUrl.length < getUrlMaxLength();\n\n if (isAsync) {\n switch (this.config.requestType) {\n case 'xhr':\n sendXhr.call(this, 'POST', url, extendedEventBody, cb);\n break;\n case 'beacon':\n if (getRequestUrlOkLength) {\n sendBeacon.call(this, getRequestUrl, cb);\n }\n else {\n attemptPostXhr.call(this, url, extendedEventBody,\n 'Beacon URL length exceeds current browser limit, and XHR is not supported.', cb)\n }\n break;\n default:\n if (getRequestUrlOkLength) {\n sendJSONp.call(this, getRequestUrl, cb);\n }\n else {\n attemptPostXhr.call(this, url, extendedEventBody,\n 'JSONp URL length exceeds current browser limit, and XHR is not supported.', cb)\n }\n break;\n }\n }\n else {\n // Send synchronous request\n if (getRequestUrlOkLength) {\n sendSynchronousXhr(getRequestUrl);\n }\n }\n\n callback = cb = null;\n return this;\n}\n\n// ------------------------------\n// .recordEvents\n// ------------------------------\n\nfunction recordEvents(eventsHash, callback){\n var self = this, url, cb, extendedEventsHash;\n\n url = this.url(this.writePath());\n cb = callback;\n callback = null;\n\n if (!checkValidation.call(this, cb)) {\n return;\n }\n\n if ('object' !== typeof eventsHash || eventsHash instanceof Array) {\n handleValidationError.call(this, 'First argument must be an object', cb);\n return;\n }\n\n if (arguments.length > 2) {\n handleValidationError.call(this, 'Incorrect arguments provided to #recordEvents method', cb);\n return;\n }\n\n // ------------------------------\n // DEPRECATED\n // Apply client.globalProperties\n // ------------------------------\n if (this.config.globalProperties) {\n // Loop over each set of events\n each(eventsHash, function(events, collection){\n // Loop over each individual event\n each(events, function(body, index){\n // Start with global properties for this collection\n var modified = self.config.globalProperties(collection);\n // Apply provided properties for this event body\n eventsHash[collection][index] = extend(modified, body);\n });\n });\n }\n\n // ------------------------------\n // Run extendEvent(s) transforms\n // ------------------------------\n extendedEventsHash = {};\n each(eventsHash, function(eventList, eventCollection){\n // Find or create collection on new hash\n extendedEventsHash[eventCollection] = extendedEventsHash[eventCollection] || [];\n // Loop over each eventBody in the existing hash\n each(eventList, function(eventBody, index){\n // Create a new data object\n var extendedEventBody = {};\n // Process \"events\" transform pipeline\n extendEvents.getExtendedEventBody(extendedEventBody, self.extensions.events);\n // Process \"collection\" transform pipeline\n extendEvents.getExtendedEventBody(extendedEventBody, self.extensions.collections[eventCollection]);\n // Blend existing eventBody data into the result\n extendEvents.getExtendedEventBody(extendedEventBody, [eventBody]);\n // Push extendedEventBody into new hash\n extendedEventsHash[eventCollection].push(extendedEventBody);\n });\n });\n\n this.emit('recordEvents', extendedEventsHash);\n\n if (!Keen.enabled) {\n handleValidationError.call(this, 'Keen.enabled is set to false.', cb);\n return false;\n }\n\n if (getXhr()) {\n sendXhr.call(this, 'POST', url, extendedEventsHash, cb);\n }\n else {\n // each(eventsHash, function(eventArray, eventCollection){\n // ... send each individually?\n // });\n }\n\n callback = cb = null;\n return this;\n}\n\n\n// ----------------------\n// DEPRECATED\n// ----------------------\n\nfunction addEvent(){\n this.emit('error', 'This method has been deprecated. Check out #recordEvent: https://github.com/keen/keen-tracking.js#record-a-single-event');\n recordEvent.apply(this, arguments);\n}\n\nfunction addEvents(){\n this.emit('error', 'This method has been deprecated. Check out #recordEvents: https://github.com/keen/keen-tracking.js#record-multiple-events');\n recordEvents.apply(this, arguments);\n}\n\n\n// ------------------------------\n// Validation\n// ------------------------------\n\nfunction checkValidation(callback){\n var cb = callback;\n callback = null;\n\n if (!this.projectId()) {\n handleValidationError.call(this, 'Keen.Client is missing a projectId property.', cb);\n return false;\n }\n if (!this.writeKey()) {\n handleValidationError.call(this, 'Keen.Client is missing a writeKey property.', cb);\n return false;\n }\n return true;\n}\n\nfunction handleValidationError(message, cb){\n var err = 'Event(s) not recorded: ' + message;\n this.emit('error', err);\n if (cb) {\n cb.call(this, err, null);\n cb = null;\n }\n}\n\nfunction getUrlMaxLength(){\n if ('undefined' !== typeof window) {\n if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {\n return 2000;\n }\n }\n return 16000;\n}\n\n\n// ------------------------------\n// XHR Requests\n// ------------------------------\n\nfunction attemptPostXhr(url, data, noXhrError, callback) {\n if (getXhr()) {\n sendXhr.call(this, 'POST', url, data, callback);\n }\n else {\n handleValidationError.call(this, noXhrError);\n }\n}\n\nfunction sendXhr(method, url, data, callback){\n var self = this;\n var payload;\n var xhr = getXhr();\n var cb = callback;\n callback = null;\n\n xhr.onreadystatechange = function() {\n var response;\n if (xhr.readyState == 4) {\n if (xhr.status >= 200 && xhr.status < 300) {\n try {\n response = JSON2.parse(xhr.responseText);\n } catch (e) {\n Keen.emit('error', 'Could not parse HTTP response: ' + xhr.responseText);\n if (cb) {\n cb.call(self, xhr, null);\n }\n }\n if (cb && response) {\n cb.call(self, null, response);\n }\n }\n else {\n Keen.emit('error', 'HTTP request failed.');\n if (cb) {\n cb.call(self, xhr, null);\n }\n }\n }\n };\n\n xhr.open(method, url, true);\n xhr.setRequestHeader('Authorization', self.writeKey());\n xhr.setRequestHeader('Content-Type', 'application/json');\n\n if (data) {\n payload = JSON2.stringify(data);\n }\n\n if (method.toUpperCase() === 'GET') {\n xhr.send();\n }\n if (method.toUpperCase() === 'POST') {\n xhr.send(payload);\n }\n\n}\n\nfunction sendSynchronousXhr(url){\n var xhr = getXhr();\n if (xhr) {\n xhr.open('GET', url, false);\n xhr.send(null);\n }\n}\n\nfunction getXhr() {\n // yay, superagent!\n var root = 'undefined' == typeof window ? this : window;\n if (root.XMLHttpRequest && ('file:' != root.location.protocol || !root.ActiveXObject)) {\n return new XMLHttpRequest;\n } else {\n try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}\n }\n return false;\n};\n\n\n// ------------------------------\n// JSON-P Requests\n// ------------------------------\n\nfunction sendJSONp(url, callback){\n var self = this,\n cb = callback,\n timestamp = new Date().getTime(),\n script = document.createElement('script'),\n parent = document.getElementsByTagName('head')[0],\n callbackName = 'keenJSONPCallback',\n loaded = false;\n\n callback = null;\n\n callbackName += timestamp;\n while (callbackName in window) {\n callbackName += 'a';\n }\n window[callbackName] = function(response) {\n if (loaded === true) return;\n loaded = true;\n if (cb) {\n cb.call(self, null, response);\n }\n cleanup();\n };\n script.src = url + '&jsonp=' + callbackName;\n parent.appendChild(script);\n\n // for early IE w/ no onerror event\n script.onreadystatechange = function() {\n if (loaded === false && this.readyState === 'loaded') {\n loaded = true;\n handleError();\n cleanup();\n }\n };\n // non-ie, etc\n script.onerror = function() {\n // on IE9 both onerror and onreadystatechange are called\n if (loaded === false) {\n loaded = true;\n handleError();\n cleanup();\n }\n };\n\n function handleError(){\n if (cb) {\n cb.call(self, 'An error occurred!', null);\n }\n }\n\n function cleanup(){\n window[callbackName] = undefined;\n try {\n delete window[callbackName];\n } catch(e){};\n parent.removeChild(script);\n }\n\n}\n\n\n// ------------------------------\n// Image Beacon Requests\n// ------------------------------\n\nfunction sendBeacon(url, callback){\n var self = this,\n cb = callback,\n img = document.createElement('img'),\n loaded = false;\n\n callback = null;\n\n img.onload = function() {\n loaded = true;\n if ('naturalHeight' in this) {\n if (this.naturalHeight + this.naturalWidth === 0) {\n this.onerror();\n return;\n }\n } else if (this.width + this.height === 0) {\n this.onerror();\n return;\n }\n if (cb) {\n cb.call(self);\n }\n };\n img.onerror = function() {\n loaded = true;\n if (cb) {\n cb.call(self, 'An error occurred!', null);\n }\n };\n img.src = url + '&c=clv1';\n}\n\n},{\"./extend-events\":3,\"./index\":10,\"./utils/base64\":12,\"./utils/each\":15,\"./utils/extend\":16,\"JSON2\":22}],12:[function(require,module,exports){\nmodule.exports = {\n map: \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\",\n encode: function (n) {\n \"use strict\";\n var o = \"\", i = 0, m = this.map, i1, i2, i3, e1, e2, e3, e4;\n n = this.utf8.encode(n);\n while (i < n.length) {\n i1 = n.charCodeAt(i++); i2 = n.charCodeAt(i++); i3 = n.charCodeAt(i++);\n e1 = (i1 >> 2); e2 = (((i1 & 3) << 4) | (i2 >> 4)); e3 = (isNaN(i2) ? 64 : ((i2 & 15) << 2) | (i3 >> 6));\n e4 = (isNaN(i2) || isNaN(i3)) ? 64 : i3 & 63;\n o = o + m.charAt(e1) + m.charAt(e2) + m.charAt(e3) + m.charAt(e4);\n } return o;\n },\n decode: function (n) {\n \"use strict\";\n var o = \"\", i = 0, m = this.map, cc = String.fromCharCode, e1, e2, e3, e4, c1, c2, c3;\n n = n.replace(/[^A-Za-z0-9\\+\\/\\=]/g, \"\");\n while (i < n.length) {\n e1 = m.indexOf(n.charAt(i++)); e2 = m.indexOf(n.charAt(i++));\n e3 = m.indexOf(n.charAt(i++)); e4 = m.indexOf(n.charAt(i++));\n c1 = (e1 << 2) | (e2 >> 4); c2 = ((e2 & 15) << 4) | (e3 >> 2);\n c3 = ((e3 & 3) << 6) | e4;\n o = o + (cc(c1) + ((e3 != 64) ? cc(c2) : \"\")) + (((e4 != 64) ? cc(c3) : \"\"));\n } return this.utf8.decode(o);\n },\n utf8: {\n encode: function (n) {\n \"use strict\";\n var o = \"\", i = 0, cc = String.fromCharCode, c;\n while (i < n.length) {\n c = n.charCodeAt(i++); o = o + ((c < 128) ? cc(c) : ((c > 127) && (c < 2048)) ?\n (cc((c >> 6) | 192) + cc((c & 63) | 128)) : (cc((c >> 12) | 224) + cc(((c >> 6) & 63) | 128) + cc((c & 63) | 128)));\n } return o;\n },\n decode: function (n) {\n \"use strict\";\n var o = \"\", i = 0, cc = String.fromCharCode, c2, c;\n while (i < n.length) {\n c = n.charCodeAt(i);\n o = o + ((c < 128) ? [cc(c), i++][0] : ((c > 191) && (c < 224)) ?\n [cc(((c & 31) << 6) | ((c2 = n.charCodeAt(i + 1)) & 63)), (i += 2)][0] :\n [cc(((c & 15) << 12) | (((c2 = n.charCodeAt(i + 1)) & 63) << 6) | ((c3 = n.charCodeAt(i + 2)) & 63)), (i += 3)][0]);\n } return o;\n }\n }\n};\n\n},{}],13:[function(require,module,exports){\nvar Cookies = require('cookies-js');\nvar JSON2 = require('JSON2');\nvar extend = require('./extend');\n\nmodule.exports = cookie;\n\nfunction cookie(str){\n if (!arguments.length) return;\n if (this instanceof cookie === false) {\n return new cookie(str);\n }\n\n this.config = {\n key: str,\n options: {}\n };\n this.data = this.get();\n return this;\n}\n\ncookie.prototype.get = function(str){\n var data = Cookies.get(this.config.key) ? JSON2.parse( decodeURIComponent(Cookies.get(this.config.key)) ) : {};\n return (str && typeof data[str] !== 'undefined') ? data[str] : data;\n};\n\ncookie.prototype.set = function(str, value){\n if (!arguments.length) return this;\n if ('string' === typeof str && arguments.length === 2) {\n this.data[str] = value ? value : null;\n }\n else if ('object' === typeof str && arguments.length === 1) {\n extend(this.data, str);\n }\n Cookies.set(this.config.key, encodeURIComponent( JSON2.stringify(this.data) ), this.config.options);\n return this;\n};\n\ncookie.prototype.expire = function(){\n Cookies.expire(this.config.key);\n this.data = {};\n return this;\n};\n\ncookie.prototype.options = function(obj){\n if (!arguments.length) return this.config.options;\n this.config.options = (typeof obj === 'object') ? obj : {};\n return this;\n};\n\n},{\"./extend\":16,\"JSON2\":22,\"cookies-js\":25}],14:[function(require,module,exports){\nvar JSON2 = require('JSON2');\n\nmodule.exports = deepExtend;\n\nfunction deepExtend(target){\n for (var i = 1; i < arguments.length; i++) {\n // Copy unique items from incoming array\n if (target instanceof Array && arguments[i] instanceof Array) {\n for (var j = 0; j < arguments[i].length; j++) {\n if (target.indexOf(arguments[i][j]) < 0) {\n target.push(arguments[i][j]);\n }\n }\n }\n // Blend objects\n else {\n for (var prop in arguments[i]){\n // Recurse when both contain objects of same name and incoming is not a null object\n if ('undefined' !== typeof target[prop] && 'object' === typeof arguments[i][prop] && arguments[i][prop] !== null) {\n deepExtend(target[prop], clone(arguments[i][prop]));\n }\n // Otherwise just copy it over...\n else {\n target[prop] = clone(arguments[i][prop]);\n }\n }\n }\n }\n return target;\n}\n\nfunction clone(input){\n return JSON2.parse(JSON2.stringify(input))\n}\n\n},{\"JSON2\":22}],15:[function(require,module,exports){\nmodule.exports = each;\n\nfunction each(o, cb, s){\n var n;\n if (!o){\n return 0;\n }\n s = !s ? o : s;\n if (o instanceof Array){\n // Indexed arrays, needed for Safari\n for (n=0; n a\");\n\n // Listen for a given event\n myClicker.on(\"click\", function(e){\n // do stuff!\n });\n\n // Listen for event once\n myClicker.once(\"click\", function(e){ });\n\n // Cancel a given event listener\n myClicker.off(\"click\");\n\n // Cancel all event listners\n myClicker.off();\n\n*/\n\nmodule.exports = function(ctx){\n\n // Make sure this object exists\n ctx.domListeners = ctx.domListeners || {\n /*\n 'click': {\n '.nav li > a': [fn, fn, fn]\n }\n */\n };\n\n function listener(str){\n if (!str) return;\n if (this instanceof listener === false) {\n return new listener(str);\n }\n this.selector = str;\n return this;\n }\n\n listener.prototype.on = function(str, fn){\n var self = this;\n\n if (arguments.length !== 2 || 'string' !== typeof str || 'function' !== typeof fn) return this;\n\n // Set each listener on a parent dictionary, indexed by event:\n if ('undefined' === typeof ctx.domListeners[str]) {\n addListener(str, eventHandler(str));\n ctx.domListeners[str] = {};\n }\n ctx.domListeners[str][self.selector] = ctx.domListeners[str][self.selector] || [];\n ctx.domListeners[str][self.selector].push(fn);\n return self;\n };\n\n listener.prototype.once = function(str, fn){\n var self = this;\n function on() {\n self.off(str, on);\n return fn.apply(self, arguments);\n }\n on.fn = fn;\n self.on(str, on);\n return self;\n };\n\n listener.prototype.off = function(str, fn){\n var self = this, survivors = [];\n if (arguments.length === 2) {\n each(ctx.domListeners[str][self.selector], function(handler, i){\n if (handler === fn || handler.fn === fn) return;\n survivors.push(handler);\n });\n ctx.domListeners[str][self.selector] = survivors;\n }\n else if (arguments.length === 1) {\n try {\n delete ctx.domListeners[str][self.selector];\n }\n catch(e){\n ctx.domListeners[str][self.selector] = [];\n }\n }\n else {\n // loop over every eventType and delete handlers\n each(ctx.domListeners, function(hash, eventType){\n // if ('undefined' === typeof hash[str]) return;\n try {\n delete ctx.domListeners[eventType][self.selector];\n }\n catch(e){\n ctx.domListeners[eventType][self.selector] = function(){};\n }\n });\n }\n return self;\n };\n\n function eventHandler(eventType){\n return function(e){\n var evt, target;\n\n evt = e || window.event;\n target = evt.target || evt.srcElement;\n\n // If nothing assigned to this event type, let it go\n if ('undefined' === ctx.domListeners[eventType]) return;\n\n each(ctx.domListeners[eventType], function(handlers, key){\n\n if (matches(target, key)) {\n // Call all handlers for this eventType + node\n each(handlers, function(fn, i){\n if ('click' === eventType && 'A' === target.nodeName) {\n deferClickEvent(evt, target, fn);\n }\n else if ('submit' === eventType && 'FORM' === target.nodeName) {\n deferFormSubmit(evt, target, fn);\n }\n else {\n fn(evt);\n }\n });\n }\n else if ('window' === key) {\n // Call all handlers\n each(handlers, function(fn, i){\n fn(evt);\n });\n }\n return;\n });\n };\n }\n\n return listener;\n}\n\n\n// ------------------------------\n// Attach global event listener\n// ------------------------------\n\nfunction addListener(eventType, fn){\n if (document.addEventListener) {\n document.addEventListener(eventType, fn, false);\n } else {\n document.attachEvent(\"on\" + eventType, fn);\n }\n}\n\n\n// ------------------------------\n// Match DOM element to selector\n// ------------------------------\n\nfunction matches(elem, selector) {\n // We'll use querySelectorAll to find all element matching the selector,\n // then check if the given element is included in that list.\n // Executing the query on the parentNode reduces the resulting nodeList,\n // document doesn't have a parentNode, though.\n var nodeList = ( elem.parentNode || document ).querySelectorAll( selector ) || [],\n i = nodeList.length;\n\n // loop on the nodeList\n while ( i-- ) {\n if ( nodeList[i] == elem ) { return true; }\n }\n return false;\n}\n\n\n// ------------------------------\n// Handle 'click' events (A)\n// ------------------------------\n\nfunction deferClickEvent(evt, anchor, callback){\n var timeout = 500,\n targetAttr,\n cbResponse;\n\n // Get 'target' attribute from anchor\n if (anchor.getAttribute !== void 0) {\n targetAttr = anchor.getAttribute(\"target\");\n } else if (anchor.target) {\n targetAttr = anchor.target;\n }\n\n // Fire listener and catch possible response (return false)\n cbResponse = callback(evt);\n\n // If prevented within callback, bail:\n if (('boolean' === typeof cbResponse && cbResponse === false) || evt.defaultPrevented || evt.returnValue === false) {\n if (evt.preventDefault) {\n evt.preventDefault();\n }\n evt.returnValue = false;\n return false;\n }\n // Else if anchor doesn't kick off a new window or tab.. defer and replay the event:\n else if (targetAttr !== '_blank' && targetAttr !== 'blank' && !evt.metaKey) {\n if (evt.preventDefault) {\n evt.preventDefault();\n }\n evt.returnValue = false;\n setTimeout(function(){\n window.location = anchor.href;\n }, timeout);\n }\n\n return false;\n}\n\n\n// ------------------------------\n// Handle 'submit' events (FORM)\n// ------------------------------\n\nfunction deferFormSubmit(evt, form, callback){\n var timeout = 500;\n\n // Fire listener and catch possible response (return false)\n cbResponse = callback(evt);\n\n // If prevented within callback, bail\n if (('boolean' === typeof cbResponse && cbResponse === false) || evt.defaultPrevented || evt.returnValue === false) {\n if (evt.preventDefault) {\n evt.preventDefault();\n }\n evt.returnValue = false;\n return false;\n }\n // Defer and replay event\n else {\n if (evt.preventDefault) {\n evt.preventDefault();\n }\n evt.returnValue = false;\n setTimeout(function(){\n form.submit();\n }, timeout);\n }\n\n return false;\n}\n\n},{\"./each\":15,\"component-emitter\":24}],18:[function(require,module,exports){\nfunction parseParams(str){\n // via: http://stackoverflow.com/a/2880929/2511985\n var urlParams = {},\n match,\n pl = /\\+/g, // Regex for replacing addition symbol with a space\n search = /([^&=]+)=?([^&]*)/g,\n decode = function (s) { return decodeURIComponent(s.replace(pl, \" \")); },\n query = str.split(\"?\")[1];\n\n while (!!(match=search.exec(query))) {\n urlParams[decode(match[1])] = decode(match[2]);\n }\n return urlParams;\n};\n\nmodule.exports = parseParams;\n\n},{}],19:[function(require,module,exports){\nvar Emitter = require('component-emitter');\n\nmodule.exports = queue;\n\nfunction queue(){\n var self = this;\n if (this instanceof queue === false) {\n return new queue();\n }\n\n self.capacity = 0;\n self.interval = 0;\n\n self.config = {\n capacity: 5000,\n interval: 15\n };\n\n self.events = {\n // \"collection 1\": [],\n // \"collection 2\": []\n };\n\n setInterval(function(){\n self.interval++;\n checkQueue.call(self);\n }, 1000);\n\n return self;\n}\n\nfunction checkQueue(){\n if ((this.capacity > 0 && this.interval >= this.config.interval)\n || this.capacity >= this.config.capacity) {\n this.emit('flush');\n this.interval = 0;\n }\n}\n\nEmitter(queue.prototype);\n\n},{\"component-emitter\":24}],20:[function(require,module,exports){\nmodule.exports = timer;\n\nfunction timer(num){\n if (this instanceof timer === false) {\n return new timer(num);\n }\n this.count = num || 0;\n return this;\n}\n\ntimer.prototype.start = function(){\n var self = this;\n this.pause();\n this.interval = setInterval(function(){\n self.count++;\n }, 1000);\n return this;\n};\n\ntimer.prototype.pause = function(){\n clearInterval(this.interval);\n return this;\n};\n\ntimer.prototype.value = function(){\n return this.count;\n};\n\ntimer.prototype.clear = function(){\n this.count = 0;\n return this;\n};\n\n},{}],21:[function(require,module,exports){\n// cycle.js\n// 2011-08-24\n\n/*jslint evil: true, regexp: true */\n\n/*members $ref, apply, call, decycle, hasOwnProperty, length, prototype, push,\n retrocycle, stringify, test, toString\n*/\n\n(function (exports) {\n\nif (typeof exports.decycle !== 'function') {\n exports.decycle = function decycle(object) {\n 'use strict';\n\n// Make a deep copy of an object or array, assuring that there is at most\n// one instance of each object or array in the resulting structure. The\n// duplicate references (which might be forming cycles) are replaced with\n// an object of the form\n// {$ref: PATH}\n// where the PATH is a JSONPath string that locates the first occurance.\n// So,\n// var a = [];\n// a[0] = a;\n// return JSON.stringify(JSON.decycle(a));\n// produces the string '[{\"$ref\":\"$\"}]'.\n\n// JSONPath is used to locate the unique object. $ indicates the top level of\n// the object or array. [NUMBER] or [STRING] indicates a child member or\n// property.\n\n var objects = [], // Keep a reference to each unique object or array\n paths = []; // Keep the path to each unique object or array\n\n return (function derez(value, path) {\n\n// The derez recurses through the object, producing the deep copy.\n\n var i, // The loop counter\n name, // Property name\n nu; // The new object or array\n\n switch (typeof value) {\n case 'object':\n\n// typeof null === 'object', so get out if this value is not really an object.\n\n if (!value) {\n return null;\n }\n\n// If the value is an object or array, look to see if we have already\n// encountered it. If so, return a $ref/path object. This is a hard way,\n// linear search that will get slower as the number of unique objects grows.\n\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return {$ref: paths[i]};\n }\n }\n\n// Otherwise, accumulate the unique value and its path.\n\n objects.push(value);\n paths.push(path);\n\n// If it is an array, replicate the array.\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n\n// If it is an object, replicate the object.\n\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(value[name],\n path + '[' + JSON.stringify(name) + ']');\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n }(object, '$'));\n };\n}\n\n\nif (typeof exports.retrocycle !== 'function') {\n exports.retrocycle = function retrocycle($) {\n 'use strict';\n\n// Restore an object that was reduced by decycle. Members whose values are\n// objects of the form\n// {$ref: PATH}\n// are replaced with references to the value found by the PATH. This will\n// restore cycles. The object will be mutated.\n\n// The eval function is used to locate the values described by a PATH. The\n// root object is kept in a $ variable. A regular expression is used to\n// assure that the PATH is extremely well formed. The regexp contains nested\n// * quantifiers. That has been known to have extremely bad performance\n// problems on some browsers for very long strings. A PATH is expected to be\n// reasonably short. A PATH is allowed to belong to a very restricted subset of\n// Goessner's JSONPath.\n\n// So,\n// var s = '[{\"$ref\":\"$\"}]';\n// return JSON.retrocycle(JSON.parse(s));\n// produces an array containing a single element which is the array itself.\n\n var px =\n /^\\$(?:\\[(?:\\d+|\\\"(?:[^\\\\\\\"\\u0000-\\u001f]|\\\\([\\\\\\\"\\/bfnrt]|u[0-9a-zA-Z]{4}))*\\\")\\])*$/;\n\n (function rez(value) {\n\n// The rez function walks recursively through the object looking for $ref\n// properties. When it finds one that has a value that is a path, then it\n// replaces the $ref object with a reference to the value that is found by\n// the path.\n\n var i, item, name, path;\n\n if (value && typeof value === 'object') {\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n for (i = 0; i < value.length; i += 1) {\n item = value[i];\n if (item && typeof item === 'object') {\n path = item.$ref;\n if (typeof path === 'string' && px.test(path)) {\n value[i] = eval(path);\n } else {\n rez(item);\n }\n }\n }\n } else {\n for (name in value) {\n if (typeof value[name] === 'object') {\n item = value[name];\n if (item) {\n path = item.$ref;\n if (typeof path === 'string' && px.test(path)) {\n value[name] = eval(path);\n } else {\n rez(item);\n }\n }\n }\n }\n }\n }\n }($));\n return $;\n };\n}\n}) (\n (typeof exports !== 'undefined') ? \n exports : \n (window.JSON ? \n (window.JSON) :\n (window.JSON = {})\n )\n);\n\n},{}],22:[function(require,module,exports){\n// For use in Node.js\n\nvar JSON2 = require('./json2');\nvar cycle = require('./cycle');\n\nJSON2.decycle = cycle.decycle;\nJSON2.retrocycle = cycle.retrocycle;\n\nmodule.exports = JSON2;\n\n},{\"./cycle\":21,\"./json2\":23}],23:[function(require,module,exports){\n/*\n json2.js\n 2011-10-19\n\n Public Domain.\n\n NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\n See http://www.JSON.org/js.html\n\n\n This code should be minified before deployment.\n See http://javascript.crockford.com/jsmin.html\n\n USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO\n NOT CONTROL.\n\n\n This file creates a global JSON object containing two methods: stringify\n and parse.\n\n JSON.stringify(value, replacer, space)\n value any JavaScript value, usually an object or array.\n\n replacer an optional parameter that determines how object\n values are stringified for objects. It can be a\n function or an array of strings.\n\n space an optional parameter that specifies the indentation\n of nested structures. If it is omitted, the text will\n be packed without extra whitespace. If it is a number,\n it will specify the number of spaces to indent at each\n level. If it is a string (such as '\\t' or ' '),\n it contains the characters used to indent at each level.\n\n This method produces a JSON text from a JavaScript value.\n\n When an object value is found, if the object contains a toJSON\n method, its toJSON method will be called and the result will be\n stringified. A toJSON method does not serialize: it returns the\n value represented by the name/value pair that should be serialized,\n or undefined if nothing should be serialized. The toJSON method\n will be passed the key associated with the value, and this will be\n bound to the value\n\n For example, this would serialize Dates as ISO strings.\n\n Date.prototype.toJSON = function (key) {\n function f(n) {\n // Format integers to have at least two digits.\n return n < 10 ? '0' + n : n;\n }\n\n return this.getUTCFullYear() + '-' +\n f(this.getUTCMonth() + 1) + '-' +\n f(this.getUTCDate()) + 'T' +\n f(this.getUTCHours()) + ':' +\n f(this.getUTCMinutes()) + ':' +\n f(this.getUTCSeconds()) + 'Z';\n };\n\n You can provide an optional replacer method. It will be passed the\n key and value of each member, with this bound to the containing\n object. The value that is returned from your method will be\n serialized. If your method returns undefined, then the member will\n be excluded from the serialization.\n\n If the replacer parameter is an array of strings, then it will be\n used to select the members to be serialized. It filters the results\n such that only members with keys listed in the replacer array are\n stringified.\n\n Values that do not have JSON representations, such as undefined or\n functions, will not be serialized. Such values in objects will be\n dropped; in arrays they will be replaced with null. You can use\n a replacer function to replace those with JSON values.\n JSON.stringify(undefined) returns undefined.\n\n The optional space parameter produces a stringification of the\n value that is filled with line breaks and indentation to make it\n easier to read.\n\n If the space parameter is a non-empty string, then that string will\n be used for indentation. If the space parameter is a number, then\n the indentation will be that many spaces.\n\n Example:\n\n text = JSON.stringify(['e', {pluribus: 'unum'}]);\n // text is '[\"e\",{\"pluribus\":\"unum\"}]'\n\n\n text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\\t');\n // text is '[\\n\\t\"e\",\\n\\t{\\n\\t\\t\"pluribus\": \"unum\"\\n\\t}\\n]'\n\n text = JSON.stringify([new Date()], function (key, value) {\n return this[key] instanceof Date ?\n 'Date(' + this[key] + ')' : value;\n });\n // text is '[\"Date(---current time---)\"]'\n\n\n JSON.parse(text, reviver)\n This method parses a JSON text to produce an object or array.\n It can throw a SyntaxError exception.\n\n The optional reviver parameter is a function that can filter and\n transform the results. It receives each of the keys and values,\n and its return value is used instead of the original value.\n If it returns what it received, then the structure is not modified.\n If it returns undefined then the member is deleted.\n\n Example:\n\n // Parse the text. Values that look like ISO date strings will\n // be converted to Date objects.\n\n myData = JSON.parse(text, function (key, value) {\n var a;\n if (typeof value === 'string') {\n a =\n/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}(?:\\.\\d*)?)Z$/.exec(value);\n if (a) {\n return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],\n +a[5], +a[6]));\n }\n }\n return value;\n });\n\n myData = JSON.parse('[\"Date(09/09/2001)\"]', function (key, value) {\n var d;\n if (typeof value === 'string' &&\n value.slice(0, 5) === 'Date(' &&\n value.slice(-1) === ')') {\n d = new Date(value.slice(5, -1));\n if (d) {\n return d;\n }\n }\n return value;\n });\n\n\n This is a reference implementation. You are free to copy, modify, or\n redistribute.\n*/\n\n/*jslint evil: true, regexp: true */\n\n/*members \"\", \"\\b\", \"\\t\", \"\\n\", \"\\f\", \"\\r\", \"\\\"\", JSON, \"\\\\\", apply,\n call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,\n getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,\n lastIndex, length, parse, prototype, push, replace, slice, stringify,\n test, toJSON, toString, valueOf\n*/\n\n\n(function (JSON) {\n 'use strict';\n\n function f(n) {\n // Format integers to have at least two digits.\n return n < 10 ? '0' + n : n;\n }\n\n /* DDOPSON-2012-04-16 - mutating global prototypes is NOT allowed for a well-behaved module. \n * It's also unneeded, since Date already defines toJSON() to the same ISOwhatever format below\n * Thus, we skip this logic for the CommonJS case where 'exports' is defined\n */\n if (typeof exports === 'undefined') {\n if (typeof Date.prototype.toJSON !== 'function') {\n Date.prototype.toJSON = function (key) {\n\n return isFinite(this.valueOf())\n ? this.getUTCFullYear() + '-' +\n f(this.getUTCMonth() + 1) + '-' +\n f(this.getUTCDate()) + 'T' +\n f(this.getUTCHours()) + ':' +\n f(this.getUTCMinutes()) + ':' +\n f(this.getUTCSeconds()) + 'Z'\n : null;\n };\n }\n \n if (typeof String.prototype.toJSON !== 'function') {\n String.prototype.toJSON = function (key) { return this.valueOf(); };\n }\n\n if (typeof Number.prototype.toJSON !== 'function') {\n Number.prototype.toJSON = function (key) { return this.valueOf(); };\n }\n \n if (typeof Boolean.prototype.toJSON !== 'function') {\n Boolean.prototype.toJSON = function (key) { return this.valueOf(); };\n }\n }\n var cx = /[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n escapable = /[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n gap,\n indent,\n meta = { // table of character substitutions\n '\\b': '\\\\b',\n '\\t': '\\\\t',\n '\\n': '\\\\n',\n '\\f': '\\\\f',\n '\\r': '\\\\r',\n '\"' : '\\\\\"',\n '\\\\': '\\\\\\\\'\n },\n rep;\n\n\n function quote(string) {\n\n// If the string contains no control characters, no quote characters, and no\n// backslash characters, then we can safely slap some quotes around it.\n// Otherwise we must also replace the offending characters with safe escape\n// sequences.\n\n escapable.lastIndex = 0;\n return escapable.test(string) ? '\"' + string.replace(escapable, function (a) {\n var c = meta[a];\n return typeof c === 'string'\n ? c\n : '\\\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n }) + '\"' : '\"' + string + '\"';\n }\n\n\n function str(key, holder) {\n\n// Produce a string from holder[key].\n\n var i, // The loop counter.\n k, // The member key.\n v, // The member value.\n length,\n mind = gap,\n partial,\n value = holder[key];\n\n// If the value has a toJSON method, call it to obtain a replacement value.\n\n if (value && typeof value === 'object' &&\n typeof value.toJSON === 'function') {\n value = value.toJSON(key);\n }\n\n// If we were called with a replacer function, then call the replacer to\n// obtain a replacement value.\n\n if (typeof rep === 'function') {\n value = rep.call(holder, key, value);\n }\n\n// What happens next depends on the value's type.\n\n switch (typeof value) {\n case 'string':\n return quote(value);\n\n case 'number':\n\n// JSON numbers must be finite. Encode non-finite numbers as null.\n\n return isFinite(value) ? String(value) : 'null';\n\n case 'boolean':\n case 'null':\n\n// If the value is a boolean or null, convert it to a string. Note:\n// typeof null does not produce 'null'. The case is included here in\n// the remote chance that this gets fixed someday.\n\n return String(value);\n\n// If the type is 'object', we might be dealing with an object or an array or\n// null.\n\n case 'object':\n\n// Due to a specification blunder in ECMAScript, typeof null is 'object',\n// so watch out for that case.\n\n if (!value) {\n return 'null';\n }\n\n// Make an array to hold the partial results of stringifying this object value.\n\n gap += indent;\n partial = [];\n\n// Is the value an array?\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n\n// The value is an array. Stringify every element. Use null as a placeholder\n// for non-JSON values.\n\n length = value.length;\n for (i = 0; i < length; i += 1) {\n partial[i] = str(i, value) || 'null';\n }\n\n// Join all of the elements together, separated with commas, and wrap them in\n// brackets.\n\n v = partial.length === 0\n ? '[]'\n : gap\n ? '[\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + ']'\n : '[' + partial.join(',') + ']';\n gap = mind;\n return v;\n }\n\n// If the replacer is an array, use it to select the members to be stringified.\n\n if (rep && typeof rep === 'object') {\n length = rep.length;\n for (i = 0; i < length; i += 1) {\n if (typeof rep[i] === 'string') {\n k = rep[i];\n v = str(k, value);\n if (v) {\n partial.push(quote(k) + (gap ? ': ' : ':') + v);\n }\n }\n }\n } else {\n\n// Otherwise, iterate through all of the keys in the object.\n\n for (k in value) {\n if (Object.prototype.hasOwnProperty.call(value, k)) {\n v = str(k, value);\n if (v) {\n partial.push(quote(k) + (gap ? ': ' : ':') + v);\n }\n }\n }\n }\n\n// Join all of the member texts together, separated with commas,\n// and wrap them in braces.\n\n v = partial.length === 0\n ? '{}'\n : gap\n ? '{\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + '}'\n : '{' + partial.join(',') + '}';\n gap = mind;\n return v;\n }\n }\n\n// If the JSON object does not yet have a stringify method, give it one.\n\n if (typeof JSON.stringify !== 'function') {\n JSON.stringify = function (value, replacer, space) {\n\n// The stringify method takes a value and an optional replacer, and an optional\n// space parameter, and returns a JSON text. The replacer can be a function\n// that can replace values, or an array of strings that will select the keys.\n// A default replacer method can be provided. Use of the space parameter can\n// produce text that is more easily readable.\n\n var i;\n gap = '';\n indent = '';\n\n// If the space parameter is a number, make an indent string containing that\n// many spaces.\n\n if (typeof space === 'number') {\n for (i = 0; i < space; i += 1) {\n indent += ' ';\n }\n\n// If the space parameter is a string, it will be used as the indent string.\n\n } else if (typeof space === 'string') {\n indent = space;\n }\n\n// If there is a replacer, it must be a function or an array.\n// Otherwise, throw an error.\n\n rep = replacer;\n if (replacer && typeof replacer !== 'function' &&\n (typeof replacer !== 'object' ||\n typeof replacer.length !== 'number')) {\n throw new Error('JSON.stringify');\n }\n\n// Make a fake root object containing our value under the key of ''.\n// Return the result of stringifying the value.\n\n return str('', {'': value});\n };\n }\n\n\n// If the JSON object does not yet have a parse method, give it one.\n\n if (typeof JSON.parse !== 'function') {\n JSON.parse = function (text, reviver) {\n\n// The parse method takes a text and an optional reviver function, and returns\n// a JavaScript value if the text is a valid JSON text.\n\n var j;\n\n function walk(holder, key) {\n\n// The walk method is used to recursively walk the resulting structure so\n// that modifications can be made.\n\n var k, v, value = holder[key];\n if (value && typeof value === 'object') {\n for (k in value) {\n if (Object.prototype.hasOwnProperty.call(value, k)) {\n v = walk(value, k);\n if (v !== undefined) {\n value[k] = v;\n } else {\n delete value[k];\n }\n }\n }\n }\n return reviver.call(holder, key, value);\n }\n\n\n// Parsing happens in four stages. In the first stage, we replace certain\n// Unicode characters with escape sequences. JavaScript handles many characters\n// incorrectly, either silently deleting them, or treating them as line endings.\n\n text = String(text);\n cx.lastIndex = 0;\n if (cx.test(text)) {\n text = text.replace(cx, function (a) {\n return '\\\\u' +\n ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n });\n }\n\n// In the second stage, we run the text against regular expressions that look\n// for non-JSON patterns. We are especially concerned with '()' and 'new'\n// because they can cause invocation, and '=' because it can cause mutation.\n// But just to be safe, we want to reject all unexpected forms.\n\n// We split the second stage into 4 regexp operations in order to work around\n// crippling inefficiencies in IE's and Safari's regexp engines. First we\n// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we\n// replace all simple value tokens with ']' characters. Third, we delete all\n// open brackets that follow a colon or comma or that begin the text. Finally,\n// we look to see that the remaining characters are only whitespace or ']' or\n// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.\n\n if (/^[\\],:{}\\s]*$/\n .test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')\n .replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g, ']')\n .replace(/(?:^|:|,)(?:\\s*\\[)+/g, ''))) {\n\n// In the third stage we use the eval function to compile the text into a\n// JavaScript structure. The '{' operator is subject to a syntactic ambiguity\n// in JavaScript: it can begin a block or an object literal. We wrap the text\n// in parens to eliminate the ambiguity.\n\n j = eval('(' + text + ')');\n\n// In the optional fourth stage, we recursively walk the new structure, passing\n// each name/value pair to a reviver function for possible transformation.\n\n return typeof reviver === 'function'\n ? walk({'': j}, '')\n : j;\n }\n\n// If the text is not JSON parseable, then a SyntaxError is thrown.\n\n throw new SyntaxError('JSON.parse');\n };\n }\n})(\n \n // Create a JSON object only if one does not already exist. We create the\n // methods in a closure to avoid creating global variables.\n \n (typeof exports !== 'undefined') ? \n exports : \n (window.JSON ? \n (window.JSON) :\n (window.JSON = {})\n )\n);\n\n},{}],24:[function(require,module,exports){\n\n/**\n * Expose `Emitter`.\n */\n\nmodule.exports = Emitter;\n\n/**\n * Initialize a new `Emitter`.\n *\n * @api public\n */\n\nfunction Emitter(obj) {\n if (obj) return mixin(obj);\n};\n\n/**\n * Mixin the emitter properties.\n *\n * @param {Object} obj\n * @return {Object}\n * @api private\n */\n\nfunction mixin(obj) {\n for (var key in Emitter.prototype) {\n obj[key] = Emitter.prototype[key];\n }\n return obj;\n}\n\n/**\n * Listen on the given `event` with `fn`.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.on =\nEmitter.prototype.addEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n (this._callbacks['$' + event] = this._callbacks['$' + event] || [])\n .push(fn);\n return this;\n};\n\n/**\n * Adds an `event` listener that will be invoked a single\n * time then automatically removed.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.once = function(event, fn){\n function on() {\n this.off(event, on);\n fn.apply(this, arguments);\n }\n\n on.fn = fn;\n this.on(event, on);\n return this;\n};\n\n/**\n * Remove the given callback for `event` or all\n * registered callbacks.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.off =\nEmitter.prototype.removeListener =\nEmitter.prototype.removeAllListeners =\nEmitter.prototype.removeEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n\n // all\n if (0 == arguments.length) {\n this._callbacks = {};\n return this;\n }\n\n // specific event\n var callbacks = this._callbacks['$' + event];\n if (!callbacks) return this;\n\n // remove all handlers\n if (1 == arguments.length) {\n delete this._callbacks['$' + event];\n return this;\n }\n\n // remove specific handler\n var cb;\n for (var i = 0; i < callbacks.length; i++) {\n cb = callbacks[i];\n if (cb === fn || cb.fn === fn) {\n callbacks.splice(i, 1);\n break;\n }\n }\n return this;\n};\n\n/**\n * Emit `event` with the given args.\n *\n * @param {String} event\n * @param {Mixed} ...\n * @return {Emitter}\n */\n\nEmitter.prototype.emit = function(event){\n this._callbacks = this._callbacks || {};\n var args = [].slice.call(arguments, 1)\n , callbacks = this._callbacks['$' + event];\n\n if (callbacks) {\n callbacks = callbacks.slice(0);\n for (var i = 0, len = callbacks.length; i < len; ++i) {\n callbacks[i].apply(this, args);\n }\n }\n\n return this;\n};\n\n/**\n * Return array of callbacks for `event`.\n *\n * @param {String} event\n * @return {Array}\n * @api public\n */\n\nEmitter.prototype.listeners = function(event){\n this._callbacks = this._callbacks || {};\n return this._callbacks['$' + event] || [];\n};\n\n/**\n * Check if this emitter has `event` handlers.\n *\n * @param {String} event\n * @return {Boolean}\n * @api public\n */\n\nEmitter.prototype.hasListeners = function(event){\n return !! this.listeners(event).length;\n};\n\n},{}],25:[function(require,module,exports){\n/*\r\n * Cookies.js - 1.2.1\r\n * https://github.com/ScottHamper/Cookies\r\n *\r\n * This is free and unencumbered software released into the public domain.\r\n */\r\n(function (global, undefined) {\r\n 'use strict';\r\n\r\n var factory = function (window) {\r\n if (typeof window.document !== 'object') {\r\n throw new Error('Cookies.js requires a `window` with a `document` object');\r\n }\r\n\r\n var Cookies = function (key, value, options) {\r\n return arguments.length === 1 ?\r\n Cookies.get(key) : Cookies.set(key, value, options);\r\n };\r\n\r\n // Allows for setter injection in unit tests\r\n Cookies._document = window.document;\r\n\r\n // Used to ensure cookie keys do not collide with\r\n // built-in `Object` properties\r\n Cookies._cacheKeyPrefix = 'cookey.'; // Hurr hurr, :)\r\n \r\n Cookies._maxExpireDate = new Date('Fri, 31 Dec 9999 23:59:59 UTC');\r\n\r\n Cookies.defaults = {\r\n path: '/',\r\n secure: false\r\n };\r\n\r\n Cookies.get = function (key) {\r\n if (Cookies._cachedDocumentCookie !== Cookies._document.cookie) {\r\n Cookies._renewCache();\r\n }\r\n\r\n return Cookies._cache[Cookies._cacheKeyPrefix + key];\r\n };\r\n\r\n Cookies.set = function (key, value, options) {\r\n options = Cookies._getExtendedOptions(options);\r\n options.expires = Cookies._getExpiresDate(value === undefined ? -1 : options.expires);\r\n\r\n Cookies._document.cookie = Cookies._generateCookieString(key, value, options);\r\n\r\n return Cookies;\r\n };\r\n\r\n Cookies.expire = function (key, options) {\r\n return Cookies.set(key, undefined, options);\r\n };\r\n\r\n Cookies._getExtendedOptions = function (options) {\r\n return {\r\n path: options && options.path || Cookies.defaults.path,\r\n domain: options && options.domain || Cookies.defaults.domain,\r\n expires: options && options.expires || Cookies.defaults.expires,\r\n secure: options && options.secure !== undefined ? options.secure : Cookies.defaults.secure\r\n };\r\n };\r\n\r\n Cookies._isValidDate = function (date) {\r\n return Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime());\r\n };\r\n\r\n Cookies._getExpiresDate = function (expires, now) {\r\n now = now || new Date();\r\n\r\n if (typeof expires === 'number') {\r\n expires = expires === Infinity ?\r\n Cookies._maxExpireDate : new Date(now.getTime() + expires * 1000);\r\n } else if (typeof expires === 'string') {\r\n expires = new Date(expires);\r\n }\r\n\r\n if (expires && !Cookies._isValidDate(expires)) {\r\n throw new Error('`expires` parameter cannot be converted to a valid Date instance');\r\n }\r\n\r\n return expires;\r\n };\r\n\r\n Cookies._generateCookieString = function (key, value, options) {\r\n key = key.replace(/[^#$&+\\^`|]/g, encodeURIComponent);\r\n key = key.replace(/\\(/g, '%28').replace(/\\)/g, '%29');\r\n value = (value + '').replace(/[^!#$&-+\\--:<-\\[\\]-~]/g, encodeURIComponent);\r\n options = options || {};\r\n\r\n var cookieString = key + '=' + value;\r\n cookieString += options.path ? ';path=' + options.path : '';\r\n cookieString += options.domain ? ';domain=' + options.domain : '';\r\n cookieString += options.expires ? ';expires=' + options.expires.toUTCString() : '';\r\n cookieString += options.secure ? ';secure' : '';\r\n\r\n return cookieString;\r\n };\r\n\r\n Cookies._getCacheFromString = function (documentCookie) {\r\n var cookieCache = {};\r\n var cookiesArray = documentCookie ? documentCookie.split('; ') : [];\r\n\r\n for (var i = 0; i < cookiesArray.length; i++) {\r\n var cookieKvp = Cookies._getKeyValuePairFromCookieString(cookiesArray[i]);\r\n\r\n if (cookieCache[Cookies._cacheKeyPrefix + cookieKvp.key] === undefined) {\r\n cookieCache[Cookies._cacheKeyPrefix + cookieKvp.key] = cookieKvp.value;\r\n }\r\n }\r\n\r\n return cookieCache;\r\n };\r\n\r\n Cookies._getKeyValuePairFromCookieString = function (cookieString) {\r\n // \"=\" is a valid character in a cookie value according to RFC6265, so cannot `split('=')`\r\n var separatorIndex = cookieString.indexOf('=');\r\n\r\n // IE omits the \"=\" when the cookie value is an empty string\r\n separatorIndex = separatorIndex < 0 ? cookieString.length : separatorIndex;\r\n\r\n return {\r\n key: decodeURIComponent(cookieString.substr(0, separatorIndex)),\r\n value: decodeURIComponent(cookieString.substr(separatorIndex + 1))\r\n };\r\n };\r\n\r\n Cookies._renewCache = function () {\r\n Cookies._cache = Cookies._getCacheFromString(Cookies._document.cookie);\r\n Cookies._cachedDocumentCookie = Cookies._document.cookie;\r\n };\r\n\r\n Cookies._areEnabled = function () {\r\n var testKey = 'cookies.js';\r\n var areEnabled = Cookies.set(testKey, 1).get(testKey) === '1';\r\n Cookies.expire(testKey);\r\n return areEnabled;\r\n };\r\n\r\n Cookies.enabled = Cookies._areEnabled();\r\n\r\n return Cookies;\r\n };\r\n\r\n var cookiesExport = typeof global.document === 'object' ? factory(global) : factory;\r\n\r\n // AMD support\r\n if (typeof define === 'function' && define.amd) {\r\n define(function () { return cookiesExport; });\r\n // CommonJS/Node.js support\r\n } else if (typeof exports === 'object') {\r\n // Support Node.js specific `module.exports` (which can be a function)\r\n if (typeof module === 'object' && typeof module.exports === 'object') {\r\n exports = module.exports = cookiesExport;\r\n }\r\n // But always support CommonJS module 1.1.1 spec (`exports` cannot be a function)\r\n exports.Cookies = cookiesExport;\r\n } else {\r\n global.Cookies = cookiesExport;\r\n }\r\n})(typeof window === 'undefined' ? this : window);\n},{}]},{},[1]);\n"],"file":"keen-tracking.js","sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"names":[],"mappings":"","sources":["keen-tracking.js"],"sourcesContent":["(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o or DOM element');\n }\n if (timeoutCallback) {\n callback = function(){\n if(!triggered){\n triggered = true;\n timeoutCallback();\n }\n };\n }\n this.recordEvent(eventCollection, payload, callback);\n setTimeout(callback, timer);\n if (!evt.metaKey) {\n return false;\n }\n }\n\n // IE-specific polyfills, yay!\n // -----------------------------\n if (!Array.prototype.indexOf){\n Array.prototype.indexOf = function(elt /*, from*/) {\n var len = this.length >>> 0;\n\n var from = Number(arguments[1]) || 0;\n from = (from < 0)\n ? Math.ceil(from)\n : Math.floor(from);\n if (from < 0)\n from += len;\n\n for (; from < len; from++) {\n if (from in this &&\n this[from] === elt)\n return from;\n }\n return -1;\n };\n }\n\n module.exports = Keen;\n return Keen;\n});\n\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{\"./\":10,\"./defer-events\":2,\"./extend-events\":3,\"./helpers/getBrowserProfile\":4,\"./helpers/getDatetimeIndex\":5,\"./helpers/getDomNodePath\":6,\"./helpers/getScreenProfile\":7,\"./helpers/getUniqueId\":8,\"./helpers/getWindowProfile\":9,\"./record-events-browser\":11,\"./utils/cookie\":13,\"./utils/deepExtend\":14,\"./utils/each\":15,\"./utils/extend\":16,\"./utils/listener\":17,\"./utils/parseParams\":18,\"./utils/timer\":20}],2:[function(require,module,exports){\nvar Keen = require('./index');\nvar each = require('./utils/each');\nvar queue = require('./utils/queue');\n\nmodule.exports = {\n 'deferEvent': deferEvent,\n 'deferEvents': deferEvents,\n 'queueCapacity': queueCapacity,\n 'queueInterval': queueInterval,\n 'recordDeferredEvents': recordDeferredEvents\n};\n\nfunction deferEvent(eventCollection, eventBody){\n\n if (arguments.length !== 2 || typeof eventCollection !== 'string') {\n handleValidationError.call(this, 'Incorrect arguments provided to #deferEvent method');\n return;\n }\n\n this.queue.events[eventCollection] = this.queue.events[eventCollection] || [];\n this.queue.events[eventCollection].push(eventBody);\n this.queue.capacity++;\n this.emit('deferEvent', eventCollection, eventBody);\n return this;\n}\n\nfunction deferEvents(eventsHash){\n var self = this;\n\n if (arguments.length !== 1 || typeof eventsHash !== 'object') {\n handleValidationError.call(this, 'Incorrect arguments provided to #deferEvents method');\n return;\n }\n\n each(eventsHash, function(eventList, eventCollection){\n self.queue.events[eventCollection] = self.queue.events[eventCollection] || [];\n self.queue.events[eventCollection] = self.queue.events[eventCollection].concat(eventList);\n self.queue.capacity = self.queue.capacity + eventList.length;\n });\n self.emit('deferEvents', eventsHash);\n return self;\n}\n\nfunction queueCapacity(num){\n if (!arguments.length) return this.queue.config.capacity;\n this.queue.config.capacity = num ? Number(num): 0;\n return this;\n}\n\nfunction queueInterval(num){\n if (!arguments.length) return this.queue.config.interval;\n this.queue.config.interval = num ? Number(num): 0;\n return this;\n}\n\nfunction recordDeferredEvents(){\n var self = this, currentQueue;\n if (self.queue.capacity > 0) {\n currentQueue = JSON.parse(JSON.stringify(self.queue));\n self.queue = queue();\n self.queue.options = currentQueue.options;\n\n self.emit('recordDeferredEvents', currentQueue.events);\n self.recordEvents(currentQueue.events, function(err, res){\n if (err) {\n // Retry once\n self.recordEvents(currentQueue.events);\n }\n else {\n currentQueue = void 0;\n }\n });\n }\n return self;\n}\n\nfunction handleValidationError(message){\n var err = 'Event(s) not deferred: ' + message;\n this.emit('error', err);\n}\n\n},{\"./index\":10,\"./utils/each\":15,\"./utils/queue\":19}],3:[function(require,module,exports){\nvar deepExtend = require('./utils/deepExtend');\nvar each = require('./utils/each');\n\nmodule.exports = {\n 'extendEvent': extendEvent,\n 'extendEvents': extendEvents,\n 'getExtendedEventBody': getExtendedEventBody\n};\n\nfunction extendEvent(eventCollection, eventModifier){\n if (arguments.length !== 2 || typeof eventCollection !== 'string'\n || ('object' !== typeof eventModifier && 'function' !== typeof eventModifier)) {\n handleValidationError.call(this, 'Incorrect arguments provided to #extendEvent method');\n return;\n }\n this.extensions.collections[eventCollection] = this.extensions.collections[eventCollection] || [];\n this.extensions.collections[eventCollection].push(eventModifier);\n this.emit('extendEvent', eventCollection, eventModifier);\n return this;\n}\n\nfunction extendEvents(eventsModifier){\n if (arguments.length !== 1 || ('object' !== typeof eventsModifier && 'function' !== typeof eventsModifier)) {\n handleValidationError.call(this, 'Incorrect arguments provided to #extendEvents method');\n return;\n }\n this.extensions.events.push(eventsModifier);\n this.emit('extendEvents', eventsModifier);\n return this;\n}\n\nfunction handleValidationError(message){\n var err = 'Event(s) not extended: ' + message;\n this.emit('error', err);\n}\n\nfunction getExtendedEventBody(result, queue){\n if (queue && queue.length > 0) {\n each(queue, function(eventModifier, i){\n var modifierResult = (typeof eventModifier === 'function') ? eventModifier() : eventModifier;\n deepExtend(result, modifierResult);\n });\n }\n return result;\n}\n\n},{\"./utils/deepExtend\":14,\"./utils/each\":15}],4:[function(require,module,exports){\nvar getScreenProfile = require('./getScreenProfile'),\n getWindowProfile = require('./getWindowProfile');\n\nfunction getBrowserProfile(){\n return {\n 'cookies' : ('undefined' !== typeof navigator.cookieEnabled) ? navigator.cookieEnabled : false,\n 'codeName' : navigator.appCodeName,\n 'language' : navigator.language,\n 'name' : navigator.appName,\n 'online' : navigator.onLine,\n 'platform' : navigator.platform,\n 'useragent': navigator.userAgent,\n 'version' : navigator.appVersion,\n 'screen' : getScreenProfile(),\n 'window' : getWindowProfile()\n }\n}\n\nmodule.exports = getBrowserProfile;\n\n},{\"./getScreenProfile\":7,\"./getWindowProfile\":9}],5:[function(require,module,exports){\nfunction getDateTimeIndex(input){\n var date = input || new Date();\n return {\n 'hour_of_day' : date.getHours(),\n 'day_of_week' : parseInt( 1 + date.getDay() ),\n 'day_of_month' : date.getDate(),\n 'month' : parseInt( 1 + date.getMonth() ),\n 'year' : date.getFullYear()\n };\n}\n\nmodule.exports = getDateTimeIndex;\n\n},{}],6:[function(require,module,exports){\nfunction getDomNodePath(el){\n if (!el.nodeName) return '';\n\n var stack = [];\n while ( el.parentNode != null ) {\n // console.log(el.nodeName);\n var sibCount = 0;\n var sibIndex = 0;\n for ( var i = 0; i < el.parentNode.childNodes.length; i++ ) {\n var sib = el.parentNode.childNodes[i];\n if ( sib.nodeName == el.nodeName ) {\n if ( sib === el ) {\n sibIndex = sibCount;\n }\n sibCount++;\n }\n }\n if ( el.hasAttribute('id') && el.id != '' ) {\n stack.unshift(el.nodeName.toLowerCase() + '#' + el.id);\n } else if ( sibCount > 1 ) {\n stack.unshift(el.nodeName.toLowerCase() + ':eq(' + sibIndex + ')');\n } else {\n stack.unshift(el.nodeName.toLowerCase());\n }\n el = el.parentNode;\n }\n\n return stack.slice(1).join(' > ');\n}\n\nmodule.exports = getDomNodePath;\n\n// via: http://stackoverflow.com/a/16742828/2511985\n\n},{}],7:[function(require,module,exports){\nfunction getScreenProfile(){\n var keys, output;\n\n if ('undefined' == typeof window || !window.screen) return {};\n\n keys = ['height', 'width', 'colorDepth', 'pixelDepth', 'availHeight', 'availWidth'];\n output = {};\n\n for (var i = 0; i < keys.length; i++) {\n output[keys[i]] = window.screen[keys[i]] ? window.screen[keys[i]] : null;\n }\n\n output.orientation = {\n 'angle' : window.screen.orientation ? window.screen.orientation['angle'] : 0,\n 'type' : window.innerWidth > window.innerHeight ? 'landscape': 'portrait'\n };\n\n return output;\n}\n\nmodule.exports = getScreenProfile;\n\n},{}],8:[function(require,module,exports){\n// via: http://stackoverflow.com/a/2117523/2511985\n\nfunction getUniqueId(){\n var str = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n return str.replace(/[xy]/g, function(c) {\n var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);\n return v.toString(16);\n });\n}\n\nmodule.exports = getUniqueId;\n\n},{}],9:[function(require,module,exports){\nfunction getWindowProfile(){\n var body, html, output;\n\n if ('undefined' == typeof document) return {};\n\n body = document.body;\n html = document.documentElement;\n\n output = {\n 'height': ('innerHeight' in window) ? window.innerHeight : document.documentElement.offsetHeight,\n 'width': ('innerWidth' in window) ? window.innerWidth : document.documentElement.offsetWidth,\n 'scrollHeight': Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight ) || null\n };\n\n if (window.screen) {\n output.ratio = {\n 'height': (window.screen.availHeight) ? parseFloat( (window.innerHeight/window.screen.availHeight).toFixed(2) ) : null,\n 'width': (window.screen.availWidth) ? parseFloat( (window.innerWidth/window.screen.availWidth).toFixed(2) ) : null\n };\n }\n\n return output;\n}\n\nmodule.exports = getWindowProfile;\n\n/*\n Notes:\n document.documentElement.offsetHeight/Width is a workaround for IE8 and below, where window.innerHeight/Width is undefined\n*/\n\n},{}],10:[function(require,module,exports){\nvar Emitter = require('component-emitter');\nvar JSON2 = require('JSON2');\n\nvar each = require('./utils/each');\nvar extend = require('./utils/extend');\nvar queue = require('./utils/queue');\n\nvar root = this;\nvar previousKeen = root.Keen;\n\nvar Keen = function(config){\n this.configure(config);\n Keen.emit('client', this);\n};\n\nKeen.prototype.configure = function(config){\n var self = this, defaultProtocol;\n\n if (config['host']) {\n config['host'].replace(/.*?:\\/\\//g, '');\n }\n\n defaultProtocol = 'https';\n // IE<10 request shim\n if ('undefined' !== typeof document && document.all) {\n config['protocol'] = (document.location.protocol !== 'https:') ? 'http' : defaultProtocol;\n }\n\n self.config = self.config || {\n // projectId\n // writeKey\n host: 'api.keen.io',\n protocol: defaultProtocol,\n requestType: 'jsonp'\n // writePath (generated)\n };\n\n extend(self.config, config || {});\n\n self.queue = queue();\n self.queue.on('flush', function(){\n self.recordDeferredEvents();\n });\n\n self.extensions = {\n events: [],\n collections: {}\n };\n\n if (Keen.debug) {\n self.on('error', Keen.log);\n }\n self.emit('ready');\n return self;\n};\n\nKeen.prototype.projectId = function(str){\n if (!arguments.length) return this.config.projectId;\n this.config.projectId = (str ? String(str) : null);\n return this;\n};\n\nKeen.prototype.writeKey = function(str){\n if (!arguments.length) return this.config.writeKey;\n this.config.writeKey = (str ? String(str) : null);\n return this;\n};\n\nKeen.prototype.writePath = function(str){\n if (!arguments.length) {\n if (!this.projectId()) {\n this.emit('error', 'Keen is missing a projectId property');\n return;\n }\n return this.config.writePath ? this.config.writePath : ('/3.0/projects/' + this.projectId() + '/events');\n }\n this.config.writePath = (str ? String(str) : null);\n return this;\n};\n\nKeen.prototype.url = function(path, data){\n var url;\n if (!this.projectId()) {\n this.emit('error', 'Keen is missing a projectId property');\n return;\n }\n url = this.config.protocol + '://' + this.config.host;\n if (path) {\n url += path;\n }\n if (data) {\n url += '?' + serialize(data);\n }\n return url;\n};\n\n// ----------------------\n// DEPRECATED\n// ----------------------\nKeen.prototype.setGlobalProperties = function(props){\n this.emit('error', 'This method has been deprecated. Check out #extendEvents: https://github.com/keen/keen-tracking.js#extend-events');\n if (!props || typeof props !== 'function') {\n this.emit('error', 'Invalid value for global properties: ' + props);\n return;\n }\n this.config.globalProperties = props;\n return this;\n};\n\nEmitter(Keen);\nEmitter(Keen.prototype);\n\nextend(Keen, {\n debug: false,\n enabled: true,\n loaded: false,\n helpers: {},\n utils: {},\n version: '__VERSION__'\n});\n\nKeen.log = function(message) {\n if (Keen.debug && typeof console == 'object') {\n console.log('[Keen IO]', message);\n }\n};\n\nfunction serialize(data){\n var query = [];\n each(data, function(value, key){\n if ('string' !== typeof value) {\n value = JSON2.stringify(value);\n }\n query.push(key + '=' + encodeURIComponent(value));\n });\n return query.join('&');\n}\n\nmodule.exports = Keen;\n\n},{\"./utils/each\":15,\"./utils/extend\":16,\"./utils/queue\":19,\"JSON2\":22,\"component-emitter\":24}],11:[function(require,module,exports){\nvar Keen = require('./index');\nvar base64 = require('./utils/base64');\nvar each = require('./utils/each');\nvar extend = require('./utils/extend');\nvar extendEvents = require('./extend-events');\nvar JSON2 = require('JSON2');\n\nmodule.exports = {\n 'recordEvent': recordEvent,\n 'recordEvents': recordEvents,\n\n // DEPRECATED\n 'addEvent': addEvent,\n 'addEvents': addEvents\n};\n\n// ------------------------------\n// .recordEvent\n// ------------------------------\n\nfunction recordEvent(eventCollection, eventBody, callback, async){\n var url, data, cb, getRequestUrl, getRequestUrlOkLength, extendedEventBody, isAsync;\n\n url = this.url(this.writePath() + '/' + encodeURIComponent(eventCollection));\n data = {};\n cb = callback;\n\n // Requests are asynchronous by default\n isAsync = ('boolean' === typeof async) ? async : true;\n\n if (!checkValidation.call(this, cb)) {\n return;\n }\n\n if (!eventCollection || typeof eventCollection !== 'string') {\n handleValidationError.call(this, 'Collection name must be a string.', cb);\n return;\n }\n\n // ------------------------------\n // DEPRECATED\n // Apply client.globalProperties\n // ------------------------------\n if (this.config.globalProperties) {\n data = this.config.globalProperties(eventCollection);\n }\n extend(data, eventBody);\n\n // ------------------------------\n // Run extendEvent(s) transforms\n // ------------------------------\n extendedEventBody = {};\n extendEvents.getExtendedEventBody(extendedEventBody, this.extensions.events);\n extendEvents.getExtendedEventBody(extendedEventBody, this.extensions.collections[eventCollection]);\n extendEvents.getExtendedEventBody(extendedEventBody, [data]);\n\n this.emit('recordEvent', eventCollection, extendedEventBody);\n\n if (!Keen.enabled) {\n handleValidationError.call(this, 'Keen.enabled is set to false.', cb);\n return false;\n }\n\n // ------------------------------\n // Send event\n // ------------------------------\n\n getRequestUrl = this.url(this.writePath() + '/' + encodeURIComponent(eventCollection), {\n api_key : this.writeKey(),\n data : base64.encode(JSON2.stringify(extendedEventBody)),\n modified : new Date().getTime()\n });\n getRequestUrlOkLength = getRequestUrl.length < getUrlMaxLength();\n\n if (isAsync) {\n switch (this.config.requestType) {\n case 'xhr':\n sendXhr.call(this, 'POST', url, extendedEventBody, cb);\n break;\n case 'beacon':\n if (getRequestUrlOkLength) {\n sendBeacon.call(this, getRequestUrl, cb);\n }\n else {\n attemptPostXhr.call(this, url, extendedEventBody,\n 'Beacon URL length exceeds current browser limit, and XHR is not supported.', cb)\n }\n break;\n default:\n if (getRequestUrlOkLength) {\n sendJSONp.call(this, getRequestUrl, cb);\n }\n else {\n attemptPostXhr.call(this, url, extendedEventBody,\n 'JSONp URL length exceeds current browser limit, and XHR is not supported.', cb)\n }\n break;\n }\n }\n else {\n // Send synchronous request\n if (getRequestUrlOkLength) {\n sendSynchronousXhr(getRequestUrl);\n }\n }\n\n callback = cb = null;\n return this;\n}\n\n// ------------------------------\n// .recordEvents\n// ------------------------------\n\nfunction recordEvents(eventsHash, callback){\n var self = this, url, cb, extendedEventsHash;\n\n url = this.url(this.writePath());\n cb = callback;\n callback = null;\n\n if (!checkValidation.call(this, cb)) {\n return;\n }\n\n if ('object' !== typeof eventsHash || eventsHash instanceof Array) {\n handleValidationError.call(this, 'First argument must be an object', cb);\n return;\n }\n\n if (arguments.length > 2) {\n handleValidationError.call(this, 'Incorrect arguments provided to #recordEvents method', cb);\n return;\n }\n\n // ------------------------------\n // DEPRECATED\n // Apply client.globalProperties\n // ------------------------------\n if (this.config.globalProperties) {\n // Loop over each set of events\n each(eventsHash, function(events, collection){\n // Loop over each individual event\n each(events, function(body, index){\n // Start with global properties for this collection\n var modified = self.config.globalProperties(collection);\n // Apply provided properties for this event body\n eventsHash[collection][index] = extend(modified, body);\n });\n });\n }\n\n // ------------------------------\n // Run extendEvent(s) transforms\n // ------------------------------\n extendedEventsHash = {};\n each(eventsHash, function(eventList, eventCollection){\n // Find or create collection on new hash\n extendedEventsHash[eventCollection] = extendedEventsHash[eventCollection] || [];\n // Loop over each eventBody in the existing hash\n each(eventList, function(eventBody, index){\n // Create a new data object\n var extendedEventBody = {};\n // Process \"events\" transform pipeline\n extendEvents.getExtendedEventBody(extendedEventBody, self.extensions.events);\n // Process \"collection\" transform pipeline\n extendEvents.getExtendedEventBody(extendedEventBody, self.extensions.collections[eventCollection]);\n // Blend existing eventBody data into the result\n extendEvents.getExtendedEventBody(extendedEventBody, [eventBody]);\n // Push extendedEventBody into new hash\n extendedEventsHash[eventCollection].push(extendedEventBody);\n });\n });\n\n this.emit('recordEvents', extendedEventsHash);\n\n if (!Keen.enabled) {\n handleValidationError.call(this, 'Keen.enabled is set to false.', cb);\n return false;\n }\n\n if (getXhr()) {\n sendXhr.call(this, 'POST', url, extendedEventsHash, cb);\n }\n else {\n // each(eventsHash, function(eventArray, eventCollection){\n // ... send each individually?\n // });\n }\n\n callback = cb = null;\n return this;\n}\n\n\n// ----------------------\n// DEPRECATED\n// ----------------------\n\nfunction addEvent(){\n this.emit('error', 'This method has been deprecated. Check out #recordEvent: https://github.com/keen/keen-tracking.js#record-a-single-event');\n recordEvent.apply(this, arguments);\n}\n\nfunction addEvents(){\n this.emit('error', 'This method has been deprecated. Check out #recordEvents: https://github.com/keen/keen-tracking.js#record-multiple-events');\n recordEvents.apply(this, arguments);\n}\n\n\n// ------------------------------\n// Validation\n// ------------------------------\n\nfunction checkValidation(callback){\n var cb = callback;\n callback = null;\n\n if (!this.projectId()) {\n handleValidationError.call(this, 'Keen.Client is missing a projectId property.', cb);\n return false;\n }\n if (!this.writeKey()) {\n handleValidationError.call(this, 'Keen.Client is missing a writeKey property.', cb);\n return false;\n }\n return true;\n}\n\nfunction handleValidationError(message, cb){\n var err = 'Event(s) not recorded: ' + message;\n this.emit('error', err);\n if (cb) {\n cb.call(this, err, null);\n cb = null;\n }\n}\n\nfunction getUrlMaxLength(){\n if ('undefined' !== typeof window) {\n if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {\n return 2000;\n }\n }\n return 16000;\n}\n\n\n// ------------------------------\n// XHR Requests\n// ------------------------------\n\nfunction attemptPostXhr(url, data, noXhrError, callback) {\n if (getXhr()) {\n sendXhr.call(this, 'POST', url, data, callback);\n }\n else {\n handleValidationError.call(this, noXhrError);\n }\n}\n\nfunction sendXhr(method, url, data, callback){\n var self = this;\n var payload;\n var xhr = getXhr();\n var cb = callback;\n callback = null;\n\n xhr.onreadystatechange = function() {\n var response;\n if (xhr.readyState == 4) {\n if (xhr.status >= 200 && xhr.status < 300) {\n try {\n response = JSON2.parse(xhr.responseText);\n } catch (e) {\n Keen.emit('error', 'Could not parse HTTP response: ' + xhr.responseText);\n if (cb) {\n cb.call(self, xhr, null);\n }\n }\n if (cb && response) {\n cb.call(self, null, response);\n }\n }\n else {\n Keen.emit('error', 'HTTP request failed.');\n if (cb) {\n cb.call(self, xhr, null);\n }\n }\n }\n };\n\n xhr.open(method, url, true);\n xhr.setRequestHeader('Authorization', self.writeKey());\n xhr.setRequestHeader('Content-Type', 'application/json');\n\n if (data) {\n payload = JSON2.stringify(data);\n }\n\n if (method.toUpperCase() === 'GET') {\n xhr.send();\n }\n if (method.toUpperCase() === 'POST') {\n xhr.send(payload);\n }\n\n}\n\nfunction sendSynchronousXhr(url){\n var xhr = getXhr();\n if (xhr) {\n xhr.open('GET', url, false);\n xhr.send(null);\n }\n}\n\nfunction getXhr() {\n // yay, superagent!\n var root = 'undefined' == typeof window ? this : window;\n if (root.XMLHttpRequest && ('file:' != root.location.protocol || !root.ActiveXObject)) {\n return new XMLHttpRequest;\n } else {\n try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}\n try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}\n }\n return false;\n};\n\n\n// ------------------------------\n// JSON-P Requests\n// ------------------------------\n\nfunction sendJSONp(url, callback){\n var self = this,\n cb = callback,\n timestamp = new Date().getTime(),\n script = document.createElement('script'),\n parent = document.getElementsByTagName('head')[0],\n callbackName = 'keenJSONPCallback',\n loaded = false;\n\n callback = null;\n\n callbackName += timestamp;\n while (callbackName in window) {\n callbackName += 'a';\n }\n window[callbackName] = function(response) {\n if (loaded === true) return;\n loaded = true;\n if (cb) {\n cb.call(self, null, response);\n }\n cleanup();\n };\n script.src = url + '&jsonp=' + callbackName;\n parent.appendChild(script);\n\n // for early IE w/ no onerror event\n script.onreadystatechange = function() {\n if (loaded === false && this.readyState === 'loaded') {\n loaded = true;\n handleError();\n cleanup();\n }\n };\n // non-ie, etc\n script.onerror = function() {\n // on IE9 both onerror and onreadystatechange are called\n if (loaded === false) {\n loaded = true;\n handleError();\n cleanup();\n }\n };\n\n function handleError(){\n if (cb) {\n cb.call(self, 'An error occurred!', null);\n }\n }\n\n function cleanup(){\n window[callbackName] = undefined;\n try {\n delete window[callbackName];\n } catch(e){};\n parent.removeChild(script);\n }\n\n}\n\n\n// ------------------------------\n// Image Beacon Requests\n// ------------------------------\n\nfunction sendBeacon(url, callback){\n var self = this,\n cb = callback,\n img = document.createElement('img'),\n loaded = false;\n\n callback = null;\n\n img.onload = function() {\n loaded = true;\n if ('naturalHeight' in this) {\n if (this.naturalHeight + this.naturalWidth === 0) {\n this.onerror();\n return;\n }\n } else if (this.width + this.height === 0) {\n this.onerror();\n return;\n }\n if (cb) {\n cb.call(self);\n }\n };\n img.onerror = function() {\n loaded = true;\n if (cb) {\n cb.call(self, 'An error occurred!', null);\n }\n };\n img.src = url + '&c=clv1';\n}\n\n},{\"./extend-events\":3,\"./index\":10,\"./utils/base64\":12,\"./utils/each\":15,\"./utils/extend\":16,\"JSON2\":22}],12:[function(require,module,exports){\nmodule.exports = {\n map: \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\",\n encode: function (n) {\n \"use strict\";\n var o = \"\", i = 0, m = this.map, i1, i2, i3, e1, e2, e3, e4;\n n = this.utf8.encode(n);\n while (i < n.length) {\n i1 = n.charCodeAt(i++); i2 = n.charCodeAt(i++); i3 = n.charCodeAt(i++);\n e1 = (i1 >> 2); e2 = (((i1 & 3) << 4) | (i2 >> 4)); e3 = (isNaN(i2) ? 64 : ((i2 & 15) << 2) | (i3 >> 6));\n e4 = (isNaN(i2) || isNaN(i3)) ? 64 : i3 & 63;\n o = o + m.charAt(e1) + m.charAt(e2) + m.charAt(e3) + m.charAt(e4);\n } return o;\n },\n decode: function (n) {\n \"use strict\";\n var o = \"\", i = 0, m = this.map, cc = String.fromCharCode, e1, e2, e3, e4, c1, c2, c3;\n n = n.replace(/[^A-Za-z0-9\\+\\/\\=]/g, \"\");\n while (i < n.length) {\n e1 = m.indexOf(n.charAt(i++)); e2 = m.indexOf(n.charAt(i++));\n e3 = m.indexOf(n.charAt(i++)); e4 = m.indexOf(n.charAt(i++));\n c1 = (e1 << 2) | (e2 >> 4); c2 = ((e2 & 15) << 4) | (e3 >> 2);\n c3 = ((e3 & 3) << 6) | e4;\n o = o + (cc(c1) + ((e3 != 64) ? cc(c2) : \"\")) + (((e4 != 64) ? cc(c3) : \"\"));\n } return this.utf8.decode(o);\n },\n utf8: {\n encode: function (n) {\n \"use strict\";\n var o = \"\", i = 0, cc = String.fromCharCode, c;\n while (i < n.length) {\n c = n.charCodeAt(i++); o = o + ((c < 128) ? cc(c) : ((c > 127) && (c < 2048)) ?\n (cc((c >> 6) | 192) + cc((c & 63) | 128)) : (cc((c >> 12) | 224) + cc(((c >> 6) & 63) | 128) + cc((c & 63) | 128)));\n } return o;\n },\n decode: function (n) {\n \"use strict\";\n var o = \"\", i = 0, cc = String.fromCharCode, c2, c;\n while (i < n.length) {\n c = n.charCodeAt(i);\n o = o + ((c < 128) ? [cc(c), i++][0] : ((c > 191) && (c < 224)) ?\n [cc(((c & 31) << 6) | ((c2 = n.charCodeAt(i + 1)) & 63)), (i += 2)][0] :\n [cc(((c & 15) << 12) | (((c2 = n.charCodeAt(i + 1)) & 63) << 6) | ((c3 = n.charCodeAt(i + 2)) & 63)), (i += 3)][0]);\n } return o;\n }\n }\n};\n\n},{}],13:[function(require,module,exports){\nvar Cookies = require('cookies-js');\nvar JSON2 = require('JSON2');\nvar extend = require('./extend');\n\nmodule.exports = cookie;\n\nfunction cookie(str){\n if (!arguments.length) return;\n if (this instanceof cookie === false) {\n return new cookie(str);\n }\n\n this.config = {\n key: str,\n options: {}\n };\n this.data = this.get();\n return this;\n}\n\ncookie.prototype.get = function(str){\n var data = Cookies.get(this.config.key) ? JSON2.parse( decodeURIComponent(Cookies.get(this.config.key)) ) : {};\n return (str && typeof data[str] !== 'undefined') ? data[str] : data;\n};\n\ncookie.prototype.set = function(str, value){\n if (!arguments.length) return this;\n if ('string' === typeof str && arguments.length === 2) {\n this.data[str] = value ? value : null;\n }\n else if ('object' === typeof str && arguments.length === 1) {\n extend(this.data, str);\n }\n Cookies.set(this.config.key, encodeURIComponent( JSON2.stringify(this.data) ), this.config.options);\n return this;\n};\n\ncookie.prototype.expire = function(){\n Cookies.expire(this.config.key);\n this.data = {};\n return this;\n};\n\ncookie.prototype.options = function(obj){\n if (!arguments.length) return this.config.options;\n this.config.options = (typeof obj === 'object') ? obj : {};\n return this;\n};\n\n},{\"./extend\":16,\"JSON2\":22,\"cookies-js\":25}],14:[function(require,module,exports){\nvar JSON2 = require('JSON2');\n\nmodule.exports = deepExtend;\n\nfunction deepExtend(target){\n for (var i = 1; i < arguments.length; i++) {\n // Copy unique items from incoming array\n if (target instanceof Array && arguments[i] instanceof Array) {\n for (var j = 0; j < arguments[i].length; j++) {\n if (target.indexOf(arguments[i][j]) < 0) {\n target.push(arguments[i][j]);\n }\n }\n }\n // Blend objects\n else {\n for (var prop in arguments[i]){\n // Recurse when both contain objects of same name and incoming is not a null object\n if ('undefined' !== typeof target[prop] && 'object' === typeof arguments[i][prop] && arguments[i][prop] !== null) {\n deepExtend(target[prop], clone(arguments[i][prop]));\n }\n // Otherwise just copy it over...\n else {\n target[prop] = clone(arguments[i][prop]);\n }\n }\n }\n }\n return target;\n}\n\nfunction clone(input){\n return JSON2.parse(JSON2.stringify(input))\n}\n\n},{\"JSON2\":22}],15:[function(require,module,exports){\nmodule.exports = each;\n\nfunction each(o, cb, s){\n var n;\n if (!o){\n return 0;\n }\n s = !s ? o : s;\n if (o instanceof Array){\n // Indexed arrays, needed for Safari\n for (n=0; n a\");\n\n // Listen for a given event\n myClicker.on(\"click\", function(e){\n // do stuff!\n });\n\n // Listen for event once\n myClicker.once(\"click\", function(e){ });\n\n // Cancel a given event listener\n myClicker.off(\"click\");\n\n // Cancel all event listners\n myClicker.off();\n\n*/\n\nmodule.exports = function(ctx){\n\n // Make sure this object exists\n ctx.domListeners = ctx.domListeners || {\n /*\n 'click': {\n '.nav li > a': [fn, fn, fn]\n }\n */\n };\n\n function listener(str){\n if (!str) return;\n if (this instanceof listener === false) {\n return new listener(str);\n }\n this.selector = str;\n return this;\n }\n\n listener.prototype.on = function(str, fn){\n var self = this;\n\n if (arguments.length !== 2 || 'string' !== typeof str || 'function' !== typeof fn) return this;\n\n // Set each listener on a parent dictionary, indexed by event:\n if ('undefined' === typeof ctx.domListeners[str]) {\n addListener(str, eventHandler(str));\n ctx.domListeners[str] = {};\n }\n ctx.domListeners[str][self.selector] = ctx.domListeners[str][self.selector] || [];\n ctx.domListeners[str][self.selector].push(fn);\n return self;\n };\n\n listener.prototype.once = function(str, fn){\n var self = this;\n function on() {\n self.off(str, on);\n return fn.apply(self, arguments);\n }\n on.fn = fn;\n self.on(str, on);\n return self;\n };\n\n listener.prototype.off = function(str, fn){\n var self = this, survivors = [];\n if (arguments.length === 2) {\n each(ctx.domListeners[str][self.selector], function(handler, i){\n if (handler === fn || handler.fn === fn) return;\n survivors.push(handler);\n });\n ctx.domListeners[str][self.selector] = survivors;\n }\n else if (arguments.length === 1) {\n try {\n delete ctx.domListeners[str][self.selector];\n }\n catch(e){\n ctx.domListeners[str][self.selector] = [];\n }\n }\n else {\n // loop over every eventType and delete handlers\n each(ctx.domListeners, function(hash, eventType){\n // if ('undefined' === typeof hash[str]) return;\n try {\n delete ctx.domListeners[eventType][self.selector];\n }\n catch(e){\n ctx.domListeners[eventType][self.selector] = function(){};\n }\n });\n }\n return self;\n };\n\n function eventHandler(eventType){\n return function(e){\n var evt, target;\n\n evt = e || window.event;\n target = evt.target || evt.srcElement;\n\n // If nothing assigned to this event type, let it go\n if ('undefined' === ctx.domListeners[eventType]) return;\n\n each(ctx.domListeners[eventType], function(handlers, key){\n\n if (matches(target, key)) {\n // Call all handlers for this eventType + node\n each(handlers, function(fn, i){\n if ('click' === eventType && 'A' === target.nodeName) {\n deferClickEvent(evt, target, fn);\n }\n else if ('submit' === eventType && 'FORM' === target.nodeName) {\n deferFormSubmit(evt, target, fn);\n }\n else {\n fn(evt);\n }\n });\n }\n else if ('window' === key) {\n // Call all handlers\n each(handlers, function(fn, i){\n fn(evt);\n });\n }\n return;\n });\n };\n }\n\n return listener;\n}\n\n\n// ------------------------------\n// Attach global event listener\n// ------------------------------\n\nfunction addListener(eventType, fn){\n if (document.addEventListener) {\n document.addEventListener(eventType, fn, false);\n } else {\n document.attachEvent(\"on\" + eventType, fn);\n }\n}\n\n\n// ------------------------------\n// Match DOM element to selector\n// ------------------------------\n\nfunction matches(elem, selector) {\n // We'll use querySelectorAll to find all element matching the selector,\n // then check if the given element is included in that list.\n // Executing the query on the parentNode reduces the resulting nodeList,\n // document doesn't have a parentNode, though.\n var nodeList = ( elem.parentNode || document ).querySelectorAll( selector ) || [],\n i = nodeList.length;\n\n // loop on the nodeList\n while ( i-- ) {\n if ( nodeList[i] == elem ) { return true; }\n }\n return false;\n}\n\n\n// ------------------------------\n// Handle 'click' events (A)\n// ------------------------------\n\nfunction deferClickEvent(evt, anchor, callback){\n var timeout = 500,\n targetAttr,\n cbResponse;\n\n // Get 'target' attribute from anchor\n if (anchor.getAttribute !== void 0) {\n targetAttr = anchor.getAttribute(\"target\");\n } else if (anchor.target) {\n targetAttr = anchor.target;\n }\n\n // Fire listener and catch possible response (return false)\n cbResponse = callback(evt);\n\n // If prevented within callback, bail:\n if (('boolean' === typeof cbResponse && cbResponse === false) || evt.defaultPrevented || evt.returnValue === false) {\n if (evt.preventDefault) {\n evt.preventDefault();\n }\n evt.returnValue = false;\n return false;\n }\n // Else if anchor doesn't kick off a new window or tab.. defer and replay the event:\n else if (targetAttr !== '_blank' && targetAttr !== 'blank' && !evt.metaKey) {\n if (evt.preventDefault) {\n evt.preventDefault();\n }\n evt.returnValue = false;\n setTimeout(function(){\n window.location = anchor.href;\n }, timeout);\n }\n\n return false;\n}\n\n\n// ------------------------------\n// Handle 'submit' events (FORM)\n// ------------------------------\n\nfunction deferFormSubmit(evt, form, callback){\n var timeout = 500;\n\n // Fire listener and catch possible response (return false)\n cbResponse = callback(evt);\n\n // If prevented within callback, bail\n if (('boolean' === typeof cbResponse && cbResponse === false) || evt.defaultPrevented || evt.returnValue === false) {\n if (evt.preventDefault) {\n evt.preventDefault();\n }\n evt.returnValue = false;\n return false;\n }\n // Defer and replay event\n else {\n if (evt.preventDefault) {\n evt.preventDefault();\n }\n evt.returnValue = false;\n setTimeout(function(){\n form.submit();\n }, timeout);\n }\n\n return false;\n}\n\n},{\"./each\":15,\"component-emitter\":24}],18:[function(require,module,exports){\nfunction parseParams(str){\n // via: http://stackoverflow.com/a/2880929/2511985\n var urlParams = {},\n match,\n pl = /\\+/g, // Regex for replacing addition symbol with a space\n search = /([^&=]+)=?([^&]*)/g,\n decode = function (s) { return decodeURIComponent(s.replace(pl, \" \")); },\n query = str.split(\"?\")[1];\n\n while (!!(match=search.exec(query))) {\n urlParams[decode(match[1])] = decode(match[2]);\n }\n return urlParams;\n};\n\nmodule.exports = parseParams;\n\n},{}],19:[function(require,module,exports){\nvar Emitter = require('component-emitter');\n\nmodule.exports = queue;\n\nfunction queue(){\n var self = this;\n if (this instanceof queue === false) {\n return new queue();\n }\n\n self.capacity = 0;\n self.interval = 0;\n\n self.config = {\n capacity: 5000,\n interval: 15\n };\n\n self.events = {\n // \"collection 1\": [],\n // \"collection 2\": []\n };\n\n setInterval(function(){\n self.interval++;\n checkQueue.call(self);\n }, 1000);\n\n return self;\n}\n\nfunction checkQueue(){\n if ((this.capacity > 0 && this.interval >= this.config.interval)\n || this.capacity >= this.config.capacity) {\n this.emit('flush');\n this.interval = 0;\n }\n}\n\nEmitter(queue.prototype);\n\n},{\"component-emitter\":24}],20:[function(require,module,exports){\nmodule.exports = timer;\n\nfunction timer(num){\n if (this instanceof timer === false) {\n return new timer(num);\n }\n this.count = num || 0;\n return this;\n}\n\ntimer.prototype.start = function(){\n var self = this;\n this.pause();\n this.interval = setInterval(function(){\n self.count++;\n }, 1000);\n return this;\n};\n\ntimer.prototype.pause = function(){\n clearInterval(this.interval);\n return this;\n};\n\ntimer.prototype.value = function(){\n return this.count;\n};\n\ntimer.prototype.clear = function(){\n this.count = 0;\n return this;\n};\n\n},{}],21:[function(require,module,exports){\n// cycle.js\n// 2011-08-24\n\n/*jslint evil: true, regexp: true */\n\n/*members $ref, apply, call, decycle, hasOwnProperty, length, prototype, push,\n retrocycle, stringify, test, toString\n*/\n\n(function (exports) {\n\nif (typeof exports.decycle !== 'function') {\n exports.decycle = function decycle(object) {\n 'use strict';\n\n// Make a deep copy of an object or array, assuring that there is at most\n// one instance of each object or array in the resulting structure. The\n// duplicate references (which might be forming cycles) are replaced with\n// an object of the form\n// {$ref: PATH}\n// where the PATH is a JSONPath string that locates the first occurance.\n// So,\n// var a = [];\n// a[0] = a;\n// return JSON.stringify(JSON.decycle(a));\n// produces the string '[{\"$ref\":\"$\"}]'.\n\n// JSONPath is used to locate the unique object. $ indicates the top level of\n// the object or array. [NUMBER] or [STRING] indicates a child member or\n// property.\n\n var objects = [], // Keep a reference to each unique object or array\n paths = []; // Keep the path to each unique object or array\n\n return (function derez(value, path) {\n\n// The derez recurses through the object, producing the deep copy.\n\n var i, // The loop counter\n name, // Property name\n nu; // The new object or array\n\n switch (typeof value) {\n case 'object':\n\n// typeof null === 'object', so get out if this value is not really an object.\n\n if (!value) {\n return null;\n }\n\n// If the value is an object or array, look to see if we have already\n// encountered it. If so, return a $ref/path object. This is a hard way,\n// linear search that will get slower as the number of unique objects grows.\n\n for (i = 0; i < objects.length; i += 1) {\n if (objects[i] === value) {\n return {$ref: paths[i]};\n }\n }\n\n// Otherwise, accumulate the unique value and its path.\n\n objects.push(value);\n paths.push(path);\n\n// If it is an array, replicate the array.\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n nu = [];\n for (i = 0; i < value.length; i += 1) {\n nu[i] = derez(value[i], path + '[' + i + ']');\n }\n } else {\n\n// If it is an object, replicate the object.\n\n nu = {};\n for (name in value) {\n if (Object.prototype.hasOwnProperty.call(value, name)) {\n nu[name] = derez(value[name],\n path + '[' + JSON.stringify(name) + ']');\n }\n }\n }\n return nu;\n case 'number':\n case 'string':\n case 'boolean':\n return value;\n }\n }(object, '$'));\n };\n}\n\n\nif (typeof exports.retrocycle !== 'function') {\n exports.retrocycle = function retrocycle($) {\n 'use strict';\n\n// Restore an object that was reduced by decycle. Members whose values are\n// objects of the form\n// {$ref: PATH}\n// are replaced with references to the value found by the PATH. This will\n// restore cycles. The object will be mutated.\n\n// The eval function is used to locate the values described by a PATH. The\n// root object is kept in a $ variable. A regular expression is used to\n// assure that the PATH is extremely well formed. The regexp contains nested\n// * quantifiers. That has been known to have extremely bad performance\n// problems on some browsers for very long strings. A PATH is expected to be\n// reasonably short. A PATH is allowed to belong to a very restricted subset of\n// Goessner's JSONPath.\n\n// So,\n// var s = '[{\"$ref\":\"$\"}]';\n// return JSON.retrocycle(JSON.parse(s));\n// produces an array containing a single element which is the array itself.\n\n var px =\n /^\\$(?:\\[(?:\\d+|\\\"(?:[^\\\\\\\"\\u0000-\\u001f]|\\\\([\\\\\\\"\\/bfnrt]|u[0-9a-zA-Z]{4}))*\\\")\\])*$/;\n\n (function rez(value) {\n\n// The rez function walks recursively through the object looking for $ref\n// properties. When it finds one that has a value that is a path, then it\n// replaces the $ref object with a reference to the value that is found by\n// the path.\n\n var i, item, name, path;\n\n if (value && typeof value === 'object') {\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n for (i = 0; i < value.length; i += 1) {\n item = value[i];\n if (item && typeof item === 'object') {\n path = item.$ref;\n if (typeof path === 'string' && px.test(path)) {\n value[i] = eval(path);\n } else {\n rez(item);\n }\n }\n }\n } else {\n for (name in value) {\n if (typeof value[name] === 'object') {\n item = value[name];\n if (item) {\n path = item.$ref;\n if (typeof path === 'string' && px.test(path)) {\n value[name] = eval(path);\n } else {\n rez(item);\n }\n }\n }\n }\n }\n }\n }($));\n return $;\n };\n}\n}) (\n (typeof exports !== 'undefined') ? \n exports : \n (window.JSON ? \n (window.JSON) :\n (window.JSON = {})\n )\n);\n\n},{}],22:[function(require,module,exports){\n// For use in Node.js\n\nvar JSON2 = require('./json2');\nvar cycle = require('./cycle');\n\nJSON2.decycle = cycle.decycle;\nJSON2.retrocycle = cycle.retrocycle;\n\nmodule.exports = JSON2;\n\n},{\"./cycle\":21,\"./json2\":23}],23:[function(require,module,exports){\n/*\n json2.js\n 2011-10-19\n\n Public Domain.\n\n NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\n See http://www.JSON.org/js.html\n\n\n This code should be minified before deployment.\n See http://javascript.crockford.com/jsmin.html\n\n USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO\n NOT CONTROL.\n\n\n This file creates a global JSON object containing two methods: stringify\n and parse.\n\n JSON.stringify(value, replacer, space)\n value any JavaScript value, usually an object or array.\n\n replacer an optional parameter that determines how object\n values are stringified for objects. It can be a\n function or an array of strings.\n\n space an optional parameter that specifies the indentation\n of nested structures. If it is omitted, the text will\n be packed without extra whitespace. If it is a number,\n it will specify the number of spaces to indent at each\n level. If it is a string (such as '\\t' or ' '),\n it contains the characters used to indent at each level.\n\n This method produces a JSON text from a JavaScript value.\n\n When an object value is found, if the object contains a toJSON\n method, its toJSON method will be called and the result will be\n stringified. A toJSON method does not serialize: it returns the\n value represented by the name/value pair that should be serialized,\n or undefined if nothing should be serialized. The toJSON method\n will be passed the key associated with the value, and this will be\n bound to the value\n\n For example, this would serialize Dates as ISO strings.\n\n Date.prototype.toJSON = function (key) {\n function f(n) {\n // Format integers to have at least two digits.\n return n < 10 ? '0' + n : n;\n }\n\n return this.getUTCFullYear() + '-' +\n f(this.getUTCMonth() + 1) + '-' +\n f(this.getUTCDate()) + 'T' +\n f(this.getUTCHours()) + ':' +\n f(this.getUTCMinutes()) + ':' +\n f(this.getUTCSeconds()) + 'Z';\n };\n\n You can provide an optional replacer method. It will be passed the\n key and value of each member, with this bound to the containing\n object. The value that is returned from your method will be\n serialized. If your method returns undefined, then the member will\n be excluded from the serialization.\n\n If the replacer parameter is an array of strings, then it will be\n used to select the members to be serialized. It filters the results\n such that only members with keys listed in the replacer array are\n stringified.\n\n Values that do not have JSON representations, such as undefined or\n functions, will not be serialized. Such values in objects will be\n dropped; in arrays they will be replaced with null. You can use\n a replacer function to replace those with JSON values.\n JSON.stringify(undefined) returns undefined.\n\n The optional space parameter produces a stringification of the\n value that is filled with line breaks and indentation to make it\n easier to read.\n\n If the space parameter is a non-empty string, then that string will\n be used for indentation. If the space parameter is a number, then\n the indentation will be that many spaces.\n\n Example:\n\n text = JSON.stringify(['e', {pluribus: 'unum'}]);\n // text is '[\"e\",{\"pluribus\":\"unum\"}]'\n\n\n text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\\t');\n // text is '[\\n\\t\"e\",\\n\\t{\\n\\t\\t\"pluribus\": \"unum\"\\n\\t}\\n]'\n\n text = JSON.stringify([new Date()], function (key, value) {\n return this[key] instanceof Date ?\n 'Date(' + this[key] + ')' : value;\n });\n // text is '[\"Date(---current time---)\"]'\n\n\n JSON.parse(text, reviver)\n This method parses a JSON text to produce an object or array.\n It can throw a SyntaxError exception.\n\n The optional reviver parameter is a function that can filter and\n transform the results. It receives each of the keys and values,\n and its return value is used instead of the original value.\n If it returns what it received, then the structure is not modified.\n If it returns undefined then the member is deleted.\n\n Example:\n\n // Parse the text. Values that look like ISO date strings will\n // be converted to Date objects.\n\n myData = JSON.parse(text, function (key, value) {\n var a;\n if (typeof value === 'string') {\n a =\n/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}(?:\\.\\d*)?)Z$/.exec(value);\n if (a) {\n return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],\n +a[5], +a[6]));\n }\n }\n return value;\n });\n\n myData = JSON.parse('[\"Date(09/09/2001)\"]', function (key, value) {\n var d;\n if (typeof value === 'string' &&\n value.slice(0, 5) === 'Date(' &&\n value.slice(-1) === ')') {\n d = new Date(value.slice(5, -1));\n if (d) {\n return d;\n }\n }\n return value;\n });\n\n\n This is a reference implementation. You are free to copy, modify, or\n redistribute.\n*/\n\n/*jslint evil: true, regexp: true */\n\n/*members \"\", \"\\b\", \"\\t\", \"\\n\", \"\\f\", \"\\r\", \"\\\"\", JSON, \"\\\\\", apply,\n call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,\n getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,\n lastIndex, length, parse, prototype, push, replace, slice, stringify,\n test, toJSON, toString, valueOf\n*/\n\n\n(function (JSON) {\n 'use strict';\n\n function f(n) {\n // Format integers to have at least two digits.\n return n < 10 ? '0' + n : n;\n }\n\n /* DDOPSON-2012-04-16 - mutating global prototypes is NOT allowed for a well-behaved module. \n * It's also unneeded, since Date already defines toJSON() to the same ISOwhatever format below\n * Thus, we skip this logic for the CommonJS case where 'exports' is defined\n */\n if (typeof exports === 'undefined') {\n if (typeof Date.prototype.toJSON !== 'function') {\n Date.prototype.toJSON = function (key) {\n\n return isFinite(this.valueOf())\n ? this.getUTCFullYear() + '-' +\n f(this.getUTCMonth() + 1) + '-' +\n f(this.getUTCDate()) + 'T' +\n f(this.getUTCHours()) + ':' +\n f(this.getUTCMinutes()) + ':' +\n f(this.getUTCSeconds()) + 'Z'\n : null;\n };\n }\n \n if (typeof String.prototype.toJSON !== 'function') {\n String.prototype.toJSON = function (key) { return this.valueOf(); };\n }\n\n if (typeof Number.prototype.toJSON !== 'function') {\n Number.prototype.toJSON = function (key) { return this.valueOf(); };\n }\n \n if (typeof Boolean.prototype.toJSON !== 'function') {\n Boolean.prototype.toJSON = function (key) { return this.valueOf(); };\n }\n }\n var cx = /[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n escapable = /[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,\n gap,\n indent,\n meta = { // table of character substitutions\n '\\b': '\\\\b',\n '\\t': '\\\\t',\n '\\n': '\\\\n',\n '\\f': '\\\\f',\n '\\r': '\\\\r',\n '\"' : '\\\\\"',\n '\\\\': '\\\\\\\\'\n },\n rep;\n\n\n function quote(string) {\n\n// If the string contains no control characters, no quote characters, and no\n// backslash characters, then we can safely slap some quotes around it.\n// Otherwise we must also replace the offending characters with safe escape\n// sequences.\n\n escapable.lastIndex = 0;\n return escapable.test(string) ? '\"' + string.replace(escapable, function (a) {\n var c = meta[a];\n return typeof c === 'string'\n ? c\n : '\\\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n }) + '\"' : '\"' + string + '\"';\n }\n\n\n function str(key, holder) {\n\n// Produce a string from holder[key].\n\n var i, // The loop counter.\n k, // The member key.\n v, // The member value.\n length,\n mind = gap,\n partial,\n value = holder[key];\n\n// If the value has a toJSON method, call it to obtain a replacement value.\n\n if (value && typeof value === 'object' &&\n typeof value.toJSON === 'function') {\n value = value.toJSON(key);\n }\n\n// If we were called with a replacer function, then call the replacer to\n// obtain a replacement value.\n\n if (typeof rep === 'function') {\n value = rep.call(holder, key, value);\n }\n\n// What happens next depends on the value's type.\n\n switch (typeof value) {\n case 'string':\n return quote(value);\n\n case 'number':\n\n// JSON numbers must be finite. Encode non-finite numbers as null.\n\n return isFinite(value) ? String(value) : 'null';\n\n case 'boolean':\n case 'null':\n\n// If the value is a boolean or null, convert it to a string. Note:\n// typeof null does not produce 'null'. The case is included here in\n// the remote chance that this gets fixed someday.\n\n return String(value);\n\n// If the type is 'object', we might be dealing with an object or an array or\n// null.\n\n case 'object':\n\n// Due to a specification blunder in ECMAScript, typeof null is 'object',\n// so watch out for that case.\n\n if (!value) {\n return 'null';\n }\n\n// Make an array to hold the partial results of stringifying this object value.\n\n gap += indent;\n partial = [];\n\n// Is the value an array?\n\n if (Object.prototype.toString.apply(value) === '[object Array]') {\n\n// The value is an array. Stringify every element. Use null as a placeholder\n// for non-JSON values.\n\n length = value.length;\n for (i = 0; i < length; i += 1) {\n partial[i] = str(i, value) || 'null';\n }\n\n// Join all of the elements together, separated with commas, and wrap them in\n// brackets.\n\n v = partial.length === 0\n ? '[]'\n : gap\n ? '[\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + ']'\n : '[' + partial.join(',') + ']';\n gap = mind;\n return v;\n }\n\n// If the replacer is an array, use it to select the members to be stringified.\n\n if (rep && typeof rep === 'object') {\n length = rep.length;\n for (i = 0; i < length; i += 1) {\n if (typeof rep[i] === 'string') {\n k = rep[i];\n v = str(k, value);\n if (v) {\n partial.push(quote(k) + (gap ? ': ' : ':') + v);\n }\n }\n }\n } else {\n\n// Otherwise, iterate through all of the keys in the object.\n\n for (k in value) {\n if (Object.prototype.hasOwnProperty.call(value, k)) {\n v = str(k, value);\n if (v) {\n partial.push(quote(k) + (gap ? ': ' : ':') + v);\n }\n }\n }\n }\n\n// Join all of the member texts together, separated with commas,\n// and wrap them in braces.\n\n v = partial.length === 0\n ? '{}'\n : gap\n ? '{\\n' + gap + partial.join(',\\n' + gap) + '\\n' + mind + '}'\n : '{' + partial.join(',') + '}';\n gap = mind;\n return v;\n }\n }\n\n// If the JSON object does not yet have a stringify method, give it one.\n\n if (typeof JSON.stringify !== 'function') {\n JSON.stringify = function (value, replacer, space) {\n\n// The stringify method takes a value and an optional replacer, and an optional\n// space parameter, and returns a JSON text. The replacer can be a function\n// that can replace values, or an array of strings that will select the keys.\n// A default replacer method can be provided. Use of the space parameter can\n// produce text that is more easily readable.\n\n var i;\n gap = '';\n indent = '';\n\n// If the space parameter is a number, make an indent string containing that\n// many spaces.\n\n if (typeof space === 'number') {\n for (i = 0; i < space; i += 1) {\n indent += ' ';\n }\n\n// If the space parameter is a string, it will be used as the indent string.\n\n } else if (typeof space === 'string') {\n indent = space;\n }\n\n// If there is a replacer, it must be a function or an array.\n// Otherwise, throw an error.\n\n rep = replacer;\n if (replacer && typeof replacer !== 'function' &&\n (typeof replacer !== 'object' ||\n typeof replacer.length !== 'number')) {\n throw new Error('JSON.stringify');\n }\n\n// Make a fake root object containing our value under the key of ''.\n// Return the result of stringifying the value.\n\n return str('', {'': value});\n };\n }\n\n\n// If the JSON object does not yet have a parse method, give it one.\n\n if (typeof JSON.parse !== 'function') {\n JSON.parse = function (text, reviver) {\n\n// The parse method takes a text and an optional reviver function, and returns\n// a JavaScript value if the text is a valid JSON text.\n\n var j;\n\n function walk(holder, key) {\n\n// The walk method is used to recursively walk the resulting structure so\n// that modifications can be made.\n\n var k, v, value = holder[key];\n if (value && typeof value === 'object') {\n for (k in value) {\n if (Object.prototype.hasOwnProperty.call(value, k)) {\n v = walk(value, k);\n if (v !== undefined) {\n value[k] = v;\n } else {\n delete value[k];\n }\n }\n }\n }\n return reviver.call(holder, key, value);\n }\n\n\n// Parsing happens in four stages. In the first stage, we replace certain\n// Unicode characters with escape sequences. JavaScript handles many characters\n// incorrectly, either silently deleting them, or treating them as line endings.\n\n text = String(text);\n cx.lastIndex = 0;\n if (cx.test(text)) {\n text = text.replace(cx, function (a) {\n return '\\\\u' +\n ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n });\n }\n\n// In the second stage, we run the text against regular expressions that look\n// for non-JSON patterns. We are especially concerned with '()' and 'new'\n// because they can cause invocation, and '=' because it can cause mutation.\n// But just to be safe, we want to reject all unexpected forms.\n\n// We split the second stage into 4 regexp operations in order to work around\n// crippling inefficiencies in IE's and Safari's regexp engines. First we\n// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we\n// replace all simple value tokens with ']' characters. Third, we delete all\n// open brackets that follow a colon or comma or that begin the text. Finally,\n// we look to see that the remaining characters are only whitespace or ']' or\n// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.\n\n if (/^[\\],:{}\\s]*$/\n .test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')\n .replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g, ']')\n .replace(/(?:^|:|,)(?:\\s*\\[)+/g, ''))) {\n\n// In the third stage we use the eval function to compile the text into a\n// JavaScript structure. The '{' operator is subject to a syntactic ambiguity\n// in JavaScript: it can begin a block or an object literal. We wrap the text\n// in parens to eliminate the ambiguity.\n\n j = eval('(' + text + ')');\n\n// In the optional fourth stage, we recursively walk the new structure, passing\n// each name/value pair to a reviver function for possible transformation.\n\n return typeof reviver === 'function'\n ? walk({'': j}, '')\n : j;\n }\n\n// If the text is not JSON parseable, then a SyntaxError is thrown.\n\n throw new SyntaxError('JSON.parse');\n };\n }\n})(\n \n // Create a JSON object only if one does not already exist. We create the\n // methods in a closure to avoid creating global variables.\n \n (typeof exports !== 'undefined') ? \n exports : \n (window.JSON ? \n (window.JSON) :\n (window.JSON = {})\n )\n);\n\n},{}],24:[function(require,module,exports){\n\n/**\n * Expose `Emitter`.\n */\n\nmodule.exports = Emitter;\n\n/**\n * Initialize a new `Emitter`.\n *\n * @api public\n */\n\nfunction Emitter(obj) {\n if (obj) return mixin(obj);\n};\n\n/**\n * Mixin the emitter properties.\n *\n * @param {Object} obj\n * @return {Object}\n * @api private\n */\n\nfunction mixin(obj) {\n for (var key in Emitter.prototype) {\n obj[key] = Emitter.prototype[key];\n }\n return obj;\n}\n\n/**\n * Listen on the given `event` with `fn`.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.on =\nEmitter.prototype.addEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n (this._callbacks['$' + event] = this._callbacks['$' + event] || [])\n .push(fn);\n return this;\n};\n\n/**\n * Adds an `event` listener that will be invoked a single\n * time then automatically removed.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.once = function(event, fn){\n function on() {\n this.off(event, on);\n fn.apply(this, arguments);\n }\n\n on.fn = fn;\n this.on(event, on);\n return this;\n};\n\n/**\n * Remove the given callback for `event` or all\n * registered callbacks.\n *\n * @param {String} event\n * @param {Function} fn\n * @return {Emitter}\n * @api public\n */\n\nEmitter.prototype.off =\nEmitter.prototype.removeListener =\nEmitter.prototype.removeAllListeners =\nEmitter.prototype.removeEventListener = function(event, fn){\n this._callbacks = this._callbacks || {};\n\n // all\n if (0 == arguments.length) {\n this._callbacks = {};\n return this;\n }\n\n // specific event\n var callbacks = this._callbacks['$' + event];\n if (!callbacks) return this;\n\n // remove all handlers\n if (1 == arguments.length) {\n delete this._callbacks['$' + event];\n return this;\n }\n\n // remove specific handler\n var cb;\n for (var i = 0; i < callbacks.length; i++) {\n cb = callbacks[i];\n if (cb === fn || cb.fn === fn) {\n callbacks.splice(i, 1);\n break;\n }\n }\n return this;\n};\n\n/**\n * Emit `event` with the given args.\n *\n * @param {String} event\n * @param {Mixed} ...\n * @return {Emitter}\n */\n\nEmitter.prototype.emit = function(event){\n this._callbacks = this._callbacks || {};\n var args = [].slice.call(arguments, 1)\n , callbacks = this._callbacks['$' + event];\n\n if (callbacks) {\n callbacks = callbacks.slice(0);\n for (var i = 0, len = callbacks.length; i < len; ++i) {\n callbacks[i].apply(this, args);\n }\n }\n\n return this;\n};\n\n/**\n * Return array of callbacks for `event`.\n *\n * @param {String} event\n * @return {Array}\n * @api public\n */\n\nEmitter.prototype.listeners = function(event){\n this._callbacks = this._callbacks || {};\n return this._callbacks['$' + event] || [];\n};\n\n/**\n * Check if this emitter has `event` handlers.\n *\n * @param {String} event\n * @return {Boolean}\n * @api public\n */\n\nEmitter.prototype.hasListeners = function(event){\n return !! this.listeners(event).length;\n};\n\n},{}],25:[function(require,module,exports){\n/*\r\n * Cookies.js - 1.2.1\r\n * https://github.com/ScottHamper/Cookies\r\n *\r\n * This is free and unencumbered software released into the public domain.\r\n */\r\n(function (global, undefined) {\r\n 'use strict';\r\n\r\n var factory = function (window) {\r\n if (typeof window.document !== 'object') {\r\n throw new Error('Cookies.js requires a `window` with a `document` object');\r\n }\r\n\r\n var Cookies = function (key, value, options) {\r\n return arguments.length === 1 ?\r\n Cookies.get(key) : Cookies.set(key, value, options);\r\n };\r\n\r\n // Allows for setter injection in unit tests\r\n Cookies._document = window.document;\r\n\r\n // Used to ensure cookie keys do not collide with\r\n // built-in `Object` properties\r\n Cookies._cacheKeyPrefix = 'cookey.'; // Hurr hurr, :)\r\n \r\n Cookies._maxExpireDate = new Date('Fri, 31 Dec 9999 23:59:59 UTC');\r\n\r\n Cookies.defaults = {\r\n path: '/',\r\n secure: false\r\n };\r\n\r\n Cookies.get = function (key) {\r\n if (Cookies._cachedDocumentCookie !== Cookies._document.cookie) {\r\n Cookies._renewCache();\r\n }\r\n\r\n return Cookies._cache[Cookies._cacheKeyPrefix + key];\r\n };\r\n\r\n Cookies.set = function (key, value, options) {\r\n options = Cookies._getExtendedOptions(options);\r\n options.expires = Cookies._getExpiresDate(value === undefined ? -1 : options.expires);\r\n\r\n Cookies._document.cookie = Cookies._generateCookieString(key, value, options);\r\n\r\n return Cookies;\r\n };\r\n\r\n Cookies.expire = function (key, options) {\r\n return Cookies.set(key, undefined, options);\r\n };\r\n\r\n Cookies._getExtendedOptions = function (options) {\r\n return {\r\n path: options && options.path || Cookies.defaults.path,\r\n domain: options && options.domain || Cookies.defaults.domain,\r\n expires: options && options.expires || Cookies.defaults.expires,\r\n secure: options && options.secure !== undefined ? options.secure : Cookies.defaults.secure\r\n };\r\n };\r\n\r\n Cookies._isValidDate = function (date) {\r\n return Object.prototype.toString.call(date) === '[object Date]' && !isNaN(date.getTime());\r\n };\r\n\r\n Cookies._getExpiresDate = function (expires, now) {\r\n now = now || new Date();\r\n\r\n if (typeof expires === 'number') {\r\n expires = expires === Infinity ?\r\n Cookies._maxExpireDate : new Date(now.getTime() + expires * 1000);\r\n } else if (typeof expires === 'string') {\r\n expires = new Date(expires);\r\n }\r\n\r\n if (expires && !Cookies._isValidDate(expires)) {\r\n throw new Error('`expires` parameter cannot be converted to a valid Date instance');\r\n }\r\n\r\n return expires;\r\n };\r\n\r\n Cookies._generateCookieString = function (key, value, options) {\r\n key = key.replace(/[^#$&+\\^`|]/g, encodeURIComponent);\r\n key = key.replace(/\\(/g, '%28').replace(/\\)/g, '%29');\r\n value = (value + '').replace(/[^!#$&-+\\--:<-\\[\\]-~]/g, encodeURIComponent);\r\n options = options || {};\r\n\r\n var cookieString = key + '=' + value;\r\n cookieString += options.path ? ';path=' + options.path : '';\r\n cookieString += options.domain ? ';domain=' + options.domain : '';\r\n cookieString += options.expires ? ';expires=' + options.expires.toUTCString() : '';\r\n cookieString += options.secure ? ';secure' : '';\r\n\r\n return cookieString;\r\n };\r\n\r\n Cookies._getCacheFromString = function (documentCookie) {\r\n var cookieCache = {};\r\n var cookiesArray = documentCookie ? documentCookie.split('; ') : [];\r\n\r\n for (var i = 0; i < cookiesArray.length; i++) {\r\n var cookieKvp = Cookies._getKeyValuePairFromCookieString(cookiesArray[i]);\r\n\r\n if (cookieCache[Cookies._cacheKeyPrefix + cookieKvp.key] === undefined) {\r\n cookieCache[Cookies._cacheKeyPrefix + cookieKvp.key] = cookieKvp.value;\r\n }\r\n }\r\n\r\n return cookieCache;\r\n };\r\n\r\n Cookies._getKeyValuePairFromCookieString = function (cookieString) {\r\n // \"=\" is a valid character in a cookie value according to RFC6265, so cannot `split('=')`\r\n var separatorIndex = cookieString.indexOf('=');\r\n\r\n // IE omits the \"=\" when the cookie value is an empty string\r\n separatorIndex = separatorIndex < 0 ? cookieString.length : separatorIndex;\r\n\r\n return {\r\n key: decodeURIComponent(cookieString.substr(0, separatorIndex)),\r\n value: decodeURIComponent(cookieString.substr(separatorIndex + 1))\r\n };\r\n };\r\n\r\n Cookies._renewCache = function () {\r\n Cookies._cache = Cookies._getCacheFromString(Cookies._document.cookie);\r\n Cookies._cachedDocumentCookie = Cookies._document.cookie;\r\n };\r\n\r\n Cookies._areEnabled = function () {\r\n var testKey = 'cookies.js';\r\n var areEnabled = Cookies.set(testKey, 1).get(testKey) === '1';\r\n Cookies.expire(testKey);\r\n return areEnabled;\r\n };\r\n\r\n Cookies.enabled = Cookies._areEnabled();\r\n\r\n return Cookies;\r\n };\r\n\r\n var cookiesExport = typeof global.document === 'object' ? factory(global) : factory;\r\n\r\n // AMD support\r\n if (typeof define === 'function' && define.amd) {\r\n define(function () { return cookiesExport; });\r\n // CommonJS/Node.js support\r\n } else if (typeof exports === 'object') {\r\n // Support Node.js specific `module.exports` (which can be a function)\r\n if (typeof module === 'object' && typeof module.exports === 'object') {\r\n exports = module.exports = cookiesExport;\r\n }\r\n // But always support CommonJS module 1.1.1 spec (`exports` cannot be a function)\r\n exports.Cookies = cookiesExport;\r\n } else {\r\n global.Cookies = cookiesExport;\r\n }\r\n})(typeof window === 'undefined' ? this : window);\n},{}]},{},[1]);\n"],"file":"keen-tracking.js","sourceRoot":"/source/"} \ No newline at end of file diff --git a/dist/keen-tracking.min.js b/dist/keen-tracking.min.js index 8a77a96..a10cd20 100644 --- a/dist/keen-tracking.min.js +++ b/dist/keen-tracking.min.js @@ -1 +1 @@ -(function e(b,g,d){function c(m,j){if(!g[m]){if(!b[m]){var i=typeof require=="function"&&require;if(!j&&i){return i(m,!0)}if(a){return a(m,!0)}var k=new Error("Cannot find module '"+m+"'");throw k.code="MODULE_NOT_FOUND",k}var h=g[m]={exports:{}};b[m][0].call(h.exports,function(l){var o=b[m][1][l];return c(o?o:l)},h,h.exports,e,b,g,d)}return g[m].exports}var a=typeof require=="function"&&require;for(var f=0;f or DOM element")}}if(t){w=function(){if(!o){o=true;t()}}}this.recordEvent(m,u,w);setTimeout(w,n);if(!v.metaKey){return false}}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(n){var m=this.length>>>0;var o=Number(arguments[1])||0;o=(o<0)?Math.ceil(o):Math.floor(o);if(o<0){o+=m}for(;o0){o=JSON.parse(JSON.stringify(n.queue));n.queue=h();n.queue.options=o.options;n.emit("recordDeferredEvents",o.events);n.recordEvents(o.events,function(q,p){if(q){n.recordEvents(o.events)}else{o=void 0}})}return n}function i(o){var n="Event(s) not deferred: "+o;this.emit("error",n)}},{"./index":10,"./utils/each":15,"./utils/queue":19}],3:[function(d,c,g){var f=d("./utils/deepExtend");var i=d("./utils/each");c.exports={extendEvent:b,extendEvents:j,getExtendedEventBody:a};function b(k,l){if(arguments.length!==2||typeof k!=="string"||("object"!==typeof l&&"function"!==typeof l)){h.call(this,"Incorrect arguments provided to #extendEvent method");return}this.extensions.collections[k]=this.extensions.collections[k]||[];this.extensions.collections[k].push(l);this.emit("extendEvent",k,l);return this}function j(k){if(arguments.length!==1||("object"!==typeof k&&"function"!==typeof k)){h.call(this,"Incorrect arguments provided to #extendEvents method");return}this.extensions.events.push(k);this.emit("extendEvents",k);return this}function h(l){var k="Event(s) not extended: "+l;this.emit("error",k)}function a(l,k){if(k&&k.length>0){i(k,function(o,n){var m=(typeof o==="function")?o():o;f(l,m)})}return l}},{"./utils/deepExtend":14,"./utils/each":15}],4:[function(d,f,b){var a=d("./getScreenProfile"),g=d("./getWindowProfile");function c(){return{cookies:("undefined"!==typeof navigator.cookieEnabled)?navigator.cookieEnabled:false,codeName:navigator.appCodeName,language:navigator.language,name:navigator.appName,online:navigator.onLine,platform:navigator.platform,useragent:navigator.userAgent,version:navigator.appVersion,screen:a(),window:g()}}f.exports=c},{"./getScreenProfile":7,"./getWindowProfile":9}],5:[function(b,c,a){function d(f){var g=f||new Date();return{hour_of_day:g.getHours(),day_of_week:parseInt(1+g.getDay()),day_of_month:g.getDate(),month:parseInt(1+g.getMonth()),year:g.getFullYear()}}c.exports=d},{}],6:[function(c,d,a){function b(l){if(!l.nodeName){return""}var f=[];while(l.parentNode!=null){var k=0;var g=0;for(var j=0;j1){f.unshift(l.nodeName.toLowerCase()+":eq("+g+")")}else{f.unshift(l.nodeName.toLowerCase())}}l=l.parentNode}return f.slice(1).join(" > ")}d.exports=b},{}],7:[function(c,d,b){function a(){var h,f;if("undefined"==typeof window||!window.screen){return{}}h=["height","width","colorDepth","pixelDepth","availHeight","availWidth"];f={};for(var g=0;gwindow.innerHeight?"landscape":"portrait"};return f}d.exports=a},{}],8:[function(b,c,a){function d(){var f="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";return f.replace(/[xy]/g,function(i){var h=Math.random()*16|0,g=i=="x"?h:(h&3|8);return g.toString(16)})}c.exports=d},{}],9:[function(b,c,a){function d(){var f,h,g;if("undefined"==typeof document){return{}}f=document.body;h=document.documentElement;g={height:("innerHeight" in window)?window.innerHeight:document.documentElement.offsetHeight,width:("innerWidth" in window)?window.innerWidth:document.documentElement.offsetWidth,scrollHeight:Math.max(f.scrollHeight,f.offsetHeight,h.clientHeight,h.scrollHeight,h.offsetHeight)||null};if(window.screen){g.ratio={height:(window.screen.availHeight)?parseFloat((window.innerHeight/window.screen.availHeight).toFixed(2)):null,width:(window.screen.availWidth)?parseFloat((window.innerWidth/window.screen.availWidth).toFixed(2)):null}}return g}c.exports=d},{}],10:[function(b,a,c){var j=b("component-emitter");var l=b("JSON2");var k=b("./utils/each");var h=b("./utils/extend");var f=b("./utils/queue");var i=this;var g=i.Keen;var d=function(n){this.configure(n);d.emit("client",this)};d.prototype.configure=function(o){var n=this,p;if(o.host){o.host.replace(/.*?:\/\//g,"")}p="https";if("undefined"!==typeof document&&document.all){o.protocol=(document.location.protocol!=="https:")?"http":p}n.config=n.config||{host:"api.keen.io",protocol:p,requestType:"jsonp"};h(n.config,o||{});n.queue=f();n.queue.on("flush",function(){n.recordDeferredEvents()});n.extensions={events:[],collections:{}};if(d.debug){n.on("error",d.log)}n.emit("ready");return n};d.prototype.projectId=function(n){if(!arguments.length){return this.config.projectId}this.config.projectId=(n?String(n):null);return this};d.prototype.writeKey=function(n){if(!arguments.length){return this.config.writeKey}this.config.writeKey=(n?String(n):null);return this};d.prototype.writePath=function(n){if(!arguments.length){if(!this.projectId()){this.emit("error","Keen is missing a projectId property");return}return this.config.writePath?this.config.writePath:("/3.0/projects/"+this.projectId()+"/events")}this.config.writePath=(n?String(n):null);return this};d.prototype.url=function(p,o){var n;if(!this.projectId()){this.emit("error","Keen is missing a projectId property");return}n=this.config.protocol+"://"+this.config.host;if(p){n+=p}if(o){n+="?"+m(o)}return n};d.prototype.setGlobalProperties=function(n){this.emit("error","This method has been deprecated. Check out #extendEvents: https://github.com/keen/keen-tracking.js#extend-events");if(!n||typeof n!=="function"){this.emit("error","Invalid value for global properties: "+n);return}this.config.globalProperties=n;return this};j(d);j(d.prototype);h(d,{debug:false,enabled:true,loaded:false,helpers:{},utils:{},version:"0.0.1"});d.log=function(n){if(d.debug&&typeof console=="object"){console.log("[Keen IO]",n)}};function m(o){var n=[];k(o,function(q,p){if("string"!==typeof q){q=l.stringify(q)}n.push(p+"="+encodeURIComponent(q))});return n.join("&")}a.exports=d},{"./utils/each":15,"./utils/extend":16,"./utils/queue":19,JSON2:22,"component-emitter":24}],11:[function(i,d,w){var c=i("./index");var b=i("./utils/base64");var f=i("./utils/each");var s=i("./utils/extend");var r=i("./extend-events");var g=i("JSON2");d.exports={recordEvent:l,recordEvents:j,addEvent:o,addEvents:m};function l(x,G,F,A){var y,D,B,H,C,E,z;y=this.url(this.writePath()+"/"+encodeURIComponent(x));D={};B=F;z=("boolean"===typeof A)?A:true;if(!v.call(this,B)){return}if(!x||typeof x!=="string"){n.call(this,"Collection name must be a string.",B);return}if(this.config.globalProperties){D=this.config.globalProperties(x)}s(D,G);E={};r.getExtendedEventBody(E,this.extensions.events);r.getExtendedEventBody(E,this.extensions.collections[x]);r.getExtendedEventBody(E,[D]);this.emit("recordEvent",x,E);if(!c.enabled){n.call(this,"Keen.enabled is set to false.",B);return false}H=this.url(this.writePath()+"/"+encodeURIComponent(x),{api_key:this.writeKey(),data:b.encode(g.stringify(E)),modified:new Date().getTime()});C=H.length2){n.call(this,"Incorrect arguments provided to #recordEvents method",x);return}if(this.config.globalProperties){f(B,function(D,E){f(D,function(F,H){var G=y.config.globalProperties(E);B[E][H]=s(G,F)})})}z={};f(B,function(E,D){z[D]=z[D]||[];f(E,function(H,G){var F={};r.getExtendedEventBody(F,y.extensions.events);r.getExtendedEventBody(F,y.extensions.collections[D]);r.getExtendedEventBody(F,[H]);z[D].push(F)})});this.emit("recordEvents",z);if(!c.enabled){n.call(this,"Keen.enabled is set to false.",x);return false}if(q()){u.call(this,"POST",A,z,x)}else{}C=x=null;return this}function o(){this.emit("error","This method has been deprecated. Check out #recordEvent: https://github.com/keen/keen-tracking.js#record-a-single-event");l.apply(this,arguments)}function m(){this.emit("error","This method has been deprecated. Check out #recordEvents: https://github.com/keen/keen-tracking.js#record-multiple-events");j.apply(this,arguments)}function v(y){var x=y;y=null;if(!this.projectId()){n.call(this,"Keen.Client is missing a projectId property.",x);return false}if(!this.writeKey()){n.call(this,"Keen.Client is missing a writeKey property.",x);return false}return true}function n(z,x){var y="Event(s) not recorded: "+z;this.emit("error",y);if(x){x.call(this,y,null);x=null}}function t(){if("undefined"!==typeof window){if(navigator.userAgent.indexOf("MSIE")!==-1||navigator.appVersion.indexOf("Trident/")>0){return 2000}}return 16000}function p(x,z,y,A){if(q()){u.call(this,"POST",x,z,A)}else{n.call(this,y)}}function u(E,z,A,D){var y=this;var B;var C=q();var x=D;D=null;C.onreadystatechange=function(){var F;if(C.readyState==4){if(C.status>=200&&C.status<300){try{F=g.parse(C.responseText)}catch(G){c.emit("error","Could not parse HTTP response: "+C.responseText);if(x){x.call(y,C,null)}}if(x&&F){x.call(y,null,F)}}else{c.emit("error","HTTP request failed.");if(x){x.call(y,C,null)}}}};C.open(E,z,true);C.setRequestHeader("Authorization",y.writeKey());C.setRequestHeader("Content-Type","application/json");if(A){B=g.stringify(A)}if(E.toUpperCase()==="GET"){C.send()}if(E.toUpperCase()==="POST"){C.send(B)}}function a(x){var y=q();if(y){y.open("GET",x,false);y.send(null)}}function q(){var x="undefined"==typeof window?this:window;if(x.XMLHttpRequest&&("file:"!=x.location.protocol||!x.ActiveXObject)){return new XMLHttpRequest}else{try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(y){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(y){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(y){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(y){}}return false}function h(x,G){var H=this,A=G,C=new Date().getTime(),E=document.createElement("script"),F=document.getElementsByTagName("head")[0],D="keenJSONPCallback",B=false;G=null;D+=C;while(D in window){D+="a"}window[D]=function(I){if(B===true){return}B=true;if(A){A.call(H,null,I)}y()};E.src=x+"&jsonp="+D;F.appendChild(E);E.onreadystatechange=function(){if(B===false&&this.readyState==="loaded"){B=true;z();y()}};E.onerror=function(){if(B===false){B=true;z();y()}};function z(){if(A){A.call(H,"An error occurred!",null)}}function y(){window[D]=undefined;try{delete window[D]}catch(I){}F.removeChild(E)}}function k(B,C){var z=this,x=C,y=document.createElement("img"),A=false;C=null;y.onload=function(){A=true;if("naturalHeight" in this){if(this.naturalHeight+this.naturalWidth===0){this.onerror();return}}else{if(this.width+this.height===0){this.onerror();return}}if(x){x.call(z)}};y.onerror=function(){A=true;if(x){x.call(z,"An error occurred!",null)}};y.src=B+"&c=clv1"}},{"./extend-events":3,"./index":10,"./utils/base64":12,"./utils/each":15,"./utils/extend":16,JSON2:22}],12:[function(b,c,a){c.exports={map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(f){var d="",l=0,h=this.map,k,j,g,s,r,q,p;f=this.utf8.encode(f);while(l>2);r=(((k&3)<<4)|(j>>4));q=(isNaN(j)?64:((j&15)<<2)|(g>>6));p=(isNaN(j)||isNaN(g))?64:g&63;d=d+h.charAt(s)+h.charAt(r)+h.charAt(q)+h.charAt(p)}return d},decode:function(f){var d="",p=0,h=this.map,g=String.fromCharCode,t,s,r,q,l,k,j;f=f.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(p>4);k=((s&15)<<4)|(r>>2);j=((r&3)<<6)|q;d=d+(g(l)+((r!=64)?g(k):""))+(((q!=64)?g(j):""))}return this.utf8.decode(d)},utf8:{encode:function(j){var f="",d=0,h=String.fromCharCode,g;while(d127)&&(g<2048))?(h((g>>6)|192)+h((g&63)|128)):(h((g>>12)|224)+h(((g>>6)&63)|128)+h((g&63)|128)))}return f},decode:function(k){var g="",f=0,j=String.fromCharCode,d,h;while(f191)&&(h<224))?[j(((h&31)<<6)|((d=k.charCodeAt(f+1))&63)),(f+=2)][0]:[j(((h&15)<<12)|(((d=k.charCodeAt(f+1))&63)<<6)|((c3=k.charCodeAt(f+2))&63)),(f+=3)][0])}return g}}}},{}],13:[function(b,f,a){var d=b("cookies-js");var g=b("JSON2");var h=b("./extend");f.exports=c;function c(i){if(!arguments.length){return}if(this instanceof c===false){return new c(i)}this.config={key:i,options:{}};this.data=this.get();return this}c.prototype.get=function(j){var i=d.get(this.config.key)?g.parse(decodeURIComponent(d.get(this.config.key))):{};return(j&&typeof i[j]!=="undefined")?i[j]:i};c.prototype.set=function(j,i){if(!arguments.length){return this}if("string"===typeof j&&arguments.length===2){this.data[j]=i?i:null}else{if("object"===typeof j&&arguments.length===1){h(this.data,j)}}d.set(this.config.key,encodeURIComponent(g.stringify(this.data)),this.config.options);return this};c.prototype.expire=function(){d.expire(this.config.key);this.data={};return this};c.prototype.options=function(i){if(!arguments.length){return this.config.options}this.config.options=(typeof i==="object")?i:{};return this}},{"./extend":16,JSON2:22,"cookies-js":25}],14:[function(c,d,a){var f=c("JSON2");d.exports=b;function b(l){for(var k=1;k0&&this.interval>=this.config.interval)||this.capacity>=this.config.capacity){this.emit("flush");this.interval=0}}f(a.prototype)},{"component-emitter":24}],20:[function(b,c,a){c.exports=d;function d(f){if(this instanceof d===false){return new d(f)}this.count=f||0;return this}d.prototype.start=function(){var f=this;this.pause();this.interval=setInterval(function(){f.count++},1000);return this};d.prototype.pause=function(){clearInterval(this.interval);return this};d.prototype.value=function(){return this.count};d.prototype.clear=function(){this.count=0;return this}},{}],21:[function(require,module,exports){(function(exports){if(typeof exports.decycle!=="function"){exports.decycle=function decycle(object){var objects=[],paths=[];return(function derez(value,path){var i,name,nu;switch(typeof value){case"object":if(!value){return null}for(i=0;i or DOM element")}}if(t){w=function(){if(!o){o=true;t()}}}this.recordEvent(m,u,w);setTimeout(w,n);if(!v.metaKey){return false}}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(n){var m=this.length>>>0;var o=Number(arguments[1])||0;o=(o<0)?Math.ceil(o):Math.floor(o);if(o<0){o+=m}for(;o0){o=JSON.parse(JSON.stringify(n.queue));n.queue=h();n.queue.options=o.options;n.emit("recordDeferredEvents",o.events);n.recordEvents(o.events,function(q,p){if(q){n.recordEvents(o.events)}else{o=void 0}})}return n}function i(o){var n="Event(s) not deferred: "+o;this.emit("error",n)}},{"./index":10,"./utils/each":15,"./utils/queue":19}],3:[function(d,c,g){var f=d("./utils/deepExtend");var i=d("./utils/each");c.exports={extendEvent:b,extendEvents:j,getExtendedEventBody:a};function b(k,l){if(arguments.length!==2||typeof k!=="string"||("object"!==typeof l&&"function"!==typeof l)){h.call(this,"Incorrect arguments provided to #extendEvent method");return}this.extensions.collections[k]=this.extensions.collections[k]||[];this.extensions.collections[k].push(l);this.emit("extendEvent",k,l);return this}function j(k){if(arguments.length!==1||("object"!==typeof k&&"function"!==typeof k)){h.call(this,"Incorrect arguments provided to #extendEvents method");return}this.extensions.events.push(k);this.emit("extendEvents",k);return this}function h(l){var k="Event(s) not extended: "+l;this.emit("error",k)}function a(l,k){if(k&&k.length>0){i(k,function(o,n){var m=(typeof o==="function")?o():o;f(l,m)})}return l}},{"./utils/deepExtend":14,"./utils/each":15}],4:[function(d,f,b){var a=d("./getScreenProfile"),g=d("./getWindowProfile");function c(){return{cookies:("undefined"!==typeof navigator.cookieEnabled)?navigator.cookieEnabled:false,codeName:navigator.appCodeName,language:navigator.language,name:navigator.appName,online:navigator.onLine,platform:navigator.platform,useragent:navigator.userAgent,version:navigator.appVersion,screen:a(),window:g()}}f.exports=c},{"./getScreenProfile":7,"./getWindowProfile":9}],5:[function(b,c,a){function d(f){var g=f||new Date();return{hour_of_day:g.getHours(),day_of_week:parseInt(1+g.getDay()),day_of_month:g.getDate(),month:parseInt(1+g.getMonth()),year:g.getFullYear()}}c.exports=d},{}],6:[function(c,d,a){function b(l){if(!l.nodeName){return""}var f=[];while(l.parentNode!=null){var k=0;var g=0;for(var j=0;j1){f.unshift(l.nodeName.toLowerCase()+":eq("+g+")")}else{f.unshift(l.nodeName.toLowerCase())}}l=l.parentNode}return f.slice(1).join(" > ")}d.exports=b},{}],7:[function(c,d,b){function a(){var h,f;if("undefined"==typeof window||!window.screen){return{}}h=["height","width","colorDepth","pixelDepth","availHeight","availWidth"];f={};for(var g=0;gwindow.innerHeight?"landscape":"portrait"};return f}d.exports=a},{}],8:[function(b,c,a){function d(){var f="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";return f.replace(/[xy]/g,function(i){var h=Math.random()*16|0,g=i=="x"?h:(h&3|8);return g.toString(16)})}c.exports=d},{}],9:[function(b,c,a){function d(){var f,h,g;if("undefined"==typeof document){return{}}f=document.body;h=document.documentElement;g={height:("innerHeight" in window)?window.innerHeight:document.documentElement.offsetHeight,width:("innerWidth" in window)?window.innerWidth:document.documentElement.offsetWidth,scrollHeight:Math.max(f.scrollHeight,f.offsetHeight,h.clientHeight,h.scrollHeight,h.offsetHeight)||null};if(window.screen){g.ratio={height:(window.screen.availHeight)?parseFloat((window.innerHeight/window.screen.availHeight).toFixed(2)):null,width:(window.screen.availWidth)?parseFloat((window.innerWidth/window.screen.availWidth).toFixed(2)):null}}return g}c.exports=d},{}],10:[function(b,a,c){var j=b("component-emitter");var l=b("JSON2");var k=b("./utils/each");var h=b("./utils/extend");var f=b("./utils/queue");var i=this;var g=i.Keen;var d=function(n){this.configure(n);d.emit("client",this)};d.prototype.configure=function(o){var n=this,p;if(o.host){o.host.replace(/.*?:\/\//g,"")}p="https";if("undefined"!==typeof document&&document.all){o.protocol=(document.location.protocol!=="https:")?"http":p}n.config=n.config||{host:"api.keen.io",protocol:p,requestType:"jsonp"};h(n.config,o||{});n.queue=f();n.queue.on("flush",function(){n.recordDeferredEvents()});n.extensions={events:[],collections:{}};if(d.debug){n.on("error",d.log)}n.emit("ready");return n};d.prototype.projectId=function(n){if(!arguments.length){return this.config.projectId}this.config.projectId=(n?String(n):null);return this};d.prototype.writeKey=function(n){if(!arguments.length){return this.config.writeKey}this.config.writeKey=(n?String(n):null);return this};d.prototype.writePath=function(n){if(!arguments.length){if(!this.projectId()){this.emit("error","Keen is missing a projectId property");return}return this.config.writePath?this.config.writePath:("/3.0/projects/"+this.projectId()+"/events")}this.config.writePath=(n?String(n):null);return this};d.prototype.url=function(p,o){var n;if(!this.projectId()){this.emit("error","Keen is missing a projectId property");return}n=this.config.protocol+"://"+this.config.host;if(p){n+=p}if(o){n+="?"+m(o)}return n};d.prototype.setGlobalProperties=function(n){this.emit("error","This method has been deprecated. Check out #extendEvents: https://github.com/keen/keen-tracking.js#extend-events");if(!n||typeof n!=="function"){this.emit("error","Invalid value for global properties: "+n);return}this.config.globalProperties=n;return this};j(d);j(d.prototype);h(d,{debug:false,enabled:true,loaded:false,helpers:{},utils:{},version:"0.0.2"});d.log=function(n){if(d.debug&&typeof console=="object"){console.log("[Keen IO]",n)}};function m(o){var n=[];k(o,function(q,p){if("string"!==typeof q){q=l.stringify(q)}n.push(p+"="+encodeURIComponent(q))});return n.join("&")}a.exports=d},{"./utils/each":15,"./utils/extend":16,"./utils/queue":19,JSON2:22,"component-emitter":24}],11:[function(i,d,w){var c=i("./index");var b=i("./utils/base64");var f=i("./utils/each");var s=i("./utils/extend");var r=i("./extend-events");var g=i("JSON2");d.exports={recordEvent:l,recordEvents:j,addEvent:o,addEvents:m};function l(x,G,F,A){var y,D,B,H,C,E,z;y=this.url(this.writePath()+"/"+encodeURIComponent(x));D={};B=F;z=("boolean"===typeof A)?A:true;if(!v.call(this,B)){return}if(!x||typeof x!=="string"){n.call(this,"Collection name must be a string.",B);return}if(this.config.globalProperties){D=this.config.globalProperties(x)}s(D,G);E={};r.getExtendedEventBody(E,this.extensions.events);r.getExtendedEventBody(E,this.extensions.collections[x]);r.getExtendedEventBody(E,[D]);this.emit("recordEvent",x,E);if(!c.enabled){n.call(this,"Keen.enabled is set to false.",B);return false}H=this.url(this.writePath()+"/"+encodeURIComponent(x),{api_key:this.writeKey(),data:b.encode(g.stringify(E)),modified:new Date().getTime()});C=H.length2){n.call(this,"Incorrect arguments provided to #recordEvents method",x);return}if(this.config.globalProperties){f(B,function(D,E){f(D,function(F,H){var G=y.config.globalProperties(E);B[E][H]=s(G,F)})})}z={};f(B,function(E,D){z[D]=z[D]||[];f(E,function(H,G){var F={};r.getExtendedEventBody(F,y.extensions.events);r.getExtendedEventBody(F,y.extensions.collections[D]);r.getExtendedEventBody(F,[H]);z[D].push(F)})});this.emit("recordEvents",z);if(!c.enabled){n.call(this,"Keen.enabled is set to false.",x);return false}if(q()){u.call(this,"POST",A,z,x)}else{}C=x=null;return this}function o(){this.emit("error","This method has been deprecated. Check out #recordEvent: https://github.com/keen/keen-tracking.js#record-a-single-event");l.apply(this,arguments)}function m(){this.emit("error","This method has been deprecated. Check out #recordEvents: https://github.com/keen/keen-tracking.js#record-multiple-events");j.apply(this,arguments)}function v(y){var x=y;y=null;if(!this.projectId()){n.call(this,"Keen.Client is missing a projectId property.",x);return false}if(!this.writeKey()){n.call(this,"Keen.Client is missing a writeKey property.",x);return false}return true}function n(z,x){var y="Event(s) not recorded: "+z;this.emit("error",y);if(x){x.call(this,y,null);x=null}}function t(){if("undefined"!==typeof window){if(navigator.userAgent.indexOf("MSIE")!==-1||navigator.appVersion.indexOf("Trident/")>0){return 2000}}return 16000}function p(x,z,y,A){if(q()){u.call(this,"POST",x,z,A)}else{n.call(this,y)}}function u(E,z,A,D){var y=this;var B;var C=q();var x=D;D=null;C.onreadystatechange=function(){var F;if(C.readyState==4){if(C.status>=200&&C.status<300){try{F=g.parse(C.responseText)}catch(G){c.emit("error","Could not parse HTTP response: "+C.responseText);if(x){x.call(y,C,null)}}if(x&&F){x.call(y,null,F)}}else{c.emit("error","HTTP request failed.");if(x){x.call(y,C,null)}}}};C.open(E,z,true);C.setRequestHeader("Authorization",y.writeKey());C.setRequestHeader("Content-Type","application/json");if(A){B=g.stringify(A)}if(E.toUpperCase()==="GET"){C.send()}if(E.toUpperCase()==="POST"){C.send(B)}}function a(x){var y=q();if(y){y.open("GET",x,false);y.send(null)}}function q(){var x="undefined"==typeof window?this:window;if(x.XMLHttpRequest&&("file:"!=x.location.protocol||!x.ActiveXObject)){return new XMLHttpRequest}else{try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(y){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(y){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(y){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(y){}}return false}function h(x,G){var H=this,A=G,C=new Date().getTime(),E=document.createElement("script"),F=document.getElementsByTagName("head")[0],D="keenJSONPCallback",B=false;G=null;D+=C;while(D in window){D+="a"}window[D]=function(I){if(B===true){return}B=true;if(A){A.call(H,null,I)}y()};E.src=x+"&jsonp="+D;F.appendChild(E);E.onreadystatechange=function(){if(B===false&&this.readyState==="loaded"){B=true;z();y()}};E.onerror=function(){if(B===false){B=true;z();y()}};function z(){if(A){A.call(H,"An error occurred!",null)}}function y(){window[D]=undefined;try{delete window[D]}catch(I){}F.removeChild(E)}}function k(B,C){var z=this,x=C,y=document.createElement("img"),A=false;C=null;y.onload=function(){A=true;if("naturalHeight" in this){if(this.naturalHeight+this.naturalWidth===0){this.onerror();return}}else{if(this.width+this.height===0){this.onerror();return}}if(x){x.call(z)}};y.onerror=function(){A=true;if(x){x.call(z,"An error occurred!",null)}};y.src=B+"&c=clv1"}},{"./extend-events":3,"./index":10,"./utils/base64":12,"./utils/each":15,"./utils/extend":16,JSON2:22}],12:[function(b,c,a){c.exports={map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(f){var d="",l=0,h=this.map,k,j,g,s,r,q,p;f=this.utf8.encode(f);while(l>2);r=(((k&3)<<4)|(j>>4));q=(isNaN(j)?64:((j&15)<<2)|(g>>6));p=(isNaN(j)||isNaN(g))?64:g&63;d=d+h.charAt(s)+h.charAt(r)+h.charAt(q)+h.charAt(p)}return d},decode:function(f){var d="",p=0,h=this.map,g=String.fromCharCode,t,s,r,q,l,k,j;f=f.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(p>4);k=((s&15)<<4)|(r>>2);j=((r&3)<<6)|q;d=d+(g(l)+((r!=64)?g(k):""))+(((q!=64)?g(j):""))}return this.utf8.decode(d)},utf8:{encode:function(j){var f="",d=0,h=String.fromCharCode,g;while(d127)&&(g<2048))?(h((g>>6)|192)+h((g&63)|128)):(h((g>>12)|224)+h(((g>>6)&63)|128)+h((g&63)|128)))}return f},decode:function(k){var g="",f=0,j=String.fromCharCode,d,h;while(f191)&&(h<224))?[j(((h&31)<<6)|((d=k.charCodeAt(f+1))&63)),(f+=2)][0]:[j(((h&15)<<12)|(((d=k.charCodeAt(f+1))&63)<<6)|((c3=k.charCodeAt(f+2))&63)),(f+=3)][0])}return g}}}},{}],13:[function(b,f,a){var d=b("cookies-js");var g=b("JSON2");var h=b("./extend");f.exports=c;function c(i){if(!arguments.length){return}if(this instanceof c===false){return new c(i)}this.config={key:i,options:{}};this.data=this.get();return this}c.prototype.get=function(j){var i=d.get(this.config.key)?g.parse(decodeURIComponent(d.get(this.config.key))):{};return(j&&typeof i[j]!=="undefined")?i[j]:i};c.prototype.set=function(j,i){if(!arguments.length){return this}if("string"===typeof j&&arguments.length===2){this.data[j]=i?i:null}else{if("object"===typeof j&&arguments.length===1){h(this.data,j)}}d.set(this.config.key,encodeURIComponent(g.stringify(this.data)),this.config.options);return this};c.prototype.expire=function(){d.expire(this.config.key);this.data={};return this};c.prototype.options=function(i){if(!arguments.length){return this.config.options}this.config.options=(typeof i==="object")?i:{};return this}},{"./extend":16,JSON2:22,"cookies-js":25}],14:[function(c,d,a){var f=c("JSON2");d.exports=b;function b(l){for(var k=1;k0&&this.interval>=this.config.interval)||this.capacity>=this.config.capacity){this.emit("flush");this.interval=0}}f(a.prototype)},{"component-emitter":24}],20:[function(b,c,a){c.exports=d;function d(f){if(this instanceof d===false){return new d(f)}this.count=f||0;return this}d.prototype.start=function(){var f=this;this.pause();this.interval=setInterval(function(){f.count++},1000);return this};d.prototype.pause=function(){clearInterval(this.interval);return this};d.prototype.value=function(){return this.count};d.prototype.clear=function(){this.count=0;return this}},{}],21:[function(require,module,exports){(function(exports){if(typeof exports.decycle!=="function"){exports.decycle=function decycle(object){var objects=[],paths=[];return(function derez(value,path){var i,name,nu;switch(typeof value){case"object":if(!value){return null}for(i=0;i` click events set with .once("click", fn)', function(done){ var listen = listener('a#listen-to-anchor-once'); - listen.once('click', function(e){ + listen.once('click', callback); + + this.timeout(5000); + + function callback(e){ // Keen.log('click a#listen-to-anchor-once'); done(); return false; - }); + } setTimeout(function(){ var ev, a; @@ -159,10 +162,6 @@ describe('Keen.utils.listener', function() { }, 1000); }); - function createEvent(){ - - } - it('should remove specific handlers with .off("click", fn)', function(){ var listenToThis = listener('body a#on-off');