Template:DoneCounter/Counter.js

From 2009.igem.org

(Difference between revisions)
m (Moved script to separate page.)
m (Made script use ampersands again.)
Line 4: Line 4:
     var doneCount = doneCounts[i];
     var doneCount = doneCounts[i];
     var parentElement = doneCount.parentNode;
     var parentElement = doneCount.parentNode;
-
     while(!(!parentElement ||
+
     while(parentElement &&
-
            parentElement.nodeName=='UL' ||
+
          parentElement.nodeName!='UL' &&
-
            parentElement.nodeName=='OL' ||
+
          parentElement.nodeName!='OL' &&
-
            parentElement.nodeName=='TABLE')) { // This works around ampersands not working.
+
          parentElement.nodeName!='TABLE') {
       parentElement = parentElement.nextSibling;
       parentElement = parentElement.nextSibling;
     }
     }

Revision as of 14:44, 18 May 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)';
 }

});