Advertisement
Guest User

Callback

a guest
Jul 28th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var c = 1;
  2. function progressUpdate(max, min, _callback){
  3.     if (c == 0) {
  4.         console.log(c);
  5.          _callback();
  6.     } else if (c == 1) {
  7.         t = setTimeout(function() {
  8.             CurrentProgress = min + 1;
  9.             progressUpdate(max, CurrentProgress);
  10.             console.log(CurrentProgress);
  11.             if (CurrentProgress >= max) {
  12.                 CurrentProgress = max;
  13.                
  14.                 clearTimeout(t);
  15.                 t = 0;
  16.                 c = 0;
  17.                 progressUpdate(max, CurrentProgress);
  18.            }
  19.         },100);
  20.     }
  21. }
  22. progressUpdate(2, 0, function() {
  23.     alert("test");
  24. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement