40 lines
24 KiB
JavaScript
40 lines
24 KiB
JavaScript
|
/*!
|
||
|
* Shim for MutationObserver interface
|
||
|
* Author: Graeme Yeates (github.com/megawac)
|
||
|
* Repository: https://github.com/megawac/MutationObserver.js
|
||
|
* License: WTFPL V2, 2004 (wtfpl.net).
|
||
|
* Though credit and staring the repo will make me feel pretty, you can modify and redistribute as you please.
|
||
|
* Attempts to follow spec (http:// www.w3.org/TR/dom/#mutation-observers) as closely as possible for native javascript
|
||
|
* See https://github.com/WebKit/webkit/blob/master/Source/WebCore/dom/MutationObserver.cpp for current webkit source c++ implementation
|
||
|
*/
|
||
|
window.MutationObserver=window.MutationObserver||window.WebKitMutationObserver||function(e){"use strict";function t(e){this._watched=[],this._listener=e}function i(e){!function i(){var r=e.takeRecords();r.length&&e._listener(r,e),e._timeout=setTimeout(i,t._period)}()}function r(t){var i={type:null,target:null,addedNodes:[],removedNodes:[],previousSibling:null,nextSibling:null,attributeName:null,attributeNamespace:null,oldValue:null};for(var r in t)p(i,r)&&t[r]!==e&&(i[r]=t[r]);return i}function n(e,t){var i=s(e,t);return function(r){var n,l=r.length;t.attr&&i.attr&&o(r,e,i.attr,t.afilter),(t.kids||t.descendents)&&(n=a(r,e,i,t)),(n||r.length!==l)&&(i=s(e,t))}}function o(e,t,i,n){for(var o,a,s={},l=t.attributes,u=l.length;u--;)o=l[u],a=o.name,(!n||p(n,a))&&(o.value!==i[a]&&e.push(r({type:"attributes",target:t,attributeName:a,oldValue:i[a],attributeNamespace:o.namespaceURI})),s[a]=!0);for(a in i)s[a]||e.push(r({target:t,type:"attributes",attributeName:a,oldValue:i[a]}))}function a(t,i,n,a){function s(e,i,n,s,l){for(var u,d,f,p=e.length-1,g=-~((p-l)/2);f=e.pop();)u=n[f.i],d=s[f.j],a.kids&&g&&Math.abs(f.i-f.j)>=p&&(t.push(r({type:"childList",target:i,addedNodes:[u],removedNodes:[u],nextSibling:u.nextSibling,previousSibling:u.previousSibling})),g--),a.attr&&d.attr&&o(t,u,d.attr,a.afilter),a.charData&&3===u.nodeType&&u.nodeValue!==d.charData&&t.push(r({type:"characterData",target:u})),a.descendents&&c(u,d)}function c(i,n){for(var p,g,h,m,C,v,y,k=i.childNodes,E=n.kids,P=k.length,_=E?E.length:0,b=0,F=0,x=0;P>F||_>x;)v=k[F],C=E[x],y=C&&C.node,v===y?(a.attr&&C.attr&&o(t,v,C.attr,a.afilter),a.charData&&C.charData!==e&&v.nodeValue!==C.charData&&t.push(r({type:"characterData",target:v})),g&&s(g,i,k,E,b),a.descendents&&(v.childNodes.length||C.kids&&C.kids.length)&&c(v,C),F++,x++):(d=!0,p||(p={},g=[]),v&&(p[h=u(v)]||(p[h]=!0,-1===(m=l(E,v,x))?a.kids&&(t.push(r({type:"childList",target:i,addedNodes:[v],nextSibling:v.nextSibling,previousSibling:v.previousSibling})),b++):g.push({i:F,j:m})),F++),y&&y!==k[F]&&(p[h=u(y)]||(p[h]=!0,-1===(m=f(k,y,F))?a.kids&&(t.push(r({type:"childList",target:n.node,removedNodes:[y],nextSibling:E[x+1],previousSibling:E[x-1]})),b--):g.push({i:m,j:x})),x++));g&&s(g,i,k,E,b)}var d;return c(i,n),d}function s(e,t){var i=!0;return function r(e){var n={node:e};return!t.charData||3!==e.nodeType&&8!==e.nodeType?(t.attr&&i&&1===e.nodeType&&(n.attr=d(e.attributes,function(e,i){return(!t.afilter||t.afilter[i.name])&&(e[i.name]=i.value),e},{})),i&&(t.kids||t.charData||t.attr&&t.descendents)&&(n.kids=c(e.childNodes,r)),i=t.descendents):n.charData=e.nodeValue,n}(e)}function l(e,t,i){return f(e,t,i,g("node"))}function u(e){try{return e.id||(e[m]=e[m]||h++)}catch(t){try{return e.nodeValue}catch(i){return h++}}}function c(e,t){for(var i=[],r=0;r<e.length;r++)i[r]=t(e[r],r,e);return i}function d(e,t,i){for(var r=0;r<e.length;r++)i=t(i,e[r],r,e);return i}function f(e,t,i,r){for(;i<e.length;i++)if((r?e[i][r]:e[i])===t)return i;return-1}function p(t,i){return t[i]!==e}function g(e){return e}t._period=30,t.prototype={observe:function(e,t){for(var r={attr:!!(t.attributes||t.attributeFilter||t.attributeOldValue),kids:!!t.childList,descendents:!!t.subtree,charData:!(!t.characterData&&!t.characterDataOldValue)},o=this._watched,a=0;a<o.length;a++)o[a].tar===e&&o.splice(a,1);t.attributeFilter&&(r.afilter=d(t.attributeFilter,function(e,t){return e[t]=!0,e},{})),o.push({tar:e,fn:n(e,r)}),this._timeout||i(this)},takeRecords:function(){for(var e=[],t=this._watched,i=0;i<t.length;i++)t[i].fn(e);return e},disconnect:function(){this._watched=[],clearTimeout(this._timeout),this._timeout=null}};var h=1,m="mo_id";return t}(void 0),function(e,t){"use strict";function i(){if(!o){o=!0;for(var e=0;e<n.length;e++)n[e].fn.call(window,n[e].ctx);n=[]}}function r(){"complete"===document.readyState&&i()}e=e||"docReady",t=t||window;var n=[],o=!1,a=!1;t[e]=function(e,t){return o?void setTimeout(function(){e(t)},1):(n.push({fn:e,ctx:t}),void("complete"===document.readyState||!document.attachEvent&&"interactive"===document.readyState?setTimeout(i,1):a||(document
|
||
|
|*| :: cookies.js ::
|
||
|
|*|
|
||
|
|*| A complete cookies reader/writer framework with full unicode support.
|
||
|
|*|
|
||
|
|*| Revision #1 - September 4, 2014
|
||
|
|*|
|
||
|
|*| https://developer.mozilla.org/en-US/docs/Web/API/document.cookie
|
||
|
|*| https://developer.mozilla.org/User:fusionchess
|
||
|
|*|
|
||
|
|*| This framework is released under the GNU Public License, version 3 or later.
|
||
|
|*| http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||
|
|*|
|
||
|
|*| Syntaxes:
|
||
|
|*|
|
||
|
|*| * docCookies.setItem(name, value[, end[, path[, domain[, secure]]]])
|
||
|
|*| * docCookies.getItem(name)
|
||
|
|*| * docCookies.removeItem(name[, path[, domain]])
|
||
|
|*| * docCookies.hasItem(name)
|
||
|
|*| * docCookies.keys()
|
||
|
|*|
|
||
|
|*| Modifications:
|
||
|
|*|
|
||
|
|*| * docCookies renamed to DocCookieUtility
|
||
|
|*| * Added TypeScript type definitions
|
||
|
\*/
|
||
|
return e.prototype.getItem=function(e){return e?decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null:null},e.prototype.setItem=function(e,t,i,r,n,o){if(!e||/^(?:expires|max\-age|path|domain|secure)$/i.test(e))return!1;var a="";if(i)switch(i.constructor){case Number:a=i===1/0?"; expires=Fri, 31 Dec 9999 23:59:59 GMT":"; max-age="+i;break;case String:a="; expires="+i;break;case Date:a="; expires="+i.toUTCString()}return document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(t)+a+(n?"; domain="+n:"")+(r?"; path="+r:"")+(o?"; secure":""),!0},e.prototype.hasItem=function(e){return e?new RegExp("(?:^|;\\s*)"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie):!1},e.prototype.removeItem=function(e,t,i){return this.hasItem(e)?(document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT"+(i?"; domain="+i:"")+(t?"; path="+t:""),!0):!1},e.prototype.keys=function(){for(var e=document.cookie.replace(/((?:^|\s*;)[^=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g,"").split(/\s*(?:\=[^;]*)?;\s*/),t=e.length,i=0;t>i;i++)e[i]=decodeURIComponent(e[i]);return e},e}();e.DocCookieUtility=t}(t=e.doc_cookies||(e.doc_cookies={}))}(e||(e={}));var e,t=this&&this.__extends||function(e,t){function i(){this.constructor=e}for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)};!function(e){var i;!function(e){var i=function(e){function i(t){e.call(this),this.cookieDomain=t}return t(i,e),i.prototype.setCookie=function(e,t){return this.setItem(e,t,1/0,"/",this.cookieDomain),this.getItem(e)},i.prototype.removeCookie=function(e){var t=this.getItem(e);return t?(this.removeItem(e,"/",this.cookieDomain),t):""},i}(e.DocCookieUtility);e.CaptoraDocCookieUtility=i}(i=e.doc_cookies||(e.doc_cookies={}))}(e||(e={}));var e;!function(e){var t=function(){function e(){}return e.COOKIE_NAMES={attribUrlCookieName:"colodin_attrib_url",attributableFlagCookieName:"colodin_attributable",oldCookieName:"_EXT_TRACKER_COOKIE_",origReferrerCookieName:"colodin_orig_referrer",thankYouPageReferrer:"colodin_thank_you_page_referrer",thankYouPageUrl:"colodin_thank_you_page_url",uuidCookieName:"colodin_id"},e.HIDDEN_FIELD_NAMES={attribUrl:"cpcampaign",attributable:"cpfirstentry",origReferrer:"cpreferrer"},e.PIXEL_SRC="pixel.captora.com/img/pix.gif",e.PIXEL_CALLS=["capture_card_id","capture_card_cta_id","cta_title","config_id","segment_id"],e}();e.PixelConstants=t}(e||(e={}));var e;!function(e){var t;!function(e){var t=function(){function t(e){this.pagegroups=[],this.thankYouPagePatterns=[],"undefined"!=typeof e&&("undefined"!=typeof e.domain&&this.setDomain(e.domain),"undefined"!=typeof e.fieldFilterConfig&&this.setFieldFilterConfig(e.fieldFilterConfig),"undefined"!=typeof e.formFieldMappings&&this.setFormFieldMappings(e.formFieldMappings),"undefined"!=typeof e.pagegroups&&this.setPagegroups(e.pagegroups),"undefined"!=typeof e.thankYouPagePatterns&&this.setThankYouPagePatterns(e.thankYouPagePatterns),"undefined"!=typeof e.uuid&&this.setUuid(e.uuid))}return t.prototype.setDomain=function(e){return this.domain=e,this},t.prototype.setFieldFilterConfig=function(e){return this.fieldFilterConfig=e,this},t.prototype.setFormFieldMappings=function(e){return this.formFieldMappings=e,this},t.prototype.setPagegroups=function(e){return this.pagegroups=e,this},t.prototype.setThankYouPagePatterns=function(e){return this.thankYouPagePatterns=e,this},t.prototype.setUuid=function(e){return this.uuid=e,this},t.prototype.getDomain=function(){return this.domain},t.prototype.getFieldFilterConfig=function(){return this.fieldFilterConfig},t.prototype.getFormFieldMappings=function(){return this.formFieldMappings},t.prototype.getPagegroups=function(){return this.pagegroups},t.prototype.getThankYouPagePatterns=function(){return this.thankYouPagePatterns},t.prototype.getUuid=function(){return this.uuid},t.prototype.build=function(){return new e.PixelConfig(this)},t}();e.PixelConfigBuild
|
||
|
* @copyright Captora, Inc. 2015.
|
||
|
* Any modifications to this code will not be supported by Captora and its APIs.
|
||
|
*/
|
||
|
var i;!function(t){var i=e.tracker_client.TrackerClient,r=e.TrackerUtility,n=e.element_api.ElementApiFactory,o=e.pixel_config.PixelConfigBuilder,a=null,s=[],l=[],u=null;if("undefined"==typeof window.fireColodinPixel){window.docReady(function(){var e=document.getElementsByTagName("BODY")[0];u=new MutationObserver(function(e){l.push(e)}),u.observe(e,{childList:!0,subtree:!0})}),window.fireColodinPixel=function(e){s.push(e)};var c="function"==typeof window.cpTrackingClientConfig?window.cpTrackingClientConfig:null;window.cpTrackingClientConfig=function(e){for(a=new i(new o(e).build());s.length;)a.firePixel.call(a,s.shift());window.fireColodinPixel=function(e){a.firePixel.call(a,e)};var t=function(){for(var e=document.getElementsByTagName("BODY")[0],t=r.getTrackingElements(),i=0;i<t.length;i++)n.newElement(t[i],a).addEventListenerPolyfill("click, focus, blur, change");for(var o=document.getElementsByTagName("FORM"),s=0;s<o.length;s++)n.newElement(o[s],a).isSearchForm()||a.addHiddenFieldsToForm(o[s]);l.forEach(function(e){a.mutationObserverCallback.call(a,e),u.disconnect()});var c=new MutationObserver(function(e){a.mutationObserverCallback.call(a,e)});c.observe(e,{childList:!0,subtree:!0})};window.docReady(t),c&&c(e)},r.getJSONFile("//cdn.captora.com/js/"+r.extractRootDomain(window.location.href)+"/pixel-config.json",window.cpTrackingClientConfig)}}(i||(i={}))}();
|