"MediaWiki:Common.js" sayfasının sürümleri arasındaki fark
(Sayfa oluşturdu, içeriği: '/** Collapsible tables ********************************************************* * * Description: Allows tables to be collapsed, showing only the header. See * ...') |
|||
1. satır: | 1. satır: | ||
− | + | function ModifySidebar(action, section, name, link) { | |
− | + | try { | |
− | + | switch (section) { | |
− | + | case "languages": | |
− | + | var target = "p-lang"; | |
− | + | break; | |
+ | case "toolbox": | ||
+ | var target = "p-tb"; | ||
+ | break; | ||
+ | case "navigation": | ||
+ | var target = "p-navigation"; | ||
+ | break; | ||
+ | default: | ||
+ | var target = "p-" + section; | ||
+ | var custom = true; | ||
+ | break; | ||
+ | } | ||
− | + | if (action == "addC") { | |
− | var | + | var node = document.getElementById(target) |
− | var | + | .getElementsByTagName('div')[0] |
+ | .getElementsByTagName('ul')[0]; | ||
+ | var nodeelements = node.getElementsByTagName('li'); | ||
− | + | for (var i = 0; i < nodeelements.length; i++) { | |
− | + | if (nodeelements[i].getElementsByTagName('a')[0].innerHTML == name || | |
− | + | nodeelements[i].getElementsByTagName('a')[0].href == link) { | |
− | + | node.removeChild(nodeelements[i]); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | } | + | } |
− | + | var aNode = document.createElement('a'); | |
− | + | var liNode = document.createElement('li'); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | aNode.appendChild(document.createTextNode(name)); | |
+ | aNode.setAttribute('href', link); | ||
+ | liNode.appendChild(aNode); | ||
+ | liNode.className='plainlinks'; | ||
+ | node.appendChild(liNode); | ||
+ | node.style.display = "visible"; | ||
+ | } | ||
− | + | if (action == "removeC") { | |
− | + | var list = document.getElementById(target) | |
− | + | .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]); | ||
} | } | ||
+ | } | ||
+ | } | ||
− | + | if (action == "removeP"){ | |
− | + | var node = document.getElementById(target); | |
− | + | node.style.visibility = "hidden"; | |
− | + | } | |
− | + | } catch(e) { | |
− | + | // lets just ignore what's happened | |
− | + | return; | |
− | + | } | |
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | + | function AdminSidebar() { | |
+ | ModifySidebar("addC", "source", "Design", "http://sl3d.woodassoc.us/wiki/Source:Design"); | ||
+ | ModifySidebar("addC", "source", "Conceptual", "http://sl3d.woodassoc.us/wiki/Source:Conceptual"); | ||
+ | ModifySidebar("addC", "source", "Layout", "http://sl3d.woodassoc.us/wiki/Source:Layout"); | ||
+ | ModifySidebar("addC", "project", "Design", "http://sl3d.woodassoc.us/wiki/Silverlight_3D:Design"); | ||
+ | ModifySidebar("addC", "project", "Conceptual", "http://sl3d.woodassoc.us/wiki/Silverlight_3D:Conceptual"); | ||
+ | ModifySidebar("addC", "project", "Layout", "http://sl3d.woodassoc.us/wiki/Silverlight_3D:Layout"); | ||
+ | ModifySidebar("addC", "toolbox", "Upload file", "http://sl3d.woodassoc.us/wiki/Special:Upload"); | ||
+ | } | ||
− | + | function UserSidebar(){ | |
− | + | ModifySidebar("removeP", "toolbox", "toolbox", null); | |
− | + | } | |
− | |||
− | |||
− | + | if (isArray(wgUserGroups)){ | |
− | + | if (wgUserGroups.Contains('bureaucrat') || wgUserGroups.Contains('sysop')){ | |
− | + | //If the user logged in is a Bureaucrat or Sysop | |
− | + | addOnloadHook(AdminSidebar); | |
− | + | }else{ | |
− | } | + | //If the user logged in is not a Bureaucrat or Sysop |
+ | addOnloadHook(UserSidebar); | ||
+ | } | ||
+ | }else{ | ||
+ | //If an anonymous user is viewing the site | ||
+ | addOnloadHook(UserSidebar); | ||
+ | } |
06:36, 22 Ocak 2012 tarihindeki hâli
function ModifySidebar(action, section, name, link) { try { switch (section) { case "languages": var target = "p-lang"; break; case "toolbox": var target = "p-tb"; break; case "navigation": var target = "p-navigation"; break; default: var target = "p-" + section; var custom = true; break; } if (action == "addC") { var node = document.getElementById(target) .getElementsByTagName('div')[0] .getElementsByTagName('ul')[0]; var nodeelements = node.getElementsByTagName('li'); for (var i = 0; i < nodeelements.length; i++) { if (nodeelements[i].getElementsByTagName('a')[0].innerHTML == name || nodeelements[i].getElementsByTagName('a')[0].href == link) { node.removeChild(nodeelements[i]); } } var aNode = document.createElement('a'); var liNode = document.createElement('li'); aNode.appendChild(document.createTextNode(name)); aNode.setAttribute('href', link); liNode.appendChild(aNode); liNode.className='plainlinks'; node.appendChild(liNode); node.style.display = "visible"; } if (action == "removeC") { var list = document.getElementById(target) .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]); } } } if (action == "removeP"){ var node = document.getElementById(target); node.style.visibility = "hidden"; } } catch(e) { // lets just ignore what's happened return; } } function AdminSidebar() { ModifySidebar("addC", "source", "Design", "http://sl3d.woodassoc.us/wiki/Source:Design"); ModifySidebar("addC", "source", "Conceptual", "http://sl3d.woodassoc.us/wiki/Source:Conceptual"); ModifySidebar("addC", "source", "Layout", "http://sl3d.woodassoc.us/wiki/Source:Layout"); ModifySidebar("addC", "project", "Design", "http://sl3d.woodassoc.us/wiki/Silverlight_3D:Design"); ModifySidebar("addC", "project", "Conceptual", "http://sl3d.woodassoc.us/wiki/Silverlight_3D:Conceptual"); ModifySidebar("addC", "project", "Layout", "http://sl3d.woodassoc.us/wiki/Silverlight_3D:Layout"); ModifySidebar("addC", "toolbox", "Upload file", "http://sl3d.woodassoc.us/wiki/Special:Upload"); } function UserSidebar(){ ModifySidebar("removeP", "toolbox", "toolbox", null); } if (isArray(wgUserGroups)){ if (wgUserGroups.Contains('bureaucrat') || wgUserGroups.Contains('sysop')){ //If the user logged in is a Bureaucrat or Sysop addOnloadHook(AdminSidebar); }else{ //If the user logged in is not a Bureaucrat or Sysop addOnloadHook(UserSidebar); } }else{ //If an anonymous user is viewing the site addOnloadHook(UserSidebar); }