public
Description: Various bits and helpers for Prototype and scriptaculous, that might prove useful or not. :)
Homepage:
Clone URL: git://github.com/madrobby/prototype_helpers.git
100644 31 lines (29 sloc) 1.021 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>blech</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <script src="../lib/prototype/dist/prototype.js" type="text/javascript"></script>
  <script src="deferuntil.js" type="text/javascript"></script>
</head>
<body>
  <p id="countdown">--waiting--</p>
  
  <script type="text/javascript" charset="utf-8">
    // countdown to 0
    (function(){
      var count = 4,
        timeout = setTimeout(function(){
          $('countdown').update(--count);
          if(count>0) timeout = setTimeout(arguments.callee, 1000);
        }, 1000);
    })();
    
    // poll condition until true, then execute function
    (function(){
      alert('go!');
    }).curry('hello world!').deferUntil(function(){
      return $('countdown').innerHTML == "0";
    });
  </script>
</body>
</html>