Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 18th, 2013  |  syntax: jQuery  |  size: 0.53 KB  |  views: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function countThreeSeconds() {
  2.     return $.Deferred(function(def){
  3.         var counter = 0,
  4.         timer = setInterval(function () {
  5.  
  6.             if (counter == 3) {
  7.                 console.log("All done. That was three seconds.");
  8.                 window.clearInterval(timer);
  9.                 def.resolve();
  10.  
  11.             } else {              
  12.                 console.log("Not there yet. Counter at: " + counter);
  13.                 def.notify(counter);
  14.             }
  15.             counter++;
  16.         }, 1000);
  17.     }).promise();
  18.  
  19. }