|
|
Line 1: |
Line 1: |
- | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
| + | {{Template:CambridgeRandomSponsor}} |
- | | + | |
- | <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("randomtable");
| + | |
- | }
| + | |
- | //-->
| + | |
- | </script>
| + | |
- | </head>
| + | |
- | | + | |
- | </html>
| + | |
| {{Template:Cambridge2}} | | {{Template:Cambridge2}} |
| =Sponsors= | | =Sponsors= |
Line 76: |
Line 39: |
| |} | | |} |
| | | |
- | <html><head>
| |
- | <style type="text/css">
| |
- | .group2{
| |
- | visibility: hidden;
| |
- | }
| |
- | .sponsors{
| |
- | visibility: hidden;
| |
- | }
| |
- | </style>
| |
- |
| |
- | <script type="text/javascript">
| |
- |
| |
- | /***********************************************
| |
- | * Random Content Order script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
| |
- | * This notice MUST stay intact for legal use
| |
- | * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
| |
- | ***********************************************/
| |
- |
| |
- | function randomizeContent(classname){
| |
- | var contents=randomizeContent.collectElementbyClass(classname)
| |
- | contents.text.sort(function() {return 0.5 - Math.random();})
| |
- | var tbodyref=contents.ref[0].tagName=="TR"? contents.ref[0].parentNode : new Object()
| |
- | for (var i=0; i<contents.ref.length; i++){
| |
- | if (tbodyref.moveRow) //if IE
| |
- | tbodyref.moveRow(0, Math.round(Math.random()*(tbodyref.rows.length-1)))
| |
- | else
| |
- | contents.ref[i].innerHTML=contents.text[i]
| |
- | contents.ref[i].style.visibility="visible"
| |
- | }
| |
- | }
| |
- |
| |
- | randomizeContent.collectElementbyClass=function(classname){ //return two arrays containing elements with specified classname, plus their innerHTML content
| |
- | var classnameRE=new RegExp("(^|\\s+)"+classname+"($|\\s+)", "i") //regular expression to screen for classname within element
| |
- | var contentobj=new Object()
| |
- | contentobj.ref=new Array() //array containing references to the participating contents
| |
- | contentobj.text=new Array() //array containing participating contents' contents (innerHTML property)
| |
- | var alltags=document.all? document.all : document.getElementsByTagName("*")
| |
- | for (var i=0; i<alltags.length; i++){
| |
- | if (typeof alltags[i].className=="string" && alltags[i].className.search(classnameRE)!=-1){
| |
- | contentobj.ref[contentobj.ref.length]=alltags[i]
| |
- | contentobj.text[contentobj.text.length]=alltags[i].innerHTML
| |
- | }
| |
- | }
| |
- | return contentobj
| |
- | }
| |
- | </script>
| |
- | </head>
| |
- |
| |
- | testing randomiser:
| |
- | <div class="sponsors"> 1 </div>
| |
- | <div class="sponsors"> 2 </div>
| |
- | <div class="sponsors"> 3 </div>
| |
- | <div class="sponsors"> 4 </div>
| |
- |
| |
- | <table border="1" width="100%">
| |
- | <tr class="group2">
| |
- | <td>Row 1</td>
| |
- | <td>Row 1</td>
| |
- | </tr>
| |
- | <tr class="group2">
| |
- | <td>Row 2</td>
| |
- | <td>Row 2</td>
| |
- | </tr>
| |
- | <tr class="group2">
| |
- | <td>Row 3</td>
| |
- | <td>Row 3</td>
| |
- | </tr>
| |
- | </table>
| |
| | | |
- | <script type="text/javascript">
| |
- | randomizeContent("sponsors")
| |
- | randomizeContent("group2")
| |
- | </script>
| |
- | </html>
| |
| | | |
| And finally a massive big '''Thank You''' to '''Duncan Rowe''' who helped us tremendously with organising sponsorship. | | And finally a massive big '''Thank You''' to '''Duncan Rowe''' who helped us tremendously with organising sponsorship. |
| | | |
| <!--Do not remove the first and last lines in this page!--><div id="contentbox_bottom"></div></div> | | <!--Do not remove the first and last lines in this page!--><div id="contentbox_bottom"></div></div> |