Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
Line 76: | Line 76: | ||
if(document.getElementById('test')) | if(document.getElementById('test')) | ||
{ | { | ||
− | var x = '<option value="' + | + | var drop1string = document.getElementById("test1").innerHTML; |
− | document.getElementById('test').innerHTML = '<select id="id1" style="position:absolute; top:210px; left:10px;">' + | + | var drop1array = drop1string.split("@-@"); |
+ | var drop1list = " "; | ||
+ | |||
+ | for (var m=0;m<drop1array.length;m++) | ||
+ | { | ||
+ | var x = drop1array[m].split("@@"); | ||
+ | drop1list = drop1list + '<option value="' + x[0] + '">' + x[1] + '</option>'; | ||
+ | } | ||
+ | document.getElementById('test').innerHTML = '<select id="id1" style="position:absolute; top:210px; left:10px;">' + drop1list + '</select>'; | ||
} | } | ||
} | } | ||
window.document.body.onload = test; | window.document.body.onload = test; |
Revision as of 06:46, 27 March 2013
/* Any JavaScript here will be loaded for all users on every page load. */ /* This code displays a clock or a countdown timer. Adapted from w3schools.com example. */ (function($) { function cdTimer() { var timerElem = $('#CountdownTimer'); function checkTime(i) { if (i < 10) { i = "0" + i; } return i; } if (timerElem.length > 0) { var cdoffset = Number(document.getElementById('cdoffset').innerHTML); var today = new Date(); var h = today.getUTCHours(); var m = today.getUTCMinutes(); var s = today.getUTCSeconds(); var s1 = (s !== 0) ? 60 - s : s; var m1 = (m !== 0) ? 60 - m : m; var h1 = (24 - (h - cdoffset)) % 24; // add a zero in front of numbers<10 h1 = checkTime(h1); m1 = checkTime(m1); s1 = checkTime(s1); timerElem.text(h1 + ":" + m1 + ":" + s1); t = setTimeout(function() { cdTimer(); }, 1000); } } function sTime() { var timeElem = $('#ServerTime'); function checkTime(i) { if (i < 10) { i = "0" + i; } return i; } if (timeElem.length > 0) { var soffset = Number(document.getElementById('soffset').innerHTML); var today = new Date(); var h = today.getUTCHours(); var m = today.getUTCMinutes(); var s = today.getUTCSeconds(); var h2 = (h + soffset) % 24; // add a zero in front of numbers<10 h2 = checkTime(h2); m2 = checkTime(m); s2 = checkTime(s); timeElem.text(h2 + ":" + m2 + ":" + s2); t = setTimeout(function() { sTime(); }, 1000); } } $(document).ready(cdTimer); $(document).ready(sTime); })(jQuery); function test() { if(document.getElementById('test')) { var drop1string = document.getElementById("test1").innerHTML; var drop1array = drop1string.split("@-@"); var drop1list = " "; for (var m=0;m<drop1array.length;m++) { var x = drop1array[m].split("@@"); drop1list = drop1list + '<option value="' + x[0] + '">' + x[1] + '</option>'; } document.getElementById('test').innerHTML = '<select id="id1" style="position:absolute; top:210px; left:10px;">' + drop1list + '</select>'; } } window.document.body.onload = test;