User:Dodoïste/vector.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin is at User:Dodoïste/vector.css. |
// remove original createCollapseButtons functions from onload hook for demo
var createCollapseButtonsOrig = createCollapseButtons;
for (var i = 0; i < onloadFuncts.length; i ++) {
if (onloadFuncts[i] == createCollapseButtonsOrig) {
onloadFuncts.splice(i, 1);
}
}
addOnloadHook(
function() {
for (var i = 0; i < onloadFuncts.length; i ++) {
if (onloadFuncts[i] == createCollapseButtonsOrig) {
onloadFuncts.splice(i, 1);
}
}
}
);
/** Collapsible tables *********************************************************
*
* Description: Allows tables to be collapsed, showing only the header. See
* [[Wikipedia:NavFrame]].
* Maintainers: [[User:R. Koot]]
* Changed for better usability by [[User:Cacycle]]
*/
var autoCollapseTest = 2;
var expandCaptionTest = '<a class="collapseButtonContent"><span class="collapseButtonShow"> </span>show</a>';
var collapseCaptionTest = '<a class="collapseButtonContent"><span class="collapseButtonHide"> </span>hide</a>';
var expandTitle = 'Show hidden content';
var collapseTitle = 'Hide content';
collapseTableTest = function( tableIndex )
{
var Button = document.getElementById( "collapseButton" + tableIndex );
var Table = document.getElementById( "collapsibleTable" + tableIndex );
if ( !Table || !Button ) {
return false;
}
var Rows = Table.rows;
if ( Button.title == collapseTitle ) {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = "none";
}
Button.innerHTML = expandCaptionTest;
Button.title = expandTitle;
} else {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = Rows[0].style.display;
}
Button.innerHTML = collapseCaptionTest;
Button.title = collapseTitle;
}
window.getSelection().removeAllRanges();
}
function createCollapseButtonsTest()
{
var tableIndex = 0;
var NavigationBoxes = new Object();
var Tables = document.getElementsByTagName( "table" );
for ( var i = 0; i < Tables.length; i++ ) {
if ( hasClass( Tables[i], "collapsible" ) ) {
// only add button and increment count if there is a header row to work with
var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
if (!HeaderRow) continue;
var Header = HeaderRow.getElementsByTagName( "th" )[0];
if (!Header) continue;
NavigationBoxes[ tableIndex ] = Tables[i];
Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
// Styles are declared in Common.css
Header.innerHTML += '<a href="" id="collapseButton' + tableIndex + '" class="collapseButtonTest" onclick="javascript:collapseTableTest(' + tableIndex + ')" title="' + collapseTitle + '">' + collapseCaptionTest + '</a>';
tableIndex++;
}
}
for ( var i = 0; i < tableIndex; i++ ) {
if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapseTest && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
collapseTableTest( i );
}
else if ( hasClass( NavigationBoxes[i], "innercollapse" ) ) {
var element = NavigationBoxes[i];
while (element = element.parentNode) {
if ( hasClass( element, "outercollapse" ) ) {
collapseTableTest ( i );
break;
}
}
}
}
}
addOnloadHook(createCollapseButtonsTest);