Template:DoneCounter

From 2009.igem.org

(Difference between revisions)
(Moved doneCounter to template.)
m (Trying Dojo 1.3.2)
 
(7 intermediate revisions not shown)
Line 1: Line 1:
-
<!-- This counts the number of todo/done items and puts the results in the element with class doneCount. -->
 
<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>
-
var doneCounts = dojo.query('.doneCount');
+
</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>:
-
for(var i=0; i<doneCounts.length; i++) {
+
 
-
  var doneCount = doneCounts[i];
+
* {{todo}} I definitely have to do this.
-
  var parentElement = doneCount.parentNode;
+
* {{todo|And this.}}
-
  while(!(!parentElement || parentElement.nodeName=='UL' || parentElement.nodeName=='OL' || parentElement.nodeName=='TABLE')) parentElement = parentElement.nextSibling;
+
* {{done}} But I did this.
-
  var numTodo = dojo.query('.todo',parentElement).length;
+
</noinclude>
-
  var numDone = dojo.query('.done',parentElement).length;
+
-
  doneCount.innerHTML = ' (' + numDone + ' out of ' + (numDone+numTodo) + ' done)';
+
-
}
+
-
</script>
+
-
</html>
+

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.