Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(function() {
  2.     var repeatTime = 100;
  3.     var nowClass = 1;
  4.     var func = 0;
  5.    
  6.     setInterval(function() {
  7.         $(".l" + nowClass).attr("type", "disc");
  8.         $(".l" + nowClass).css("color", getRandomColor());
  9.         if(nowClass > 1) {
  10.             if(func == 0) {
  11.                 $(".l" + (nowClass - 1)).attr("type", "circle");
  12.                 $(".l" + (nowClass - 1)).css("color", "black");
  13.             } else {
  14.                 $(".l" + (nowClass + 1)).attr("type", "circle");
  15.                 $(".l" + (nowClass + 1)).css("color", "black");
  16.             }
  17.         } else {
  18.             if(func == 0) {
  19.                 $(".l" + 6).attr("type", "circle");
  20.             } else {
  21.                 $(".l" + 2).attr("type", "circle");
  22.                 $(".l" - 6).attr("type", "circle");
  23.                
  24.                 $(".l" + 2).css("color", "black");
  25.                 $(".l" - 6).css("color", "black");
  26.             }
  27.         }
  28.        
  29.         if(nowClass > 5) {
  30.             func = 1;
  31.         } else if(nowClass == 1) {
  32.             func = 0;
  33.         }
  34.        
  35.         if(func == 0) {
  36.             nowClass++;
  37.         } else if(func == 1) {
  38.             nowClass--;
  39.         }
  40.        
  41.     }, repeatTime);
  42.    
  43.     randomProgressBar(".progress1");
  44.     randomProgressBar(".progress2");
  45.     randomProgressBar(".progress3");
  46.    
  47.     function getRandom(multi) {
  48.         return Math.floor(Math.random() * multi);
  49.     }
  50.    
  51.     function setProgressBarWidth(progressBar, width) {
  52.         progressBar.css("width", width);
  53.     }
  54.    
  55.     function getRandomColor() {
  56.         var letters = '0123456789ABCDEF'.split('');
  57.         var color = '#';
  58.         for (var i = 0; i < 6; i++ ) {
  59.             color += letters[Math.floor(Math.random() * 16)];
  60.         }
  61.         return color;
  62.     }
  63.    
  64.     function randomProgressBar(progressDiv) {
  65.         var timeSpeed = 5;
  66.         var randomWidth = 0;
  67.         var nowWidth = 0;
  68.         var width_switch = false;
  69.         var progressBar = $(progressDiv);
  70.         var randomColor = "black"
  71.        
  72.         setInterval(function() {
  73.            
  74.             if(nowWidth == 0) {
  75.                 randomWidth = getRandom(500);
  76.                 randomColor = getRandomColor();
  77.             }
  78.            
  79.             if(width_switch == false) {
  80.                 if(nowWidth <= randomWidth) {
  81.                     nowWidth++;
  82.                 } else {
  83.                     width_switch = true;
  84.                 }
  85.             } else {
  86.                 if(nowWidth > 0) {
  87.                     nowWidth--;
  88.                 } else {
  89.                     width_switch = false;
  90.                 }
  91.             }
  92.            
  93.             setProgressBarWidth(progressBar, nowWidth);
  94.             progressBar.css("background", randomColor);
  95.         }, timeSpeed);
  96.     }
  97.    
  98. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement