Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- var repeatTime = 100;
- var nowClass = 1;
- var func = 0;
- setInterval(function() {
- $(".l" + nowClass).attr("type", "disc");
- $(".l" + nowClass).css("color", getRandomColor());
- if(nowClass > 1) {
- if(func == 0) {
- $(".l" + (nowClass - 1)).attr("type", "circle");
- $(".l" + (nowClass - 1)).css("color", "black");
- } else {
- $(".l" + (nowClass + 1)).attr("type", "circle");
- $(".l" + (nowClass + 1)).css("color", "black");
- }
- } else {
- if(func == 0) {
- $(".l" + 6).attr("type", "circle");
- } else {
- $(".l" + 2).attr("type", "circle");
- $(".l" - 6).attr("type", "circle");
- $(".l" + 2).css("color", "black");
- $(".l" - 6).css("color", "black");
- }
- }
- if(nowClass > 5) {
- func = 1;
- } else if(nowClass == 1) {
- func = 0;
- }
- if(func == 0) {
- nowClass++;
- } else if(func == 1) {
- nowClass--;
- }
- }, repeatTime);
- randomProgressBar(".progress1");
- randomProgressBar(".progress2");
- randomProgressBar(".progress3");
- function getRandom(multi) {
- return Math.floor(Math.random() * multi);
- }
- function setProgressBarWidth(progressBar, width) {
- progressBar.css("width", width);
- }
- function getRandomColor() {
- var letters = '0123456789ABCDEF'.split('');
- var color = '#';
- for (var i = 0; i < 6; i++ ) {
- color += letters[Math.floor(Math.random() * 16)];
- }
- return color;
- }
- function randomProgressBar(progressDiv) {
- var timeSpeed = 5;
- var randomWidth = 0;
- var nowWidth = 0;
- var width_switch = false;
- var progressBar = $(progressDiv);
- var randomColor = "black"
- setInterval(function() {
- if(nowWidth == 0) {
- randomWidth = getRandom(500);
- randomColor = getRandomColor();
- }
- if(width_switch == false) {
- if(nowWidth <= randomWidth) {
- nowWidth++;
- } else {
- width_switch = true;
- }
- } else {
- if(nowWidth > 0) {
- nowWidth--;
- } else {
- width_switch = false;
- }
- }
- setProgressBarWidth(progressBar, nowWidth);
- progressBar.css("background", randomColor);
- }, timeSpeed);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement