-
Notifications
You must be signed in to change notification settings - Fork 0
/
redTag.min.js
13 lines (13 loc) · 2.33 KB
/
redTag.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
/**
* redTag library.
*
* @ v2.0.0
* @
* @ Helper class created to facilitate a/b testing development process;
* @ Contains methods that that are dependent of jQuery and Optimizely
* @ Created by Robert Vilcu : http://crafton.ro
* @ https://github.com/vilcuRob/redTag/
* @ 02 July 2016
* @
*/
!function(t,e){"use strict";const n=t.jQuery=t.$||"undefined",i=t.optimizely||[];var o=function(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0};return o(e)?(e=function(){this.config=function(t){var t=t||{};this.optyLog=t.optyLog||!1,this.tagErrors=t.tagErrors||!1,this.goalsQa=t.goalsQa||!1,this.tagErrors===!0&&e(),this.optyLog===!0&&this.logOptimizely()};var e=function(){"undefined"===n&&a("jQuery is not available"),(!i||0===i.length||"object"!=typeof i||o(i))&&a("Optimizely is not available")},r=0,a=function(t){r++,console.log("%c["+r+"]%c[redTag]:%c "+t,"color:black;","color:red;","color:blue;")};if(this.triggerEvent=function(t){i.push(["trackEvent",t]),this.goalsQa===!0&&a('"'+t+'" event was triggered')},this.logOptimizely=function(){i.push("log")},this.setCookie=function(t,e,n){if(n){var i=new Date;i.setTime(i.getTime()+24*n*60*60*1e3);var o="; expires="+i.toGMTString()}else var o="";document.cookie=t+"="+e+o+"; path=/"},this.readCookie=function(t){for(var e=t+"=",n=document.cookie.split(";"),i=0;i<n.length;i++){for(var o=n[i];" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(e))return o.substring(e.length,o.length)}return null},this.deleteCookie=function(t){this.setCookie(t,"",-1)},this.ajaxFin=function(t){var e,n;XMLHttpRequest.callbacks?XMLHttpRequest.callbacks.push(t):(XMLHttpRequest.callbacks=[t],e=XMLHttpRequest.prototype.send,XMLHttpRequest.prototype.send=function(){for(n=0;n<XMLHttpRequest.callbacks.length;n++)XMLHttpRequest.callbacks[n](this);e.apply(this,arguments)})},this.whenTrue=function(t){var t=t||{},e=t.condition||function(){return!0},n=t.callback||function(){},i=t.delay||50,o=function(){e()?n():setTimeout(o,i)};o()},"undefined"!==n){var s={},u=function(e){s[e]&&(t.clearInterval(s[e]),s[e]=null)},c="waitFor.found";n.fn.waitFor=function(e,i,o){var r=this.selector,a=n(r),l=a.not(function(){return n(this).data(c)});return"remove"===e?u(r):(l.each(e).data(c,!0),i&&a.length?u(r):o||(s[r]=t.setInterval(function(){a.waitFor(e,i,!0)},50))),a}}},void(t.redTag=new e)):!1}(window,window.redTag=window.redTag||{});