Template:DoneCounter/Counter.js

From 2009.igem.org

Revision as of 14:41, 18 May 2009 by Jaspervdg (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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')) { // This works around ampersands not working.
     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)';
 }

});