User:Manishearth/sidebartoggle.js

var ml=10; var stundefined; var sideHidden=true; if(readCookie('sidebarconfig')===null){ saveSidebar; } sideHidden=(readCookie('sidebarconfig')=="true")?true:false

var tabHide="Hide Sidebar (s)" var tabShow="Show Sidebar (s)" function hideSide{ sideHidden=true; document.getElementById('ca-tSH').innerHTML=tabShow

if(document.getElementById('p-logo').style!==null){document.getElementById('p-logo').style.display='none'} if(document.getElementById('p-navigation').style!==null){document.getElementById('p-navigation').style.display='none'} if(document.getElementById('p-search').style!==null){document.getElementById('p-search').style.display='none'} if(document.getElementById('p-interaction')!==null){document.getElementById('p-interaction').style.display='none'} if(document.getElementById('p-tb')!==null){document.getElementById('p-tb').style.display='none'} if(document.getElementById('p-lang')!==null){if(document.getElementById('p-lang').style!==null){document.getElementById('p-lang').style.display='none'}} if(document.getElementById('p-coll-print_export')!==null){document.getElementById('p-coll-print_export').style.display='none'} document.getElementById('content').style.marginLeft=0; } //hideSide; //showSide;

function showSide{ sideHidden=false; document.getElementById('ca-tSH').innerHTML=tabHide

if(document.getElementById('p-logo').style!==null){document.getElementById('p-logo').style.display=''} if(document.getElementById('p-navigation').style!==null){document.getElementById('p-navigation').style.display=''} if(document.getElementById('p-search').style!==null){document.getElementById('p-search').style.display=''} if(document.getElementById('p-interaction')!==null){document.getElementById('p-interaction').style.display=''} if(document.getElementById('p-tb')!==null){document.getElementById('p-tb').style.display=''} if(document.getElementById('p-lang')!==null){if(document.getElementById('p-lang').style!==null){document.getElementById('p-lang').style.display=''}} if(document.getElementById('p-coll-print_export')!==null){document.getElementById('p-coll-print_export').style.display=''}

document.getElementById('content').style.marginLeft='12.2em'; } function toggleShowHide{ if(sideHidden){ showSide }else{ hideSide; }

} addOnloadHook( function{ var tabcont=" " mw.util.addPortletLink('p-cactions','javascript:toggleShowHide',tabcont,'ca-tSH','Toggle the sidebar') document.getElementById('ca-tSH').innerHTML=tabHide if(sideHidden){ hideSide; } })

function saveSidebar{ createCookie('sidebarconfig',sideHidden,365)

}

function createCookie(name,value,days) { if (days) { var date = new Date; date.setTime(date.getTime+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString; }	else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; }

function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); }	return null; }

function eraseCookie(name) { createCookie(name,"",-1); }