|
|
Linje 1: |
Linje 1: |
| | /*<pre>*/ |
| /* Javascript inkluderet her vil være aktivt for alle brugere. */ | | /* Javascript inkluderet her vil være aktivt for alle brugere. */ |
|
| |
|
Linje 13: |
Linje 14: |
| + 'http://meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js' | | + 'http://meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js' |
| + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); | | + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); |
| | // This is a 3 set parts script |
| | // This script is from Wikipedia. For author attribution, please see |
| | // http://en.wikipedia.org/w/index.php?title=MediaWiki:Common.js |
|
| |
|
| | | // 1st part will look for the class name |
| /* Test if an element has a certain class ************************************** | | /* Test if an element has a certain class ************************************** |
| * | | * |
| * Description: Uses regular expressions and caching for better performance. | | * Description: Uses regular expressions and caching for better performance. |
| * Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]] | | * Maintainers: [[Wikipedia:User:Mike Dillon]], [[Wikipedia:User:R. Koot]], [[Wikipedia:User:SG]] |
| */ | | */ |
| | | |
| var hasClass = (function () { | | var hasClass = (function () { |
| var reCache = {}; | | var reCache = {}; |
| return function (element, className) { | | return function (element, className) { |
| return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className); | | return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className); |
| }; | | }; |
| })(); | | })(); |
|
| |
|
| | | // 2nd part is the Scrip for Wikitables |
| /** Collapsible tables ********************************************************* | | /* <pre style="height: 45em"><nowiki> */ |
| * | | /** Collapsible tables ********************************************************* |
| * Description: Allows tables to be collapsed, showing only the header. See | | * |
| * [[Wikipedia:NavFrame]]. | | * Description: Allows tables to be collapsed, showing only the header. See |
| * Maintainers: [[User:R. Koot]] | | * [[Wikipedia:Wikipedia:NavFrame]]. |
| */ | | * Maintainers: [[Wikipedia:User:R. Koot]] |
| | */ |
| | | |
| var autoCollapse = 2; | | var autoCollapse = 2; |
| var collapseCaption = "skjul"; | | var collapseCaption = "hide"; |
| var expandCaption = "vis"; | | var expandCaption = "show"; |
| | | |
| function collapseTable( tableIndex ) | | function collapseTable( tableIndex ) |
| { | | { |
| var Button = document.getElementById( "collapseButton" + tableIndex ); | | var Button = document.getElementById( "collapseButton" + tableIndex ); |
| var Table = document.getElementById( "collapsibleTable" + tableIndex ); | | var Table = document.getElementById( "collapsibleTable" + tableIndex ); |
| | | |
| if ( !Table || !Button ) { | | if ( !Table || !Button ) { |
| return false; | | return false; |
| } | | } |
| | | |
| var Rows = Table.rows; | | var Rows = Table.rows; |
| | | |
| if ( Button.firstChild.data == collapseCaption ) { | | if ( Button.firstChild.data == collapseCaption ) { |
| for ( var i = 1; i < Rows.length; i++ ) { | | for ( var i = 1; i < Rows.length; i++ ) { |
| Rows[i].style.display = "none"; | | Rows[i].style.display = "none"; |
| } | | } |
| Button.firstChild.data = expandCaption; | | Button.firstChild.data = expandCaption; |
| } else { | | } else { |
| for ( var i = 1; i < Rows.length; i++ ) { | | for ( var i = 1; i < Rows.length; i++ ) { |
| Rows[i].style.display = Rows[0].style.display; | | Rows[i].style.display = Rows[0].style.display; |
| } | | } |
| Button.firstChild.data = collapseCaption; | | Button.firstChild.data = collapseCaption; |
| } | | } |
| } | | } |
| | | |
| function createCollapseButtons() | | function createCollapseButtons() |
| { | | { |
| var tableIndex = 0; | | var tableIndex = 0; |
| var NavigationBoxes = new Object(); | | var NavigationBoxes = new Object(); |
| var Tables = document.getElementsByTagName( "table" ); | | var Tables = document.getElementsByTagName( "table" ); |
| | | |
| for ( var i = 0; i < Tables.length; i++ ) { | | for ( var i = 0; i < Tables.length; i++ ) { |
| if ( hasClass( Tables[i], "collapsible" ) ) { | | if ( hasClass( Tables[i], "collapsible" ) ) { |
| | | |
| /* only add button and increment count if there is a header row to work with */ | | /* only add button and increment count if there is a header row to work with */ |
| var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0]; | | var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0]; |
| if (!HeaderRow) continue; | | if (!HeaderRow) continue; |
| var Header = HeaderRow.getElementsByTagName( "th" )[0]; | | var Header = HeaderRow.getElementsByTagName( "th" )[0]; |
| if (!Header) continue; | | if (!Header) continue; |
| | | |
| NavigationBoxes[ tableIndex ] = Tables[i]; | | NavigationBoxes[ tableIndex ] = Tables[i]; |
| Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex ); | | Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex ); |
| | | |
| var Button = document.createElement( "span" ); | | var Button = document.createElement( "span" ); |
| var ButtonLink = document.createElement( "a" ); | | var ButtonLink = document.createElement( "a" ); |
| var ButtonText = document.createTextNode( collapseCaption ); | | var ButtonText = document.createTextNode( collapseCaption ); |
| | | |
| Button.style.styleFloat = "right"; | | Button.style.styleFloat = "right"; |
| Button.style.cssFloat = "right"; | | Button.style.cssFloat = "right"; |
| Button.style.fontWeight = "normal"; | | Button.style.fontWeight = "normal"; |
| Button.style.textAlign = "right"; | | Button.style.textAlign = "right"; |
| Button.style.width = "6em"; | | Button.style.width = "6em"; |
| | | |
| ButtonLink.style.color = Header.style.color; | | ButtonLink.style.color = Header.style.color; |
| ButtonLink.setAttribute( "id", "collapseButton" + tableIndex ); | | ButtonLink.setAttribute( "id", "collapseButton" + tableIndex ); |
| ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" ); | | ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" ); |
| ButtonLink.appendChild( ButtonText ); | | ButtonLink.appendChild( ButtonText ); |
| | | |
| Button.appendChild( document.createTextNode( "[" ) ); | | Button.appendChild( document.createTextNode( "[" ) ); |
| Button.appendChild( ButtonLink ); | | Button.appendChild( ButtonLink ); |
| Button.appendChild( document.createTextNode( "]" ) ); | | Button.appendChild( document.createTextNode( "]" ) ); |
| | | |
| Header.insertBefore( Button, Header.childNodes[0] ); | | Header.insertBefore( Button, Header.childNodes[0] ); |
| tableIndex++; | | tableIndex++; |
| } | | } |
| } | | } |
| | | |
| for ( var i = 0; i < tableIndex; i++ ) { | | for ( var i = 0; i < tableIndex; i++ ) { |
| if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) { | | if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) { |
| collapseTable( i ); | | collapseTable( i ); |
| } | | } |
| } | | } |
| } | | } |
| | | |
| addOnloadHook( createCollapseButtons ); | | addOnloadHook( createCollapseButtons ); |
| | /* </nowiki></pre> */ |
|
| |
|
| /** Dynamic Navigation Bars (experimental) ************************************* | | // 3er part is the Scrip for NavFram |
| | /* <pre style="height: 45em"><nowiki> */ |
| | /** Dynamic Navigation Bars (experimental) ************************************* |
| * | | * |
| * Description: See [[Wikipedia:NavFrame]]. | | * Description: See [[Wikipedia:Wikipedia:NavFrame]]. |
| * Maintainers: UNMAINTAINED | | * Maintainers: UNMAINTAINED |
| */ | | */ |
Linje 171: |
Linje 179: |
| } | | } |
| | | |
| // Changed function from da.wikipedia 2008-07-02 ------------------
| | // adds show/hide-button to navigation bars |
| // adds show/hide-button to navigation bars | | function createNavigationBarToggleButton() |
| function createNavigationBarToggleButton()
| | { |
| {
| | var indexNavigationBar = 0; |
| var indexNavigationBar = 0;
| | // iterate over all < div >-elements |
| // iterate over all < div >-elements
| | var divs = document.getElementsByTagName("div"); |
| for(
| | for( |
| var i=0;
| | var i=0; |
| NavFrame = document.getElementsByTagName("div")[i];
| | NavFrame = divs[i]; |
| i++
| | i++ |
| ) {
| | ) { |
| // if found a navigation bar
| | // if found a navigation bar |
| if (NavFrame.className == "NavFrame") {
| | if (hasClass(NavFrame, "NavFrame")) { |
| | | |
| indexNavigationBar++;
| | indexNavigationBar++; |
| var NavToggle = document.createElement("a");
| | var NavToggle = document.createElement("a"); |
| NavToggle.className = 'NavToggle';
| | NavToggle.className = 'NavToggle'; |
| NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
| | NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); |
| NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
| | NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); |
| | | |
| var NavToggleText = document.createTextNode(NavigationBarHide);
| | var NavToggleText = document.createTextNode(NavigationBarHide); |
| NavToggle.appendChild(NavToggleText);
| | for ( |
| | var NavChild = NavFrame.firstChild; |
| | NavChild != null; |
| | NavChild = NavChild.nextSibling |
| | ) { |
| | if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) { |
| | if (NavChild.style.display == 'none') { |
| | NavToggleText = document.createTextNode(NavigationBarShow); |
| | break; |
| | } |
| | } |
| | } |
| | | |
| // add NavToggle-Button as first div-element
| | NavToggle.appendChild(NavToggleText); |
| // in < div class="NavFrame" >
| | // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) |
| NavFrame.insertBefore(
| | for( |
| NavToggle,
| | var j=0; |
| NavFrame.firstChild
| | j < NavFrame.childNodes.length; |
| );
| | j++ |
| NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
| | ) { |
| }
| | if (hasClass(NavFrame.childNodes[j], "NavHead")) { |
| }
| | NavFrame.childNodes[j].appendChild(NavToggle); |
| // if more Navigation Bars found than Default: hide all
| | } |
| //if (NavigationBarShowDefault < indexNavigationBar && !document.getElementById("NavFrameOpenAll")) {
| | } |
| // for(
| | NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); |
| // var i=1;
| | } |
| // i<=indexNavigationBar;
| | } |
| // i++
| | } |
| // ) {
| |
| // toggleNavigationBar(i);
| |
| // }
| |
| //}
| |
|
| |
| }
| |
| | | |
| addOnloadHook(createNavigationBarToggleButton);
| | addOnloadHook( createNavigationBarToggleButton ); |
| | /*</pre>*/ |