Ero sivun ”Järjestelmäviesti:Common.js” versioiden välillä
Siirry navigaatioon
Siirry hakuun
Poistettu sisältö Lisätty sisältö
päivitetty collapsible tables, kopioitu versiosta https://www.wikidata.org/w/index.php?title=MediaWiki:Common.js&oldid=84385857 |
MitM-domain poistettu .fi-juuresta eikä muita näytä putkahdelleen esiin. Pois toistaiseksi. |
||
Rivi 9: | Rivi 9: | ||
* [[Käyttäjä:Zache|Zache]] ([[Keskustelu käyttäjästä:Zache|keskustelu]]) |
* [[Käyttäjä:Zache|Zache]] ([[Keskustelu käyttäjästä:Zache|keskustelu]]) |
||
*/ |
*/ |
||
/** Man in the middle ********************************************************* |
|||
* |
|||
* Description: Mies välissä -höyökkäyksen uudelleenohjaus sivulle, jossa kerrotaan aiheesta. Tätä kautta hyökkääjät saattavat esimerkiksi urkkia käyttäjien salasanoja tai lähettää haitallista sähköpostia rekisteröityneille. JS-pätkä lainattu italiankielisestä Wikipediasta, jossa on samanlainen toteutus: https://it.wikipedia.org/wiki/MediaWiki:Common.js |
|||
* Maintainers: [[Käyttäjä:str4nd]] |
|||
*/ |
|||
if (mw.config.get('wgIsMainPage') && top != self) |
|||
top.location.replace('http://toolserver.org/~str4nd/wikipedia_redirect.php'); |
|||
if (location.host == "facebok.fi" || location.host == "www.facebok.fi") |
|||
self.location.replace('http://toolserver.org/~str4nd/wikipedia_redirect.php'); |
|||
/* Man in the middle ends */ |
|||
if (wgAction == "edit" || wgAction == "submit") { // skriptit muokkaussivuille |
if (wgAction == "edit" || wgAction == "submit") { // skriptit muokkaussivuille |
Versio 4. tammikuuta 2014 kello 07.46
/* '''Suomenkielisen Wikipedian JavaScript'''
*
* Tämä sivu on suojattu [[Wikipedia:Ylläpitäjät|vain ylläpitäjien]] muokattavaksi. Mikäli haluat
* muutoksia JavaScript-koodiin, voit tehdä oman [[Toiminnot:Mypage/monobook.js|monobook.js]]-tiedoston tai
* esittää pyynnön jollekin tämän koodin ylläpitäjistä.
*
* Ylläpitäjät:
* [[Käyttäjä:Str4nd|str4nd]] ([[Keskustelu käyttäjästä:Str4nd|keskustelu]])
* [[Käyttäjä:Zache|Zache]] ([[Keskustelu käyttäjästä:Zache|keskustelu]])
*/
if (wgAction == "edit" || wgAction == "submit") { // skriptit muokkaussivuille
importScript("Järjestelmäviesti:Edittools.js")
}
if (wgCanonicalSpecialPageName == "Upload") { // skriptit tiedostojen tallennukselle
importScript("Järjestelmäviesti:Onlyifuploading.js");
}
function initializebuttons() {
if (window.addEventListener) window.addEventListener("load",buttons,false);
else if (window.attachEvent) window.attachEvent("onload",buttons);
}
function sysopFunctions() { // skriptit ylläpitäjille
if ( wgUserGroups && !window.disableSysopJS ) {
for ( var g = 0; g < wgUserGroups.length; ++g ) {
if ( wgUserGroups[g] == "sysop" ) {
importScript( "Järjestelmäviesti:Sysop.js" );
break;
}
}
}
}
addOnloadHook( sysopFunctions );
/** Collapsible tables *********************************************************
*
* Description: Allows tables to be collapsed, showing only the header. See
* [[Wikipedia:NavFrame]].
* Maintainers: [[User:R. Koot]]
* Suomenkielisen version muokkauksesta vastaa [[Käyttäjä:Zache]]
*/
var autoCollapse = 2;
var collapseCaption = "Piilota";
var expandCaption = "Näytä";
/* 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);
};
})();
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 = {};
var Tables = document.getElementsByTagName( 'table' );
var i;
function handleButtonLink( index, e ) {
window.collapseTable( index );
e.preventDefault();
}
for ( i = 0; i < Tables.length; i++ ) {
if ( $( Tables[i] ).hasClass( '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.className = 'collapseButton'; /* Styles are declared in Common.css */
ButtonLink.style.color = Header.style.color;
ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
ButtonLink.setAttribute( 'href', '#' );
$( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, tableIndex ) );
ButtonLink.appendChild( ButtonText );
Button.appendChild( document.createTextNode( '[' ) );
Button.appendChild( ButtonLink );
Button.appendChild( document.createTextNode( ']' ) );
Header.insertBefore( Button, Header.firstChild );
tableIndex++;
}
}
for ( i = 0; i < tableIndex; i++ ) {
if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) || ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) ) ) {
window.collapseTable( i );
}
else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
var element = NavigationBoxes[i];
while ((element = element.parentNode)) {
if ( $( element ).hasClass( 'outercollapse' ) ) {
window.collapseTable ( i );
break;
}
}
}
}
}
mw.hook( 'wikipage.content' ).add( createCollapseButtons );
/** "Technical restrictions" title fix *****************************************
*
* Description:
* Maintainers: [[:en:User:Interiot]], [[:en:User:Mets501]]
* Suomenkielisen version muokkauksesta vastaa [[Käyttäjä:Agony]]
*/
// For pages that have something like Template:Lowercase, replace the title, but only if it is
// cut-and-pasteable as a valid wikilink.
// (for instance [[iPod]]'s title is updated. <nowiki>But [[C#]] is not an equivalent wikilink,
// so [[C Sharp]] doesn't have its main title changed)</nowiki>
//
// The function looks for a banner like this: <nowiki>
// <div id="RealTitleBanner"> <!-- div that gets hidden -->
// <span id="RealTitle">title</span>
// </div>
// </nowiki>An element with id=DisableRealTitle disables the function.
var disableRealTitle = 0; // users can disable this by making this true from their monobook.js
if ((wgIsArticle)&&(wgNamespaceNumber == 0)) { // don't display the RealTitle when editing, since it is apparently inconsistent (doesn't show when editing sections, doesn't show when not previewing)
addOnloadHook(function() {
try {
var realTitleBanner = document.getElementById("RealTitleBanner");
if (realTitleBanner && !document.getElementById("DisableRealTitle") && !disableRealTitle) {
var realTitle = document.getElementById("RealTitle");
if (realTitle) {
var realTitleHTML = realTitle.innerHTML;
realTitleText = pickUpText(realTitle);
var isPasteable = 0;
//var containsHTML = /</.test(realTitleHTML); // contains ANY HTML
var containsTooMuchHTML = /</.test( realTitleHTML.replace(/<\/?(sub|sup|small|big)>/gi, "") ); // contains HTML that will be ignored when cut-n-pasted as a wikilink
// calculate whether the title is pasteable
var verifyTitle = realTitleText.replace(/^ +/, ""); // trim left spaces
verifyTitle = verifyTitle.charAt(0).toUpperCase() + verifyTitle.substring(1, verifyTitle.length); // uppercase first character
// if the namespace prefix is there, remove it on our verification copy. If it isn't there, add it to the original realValue copy.
if (wgNamespaceNumber != 0) {
if (wgCanonicalNamespace == verifyTitle.substr(0, wgCanonicalNamespace.length).replace(/ /g, "_") && verifyTitle.charAt(wgCanonicalNamespace.length) == ":") {
verifyTitle = verifyTitle.substr(wgCanonicalNamespace.length + 1);
} else {
realTitleText = wgCanonicalNamespace.replace(/_/g, " ") + ":" + realTitleText;
realTitleHTML = wgCanonicalNamespace.replace(/_/g, " ") + ":" + realTitleHTML;
}
}
// verify whether wgTitle matches
verifyTitle = verifyTitle.replace(/^ +/, "").replace(/ +$/, ""); // trim left and right spaces
verifyTitle = verifyTitle.replace(/_/g, " "); // underscores to spaces
verifyTitle = verifyTitle.charAt(0).toUpperCase() + verifyTitle.substring(1, verifyTitle.length); // uppercase first character
isPasteable = (verifyTitle == wgTitle);
var h1 = document.getElementsByTagName("h1")[0];
if (h1 && isPasteable) {
h1.innerHTML = containsTooMuchHTML ? realTitleText : realTitleHTML;
if (!containsTooMuchHTML)
realTitleBanner.style.display = "none";
}
document.title = realTitleText + " - Wikipedia";
}
}
} catch (e) {
/* Something went wrong. */
}
});
}
// similar to innerHTML, but only returns the text portions of the insides, excludes HTML
function pickUpText(aParentElement) {
var str = "";
function pickUpTextInternal(aElement) {
var child = aElement.firstChild;
while (child) {
if (child.nodeType == 1) // ELEMENT_NODE
pickUpTextInternal(child);
else if (child.nodeType == 3) // TEXT_NODE
str += child.nodeValue;
child = child.nextSibling;
}
}
pickUpTextInternal(aParentElement);
return str;
}
function toggleTemplateTable() {
document.getElementById('fiwiki-templatetable').style.display=(document.getElementById('fiwiki-templatetable').style.display == 'none') ? 'block' : 'none';
document.getElementById('fiwiki-templatetoggle').innerHTML=(document.getElementById('fiwiki-templatetable').style.display == 'none') ? '▼ Mallineet' : '▲ Piilota';
}
// ============================================================
// BEGIN Enable multiple onload functions
// setup onload functions this way:
// aOnloadFunctions[aOnloadFunctions.length] = function_name; // without brackets!
if (!window.aOnloadFunctions) {
var aOnloadFunctions = new Array();
}
window.onload = function() {
if (window.aOnloadFunctions) {
for (var _i=0; _i<aOnloadFunctions.length; _i++) {
aOnloadFunctions[_i]();
}
}
}
// END Enable multiple onload functions
// ============================================================
// ============================================================
// BEGIN Dynamic Navigation Bars
// set up the words in your language
var NavigationBarHide = 'Piilota';
var NavigationBarShow = 'Näytä';
// set up max count of Navigation Bars on page,
// if there are more, all will be hidden
// NavigationBarShowDefault = 0; // all bars will be hidden
// NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
var NavigationBarShowDefault = 0;
// shows and hides content and picture (if available) of navigation bars
// Parameters:
// indexNavigationBar: the index of navigation bar to be toggled
function toggleNavigationBar(indexNavigationBar)
{
var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
if (!NavFrame || !NavToggle) {
return false;
}
// if shown now
if (NavToggle.firstChild.data == NavigationBarHide) {
for (
var NavChild = NavFrame.firstChild;
NavChild != null;
NavChild = NavChild.nextSibling
) {
if (NavChild.className == 'NavPic') {
NavChild.style.display = 'none';
}
if (NavChild.className == 'NavContent') {
NavChild.style.display = 'none';
}
if (NavChild.className == 'NavToggle') {
NavChild.firstChild.data = NavigationBarShow;
}
}
// if hidden now
} else if (NavToggle.firstChild.data == NavigationBarShow) {
for (
var NavChild = NavFrame.firstChild;
NavChild != null;
NavChild = NavChild.nextSibling
) {
if (NavChild.className == 'NavPic') {
NavChild.style.display = 'block';
}
if (NavChild.className == 'NavContent') {
NavChild.style.display = 'block';
}
if (NavChild.className == 'NavToggle') {
NavChild.firstChild.data = NavigationBarHide;
}
}
}
}
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton()
{
var indexNavigationBar = 0;
// iterate over all < div >-elements
var divs= document.getElementsByTagName("div");
for(
var i=0;
i<divs.length;
i++
) {
NavFrame = divs[i];
// if found a navigation bar
if (hasClass(NavFrame,"NavFrame")) {
indexNavigationBar++;
var NavToggle = document.createElement("a");
NavToggle.className = 'NavToggle';
NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
var NavToggleText = document.createTextNode(NavigationBarHide);
NavToggle.appendChild(NavToggleText);
// add NavToggle-Button as first div-element
// in < div class="NavFrame" >
NavFrame.insertBefore(
NavToggle,
NavFrame.firstChild
);
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
if (!hasClass(NavFrame,"Expand")) {
toggleNavigationBar(indexNavigationBar);
}
}
}
}
jQuery(document).ready(createNavigationBarToggleButton);
// END Dynamic Navigation Bars
// ============================================================
function addLoadEvent(func)
{
if (window.addEventListener)
window.addEventListener("load", func, false);
else if (window.attachEvent)
window.attachEvent("onload", func);
}
/** Interwiki links to featured articles ***************************************
*
* Description: Highlights interwiki links to featured articles (or
* equivalents) by changing the bullet before the interwiki link
* into a star.
* Maintainers: User:R. Koot
*/
function LinkFA()
{
if ( document.getElementById( "p-lang" ) ) {
var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );
for ( var i = 0; i < InterwikiLinks.length; i++ ) {
if ( document.getElementById( InterwikiLinks[i].className + "-fa" ) ) {
InterwikiLinks[i].className += " FA"
InterwikiLinks[i].title = "Tästä aiheesta on suositeltu artikkeli toisessa Wikipedian kieliversiossa.";
}
}
}
}
addOnloadHook( LinkFA );
function LinkGA()
{
if ( document.getElementById( "p-lang" ) ) {
var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );
for ( var i = 0; i < InterwikiLinks.length; i++ ) {
if ( document.getElementById( InterwikiLinks[i].className + "-ga" ) ) {
InterwikiLinks[i].className += " GA"
InterwikiLinks[i].title = "Tästä aiheesta on hyvä artikkeli toisessa Wikipedian kieliversiossa.";
}
}
}
}
addOnloadHook( LinkGA );
function LinkLA()
{
if ( document.getElementById( "p-lang" ) ) {
var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );
for ( var i = 0; i < InterwikiLinks.length; i++ ) {
if ( document.getElementById( InterwikiLinks[i].className + "-la" ) ) {
InterwikiLinks[i].className += " LA"
InterwikiLinks[i].title = "Tästä aiheesta on lupaava artikkeli toisessa Wikipedian kieliversiossa.";
}
}
}
}
addOnloadHook( LinkLA );
/* Special functionality for fi-wiki AFD */
function appendVote(content, vote) {
document.editform.wpSummary.value=vote;
if (content.match(/===( )*Äänet( )*===[\s\S]*(===)/im)) { /* Do we have subsections? */
/* Insert vote at the end of voting section */
newContent=content.replace(/===( )*Äänet( )*===([\s\S]*?)[\s]*(?====)/im, '===Äänet===$3\r\n' + vote + '\r\n\r\n');
return(newContent);
} else {
return(content + '\r\n' + vote + '\r\n'); /* Append vote to the end of page */
}
}
addLoadEvent(LinkFA);
/** Change Special:Search to use a radio menu *******************************************************
*
* Description: Change Special:Search to use a radio menu, with the default being
* the internal MediaWiki engine
* Created and maintained by: [[:fr:User:Pmartin]]
*/
if ((wgNamespaceNumber == -1) && (wgCanonicalSpecialPageName == "Search")) {
var searchEngines = {
mediawiki: {
ShortName: "MediaWiki-haku",
Template: "/w/index.php?search={searchTerms}"
},
google: {
ShortName: "Google",
Template: "http://www.google.com/search?hl=" + wgUserLanguage + "&q={searchTerms}&as_sitesearch=" + wgServer.substr(2)
},
yahoo: {
ShortName: "Yahoo",
Template: "http://" + wgUserLanguage + ".search.yahoo.com/search?p={searchTerms}&vs=" + wgServer
},
bing: {
ShortName: "Bing",
Template: "http://www.bing.com/search?q={searchTerms}&q1=site:" + wgServer
},
wikiwix: {
ShortName: "Wikiwix",
Template: "http://www.wikiwix.com/index.php?action={searchTerms}&lang="+wgContentLanguage
}
};
addOnloadHook(externalSearchEngines);
}
function externalSearchEngines() {
if (typeof SpecialSearchEnhanced2Disabled != 'undefined') return;
var mainNode = document.getElementById("powersearch");
if (!mainNode) mainNode = document.getElementById("search");
if (!mainNode) return;
var beforeNode = document.getElementById("mw-search-top-table");
if (!beforeNode) return;
beforeNode = beforeNode.nextSibling;
if (!beforeNode) return;
var firstEngine = "mediawiki";
var choices = document.createElement("div");
choices.setAttribute("id","searchengineChoices");
choices.style.textAlign = "center";
var lsearchbox = document.getElementById("searchText");
var initValue = lsearchbox.value;
var space = "";
for (var id in searchEngines) {
var engine = searchEngines[id];
if(engine.ShortName)
{
if (space) choices.appendChild(space);
space = document.createTextNode(" ");
var attr = {
type: "radio",
name: "searchengineselect",
value: id,
onFocus: "changeSearchEngine(this.value)",
id: "searchengineRadio-"+id
};
var html = "<input";
for (var a in attr) html += " " + a + "='" + attr[a] + "'";
html += " />";
var span = document.createElement("span");
span.innerHTML = html;
choices.appendChild( span );
var label
if (engine.Template.indexOf('http') == 0) {
label = document.createElement("a");
label.href = engine.Template.replace("{searchTerms}", initValue).replace("{language}", "fr");
} else {
label = document.createElement("label");
}
label.appendChild( document.createTextNode( engine.ShortName ) );
choices.appendChild( label );
}
}
mainNode.insertBefore(choices, beforeNode);
var input = document.createElement("input");
input.id = "searchengineextraparam";
input.type = "hidden";
mainNode.insertBefore(input, beforeNode);
changeSearchEngine(firstEngine, initValue);
}
function changeSearchEngine(selectedId, searchTerms) {
var currentId = document.getElementById("searchengineChoices").currentChoice;
if (selectedId == currentId) return;
document.getElementById("searchengineChoices").currentChoice = selectedId;
var radio = document.getElementById('searchengineRadio-' + selectedId);
radio.checked = "checked";
var engine = searchEngines[selectedId];
var p = engine.Template.indexOf('?');
var params = engine.Template.substr(p+1);
var form;
if (document.forms["search"]) {
form = document.forms["search"];
} else {
form = document.getElementById("powersearch");
}
form.setAttribute("action", engine.Template.substr(0,p));
var l = ("" + params).split("&");
for (var idx = 0;idx < l.length;idx++) {
var p = l[idx].split("=");
var pValue = p[1];
if (pValue == "{language}") {
} else if (pValue == "{searchTerms}") {
var input;
input = document.getElementById("searchText");
input.name = p[0];
} else {
var input = document.getElementById("searchengineextraparam");
input.name = p[0];
input.value = pValue;
}
}
}
// Korjataan Suomen oloissa bugaava ts_parseFloat
function ts_parseFloat(num) {
if (!num) return 0;
num = parseFloat(num.replace(/,/, "."));
return (isNaN(num) ? 0 : num);
}
/**
* Funktio välilehtien lisäämiseksi, alkuperäinen koodi
* [[commons:MediaWiki:Extra-tabs.js]] lisättynä api-kutsulla
* joka tarkastaa oletuksena sivun olemassaolon api.php kautta
*
* Käyttöesimerkki:
* function myTabs() {
* // Omat muokkaukset, ei varsinainen sivu joten ohitetaan apikutsu
* global_append_tab('Toiminnot:Muokkaukset/' + wgUserName, 'Omat muokkaukset', 'ca-contribs', false);
* // Välilehti omaan monobook.js-tiedostoon
* global_append_tab('Käyttäjä:' + wgUserName + '/monobook.js', 'monobook.js', 'ca-monobookjs');
* }
*
* addOnloadHook( myTabs );
*/
function global_append_tab(url, name, id, apicheck, preload) {
if (apicheck != false) { apicheck = true; }
var path = '/wiki/';
if (url.substring(0, 9) == 'index.php') {
path = '/w/';
}
var na = document.createElement('a');
var xmlhttp = sajax_init_object();
var li = document.createElement('li');
if(id) li.id = id;
if (apicheck == true) {
xmlhttp.open( 'GET' , wgServer + wgScriptPath + '/api.php?format=json&action=query&prop=info&titles=' + encodeURIComponent(url), false);
xmlhttp.send(null);
if (xmlhttp.status == 200) {
var data = xmlhttp.responseText;
if (data.indexOf('missing') != -1) {
li.setAttribute('class', 'new');
if (preload) {
na.setAttribute('href', '/w/index.php?action=edit&title=' + encodeURIComponent(url) +
'&preload=' + encodeURIComponent(preload));
}
}
}
}
if (!na.getAttribute('href')) {
na.setAttribute('href', path + url);
}
var txt = document.createTextNode(name);
var span = document.createElement('span');
span.appendChild(txt);
na.appendChild(span);
li.appendChild(na);
// Grab the element we want to append the tab and append the tab to it.
if ( skin == 'vector' ) {
var c1 = document.getElementById('p-views');
var tabs = c1.getElementsByTagName('ul')[0];
} else {
var c1 = document.getElementById('column-one');
var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
}
tabs.appendChild(li);
}
/** Election Javascript ****************************************************
* Kuvaus: Ehdokkaiden sekoitus äänestyksissä.
*/
if (wgCanonicalNamespace == "Project" && wgAction == "view") {
importScript("Järjestelmäviesti:Dshuf.js");
}
/* <syntaxhighlight lang="javascript"> */
/* Script to rewrite external links to Wikipedia (and other Wikimedia projects) to
* use the secure server when already browsing from https://secure.wikimedia.org, so
* that links to diffs, etc., don't take you off the site.
* Original source: http://en.wikipedia.org/wiki/MediaWiki:Common.js/secure.js
* Added: 5.3.2011 by Zache
*/
if ( mw.config.get('wgServer') == 'https://secure.wikimedia.org' ) {
jQuery( document ).ready( alwayssecurelinks );
}
function alwayssecurelinks() {
if( window.disableSecureLinks===true) return;
var re1 = /^http:\/\/(?:([a-z0-9\.\\-]+)\.)?(wik(?:i[mp]edia|tionary|isource|iquote|ibooks|inews|iversity|imediafoundation)|mediawiki)\.org(\/[^?#]*)([#?].*|)$/i;
var links = document.getElementsByTagName('a');
for (var i = links.length; i--;) {
var link = links[i], href = link.href;
var m, main, sub, page, query;
if (m = href.match(re1)) {
main = m[2].toLowerCase();
sub = m[1];
page = m[3];
query = m[4];
if( main === 'mediawiki' ) {sub = main; main = 'wikipedia';}
if( main === 'wikimediafoundation' ) {sub = 'foundation'; main = 'wikipedia';}
if( main === 'wikisource' && !sub ) {main = 'wikipedia'; sub = 'sources';}
if (sub === undefined) continue;
sub = sub.toLowerCase();
if (sub === 'www' || sub === 'mail') continue;
if (main === 'wikipedia') {
if (sub.match(/^(download|mobile|.*?\.mobile|.*?\.m)$/)) {
continue;
}
} else if (main === 'wikimedia') {
if (sub.match(/^(lists|upload|download|bugzilla|(tech|)blog|wikitech|svn|stats|volunteer|ticket|survey|dumps|noc|nyc|status|prototype|.*?planet|.*?donate)$/)) {
continue;
}
if (!sub.match(/^(?:.{1,3}|.{1,3}?\..{1,3}|(?:.+?)\.labs)$/)) { // labs, regional wikimedias
main = 'wikipedia'; // commons, meta, species, wikimania200x, many others
}
}
sub = sub.replace(/\./g, '-');
} else continue;
if( !page || page == '/' ) page = '/wiki/'
link.href = wgServer + '/' + main + '/' + sub + page + query;
}
}
/* Näytetään vakautetuilla ja vakailla sivuilla FlaggedRevs-tiedotelaatikot */
/* Voidaan poistaa sen jälkeen kun FlaggedRevs-piilotus on poistettu */
/* -- Zache 14.2.2012 */
if (wgStableRevisionId>0)
{
var e=document.getElementById("mw-fr-revisiontag");
if (e && (wgStableRevisionId!=wgCurRevisionId))
{
if (e.innerHTML.search("doc-magnify.png")!=-1) { e.style.display="block"; }
else if (e.innerHTML.search("img/2.png")!=-1) { e.style.display="block"; }
}
}
/* vaihtaa sivun vanhimpaan odottavaan muutokseen */
function check_unreviewed() {
$.getJSON("//fi.wikipedia.org/w/api.php?action=query&list=oldreviewedpages&ornamespace=0&format=json&orlimit=50"
, function(data)
{
if (data.query.oldreviewedpages.length)
{
var pos=Math.floor(Math.random()*data.query.oldreviewedpages.length);
var url="//fi.wikipedia.org/w/index.php?"
+ "title=" + data.query.oldreviewedpages[pos].title.replace(" ", "_")
+ "&diff=cur"
+ "&oldid=" + data.query.oldreviewedpages[pos].stable_revid
+ "&wikeddiff=1";
document.location=url;
}
});
}
/* Mikäli kuva on common-kuva niin siirrytään suoraan sinne fiwikin kuvasivun sijaan */
function alwayscommonslinks() {
var re1 = /^http:\/\/(?:(upload)\.)?(wikimedia)\.org(\/wikipedia\/commons\/[^?#]*)([#?].*|)$/i;
var images = document.getElementsByTagName('img');
for (var i = images.length; i--;) {
var image = images[i], src = image.src;
var m, main, sub, page, query;
if ((m = src.match(re1)) && image.parentNode.href) {
image.parentNode.href=image.parentNode.href.replace("//fi.wikipedia.org/wiki/Tiedosto:", "//commons.wikimedia.org/wiki/File:");
}
}
}
jQuery( document ).ready( alwayscommonslinks );
/* </syntaxhighlight> */
/**
* Description: Adapt multiple columns to the actual size of the bodyContent div.
* Maintainers: [[:no:User:Jeblad]]
*/
(function(mw, $) {
var widths = [
{ size : 300, name : 'multicol-xx-small' },
{ size : 600, name : 'multicol-x-small' },
{ size : 900, name : 'multicol-small' },
{ size : 1200, name : 'multicol-normal' },
{ size : 1500, name : 'multicol-large' },
{ size : 1800, name : 'multicol-x-large' },
{ size : 2100, name : 'multicol-xx-large' }
];
$( function() {
var found = 0;
var width = $('#bodyContent').width();
if (width < widths[0]) {
$('#bodyContent').addClass('multicol-verysmall');
return;
}
for (var i = 1; i<widths.length; i++) {
if (widths[i-1].size <= width && width < widths[i].size) {
$('#bodyContent').addClass( widths[i].name);
found++;
break;
}
}
if (!found) {
$('#bodyContent').addClass('multicol-verylarge');
}
});
})(mediaWiki, jQuery);