9,793
edits
Welcome to the Lylat Wiki, all about the Star Fox series! If you'd like to help out, please take a look at our community portal.
Line 414: | Line 414: | ||
return node; | return node; | ||
} | } | ||
/* | |||
######### | |||
### ProjectLinks | |||
### by [[user:Pathoschild]] (idea from an older, uncredited script) | |||
### * generates a sidebar list of links to other projects from {{projectlinks}} | |||
######### | |||
*/ | |||
function Projectlinks() { | |||
var elements = new Array(); | |||
var spans = document.getElementsByTagName('span'); | |||
// filter for projectlinks | |||
for (var i=0, j=0; i<spans.length; i++) { | |||
if (spans[i].className == 'interProject') { | |||
elements[j] = spans[i].getElementsByTagName('a')[0]; | |||
j++; | |||
} | |||
} | |||
if (j == 0) | |||
return; | |||
// sort alphabetically | |||
function sortbylabel(a,b) { | |||
// get labels | |||
a = a.innerHTML.replace(/^.*<a[^>]*>(.*)<\/a>.*$/i,'$1'); | |||
b = b.innerHTML.replace(/^.*<a[^>]*>(.*)<\/a>.*$/i,'$1'); | |||
// return sort order | |||
if (a < b) return -1; | |||
if (a > b) return 1; | |||
return 0; | |||
} | |||
elements.sort(sortbylabel); | |||
// Create the list of project links | |||
var pllist = newNode('ul'); | |||
for (var i=0; i<elements.length; i++) { | |||
pllist.appendChild(newNode('li', elements[i])); | |||
} | |||
var projectBox = newNode('div', {'class': 'portlet portal', id: 'p-projects'}, | |||
newNode('h5', 'On other wikis'), | |||
newNode('div', {'class': 'pBody body'}, pllist) | |||
); | |||
var insert = document.getElementById('p-tb'); | |||
if (!insert) | |||
return; | |||
if (insert.nextSibling) | |||
insert.parentNode.insertBefore(projectBox, insert.nextSibling); | |||
else | |||
insert.parentNode.appendChild(projectBox); | |||
} | |||
addOnloadHook(Projectlinks); | |||
/*</pre> | /*</pre> |