Template:DoneCounter/Counter.js
From 2009.igem.org
(Difference between revisions)
m (Moved script to separate page.) |
m (Template:Team:Groningen/DoneCounter/Counter.js moved to Template:DoneCounter/Counter.js: The DoneCounter itself also didn't live in Team:Groningen (and it shouldn't, as it's in principle general).) |
||
(One intermediate revision not shown) | |||
Line 4: | Line 4: | ||
var doneCount = doneCounts[i]; | var doneCount = doneCounts[i]; | ||
var parentElement = doneCount.parentNode; | var parentElement = doneCount.parentNode; | ||
- | while( | + | while(parentElement && |
- | + | parentElement.nodeName!='UL' && | |
- | + | parentElement.nodeName!='OL' && | |
- | + | parentElement.nodeName!='TABLE') { | |
parentElement = parentElement.nextSibling; | parentElement = parentElement.nextSibling; | ||
} | } |
Latest revision as of 12:02, 21 June 2009
dojo.addOnLoad(function(){
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)'; }
});