MediaWiki:Common.js

Version fra 20. mar 2012, 19:46 af Hp (diskussion | bidrag) Hp (diskussion | bidrag)
(forskel) ←Ældre version | Nuværende version (forskel) | Nyere version→ (forskel)
Skift til: navigering, søgning

Bemærk: Efter at have gemt er du måske nødt til at tømme din browsers cache for at kunne se ændringerne.

  • Firefox / Safari: Hold Shift nede og klik på Reload, eller tryk enten Ctrl-F5 eller Ctrl-R (⌘-R på en Mac).
  • Google Chrome: Tryk Ctrl-Shift-R (⌘-Shift-R på en Mac).
  • Internet Explorer: Hold Ctrl nede og klik på Refresh, eller tryk på Ctrl-F5.
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files
/* Javascript inkluderet her vil være aktivt for alle brugere. */

if (mwCustomEditButtons) {
   mwCustomEditButtons.push({
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/4/4c/Button_interprojet.png",
     "speedTip": "Indsætter en navigationsboks",
     "tagOpen": '{{Navboks\n| navn   = \n| titel  = [[:kategori:',
     "tagClose": '|]]\n| billede-venstre = \n| billede = \n\n| liste1  = \n\n',
     "sampleText": "Navn"
    });

   mwCustomEditButtons.push({
     "imageFile": "http://upload.wikimedia.org/wikipedia/en/1/12/Button_gallery.png",
     "speedTip": "Indsæt et billedgalleri",
     "tagOpen": "\n<gallery>\n",
     "tagClose": "\n</gallery>",
     "sampleText": "Fil:Example.jpg|Undertekst 1\nFil:Example.jpg|Undertekst 2"
    });
  
   mwCustomEditButtons.push({
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/1/1a/Button_fact.png",
     "speedTip": "Indsætter dokumentation",
     "tagOpen": '== Noter ==\n№.\n{{Doku||',
     "tagClose": '\n',
     "sampleText": "album"
    });

   mwCustomEditButtons.push({
     "imageFile": "http://upload.wikimedia.org/wikipedia/en/6/60/Button_insert_table.png",
     "speedTip": "Indsætter en ny tabel",
     "tagOpen": '{| class="wikitable"\n|',
     "tagClose": "\n|}",
     "sampleText": "-\n! Overskrift 1\n! overskrift 2\n! overskrift 3\n|-\n| række 1, celle 1\n| række 1, celle 2\n| række 1, celle 3\n|-\n| række 2, celle 1\n| række 2, celle 2\n| række 2, celle 3"
    });

   mwCustomEditButtons.push({
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/d/d7/Button_more.png",
     "speedTip": "Sortérbar tabel",
     "tagOpen": ' class="wikitable sortable"',
     "tagClose": "\n",
     "sampleText": " "
    });
 
   mwCustomEditButtons.push({
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/0/04/Button_multicol.png",
     "speedTip": "Opdeler i 2 kolonner",
     "tagOpen": "<table width=100%>\n<tr valign=top>\n<td width=50%>\n",
     "tagClose": "\n<td>\n\n</tr>\n</table>",
     "sampleText": "Tekst i venstre spalte"
    });
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.ribewiki.dk/dansk/images/Knap.firmasignatur.jpg",
     "speedTip": "Venstrestillet kursiv tekst med mellemrum",
     "tagOpen": "<div style='white-space:pre'>''",
     "tagClose": "''</div>",
     "sampleText": "Skriver"};
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.ribewiki.dk/dansk/images/Knap.signatur.png",
     "speedTip": "Centreret kursiv tekst med mellemrum",
     "tagOpen": "<center style='white-space:pre'>''",
     "tagClose": "''</center>",
     "sampleText": "Underskrift"};

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/4/4d/Button_quotes.png",
     "speedTip": "Fed kursiv tekst",
     "tagOpen": "'''''",
     "tagClose": "'''''",
     "sampleText": "Tekst"};

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/5/5f/Button_center.png",
     "speedTip": "Centrér tekst",
     "tagOpen": "<center>",
     "tagClose": "</center>",
     "sampleText": "Tekst"};
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/a/a5/Button_align_right.png",
     "speedTip": "Højrestil tekst",
     "tagOpen": "<div style='text-align:right'>",
     "tagClose": "</div>",
     "sampleText": "Tekst"};
  
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://ribewiki.dk/dansk/images/Knap.gennemstregning.png",
     "speedTip": "Gennemstregning",
     "tagOpen": "<s>",
     "tagClose": "</s>",
     "sampleText": "Tekst"};
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.ribewiki.dk/dansk/images/Knap.understreget.png",
     "speedTip": "Understregning",
     "tagOpen": "<u>",
     "tagClose": "</u>",
     "sampleText": "Tekst"};

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://ribewiki.dk/dansk/images/Knap.brøk.png",
     "speedTip": "Brøk",
     "tagOpen": "<font size='-2'><sup>",
     "tagClose": "</sup>/<sub>16</sub></font>",
     "sampleText": "Tekst"};
 
   mwCustomEditButtons.push({
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/1/11/Btn_toolbar_liste.png",
     "speedTip": "Indsætter liste",
     "tagOpen": "<ol type=",
     "tagClose": " >\n<li>\n</ol> ",
     "sampleText": "Tabeltype"
    });

   mwCustomEditButtons.push({
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png",
     "speedTip": "Indsætter en reference",
     "tagOpen": "<ref>",
     "tagClose": "</ref>",
     "sampleText": "Indsæt fodnote her"
    });

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://ribewiki.dk/dansk/images/Knap.wiktionary.png",
     "speedTip": "Omdirigér til engelsk Wiktionary",
     "tagOpen": "#REDIRECT [[wikt:",
     "tagClose": "#Latin]]\n[[kategori:wiktionary]]\n[[kategori:latin]]",
     "sampleText": "Ord"};
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://ribewiki.dk/dansk/images/Knap.wikipedia.png",
     "speedTip": "Dansk Wikipedia",
     "tagOpen": "#REDIRECT [[wp:",
     "tagClose": "]]\n[[kategori:wikipedia]]",
     "sampleText": "Ord"};

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://ribewiki.dk/dansk/images/Knap.ordnet.dk.png",
     "speedTip": "Ordbog over det Danske Sprog",
     "tagOpen": "#REDIRECT [[ods:",
     "tagClose": "]]\n[[kategori:sproget]]\n[[kategori:Ordbog over det danske Sprog]]",
     "sampleText": "Ord"};

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://ribewiki.dk/dansk/images/Knap.sproget.dk.png",
     "speedTip": "Omdirigér til sproget.dk",
     "tagOpen": "#REDIRECT [[sprog:",
     "tagClose": "]]\n[[kategori:sproget]]\n[[kategori:Den Danske Ordbog]]",
     "sampleText": "Ord"};

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://ribewiki.dk/dansk/images/Knap.da.png",
     "speedTip": "Omdefinér intern link",
     "tagOpen": "#REDIRECT[[da:",
     "tagClose": "]]\n[[kategori:]]",
     "sampleText": "Navn"};

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/4/49/Button_talk.png",
     "speedTip": "Navn på præst",
     "tagOpen": "#REDIRECT[[ Pastorat#",
     "tagClose": "]]\n[[kategori: Pastorat]]\n[[kategori:Præst]]",
     "sampleText": "Præst"};

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/b/ba/Jadernyhrib-button.png",
     "speedTip": "Navn på godsejer",
     "tagOpen": "#REDIRECT[[ Hovedgård#",
     "tagClose": "]]\n[[kategori: Hovedgård]]",
     "sampleText": "Godsejer"};

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/c/c1/Button_city_silhouette.png",
     "speedTip": "Link til landsby-kategori",
     "tagOpen": "#REDIRECT[[:kategori:",
     "tagClose": "]]\n[[kategori:Landsby]]",
     "sampleText": "Navn"};

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/6/66/Button_API_tilde.png",
     "speedTip": "Bøjningsform af opslagsord",
     "tagOpen": "#REDIRECT[[da:",
     "tagClose": "]]\n[[kategori:Bøjning]]",
     "sampleText": "Ord"};

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/4/47/Button_redir.png",
     "speedTip": "Intern link til kategori",
     "tagOpen": "#REDIRECT[[:kategori:",
     "tagClose": "]]\n[[kategori:]]",
     "sampleText": "Navn"};

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/c/c6/Button_Kat.png",
     "speedTip": "Bøjningsform af kategoriord",
     "tagOpen": "#REDIRECT[[:kategori:",
     "tagClose": "]]\n[[kategori:Kategoriord]]",
     "sampleText": "Ord"};

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://ribewiki.dk/dansk/images/Knap.kategori.png",
     "speedTip": "Indsæt kategori",
     "tagOpen": "[[kategori:",
     "tagClose": "]]\n",
     "sampleText": "Kategorinavn"};

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/3/3b/Button_template_alt.png",
     "speedTip": "Indsæt skabelon",
     "tagOpen": "{{",
     "tagClose": "|-|}}\n",
     "sampleText": "Skabelon"};
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/0/0c/Button_Link_DifferentName.png",
     "speedTip": "Opret intern link med alternativ navn",
     "tagOpen": "[[",
     "tagClose": "|]]",
     "sampleText": "Ord"};

   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://ribewiki.dk/dansk/images/Knap.link.png",
     "speedTip": "Opret intern Link",
     "tagOpen": "[[",
     "tagClose": "]]",
     "sampleText": "Ord"};
}

