Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.89 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style>#link1, #link2 { display:none; }</style>
  5.  
  6. <script src="lab.js"></script>
  7.  
  8. <script>
  9. $LAB.script("jquery.js").wait(function(){
  10.    var ready = false,
  11.        chain = $LAB.script("links.js").wait(function(){
  12.           ready = true;
  13.        })
  14.    ;
  15.    // links.js may finish loading long before either link is clicked, so `chain` is resumable, or link may be clicked before links.js is loaded, so chain will just be added to while still in process
  16.  
  17.    $("#notready").hide();
  18.  
  19.    $("#link1, #link2").show().click(function(evt){
  20.       if (!ready) $("#notready").show();
  21.  
  22.       chain = chain.wait(function(){
  23.          $("#notready").hide();
  24.          linkClicked($(evt.target).attr("id")); // comes from links.js
  25.       });
  26.    });
  27. </script>
  28. </head>
  29. <body>
  30.    <div id="notready">Please wait...</div>
  31.    <a id="link1" href="#">link 1</a>
  32.    <a id="link2" href="#">link 2</a>
  33. </body>
  34. </html>