diff --git a/dist/keen-tracking.js b/dist/keen-tracking.js index 6b100fa..61da3df 100644 --- a/dist/keen-tracking.js +++ b/dist/keen-tracking.js @@ -23,10 +23,11 @@ 'getWindowProfile' : require('./helpers/getWindowProfile') }); extend(KeenLibrary.utils, { - 'cookie' : require('./utils/cookie'), - 'deepExtend' : require('./utils/deepExtend'), - 'listener' : listener, - 'timer' : require('./utils/timer') + 'cookie' : require('./utils/cookie'), + 'deepExtend' : require('./utils/deepExtend'), + 'listener' : listener, + 'serializeForm' : require('./utils/serializeForm'), + 'timer' : require('./utils/timer') }); KeenLibrary.listenTo = function(listenerHash){ each(listenerHash, function(callback, key){ @@ -115,7 +116,7 @@ env.Keen = KeenLibrary.extendLibrary(KeenLibrary); }).call(this, typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}); }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./":11,"./defer-events":2,"./extend-events":3,"./helpers/getBrowserProfile":4,"./helpers/getDatetimeIndex":5,"./helpers/getDomNodePath":6,"./helpers/getDomNodeProfile":7,"./helpers/getScreenProfile":8,"./helpers/getUniqueId":9,"./helpers/getWindowProfile":10,"./record-events-browser":12,"./utils/cookie":14,"./utils/deepExtend":15,"./utils/each":16,"./utils/extend":17,"./utils/listener":18,"./utils/timer":20}],2:[function(require,module,exports){ +},{"./":11,"./defer-events":2,"./extend-events":3,"./helpers/getBrowserProfile":4,"./helpers/getDatetimeIndex":5,"./helpers/getDomNodePath":6,"./helpers/getDomNodeProfile":7,"./helpers/getScreenProfile":8,"./helpers/getUniqueId":9,"./helpers/getWindowProfile":10,"./record-events-browser":12,"./utils/cookie":14,"./utils/deepExtend":15,"./utils/each":16,"./utils/extend":17,"./utils/listener":18,"./utils/serializeForm":20,"./utils/timer":21}],2:[function(require,module,exports){ var Keen = require('./index'); var each = require('./utils/each'); var queue = require('./utils/queue'); @@ -402,7 +403,7 @@ KeenCore.prototype.setGlobalProperties = function(props){ return this; }; module.exports = KeenCore; -},{"./utils/each":16,"./utils/extend":17,"./utils/queue":19,"keen-core":23}],12:[function(require,module,exports){ +},{"./utils/each":16,"./utils/extend":17,"./utils/queue":19,"keen-core":24}],12:[function(require,module,exports){ var Keen = require('./index'); var base64 = require('./utils/base64'); var each = require('./utils/each'); @@ -715,7 +716,7 @@ function sendBeacon(url, callback){ } },{"./extend-events":3,"./index":11,"./utils/base64":13,"./utils/each":16,"./utils/extend":17}],13:[function(require,module,exports){ module.exports = require('keen-core/lib/utils/base64'); -},{"keen-core/lib/utils/base64":24}],14:[function(require,module,exports){ +},{"keen-core/lib/utils/base64":25}],14:[function(require,module,exports){ var Cookies = require('js-cookie'); var extend = require('./extend'); module.exports = cookie; @@ -773,7 +774,7 @@ cookie.prototype.options = function(obj){ cookie.prototype.enabled = function(){ return navigator.cookieEnabled; }; -},{"./extend":17,"js-cookie":22}],15:[function(require,module,exports){ +},{"./extend":17,"js-cookie":23}],15:[function(require,module,exports){ module.exports = deepExtend; function deepExtend(target){ for (var i = 1; i < arguments.length; i++) { @@ -802,9 +803,9 @@ function clone(input){ } },{}],16:[function(require,module,exports){ module.exports = require('keen-core/lib/utils/each'); -},{"keen-core/lib/utils/each":25}],17:[function(require,module,exports){ +},{"keen-core/lib/utils/each":26}],17:[function(require,module,exports){ module.exports = require('keen-core/lib/utils/extend'); -},{"keen-core/lib/utils/extend":26}],18:[function(require,module,exports){ +},{"keen-core/lib/utils/extend":27}],18:[function(require,module,exports){ var Emitter = require('component-emitter'); var each = require('./each'); /* @@ -976,7 +977,7 @@ function deferFormSubmit(evt, form, callback){ } return false; } -},{"./each":16,"component-emitter":21}],19:[function(require,module,exports){ +},{"./each":16,"component-emitter":22}],19:[function(require,module,exports){ var Emitter = require('component-emitter'); function queue() { if (this instanceof queue === false) { @@ -1034,7 +1035,174 @@ function shouldFlushQueue(props) { return false; } module.exports = queue; -},{"component-emitter":21}],20:[function(require,module,exports){ +},{"component-emitter":22}],20:[function(require,module,exports){ +/* + This is a modified copy of https://github.com/defunctzombie/form-serialize/ v0.7.1 + Includes a new configuration option: + * ignoreTypes - Array, Default: [], Example: [ 'password' ] +*/ +var k_r_submitter = /^(?:submit|button|image|reset|file)$/i; +var k_r_success_contrls = /^(?:input|select|textarea|keygen)/i; +var brackets = /(\[[^\[\]]*\])/g; +function serialize(form, options) { + if (typeof options != 'object') { + options = { hash: !!options }; + } + else if (options.hash === undefined) { + options.hash = true; + } + var result = (options.hash) ? {} : ''; + var serializer = options.serializer || ((options.hash) ? hash_serializer : str_serialize); + var elements = form && form.elements ? form.elements : []; + var radio_store = Object.create(null); + for (var i=0 ; i -1) { + continue; + } + if ((!options.disabled && element.disabled) || !element.name) { + continue; + } + if (!k_r_success_contrls.test(element.nodeName) || + k_r_submitter.test(element.type)) { + continue; + } + var key = element.name; + var val = element.value; + if ((element.type === 'checkbox' || element.type === 'radio') && !element.checked) { + val = undefined; + } + if (options.empty) { + if (element.type === 'checkbox' && !element.checked) { + val = ''; + } + if (element.type === 'radio') { + if (!radio_store[element.name] && !element.checked) { + radio_store[element.name] = false; + } + else if (element.checked) { + radio_store[element.name] = true; + } + } + if (val == undefined && element.type == 'radio') { + continue; + } + } + else { + if (!val) { + continue; + } + } + if (element.type === 'select-multiple') { + val = []; + var selectOptions = element.options; + var isSelectedOptions = false; + for (var j=0 ; j or
DOM element"),r&&(i=function(){l||(l=!0,r())}),this.recordEvent(t,n,i),setTimeout(i,a),c.metaKey?void 0:!1}var r=e("./"),i=e("./utils/each"),s=e("./utils/extend"),c=e("./utils/listener")(r);s(r.prototype,e("./record-events-browser")),s(r.prototype,e("./defer-events")),s(r.prototype,{extendEvent:e("./extend-events").extendEvent,extendEvents:e("./extend-events").extendEvents}),r.prototype.trackExternalLink=o,s(r.helpers,{getBrowserProfile:e("./helpers/getBrowserProfile"),getDatetimeIndex:e("./helpers/getDatetimeIndex"),getDomNodePath:e("./helpers/getDomNodePath"),getDomNodeProfile:e("./helpers/getDomNodeProfile"),getScreenProfile:e("./helpers/getScreenProfile"),getUniqueId:e("./helpers/getUniqueId"),getWindowProfile:e("./helpers/getWindowProfile")}),s(r.utils,{cookie:e("./utils/cookie"),deepExtend:e("./utils/deepExtend"),listener:c,timer:e("./utils/timer")}),r.listenTo=function(e){i(e,function(e,t){var n=t.split(" "),o=n[0],r=n.slice(1,n.length).join(" ");return c(r).on(o,e)})},Array.prototype.indexOf||(Array.prototype.indexOf=function(e){var t=this.length>>>0,n=Number(arguments[1])||0;for(n=0>n?Math.ceil(n):Math.floor(n),0>n&&(n+=t);t>n;n++)if(n in this&&this[n]===e)return n;return-1}),"undefined"!=typeof t&&t.exports&&(t.exports=r),"undefined"!=typeof define&&define.amd&&define("keen-tracking",[],function(){return r}),n.Keen=r.extendLibrary(r)}).call(this,"undefined"!=typeof window?window:"undefined"!=typeof n?n:"undefined"!=typeof self?self:{})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./":11,"./defer-events":2,"./extend-events":3,"./helpers/getBrowserProfile":4,"./helpers/getDatetimeIndex":5,"./helpers/getDomNodePath":6,"./helpers/getDomNodeProfile":7,"./helpers/getScreenProfile":8,"./helpers/getUniqueId":9,"./helpers/getWindowProfile":10,"./record-events-browser":12,"./utils/cookie":14,"./utils/deepExtend":15,"./utils/each":16,"./utils/extend":17,"./utils/listener":18,"./utils/timer":20}],2:[function(e,t,n){function o(e,t){return 2!==arguments.length||"string"!=typeof e?void u.call(this,"Incorrect arguments provided to #deferEvent method"):(this.queue.events[e]=this.queue.events[e]||[],this.queue.events[e].push(t),this.queue.capacity++,this.queue.timer||this.queue.start(),this.emit("deferEvent",e,t),this)}function r(e){var t=this;return 1!==arguments.length||"object"!=typeof e?void u.call(this,"Incorrect arguments provided to #deferEvents method"):(a(e,function(e,n){t.queue.events[n]=t.queue.events[n]||[],t.queue.events[n]=t.queue.events[n].concat(e),t.queue.capacity=t.queue.capacity+e.length,t.queue.timer||t.queue.start()}),t.emit("deferEvents",e),t)}function i(e){return arguments.length?(this.queue.config.capacity=e?Number(e):0,this.queue.check(),this):this.queue.config.capacity}function s(e){return arguments.length?(this.queue.config.interval=e?Number(e):0,this.queue.check(),this):this.queue.config.interval}function c(){var e,t,n=this;return n.queue.capacity>0&&(n.queue.pause(),e=JSON.parse(JSON.stringify(n.queue.config)),t=JSON.parse(JSON.stringify(n.queue.events)),n.queue=l(),n.queue.config=e,n.emit("recordDeferredEvents",t),n.recordEvents(t,function(e,o){e?n.recordEvents(t):t=void 0})),n}function u(e){var t="Event(s) not deferred: "+e;this.emit("error",t)}var a=(e("./index"),e("./utils/each")),l=e("./utils/queue");t.exports={deferEvent:o,deferEvents:r,queueCapacity:i,queueInterval:s,recordDeferredEvents:c}},{"./index":11,"./utils/each":16,"./utils/queue":19}],3:[function(e,t,n){function o(e,t){return 2!==arguments.length||"string"!=typeof e||"object"!=typeof t&&"function"!=typeof t?void i.call(this,"Incorrect arguments provided to #extendEvent method"):(this.extensions.collections[e]=this.extensions.collections[e]||[],this.extensions.collections[e].push(t),this.emit("extendEvent",e,t),this)}function r(e){return 1!==arguments.length||"object"!=typeof e&&"function"!=typeof e?void i.call(this,"Incorrect arguments provided to #extendEvents method"):(this.extensions.events.push(e),this.emit("extendEvents",e),this)}function i(e){var t="Event(s) not extended: "+e;this.emit("error",t)}function s(e,t){return t&&t.length>0&&u(t,function(t,n){var o="function"==typeof t?t():t;c(e,o)}),e}var c=e("./utils/deepExtend"),u=e("./utils/each");t.exports={extendEvent:o,extendEvents:r,getExtendedEventBody:s}},{"./utils/deepExtend":15,"./utils/each":16}],4:[function(e,t,n){function o(){return{cookies:"undefined"!=typeof navigator.cookieEnabled?navigator.cookieEnabled:!1,codeName:navigator.appCodeName,description:r(),language:navigator.language,name:navigator.appName,online:navigator.onLine,platform:navigator.platform,useragent:navigator.userAgent,version:navigator.appVersion,screen:i(),window:s()}}function r(){var e;return document&&"function"==typeof document.querySelector&&(e=document.querySelector('meta[name="description"]')),e?e.content:""}var i=e("./getScreenProfile"),s=e("./getWindowProfile");t.exports=o},{"./getScreenProfile":8,"./getWindowProfile":10}],5:[function(e,t,n){function o(e){var t=e||new Date;return{hour_of_day:t.getHours(),day_of_week:parseInt(1+t.getDay()),day_of_month:t.getDate(),month:parseInt(1+t.getMonth()),year:t.getFullYear()}}t.exports=o},{}],6:[function(e,t,n){function o(e){if(!e.nodeName)return"";for(var t=[];null!=e.parentNode;){for(var n=0,o=0,r=0;r1?t.unshift(e.nodeName.toLowerCase()+":eq("+o+")"):t.unshift(e.nodeName.toLowerCase()),e=e.parentNode}return t.slice(1).join(" > ")}t.exports=o},{}],7:[function(e,t,n){function o(e){return{action:e.action,"class":e.className,href:e.href,id:e.id,method:e.method,name:e.name,node_name:e.nodeName,selector:r(e),text:e.text,title:e.title,type:e.type,x_position:e.offsetLeft||e.clientLeft||null,y_position:e.offsetTop||e.clientTop||null}}var r=e("./getDomNodePath");t.exports=o},{"./getDomNodePath":6}],8:[function(e,t,n){function o(){var e,t;if("undefined"==typeof window||!window.screen)return{};e=["height","width","colorDepth","pixelDepth","availHeight","availWidth"],t={};for(var n=0;nwindow.innerHeight?"landscape":"portrait"},t}t.exports=o},{}],9:[function(e,t,n){function o(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";return e.replace(/[xy]/g,function(e){var t=16*Math.random()|0,n="x"==e?t:3&t|8;return n.toString(16)})}t.exports=o},{}],10:[function(e,t,n){function o(){var e,t,n;return"undefined"==typeof document?{}:(e=document.body,t=document.documentElement,n={height:"innerHeight"in window?window.innerHeight:document.documentElement.offsetHeight,width:"innerWidth"in window?window.innerWidth:document.documentElement.offsetWidth,scrollHeight:Math.max(e.scrollHeight,e.offsetHeight,t.clientHeight,t.scrollHeight,t.offsetHeight)||null},window.screen&&(n.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}),n)}t.exports=o},{}],11:[function(e,t,n){var o=e("keen-core"),r=(e("./utils/each"),e("./utils/extend"),e("./utils/queue"));o.helpers=o.helpers||{},o.on("client",function(e){e.extensions={events:[],collections:{}},e.queue=r(),e.queue.on("flush",function(){e.recordDeferredEvents()})}),o.prototype.writeKey=function(e){return arguments.length?(this.config.writeKey=e?String(e):null,this):this.config.writeKey},o.prototype.setGlobalProperties=function(e){return o.log("This method has been deprecated. Check out #extendEvents: https://github.com/keen/keen-tracking.js#extend-events"),e&&"function"==typeof e?(this.config.globalProperties=e,this):void this.emit("error","Invalid value for global properties: "+e)},t.exports=o},{"./utils/each":16,"./utils/extend":17,"./utils/queue":19,"keen-core":23}],12:[function(e,t,n){function o(e,t,n,o){var r,i,s,h,y,b,k;if(r=this.url("events",encodeURIComponent(e)),i={},s=n,k="boolean"==typeof o?o:!0,c.call(this,s)){if(!e||"string"!=typeof e)return void u.call(this,"Collection name must be a string.",s);if(this.config.globalProperties&&(i=this.config.globalProperties(e)),x(i,t),b={},w.getExtendedEventBody(b,this.extensions.events),w.getExtendedEventBody(b,this.extensions.collections[e]),w.getExtendedEventBody(b,[i]),this.emit("recordEvent",e,b),!m.enabled)return u.call(this,"Keen.enabled is set to false.",s),!1;if(h=this.url("events",encodeURIComponent(e),{api_key:this.writeKey(),data:encodeURIComponent(v.encode(JSON.stringify(b))),modified:(new Date).getTime()}),y=h.length2?void u.call(this,"Incorrect arguments provided to #recordEvents method",o):(this.config.globalProperties&&y(e,function(t,n){y(t,function(t,o){var r=i.config.globalProperties(n);e[n][o]=x(r,t)})}),r={},y(e,function(e,t){r[t]=r[t]||[],y(e,function(e,n){var o={};w.getExtendedEventBody(o,i.extensions.events),w.getExtendedEventBody(o,i.extensions.collections[t]),w.getExtendedEventBody(o,[e]),r[t].push(o)})}),this.emit("recordEvents",r),m.enabled?(h()&&d.call(this,"POST",n,r,o),t=o=null,this):(u.call(this,"Keen.enabled is set to false.",o),!1)):void 0}function i(){this.emit("error","This method has been deprecated. Check out #recordEvent: https://github.com/keen/keen-tracking.js#record-a-single-event"),o.apply(this,arguments)}function s(){this.emit("error","This method has been deprecated. Check out #recordEvents: https://github.com/keen/keen-tracking.js#record-multiple-events"),r.apply(this,arguments)}function c(e){var t=e;return e=null,this.projectId()?this.writeKey()?!0:(u.call(this,"Keen.Client is missing a writeKey property.",t),!1):(u.call(this,"Keen.Client is missing a projectId property.",t),!1)}function u(e,t){var n="Event(s) not recorded: "+e;this.emit("error",n),t&&(t.call(this,n,null),t=null)}function a(){return"undefined"!=typeof window&&navigator&&(-1!==navigator.userAgent.indexOf("MSIE")||navigator.appVersion.indexOf("Trident/")>0)?2e3:16e3}function l(e,t,n,o){h()?d.call(this,"POST",e,t,o):u.call(this,n)}function d(e,t,n,o){var r,i=this,s=h(),c=o;o=null,s.onreadystatechange=function(){var e;if(4==s.readyState)if(s.status>=200&&s.status<300){try{e=JSON.parse(s.responseText)}catch(t){m.emit("error","Could not parse HTTP response: "+s.responseText),c&&c.call(i,s,null)}c&&e&&c.call(i,null,e)}else m.emit("error","HTTP request failed."),c&&c.call(i,s,null)},s.open(e,t,!0),s.setRequestHeader("Authorization",i.writeKey()),s.setRequestHeader("Content-Type","application/json"),n&&(r=JSON.stringify(n)),"GET"===e.toUpperCase()&&s.send(),"POST"===e.toUpperCase()&&s.send(r)}function f(e){var t=h();t&&(t.open("GET",e,!1),t.send(null))}function h(){var e="undefined"==typeof window?this:window;if(e.XMLHttpRequest&&("file:"!=e.location.protocol||!e.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}return!1}function p(e,t){function n(){i&&i.call(r,"An error occurred!",null)}function o(){window[a]=void 0;try{delete window[a]}catch(e){}u.removeChild(c)}var r=this,i=t,s=(new Date).getTime(),c=document.createElement("script"),u=document.getElementsByTagName("head")[0],a="keenJSONPCallback",l=!1;for(t=null,a+=s;a in window;)a+="a";window[a]=function(e){l!==!0&&(l=!0,i&&i.call(r,null,e),o())},c.src=e+"&jsonp="+a,u.appendChild(c),c.onreadystatechange=function(){l===!1&&"loaded"===this.readyState&&(l=!0,n(),o())},c.onerror=function(){l===!1&&(l=!0,n(),o())}}function g(e,t){var n=this,o=t,r=document.createElement("img"),i=!1;t=null,r.onload=function(){if(i=!0,"naturalHeight"in this){if(this.naturalHeight+this.naturalWidth===0)return void this.onerror()}else if(this.width+this.height===0)return void this.onerror();o&&o.call(n)},r.onerror=function(){i=!0,o&&o.call(n,"An error occurred!",null)},r.src=e+"&c=clv1"}var m=e("./index"),v=e("./utils/base64"),y=e("./utils/each"),x=e("./utils/extend"),w=e("./extend-events");t.exports={recordEvent:o,recordEvents:r,addEvent:i,addEvents:s}},{"./extend-events":3,"./index":11,"./utils/base64":13,"./utils/each":16,"./utils/extend":17}],13:[function(e,t,n){t.exports=e("keen-core/lib/utils/base64")},{"keen-core/lib/utils/base64":24}],14:[function(e,t,n){function o(e){return arguments.length?this instanceof o==!1?new o(e):(this.config={key:e,options:{expires:365}},this.data=this.get(),this):void 0}var r=e("js-cookie"),i=e("./extend");t.exports=o,o.prototype.get=function(e){var t={};return r.get(this.config.key)&&(t=r.getJSON(this.config.key)),e&&"object"==typeof t&&null!==typeof t?"undefined"!=typeof t[e]?t[e]:null:t},o.prototype.set=function(e,t){return arguments.length&&this.enabled()?("string"==typeof e&&2===arguments.length?this.data[e]=t?t:null:"object"==typeof e&&1===arguments.length&&i(this.data,e),r.set(this.config.key,this.data,this.config.options),this):this},o.prototype.expire=function(e){return e?r.set(this.config.key,this.data,i(this.config.options,{expires:e})):(r.remove(this.config.key),this.data={}),this},o.prototype.options=function(e){return arguments.length?(this.config.options="object"==typeof e?e:{},this):this.config.options},o.prototype.enabled=function(){return navigator.cookieEnabled}},{"./extend":17,"js-cookie":22}],15:[function(e,t,n){function o(e){for(var t=1;t0&&e.interval>=e.config.interval?!0:e.capacity>=e.config.capacity?!0:!1}var i=e("component-emitter");i(o.prototype),o.prototype.check=function(){return r(this)&&this.flush(),(0===this.config.interval||0===this.capacity)&&this.pause(),this},o.prototype.flush=function(){return this.emit("flush"),this.interval=0,this},o.prototype.pause=function(){return this.timer&&(clearInterval(this.timer),this.timer=null),this},o.prototype.start=function(){var e=this;return e.pause(),e.timer=setInterval(function(){e.interval++,e.check()},1e3),e},t.exports=o},{"component-emitter":21}],20:[function(e,t,n){function o(e){return this instanceof o==!1?new o(e):(this.count=e||0,this)}t.exports=o,o.prototype.start=function(){var e=this;return this.pause(),this.interval=setInterval(function(){e.count++},1e3),this},o.prototype.pause=function(){return clearInterval(this.interval),this},o.prototype.value=function(){return this.count},o.prototype.clear=function(){return this.count=0,this}},{}],21:[function(e,t,n){function o(e){return e?r(e):void 0}function r(e){for(var t in o.prototype)e[t]=o.prototype[t];return e}"undefined"!=typeof t&&(t.exports=o),o.prototype.on=o.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},o.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},o.prototype.off=o.prototype.removeListener=o.prototype.removeAllListeners=o.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o,r=0;ro;++o)n[o].apply(this,t)}return this},o.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},o.prototype.hasListeners=function(e){return!!this.listeners(e).length}},{}],22:[function(e,t,n){!function(e){if("object"==typeof n)t.exports=e();else{var o=window.Cookies,r=window.Cookies=e();r.noConflict=function(){return window.Cookies=o,r}}}(function(){function e(){for(var e=0,t={};e1){if(i=e({path:"/"},o.defaults,i),"number"==typeof i.expires){var c=new Date;c.setMilliseconds(c.getMilliseconds()+864e5*i.expires),i.expires=c}try{s=JSON.stringify(r),/^[\{\[]/.test(s)&&(r=s)}catch(u){}return r=n.write?n.write(r,t):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)),t=t.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),t=t.replace(/[\(\)]/g,escape),document.cookie=[t,"=",r,i.expires&&"; expires="+i.expires.toUTCString(),i.path&&"; path="+i.path,i.domain&&"; domain="+i.domain,i.secure?"; secure":""].join("")}t||(s={});for(var a=document.cookie?document.cookie.split("; "):[],l=/(%[0-9A-Z]{2})+/g,d=0;d-1&&(t.protocol=document.location.protocol.replace(":","")),t.host&&t.host.replace(/.*?:\/\//g,""),a(this.config,t),this},o.prototype.masterKey=function(e){return arguments.length?(this.config.masterKey=e?String(e):null,this):this.config.masterKey},o.prototype.projectId=function(e){return arguments.length?(this.config.projectId=e?String(e):null,this):this.config.projectId},o.prototype.resources=function(e){if(!arguments.length)return this.config.resources;var t=this;return"object"==typeof e&&u(e,function(e,n){t.config.resources[n]=e?e:null}),t},o.prototype.url=function(e){var t,n=Array.prototype.slice.call(arguments,1),o=this.config.resources.base||"{protocol}://{host}";return t=e&&"string"==typeof e?this.config.resources[e]?this.config.resources[e]:o+e:o,u(this.config,function(e,n){"object"!=typeof e&&(t=t.replace("{"+n+"}",e))}),u(n,function(e,n){"string"==typeof e?t+="/"+e:"object"==typeof e&&(t+="?",u(e,function(e,n){t+=n+"="+e+"&"}),t=t.slice(0,-1))}),t},r(function(){o.loaded=!0,o.emit("ready")}),t.exports=o}).call(this,"undefined"!=typeof window?window:"undefined"!=typeof n?n:"undefined"!=typeof self?self:{})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils/each":25,"./utils/extend":26,"./utils/parse-params":27,"./utils/serialize":28,"component-emitter":21}],24:[function(e,t,n){t.exports={map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){"use strict";var t,n,o,r,i,s,c,u="",a=0,l=this.map;for(e=this.utf8.encode(e);a>2,i=(3&t)<<4|n>>4,s=isNaN(n)?64:(15&n)<<2|o>>6,c=isNaN(n)||isNaN(o)?64:63&o,u=u+l.charAt(r)+l.charAt(i)+l.charAt(s)+l.charAt(c);return u},decode:function(e){"use strict";var t,n,o,r,i,s,c,u="",a=0,l=this.map,d=String.fromCharCode;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");a>4,s=(15&n)<<4|o>>2,c=(3&o)<<6|r,u=u+(d(i)+(64!=o?d(s):""))+(64!=r?d(c):"");return this.utf8.decode(u)},utf8:{encode:function(e){"use strict";for(var t,n="",o=0,r=String.fromCharCode;ot?r(t):t>127&&2048>t?r(t>>6|192)+r(63&t|128):r(t>>12|224)+r(t>>6&63|128)+r(63&t|128);return n},decode:function(e){"use strict";for(var t,n,o="",r=0,i=String.fromCharCode;rn?[i(n),r++][0]:n>191&&224>n?[i((31&n)<<6|63&(t=e.charCodeAt(r+1))),r+=2][0]:[i((15&n)<<12|(63&(t=e.charCodeAt(r+1)))<<6|63&(c3=e.charCodeAt(r+2))),r+=3][0];return o}}}},{}],25:[function(e,t,n){function o(e,t,n){var o;if(!e)return 0;if(n=n?n:e,e instanceof Array){for(o=0;o or DOM element"),o&&(i=function(){l||(l=!0,o())}),this.recordEvent(t,n,i),setTimeout(i,u),c.metaKey?void 0:!1}var o=e("./"),i=e("./utils/each"),s=e("./utils/extend"),c=e("./utils/listener")(o);s(o.prototype,e("./record-events-browser")),s(o.prototype,e("./defer-events")),s(o.prototype,{extendEvent:e("./extend-events").extendEvent,extendEvents:e("./extend-events").extendEvents}),o.prototype.trackExternalLink=r,s(o.helpers,{getBrowserProfile:e("./helpers/getBrowserProfile"),getDatetimeIndex:e("./helpers/getDatetimeIndex"),getDomNodePath:e("./helpers/getDomNodePath"),getDomNodeProfile:e("./helpers/getDomNodeProfile"),getScreenProfile:e("./helpers/getScreenProfile"),getUniqueId:e("./helpers/getUniqueId"),getWindowProfile:e("./helpers/getWindowProfile")}),s(o.utils,{cookie:e("./utils/cookie"),deepExtend:e("./utils/deepExtend"),listener:c,serializeForm:e("./utils/serializeForm"),timer:e("./utils/timer")}),o.listenTo=function(e){i(e,function(e,t){var n=t.split(" "),r=n[0],o=n.slice(1,n.length).join(" ");return c(o).on(r,e)})},Array.prototype.indexOf||(Array.prototype.indexOf=function(e){var t=this.length>>>0,n=Number(arguments[1])||0;for(n=0>n?Math.ceil(n):Math.floor(n),0>n&&(n+=t);t>n;n++)if(n in this&&this[n]===e)return n;return-1}),"undefined"!=typeof t&&t.exports&&(t.exports=o),"undefined"!=typeof define&&define.amd&&define("keen-tracking",[],function(){return o}),n.Keen=o.extendLibrary(o)}).call(this,"undefined"!=typeof window?window:"undefined"!=typeof n?n:"undefined"!=typeof self?self:{})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./":11,"./defer-events":2,"./extend-events":3,"./helpers/getBrowserProfile":4,"./helpers/getDatetimeIndex":5,"./helpers/getDomNodePath":6,"./helpers/getDomNodeProfile":7,"./helpers/getScreenProfile":8,"./helpers/getUniqueId":9,"./helpers/getWindowProfile":10,"./record-events-browser":12,"./utils/cookie":14,"./utils/deepExtend":15,"./utils/each":16,"./utils/extend":17,"./utils/listener":18,"./utils/serializeForm":20,"./utils/timer":21}],2:[function(e,t,n){function r(e,t){return 2!==arguments.length||"string"!=typeof e?void a.call(this,"Incorrect arguments provided to #deferEvent method"):(this.queue.events[e]=this.queue.events[e]||[],this.queue.events[e].push(t),this.queue.capacity++,this.queue.timer||this.queue.start(),this.emit("deferEvent",e,t),this)}function o(e){var t=this;return 1!==arguments.length||"object"!=typeof e?void a.call(this,"Incorrect arguments provided to #deferEvents method"):(u(e,function(e,n){t.queue.events[n]=t.queue.events[n]||[],t.queue.events[n]=t.queue.events[n].concat(e),t.queue.capacity=t.queue.capacity+e.length,t.queue.timer||t.queue.start()}),t.emit("deferEvents",e),t)}function i(e){return arguments.length?(this.queue.config.capacity=e?Number(e):0,this.queue.check(),this):this.queue.config.capacity}function s(e){return arguments.length?(this.queue.config.interval=e?Number(e):0,this.queue.check(),this):this.queue.config.interval}function c(){var e,t,n=this;return n.queue.capacity>0&&(n.queue.pause(),e=JSON.parse(JSON.stringify(n.queue.config)),t=JSON.parse(JSON.stringify(n.queue.events)),n.queue=l(),n.queue.config=e,n.emit("recordDeferredEvents",t),n.recordEvents(t,function(e,r){e?n.recordEvents(t):t=void 0})),n}function a(e){var t="Event(s) not deferred: "+e;this.emit("error",t)}var u=(e("./index"),e("./utils/each")),l=e("./utils/queue");t.exports={deferEvent:r,deferEvents:o,queueCapacity:i,queueInterval:s,recordDeferredEvents:c}},{"./index":11,"./utils/each":16,"./utils/queue":19}],3:[function(e,t,n){function r(e,t){return 2!==arguments.length||"string"!=typeof e||"object"!=typeof t&&"function"!=typeof t?void i.call(this,"Incorrect arguments provided to #extendEvent method"):(this.extensions.collections[e]=this.extensions.collections[e]||[],this.extensions.collections[e].push(t),this.emit("extendEvent",e,t),this)}function o(e){return 1!==arguments.length||"object"!=typeof e&&"function"!=typeof e?void i.call(this,"Incorrect arguments provided to #extendEvents method"):(this.extensions.events.push(e),this.emit("extendEvents",e),this)}function i(e){var t="Event(s) not extended: "+e;this.emit("error",t)}function s(e,t){return t&&t.length>0&&a(t,function(t,n){var r="function"==typeof t?t():t;c(e,r)}),e}var c=e("./utils/deepExtend"),a=e("./utils/each");t.exports={extendEvent:r,extendEvents:o,getExtendedEventBody:s}},{"./utils/deepExtend":15,"./utils/each":16}],4:[function(e,t,n){function r(){return{cookies:"undefined"!=typeof navigator.cookieEnabled?navigator.cookieEnabled:!1,codeName:navigator.appCodeName,description:o(),language:navigator.language,name:navigator.appName,online:navigator.onLine,platform:navigator.platform,useragent:navigator.userAgent,version:navigator.appVersion,screen:i(),window:s()}}function o(){var e;return document&&"function"==typeof document.querySelector&&(e=document.querySelector('meta[name="description"]')),e?e.content:""}var i=e("./getScreenProfile"),s=e("./getWindowProfile");t.exports=r},{"./getScreenProfile":8,"./getWindowProfile":10}],5:[function(e,t,n){function r(e){var t=e||new Date;return{hour_of_day:t.getHours(),day_of_week:parseInt(1+t.getDay()),day_of_month:t.getDate(),month:parseInt(1+t.getMonth()),year:t.getFullYear()}}t.exports=r},{}],6:[function(e,t,n){function r(e){if(!e.nodeName)return"";for(var t=[];null!=e.parentNode;){for(var n=0,r=0,o=0;o1?t.unshift(e.nodeName.toLowerCase()+":eq("+r+")"):t.unshift(e.nodeName.toLowerCase()),e=e.parentNode}return t.slice(1).join(" > ")}t.exports=r},{}],7:[function(e,t,n){function r(e){return{action:e.action,"class":e.className,href:e.href,id:e.id,method:e.method,name:e.name,node_name:e.nodeName,selector:o(e),text:e.text,title:e.title,type:e.type,x_position:e.offsetLeft||e.clientLeft||null,y_position:e.offsetTop||e.clientTop||null}}var o=e("./getDomNodePath");t.exports=r},{"./getDomNodePath":6}],8:[function(e,t,n){function r(){var e,t;if("undefined"==typeof window||!window.screen)return{};e=["height","width","colorDepth","pixelDepth","availHeight","availWidth"],t={};for(var n=0;nwindow.innerHeight?"landscape":"portrait"},t}t.exports=r},{}],9:[function(e,t,n){function r(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";return e.replace(/[xy]/g,function(e){var t=16*Math.random()|0,n="x"==e?t:3&t|8;return n.toString(16)})}t.exports=r},{}],10:[function(e,t,n){function r(){var e,t,n;return"undefined"==typeof document?{}:(e=document.body,t=document.documentElement,n={height:"innerHeight"in window?window.innerHeight:document.documentElement.offsetHeight,width:"innerWidth"in window?window.innerWidth:document.documentElement.offsetWidth,scrollHeight:Math.max(e.scrollHeight,e.offsetHeight,t.clientHeight,t.scrollHeight,t.offsetHeight)||null},window.screen&&(n.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}),n)}t.exports=r},{}],11:[function(e,t,n){var r=e("keen-core"),o=(e("./utils/each"),e("./utils/extend"),e("./utils/queue"));r.helpers=r.helpers||{},r.on("client",function(e){e.extensions={events:[],collections:{}},e.queue=o(),e.queue.on("flush",function(){e.recordDeferredEvents()})}),r.prototype.writeKey=function(e){return arguments.length?(this.config.writeKey=e?String(e):null,this):this.config.writeKey},r.prototype.setGlobalProperties=function(e){return r.log("This method has been deprecated. Check out #extendEvents: https://github.com/keen/keen-tracking.js#extend-events"),e&&"function"==typeof e?(this.config.globalProperties=e,this):void this.emit("error","Invalid value for global properties: "+e)},t.exports=r},{"./utils/each":16,"./utils/extend":17,"./utils/queue":19,"keen-core":24}],12:[function(e,t,n){function r(e,t,n,r){var o,i,s,h,y,b,k;if(o=this.url("events",encodeURIComponent(e)),i={},s=n,k="boolean"==typeof r?r:!0,c.call(this,s)){if(!e||"string"!=typeof e)return void a.call(this,"Collection name must be a string.",s);if(this.config.globalProperties&&(i=this.config.globalProperties(e)),x(i,t),b={},w.getExtendedEventBody(b,this.extensions.events),w.getExtendedEventBody(b,this.extensions.collections[e]),w.getExtendedEventBody(b,[i]),this.emit("recordEvent",e,b),!m.enabled)return a.call(this,"Keen.enabled is set to false.",s),!1;if(h=this.url("events",encodeURIComponent(e),{api_key:this.writeKey(),data:encodeURIComponent(v.encode(JSON.stringify(b))),modified:(new Date).getTime()}),y=h.length2?void a.call(this,"Incorrect arguments provided to #recordEvents method",r):(this.config.globalProperties&&y(e,function(t,n){y(t,function(t,r){var o=i.config.globalProperties(n);e[n][r]=x(o,t)})}),o={},y(e,function(e,t){o[t]=o[t]||[],y(e,function(e,n){var r={};w.getExtendedEventBody(r,i.extensions.events),w.getExtendedEventBody(r,i.extensions.collections[t]),w.getExtendedEventBody(r,[e]),o[t].push(r)})}),this.emit("recordEvents",o),m.enabled?(h()&&d.call(this,"POST",n,o,r),t=r=null,this):(a.call(this,"Keen.enabled is set to false.",r),!1)):void 0}function i(){this.emit("error","This method has been deprecated. Check out #recordEvent: https://github.com/keen/keen-tracking.js#record-a-single-event"),r.apply(this,arguments)}function s(){this.emit("error","This method has been deprecated. Check out #recordEvents: https://github.com/keen/keen-tracking.js#record-multiple-events"),o.apply(this,arguments)}function c(e){var t=e;return e=null,this.projectId()?this.writeKey()?!0:(a.call(this,"Keen.Client is missing a writeKey property.",t),!1):(a.call(this,"Keen.Client is missing a projectId property.",t),!1)}function a(e,t){var n="Event(s) not recorded: "+e;this.emit("error",n),t&&(t.call(this,n,null),t=null)}function u(){return"undefined"!=typeof window&&navigator&&(-1!==navigator.userAgent.indexOf("MSIE")||navigator.appVersion.indexOf("Trident/")>0)?2e3:16e3}function l(e,t,n,r){h()?d.call(this,"POST",e,t,r):a.call(this,n)}function d(e,t,n,r){var o,i=this,s=h(),c=r;r=null,s.onreadystatechange=function(){var e;if(4==s.readyState)if(s.status>=200&&s.status<300){try{e=JSON.parse(s.responseText)}catch(t){m.emit("error","Could not parse HTTP response: "+s.responseText),c&&c.call(i,s,null)}c&&e&&c.call(i,null,e)}else m.emit("error","HTTP request failed."),c&&c.call(i,s,null)},s.open(e,t,!0),s.setRequestHeader("Authorization",i.writeKey()),s.setRequestHeader("Content-Type","application/json"),n&&(o=JSON.stringify(n)),"GET"===e.toUpperCase()&&s.send(),"POST"===e.toUpperCase()&&s.send(o)}function f(e){var t=h();t&&(t.open("GET",e,!1),t.send(null))}function h(){var e="undefined"==typeof window?this:window;if(e.XMLHttpRequest&&("file:"!=e.location.protocol||!e.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}return!1}function p(e,t){function n(){i&&i.call(o,"An error occurred!",null)}function r(){window[u]=void 0;try{delete window[u]}catch(e){}a.removeChild(c)}var o=this,i=t,s=(new Date).getTime(),c=document.createElement("script"),a=document.getElementsByTagName("head")[0],u="keenJSONPCallback",l=!1;for(t=null,u+=s;u in window;)u+="a";window[u]=function(e){l!==!0&&(l=!0,i&&i.call(o,null,e),r())},c.src=e+"&jsonp="+u,a.appendChild(c),c.onreadystatechange=function(){l===!1&&"loaded"===this.readyState&&(l=!0,n(),r())},c.onerror=function(){l===!1&&(l=!0,n(),r())}}function g(e,t){var n=this,r=t,o=document.createElement("img"),i=!1;t=null,o.onload=function(){if(i=!0,"naturalHeight"in this){if(this.naturalHeight+this.naturalWidth===0)return void this.onerror()}else if(this.width+this.height===0)return void this.onerror();r&&r.call(n)},o.onerror=function(){i=!0,r&&r.call(n,"An error occurred!",null)},o.src=e+"&c=clv1"}var m=e("./index"),v=e("./utils/base64"),y=e("./utils/each"),x=e("./utils/extend"),w=e("./extend-events");t.exports={recordEvent:r,recordEvents:o,addEvent:i,addEvents:s}},{"./extend-events":3,"./index":11,"./utils/base64":13,"./utils/each":16,"./utils/extend":17}],13:[function(e,t,n){t.exports=e("keen-core/lib/utils/base64")},{"keen-core/lib/utils/base64":25}],14:[function(e,t,n){function r(e){return arguments.length?this instanceof r==!1?new r(e):(this.config={key:e,options:{expires:365}},this.data=this.get(),this):void 0}var o=e("js-cookie"),i=e("./extend");t.exports=r,r.prototype.get=function(e){var t={};return o.get(this.config.key)&&(t=o.getJSON(this.config.key)),e&&"object"==typeof t&&null!==typeof t?"undefined"!=typeof t[e]?t[e]:null:t},r.prototype.set=function(e,t){return arguments.length&&this.enabled()?("string"==typeof e&&2===arguments.length?this.data[e]=t?t:null:"object"==typeof e&&1===arguments.length&&i(this.data,e),o.set(this.config.key,this.data,this.config.options),this):this},r.prototype.expire=function(e){return e?o.set(this.config.key,this.data,i(this.config.options,{expires:e})):(o.remove(this.config.key),this.data={}),this},r.prototype.options=function(e){return arguments.length?(this.config.options="object"==typeof e?e:{},this):this.config.options},r.prototype.enabled=function(){return navigator.cookieEnabled}},{"./extend":17,"js-cookie":23}],15:[function(e,t,n){function r(e){for(var t=1;t0&&e.interval>=e.config.interval?!0:e.capacity>=e.config.capacity?!0:!1}var i=e("component-emitter");i(r.prototype),r.prototype.check=function(){return o(this)&&this.flush(),(0===this.config.interval||0===this.capacity)&&this.pause(),this},r.prototype.flush=function(){return this.emit("flush"),this.interval=0,this},r.prototype.pause=function(){return this.timer&&(clearInterval(this.timer),this.timer=null),this},r.prototype.start=function(){var e=this;return e.pause(),e.timer=setInterval(function(){e.interval++,e.check()},1e3),e},t.exports=r},{"component-emitter":22}],20:[function(e,t,n){function r(e,t){"object"!=typeof t?t={hash:!!t}:void 0===t.hash&&(t.hash=!0);for(var n=t.hash?{}:"",r=t.serializer||(t.hash?s:c),o=e&&e.elements?e.elements:[],i=Object.create(null),l=0;l-1)&&(t.disabled||!d.disabled)&&d.name&&u.test(d.nodeName)&&!a.test(d.type)){var f=d.name,h=d.value;if("checkbox"!==d.type&&"radio"!==d.type||d.checked||(h=void 0),t.empty){if("checkbox"!==d.type||d.checked||(h=""),"radio"===d.type&&(i[d.name]||d.checked?d.checked&&(i[d.name]=!0):i[d.name]=!1),void 0==h&&"radio"==d.type)continue}else if(!h)continue;if("select-multiple"!==d.type)n=r(n,f,h);else{h=[];for(var p=d.options,g=!1,m=0;mr;++r)n[r].apply(this,t)}return this},r.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},r.prototype.hasListeners=function(e){return!!this.listeners(e).length}},{}],23:[function(e,t,n){!function(e){if("object"==typeof n)t.exports=e();else{var r=window.Cookies,o=window.Cookies=e();o.noConflict=function(){return window.Cookies=r,o}}}(function(){function e(){for(var e=0,t={};e1){if(i=e({path:"/"},r.defaults,i),"number"==typeof i.expires){var c=new Date;c.setMilliseconds(c.getMilliseconds()+864e5*i.expires),i.expires=c}try{s=JSON.stringify(o),/^[\{\[]/.test(s)&&(o=s)}catch(a){}return o=n.write?n.write(o,t):encodeURIComponent(String(o)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)),t=t.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),t=t.replace(/[\(\)]/g,escape),document.cookie=[t,"=",o,i.expires&&"; expires="+i.expires.toUTCString(),i.path&&"; path="+i.path,i.domain&&"; domain="+i.domain,i.secure?"; secure":""].join("")}t||(s={});for(var u=document.cookie?document.cookie.split("; "):[],l=/(%[0-9A-Z]{2})+/g,d=0;d-1&&(t.protocol=document.location.protocol.replace(":","")),t.host&&t.host.replace(/.*?:\/\//g,""),u(this.config,t),this},r.prototype.masterKey=function(e){return arguments.length?(this.config.masterKey=e?String(e):null,this):this.config.masterKey},r.prototype.projectId=function(e){return arguments.length?(this.config.projectId=e?String(e):null,this):this.config.projectId},r.prototype.resources=function(e){if(!arguments.length)return this.config.resources;var t=this;return"object"==typeof e&&a(e,function(e,n){t.config.resources[n]=e?e:null}),t},r.prototype.url=function(e){var t,n=Array.prototype.slice.call(arguments,1),r=this.config.resources.base||"{protocol}://{host}";return t=e&&"string"==typeof e?this.config.resources[e]?this.config.resources[e]:r+e:r,a(this.config,function(e,n){"object"!=typeof e&&(t=t.replace("{"+n+"}",e))}),a(n,function(e,n){"string"==typeof e?t+="/"+e:"object"==typeof e&&(t+="?",a(e,function(e,n){t+=n+"="+e+"&"}),t=t.slice(0,-1))}),t},o(function(){r.loaded=!0,r.emit("ready")}),t.exports=r}).call(this,"undefined"!=typeof window?window:"undefined"!=typeof n?n:"undefined"!=typeof self?self:{})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./utils/each":26,"./utils/extend":27,"./utils/parse-params":28,"./utils/serialize":29,"component-emitter":22}],25:[function(e,t,n){t.exports={map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){"use strict";var t,n,r,o,i,s,c,a="",u=0,l=this.map;for(e=this.utf8.encode(e);u>2,i=(3&t)<<4|n>>4,s=isNaN(n)?64:(15&n)<<2|r>>6,c=isNaN(n)||isNaN(r)?64:63&r,a=a+l.charAt(o)+l.charAt(i)+l.charAt(s)+l.charAt(c);return a},decode:function(e){"use strict";var t,n,r,o,i,s,c,a="",u=0,l=this.map,d=String.fromCharCode;for(e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");u>4,s=(15&n)<<4|r>>2,c=(3&r)<<6|o,a=a+(d(i)+(64!=r?d(s):""))+(64!=o?d(c):"");return this.utf8.decode(a)},utf8:{encode:function(e){"use strict";for(var t,n="",r=0,o=String.fromCharCode;rt?o(t):t>127&&2048>t?o(t>>6|192)+o(63&t|128):o(t>>12|224)+o(t>>6&63|128)+o(63&t|128);return n},decode:function(e){"use strict";for(var t,n,r="",o=0,i=String.fromCharCode;on?[i(n),o++][0]:n>191&&224>n?[i((31&n)<<6|63&(t=e.charCodeAt(o+1))),o+=2][0]:[i((15&n)<<12|(63&(t=e.charCodeAt(o+1)))<<6|63&(c3=e.charCodeAt(o+2))),o+=3][0];return r}}}},{}],26:[function(e,t,n){function r(e,t,n){var r;if(!e)return 0;if(n=n?n:e,e instanceof Array){for(r=0;r -1) { + continue; + } + // ingore disabled fields + if ((!options.disabled && element.disabled) || !element.name) { + continue; + } + // ignore anyhting that is not considered a success field + if (!k_r_success_contrls.test(element.nodeName) || + k_r_submitter.test(element.type)) { + continue; + } + + var key = element.name; + var val = element.value; + + // we can't just use element.value for checkboxes cause some browsers lie to us + // they say "on" for value when the box isn't checked + if ((element.type === 'checkbox' || element.type === 'radio') && !element.checked) { + val = undefined; + } + + // If we want empty elements + if (options.empty) { + if (element.type === 'checkbox' && !element.checked) { + val = ''; + } + + // for radio + if (element.type === 'radio') { + if (!radio_store[element.name] && !element.checked) { + radio_store[element.name] = false; + } + else if (element.checked) { + radio_store[element.name] = true; + } + } + + // if options empty is true, continue only if its radio + if (val == undefined && element.type == 'radio') { + continue; + } + } + else { + // value-less fields are ignored unless options.empty is true + if (!val) { + continue; + } + } + + // multi select boxes + if (element.type === 'select-multiple') { + val = []; + + var selectOptions = element.options; + var isSelectedOptions = false; + for (var j=0 ; j