-
Notifications
You must be signed in to change notification settings - Fork 0
/
simpleab.min.js
1 lines (1 loc) · 1.32 KB
/
simpleab.min.js
1
(function(e){e.simpleAB=function(t){this.persist=true;this.className="simpleab";this.disableFlip=false;e.extend(this,t);if(typeof this.classCount!=="number"){throw"SimpleAB: did not specify a number of pages (set classCount in the params to fix this error)"}if(this.classCount<=0){throw"SimpleAB: need at least one page but got "+n.toString()}if(typeof this.persist!=="boolean"){throw"SimpleAB: did not specify a boolean value for persist"}if(typeof this.disableFlip!=="boolean"){throw"SimpleAB: did not specify a boolean value for disableFlip"}if(typeof this.className!=="string"||this.className===""){throw"SimpleAB: invalid class name"}var r=Math.floor(Math.random()*this.classCount+1);if(this.persist===true&&document.cookie.indexOf("simpleab-index")!=-1){var i=document.cookie.split(";");for(x in i){if(i[x].indexOf("simpleab-index")!=-1){r=parseInt(i[x].split("=")[1].trim())}}}if(this.disableFlip===false&&this.persist==true&&window.location.href.indexOf("flip=true")!==-1){if(++r>this.classCount)r=1}if(this.persist===true){var s=new Date;s.setTime(s.getTime()+90*24*60*60*1e3);document.cookie="simpleab-index="+r.toString()+"; expires="+s.toGMTString()+"; path=/"}var o=this.className+"-"+r.toString();e('[class*="'+this.className+'-"]').each(function(){if(!e(this).hasClass(o)){e(this).hide()}else{e(this).show()}});return this}})(jQuery)