-
Notifications
You must be signed in to change notification settings - Fork 0
/
Defrag.min.js
1 lines (1 loc) · 1.67 KB
/
Defrag.min.js
1
window.Defrag=function(f,k,r,n){function d(a,d){return Math.floor(Math.random()*(d-a+1))+a}function g(){function b(){if(p>l){var c=document.getElementsByClassName("defrag-block")[a];c.classList.add("moved");setTimeout(function(){c.classList.remove("moved");c.classList.add("inprogress");setTimeout(function(){c.classList.remove("inprogress");c.classList.add("done");a++;l++;b()},d(30,100))},d(20,90))}else g()}function f(){for(var c=a;c<a+e;c++){var b=document.getElementsByClassName("defrag-block")[c];b.classList.remove("moved");b.classList.add("inprogress")}setTimeout(h,d(500,3E3))}function h(){for(var c=a;c<a+e;c++){var b=document.getElementsByClassName("defrag-block")[c];b.classList.remove("inprogress");b.classList.add("done")}q?"function"==typeof n&&n():(a+=e,g())}var e=d(2,60);a+e>k&&(e=k-a,q=!0);if(80<d(0,100))p=e,l=0,b();else{for(var m=a;m<a+e;m++)document.getElementsByClassName("defrag-block")[m].classList.add("moved");setTimeout(f,d(10,1500))}}var b=document.createElement("style");b.type="text/css";b.innerHTML=".defrag-blocks{font-size:0}.defrag-block{background:#00fdff;border:1px solid #000;display:inline-block;height:7px;margin:0 1px 1px 0;width:5px}.defrag-block.moved{background:#fff;border-color:#fff}.defrag-block.inprogress{background:#ff2101}.defrag-block.done{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAGElEQVQIHWNg0P//n+H///+MIILBgIEBAFNLCFkekQ5uAAAAAElFTkSuQmCC)}";document.getElementsByTagName("head")[0].appendChild(b);var a=0,q=!1,p=0,l=0;f.classList.add("defrag-blocks");for(b=0;b<k;b++){var h=document.createElement("div");h.classList.add("defrag-block");f.appendChild(h)}r&&setTimeout(g,d(0,1E3));this.start=function(){g()}};