/** Collapsible tables *********************************************************
 *
 *  Description: Allows tables to be collapsed, showing only the header. See
 *               [[Wikipedia:NavFrame]].
 *  Maintainers: [[User:R. Koot]]
 */
 
var autoCollapse = 2;
var collapseCaption = "skjul";
var expandCaption = "vis";
 
function collapseTable( tableIndex )
{
    var Button = document.getElementById( "collapseButton" + tableIndex );
    var Table = document.getElementById( "collapsibleTable" + tableIndex );
 
    if ( !Table || !Button ) {
        return false;
    }
 
    var Rows = Table.rows;
 
    if ( Button.firstChild.data == collapseCaption ) {
        for ( var i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = "none";
        }
        Button.firstChild.data = expandCaption;
    } else {
        for ( var i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = Rows[0].style.display;
        }
        Button.firstChild.data = collapseCaption;
    }
}
 
function createCollapseButtons()
{
    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 );
 
            var Button     = document.createElement( "span" );
            var ButtonLink = document.createElement( "a" );
            var ButtonText = document.createTextNode( collapseCaption );
 
            Button.style.styleFloat = "right";
            Button.style.cssFloat = "right";
            Button.style.fontWeight = "normal";
            Button.style.textAlign = "right";
            Button.style.width = "6em";
 
            ButtonLink.style.color = Header.style.color;
            ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
            ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
            ButtonLink.appendChild( ButtonText );
 
            Button.appendChild( document.createTextNode( "[" ) );
            Button.appendChild( ButtonLink );
            Button.appendChild( document.createTextNode( "]" ) );
 
            Header.insertBefore( Button, Header.childNodes[0] );
            tableIndex++;
        }
    }
 
    for ( var i = 0;  i < tableIndex; i++ ) {
        if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
            collapseTable( i );
        }
    }
}
 
addOnloadHook( createCollapseButtons );

/* Test if an element has a certain class **************************************
*
* Description: Uses regular expressions and caching for better performance.
* Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
*/
 
var hasClass = (function () {
var reCache = {};
return function (element, className) {
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className);
};
})();


/*
F11 - fjerner søjlen til venstre [[mw:Manual:FAQ#How_do_I_hide_the_left_vertical_navigation_toolbar]]
*/

document.onkeydown = function( e ) {
	if( e == null ) e = event
	if( testKey( e, 122 ) ) { //F11
		appendCSS('#column-content {margin: 0 0 .6em 0;} #content {margin: 2.8em 0 0 0;} #p-logo, .generated-sidebar, #p-lang, #p-tb, #p-search {display:none;} #p-cactions {left: .1em;} #footer {display:none;}');
		return false;
	}
}
 
function testKey( e, intKeyCode ) {
	if( window.createPopup )
		return e.keyCode == intKeyCode
	else
		return e.which == intKeyCode
}