Guest User

Untitled

a guest
Jan 8th, 2016
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getRandomInt(min, max) {
  2.               return Math.floor(Math.random() * (max - min)) + min;
  3.             };
  4.  
  5.             function analize(link,time){
  6.  
  7.                 var
  8.                     max_errors = getRandomInt(8,16),
  9.                     xx = false,
  10.                     percent = 0.0,
  11.                     errors = 0,
  12.                     i = 0,
  13.                     j = 0,
  14.                     jj = 0,
  15.                     k = 0,
  16.                     bar = document.getElementById('progressbar'),
  17.                     aa  = document.getElementById('analyzer-errors'),
  18.                     times = [];
  19.  
  20.                 for( i = 0; i <= max_errors; i++) {
  21.                     times.push(getRandomInt(5,25)*time)
  22.                 }
  23.  
  24.                 times.sort(function() {
  25.                     return .2 - Math.random();
  26.                 });
  27.  
  28.                 var progress = setInterval(function() {
  29.  
  30.                         if( ++i < 25*time || ( i > 50*time && i < 85*time ) || i > 135*time ){
  31.                             percent = Math.round( (percent+1/time) * 10 ) / 10;
  32.                             j++;
  33.                             bar.style.width = percent+'%';
  34.  
  35.                             if( xx && errors < max_errors && j>=jj ){
  36.  
  37.                                 errors++;
  38.                                 jj += times[k++]*time/max_errors;
  39.                                 text = (errors > 1) ? "errors" : "error";
  40.                                 aa.innerHTML = errors+" "+text+" found&hellip;";
  41.  
  42.                             }
  43.  
  44.                         }
  45.  
  46.                         if( !xx && i > 40 ){
  47.                             xx= true;
  48.                             jj =j;
  49.                             aa.classList.remove("hide");
  50.  
  51.                         }
  52.  
  53.                         if ( percent >= 100 ) {
  54.  
  55.                             clearInterval(progress);
  56.  
  57.                             form.method = 'post';
  58.                             form.action = link;
  59.                             form.submit();
  60.  
  61.                         }
  62.  
  63.                     }, 5);
  64.  
  65.             };
Advertisement
Add Comment
Please, Sign In to add comment