Template:DoneCounter

From 2009.igem.org

(Difference between revisions)
m (Separate function)
m (Trying Dojo 1.3.2)
 
(5 intermediate revisions not shown)
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.2/dojo/dojo.xd.js"></script>
-
<script type="text/javascript">
+
<script type="text/javascript" src="/Template:DoneCounter/Counter.js?action=raw"></script>
-
function showDoneCounts() {
+
</html><noinclude>This is a script that counts the number of done items in a task list and puts it in the element with class doneCount above the list. Like this<span class="doneCount"></span>:
-
  var doneCounts = dojo.query('.doneCount');
+
 
-
  for(var i=0; i<doneCounts.length; i++) {
+
* {{todo}} I definitely have to do this.
-
    var doneCount = doneCounts[i];
+
* {{todo|And this.}}
-
    var parentElement = doneCount.parentNode;
+
* {{done}} But I did this.
-
    while(!(!parentElement ||
+
</noinclude>
-
            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)';
+
-
}
+
-
dojo.addOnLoad(showDoneCounts);
+
-
</script>
+
-
</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>
+

Latest revision as of 12:40, 30 July 2009

This is a script that counts the number of done items in a task list and puts it in the element with class doneCount above the list. Like this:

  • TODO I definitely have to do this.
  • And this.
  • DONE But I did this.