-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOptimizelyAbCallback.min.js
4 lines (4 loc) · 1.24 KB
/
OptimizelyAbCallback.min.js
1
2
3
4
/*! OptimizelyAbCallback 04-02-2015 */
/*! VERSION: 1.0.0 */
/*! http://github.com/guilhermef/OptimizelyAbCallback */
!function(a,b,c){"use strict";var d=function(){this.experiments={},this.initialized=!1};d.prototype.includeABScript=function(a){var c=b.createElement("script"),d=b.getElementsByTagName("script")[0];c.src="//cdn.optimizely.com/js/"+a+".js",c.async=!0,d.parentNode.insertBefore(c,d)},d.prototype.init=function(){if(!this.initialized){this.initialized=!0,a._optiab=a._optiab||[];var b,c,d,e=a.optimizely.data.state.activeExperiments.length,f=this;for(b=0;e>b;b++)c=a.optimizely.data.state.activeExperiments[b],d=a.optimizely.data.state.variationNamesMap[c]||"Original",d=d.toLowerCase().replace(" ","-").replace("#",""),this.experiments[c]=d;for(b=0;b<a._optiab.length;b++)this._callHome(a._optiab.shift());a._optiab.push=function(a){f._callHome.apply(f,[a])}}},d.prototype.addExperimentClass=function(a,c){var d=" ab-"+a+"-"+c;-1===b.documentElement.className.indexOf(d)&&(b.documentElement.className+=" ab-"+a+"-"+c)},d.prototype._callHome=function(a){var b="original";a.length<2||"function"!=typeof a[1]||(this.experiments[a[0]]!==c&&(b=this.experiments[a[0]]),this.addExperimentClass(a[0],b),a[1](b))},a.OptimizelyAbCallback=new d}(window,document);