Template:KAISTRandom2

From 2010.igem.org

(Difference between revisions)
(New page: <html> <head> <script type="text/javascript"> <!-- Array.prototype.shuffle = function() { for (var i = 0; i < this.length; i++) { // Random item in this array. var r = parseInt(...)
(Removing all content from page)
 
Line 1: Line 1:
-
<html>
 
-
<head>
 
-
<script type="text/javascript">
 
-
<!--
 
-
Array.prototype.shuffle = function() {
 
-
  for (var i = 0; i < this.length; i++) {
 
-
    // Random item in this array.
 
-
    var r = parseInt(Math.random() * this.length);
 
-
    var obj = this[r];
 
-
 
-
    // Swap.
 
-
    this[r] = this[i];
 
-
    this[i] = obj;
 
-
  }
 
-
}
 
-
function randomize(tableID) {
 
-
var myTable = document.getElementById(tableID);
 
-
var myRows = new Array();
 
-
for (i=myTable.rows.length-1; i>=0; i--) {
 
-
var theRow = myTable.rows[i];
 
-
myRows.push(theRow);
 
-
theRow.parentNode.removeChild(theRow);
 
-
}
 
-
myRows.shuffle();
 
-
for (j=0; j<myRows.length; j++) {
 
-
myTable.appendChild(myRows[j]);
 
-
}
 
-
}
 
-
window.onload = function() {
 
-
randomize("randomtable2");
 
-
}
 
-
//-->
 
-
</script>
 
-
 
-
</head>
 
-
</html>
 

Latest revision as of 10:12, 21 June 2010