User:Abdullah/SidebarFunctions.js

// // SearchBar // Removes the searchbar at the top and places it on the left, like monobook // function SearchBar { //-Remove search bar at top var del = document.getElementById('p-search'); del.parentNode.removeChild(del);

//-Indent top-right tabs so the dropdown button works nicely document.getElementById('right-navigation').style.margin = "2.5em 3em 0 0";

//-Create a search bar under the navigation thing on the left var newdiv = document.createElement('div'); var olddiv = document.getElementById('p-Navigation') newdiv.setAttribute('id','search');

newdiv.innerHTML = '\  \  \ \             \  \ \      ';

document.getElementById("mw-panel").insertBefore(newdiv, olddiv.nextSibling); }

// // AddLink / RemoveLink // Modifies a section of the sidebar by either adding or removing a link to it. "Remove" is still experimental. // // action = "add" or "remove" // section = The section to remove (eg. "community") // name = The name of the entry (eg. "Castle Town") // link = The page the entry links to (eg. "/Zelda_Wiki.org:Castle_Town") // text = The tooltip text (eg. "Community Portal) // addPortletLink('new-talk', getElementUrl(caTalk) + '?action=edit', 'edit'); //

function AddLink(section, name, link, text) { id=name.replace(/ /g,"-"); addPortletLink(Section(section), link, name, "pt-" + id, text); }

function RemoveLink(section, name, link) { var list = document.getElementById(Section(section)) .getElementsByTagName('div')[0] .getElementsByTagName('ul')[0]; var listelements = list.getElementsByTagName('li'); for (var i = 0; i < listelements.length; i++) { if (listelements[i].getElementsByTagName('a')[0].innerHTML == name ||           listelements[i].getElementsByTagName('a')[0].href == link) { list.removeChild(listelements[i]); }   } }

// // NewSidebar // Creates a new section in the sidebar. It will be blank, so use the ModifySidebar function to add links in it. // // id = The id of the section to create. // name = The displayed name of the section. Automatically lowercase'd // placeafter = The id of the section you want to place your new section under. To place it at the top, type "logo" or "personal" //

function NewSidebar(id, name, placeafter) { var newdiv = document.createElement('div'); var olddiv = document.getElementById(Section(placeafter)) newdiv.setAttribute('id',id);

if (skin=='monobook') {     newdiv.setAttribute('class','portlet'); newdiv.innerHTML = ' ' + name + '  '; document.getElementById("column-one").insertBefore(newdiv, olddiv.nextSibling) } if (skin=='vector') {     newdiv.setAttribute('class','portal collapsed'); newdiv.innerHTML = ' ' + name + '  '; document.getElementById("mw-panel").insertBefore(newdiv, olddiv.nextSibling) } }

// // RemoveSidebar // Removes a section from the sidebar. Writing "p-" in the beginning is not required //

function RemoveSidebar(id) { var del = document.getElementById('p-' + Section(id)); del.parentNode.removeChild(del); }

// // Section // Runs the section name and returns the proper id //

function Section (sec) { switch (sec.toLowerCase) { case "personal":         return "p-personal"; case "navigation":       return "p-Navigation"; case "community":        return "p-Community"; case "the masterminds":  return "p-The_Masterminds"; case "masterminds":      return "p-The_Masterminds"; case "toolbox":          return "p-tb"; case "languages":        return "p-lang"; default:                 return sec; } }