Template:DoneCounter
From 2009.igem.org
(Difference between revisions)
(Moved doneCounter to template.) |
(Try onLoad) |
||
Line 1: | Line 1: | ||
- | < | + | <includeonly><html> |
- | <html> | + | |
<script type="text/javascript" src="http://o.aolcdn.com/dojo/1.3.0/dojo/dojo.xd.js"></script> | <script type="text/javascript" src="http://o.aolcdn.com/dojo/1.3.0/dojo/dojo.xd.js"></script> | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
- | var doneCounts = dojo.query('.doneCount'); | + | dojo.addOnLoad(function(){ |
- | for(var i=0; i<doneCounts.length; i++) { | + | var doneCounts = dojo.query('.doneCount'); |
- | + | for(var i=0; i<doneCounts.length; i++) { | |
- | + | var doneCount = doneCounts[i]; | |
- | + | var parentElement = doneCount.parentNode; | |
- | + | while(!(!parentElement || | |
- | + | parentElement.nodeName=='UL' || | |
- | + | parentElement.nodeName=='OL' || | |
- | } | + | parentElement.nodeName=='TABLE')) { |
+ | parentElement = parentElement.nextSibling; | ||
+ | } | ||
+ | var numTodo = dojo.query('.todo',parentElement).length; | ||
+ | var numDone = dojo.query('.done',parentElement).length; | ||
+ | doneCount.innerHTML = ' (' + numDone + ' out of ' + (numDone+numTodo) + ' done)'; | ||
+ | }); | ||
</script> | </script> | ||
- | </html> | + | </html></includeonly><noinclude>This is a script that counts the number of done tasks in a list and puts a string like " (8 out of 9 done)" in fields (spans) with class="doneCount".</noinclude> |
Revision as of 13:53, 14 May 2009
This is a script that counts the number of done tasks in a list and puts a string like " (8 out of 9 done)" in fields (spans) with class="doneCount".