MediaWiki:Tabs/code.js

/* Any JavaScript here will be loaded for all users on every page load. */ /* created by Curiouscrab */ /* ask questions at User:Curiouscrab/talk */ /* copied from Scratchpad by Curiouscrab */ /* All functions are automated and will run perfectly if the first item is entered properly (see bottom) */ function show(id) { document.getElementById(id).style.display = 'block'; }

function hide(id) { document.getElementById(id).style.display = 'none'; }

function update(number) { for (i = 1; i < +document.getElementById('tabs').innerHTML + 1; i++) { if (number !== i) { document.getElementById('tab' + i).className = 'taboff'; hide('content' + i); }   } }

function check(number) { if (document.getElementById('tab' + number).className === 'taboff') { document.getElementById('tab' + number).className = 'tabon'; show('content' + number); update(number); } } /* function resize { for(i=1; i<+document.getElementById('tabs').innerHTML+1; i++) { document.getElementById('tab' + i).style.width = 96/document.getElementById('tabs').innerHTML + '%'; }   document.getElementById('tab2').style.marginLeft=+document.getElementById('tab1').style.width++document.getElemensByClassName('clearer').style.width; } */ /* function load { for(i=1; i<+document.getElementById('tabs').innerHTML+1; i++) { document.getElementById('tab' + i).addEventListener("click", function {       check(i);        }, false); } } */ /* resize; */ /* load; */ /* Add items below manually as you add more tabs */ if(window.location.pathname==='/wiki/Template:Tabs') { document.getElementById('tab1').addEventListener("click", function {    check(1); }, false); document.getElementById('tab2').addEventListener("click", function {    check(2); }, false); document.getElementById('tab3').addEventListener("click", function {    check(3); }, false); }