„MediaWiki:Common.js” változatai közötti eltérés
Tartalom törölve Tartalom hozzáadva
Tgr (vitalap | szerkesztései) Nincs szerkesztési összefoglaló |
JulesWinnfield-hu javaslata: Special:Diff/15107213 |
||
1 233. sor: | 1 233. sor: | ||
// statistics from the squid logs. |
// statistics from the squid logs. |
||
// Based on [[wikt:de:MediaWiki:If-search.js]]. |
// Based on [[wikt:de:MediaWiki:If-search.js]]. |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
} |
|||
function SubSearch(formId, inputId) { |
function SubSearch(formId, inputId) { |
||
var form = $('#' + formId); |
var form = $('#' + formId); |
||
1 262. sor: | 1 246. sor: | ||
form.find('input[name="title"]:first').remove(); |
form.find('input[name="title"]:first').remove(); |
||
} |
} |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
/********************************************************** |
/********************************************************** |
A lap 2014. szeptember 16., 23:44-kori változata
/* Any JavaScript here will be loaded for all users on every page load. */
/*
Wikis függvények és segédletek ($.wiki)
*/
(function($){
$.wiki = {};
/* $.wiki.contentSelector: visszaadja magát a szócikket tartalmazó
elem szelektorát a skintől függően */
if (skin == "modern") $.wiki.contentSelector = "#mw_contentholder";
else if (skin == "standard" || skin == "nostalgia" || skin == "cologneblue") $.wiki.contentSelector = "#article";
else $.wiki.contentSelector = "#bodyContent";
/* Ajaxon keresztül lekéri a megadott oldalt opcionális paraméterekkel */
$.wiki.getPage = function(settings) {
if (typeof(settings.pageName) == "undefined" || settings.pageName == "")
settings.error.call();
var ajaxSettings = {
url: $.wiki.wikiEntryLink(settings.pageName, (typeof(settings.params) == "undefined" ? {} : settings.params))
}
if (typeof(settings.async) != "undefined") ajaxSettings = $.extend(ajaxSettings, {async: settings.async});
if (typeof(settings.success) != "undefined") ajaxSettings = $.extend(ajaxSettings, {success: settings.success});
if (typeof(settings.error) != "undefined") ajaxSettings = $.extend(ajaxSettings, {error: settings.error});
return $.ajax(ajaxSettings);
};
/* Ajaxon keresztül lekéri a megadott oldal nyers változatát opcionális további paraméterekkel */
$.wiki.getPageRaw = function(settings) {
if (typeof(settings.params) != "undefined")
settings.params.action = "raw";
else
settings.params = {action: "raw"};
return $.wiki.getPage(settings);
};
/* Egyszerű wikilink generálása lapnévből: http://hu.wikipedia.org/wiki/Pagename */
$.wiki.wikiLink = function(page) {
var prep = page.replace(/ /g, "_");
return wgServer + wgArticlePath.replace(/\$1/g, prep);
};
/* Link a belépési ponthoz (index.php): http://hu.wikipedia.org/w/index.php?title=Pagename
Opcionálisan további paraméterekkel
*/
$.wiki.wikiEntryLink = function(page, args) {
var prep = page.replace(/ /g, "_");
prep = wgServer + wgScript + "?title=" + prep;
$.each(args, function(key, value) {
prep = prep + "&" + key + "=" + value;
});
return prep;
}
})(jQuery);
/*
== Segédfüggvények ==
*/
/* Chrome sniffing */
var is_chrome = /Chrome/.test(navigator.userAgent);
/* kell a sablonmesternek */
var is_khtml = false;
function addLoadEvent(func) {
$(func);
}
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 escapeRegexp(s) {
return s.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
}
function getCookie(name) {
var cookieText;
var cookiePos = document.cookie.indexOf(name + '=');
if(cookiePos!=-1) {
var results = document.cookie.match(name+'=(.*?)(;|$)');
if(results) cookieText = decodeURIComponent(results[1]);
return cookieText;
} else return null;
}
function setCookie(name, text, expires) {
if(text) {
if(expires) {
document.cookie = name + '=' + encodeURIComponent(text) + '; expires=' + expires.toUTCString() + '; path=/';
} else {
document.cookie = name + '=' + encodeURIComponent(text) + '; path=/';
}
} else {
document.cookie = name + '=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/'; // delete cookie
}
}
/* A wikibits.js importScriptjének emulálása az új betöltőrendszer használatával */
function mwImportScript(page) {
mw.loader.load(mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' +
encodeURIComponent(page.replace(/ /g,'_')).replace(/%2F/ig,'/').replace(/%3A/ig,':') +
'&action=raw&ctype=text/javascript');
}
function cleanHtmlTags(str) {
return str.replace(/<>/g, '');
}
$.fn.log = function(msg) {
if (!window.console || !console.log) return;
if (msg) {
if (typeof msg == 'string') {
console.log('%s: %o', msg, this);
} else {
console.log('%o -> %o', this, msg);
}
} else {
console.log(this);
}
return this;
};
// for inlog gadget
$.startInlog = $.fn.startInlog = function(config) {
if (!$.inlog) return;
$.inlog({
enabled: true,
thisValue: true
});
return this;
};
$.endInlog = $.fn.endInlog = function(config) {
if (!$.inlog) return;
$.inlog(false);
return this;
};
/*
== Wikimenü ==
*/
mw.loader.load('ext.gadget.wikiMenu');
/*
== Kezdőlap RSS ==
*/
if (wgPageName == 'Kezdőlap') {
$(function addFeaturedRSS() {
var feeds = {
'kiemelt': 'Kiemelt szócikkek',
'kiemelt-kep': 'Kiemelt képek',
'evfordulok': 'Évfordulók'
}
for (i in feeds) {
var url = 'http://feeds.feedburner.com/huwiki-' + i;
$('head').append('<link href="'+url+'" title="'+feeds[i]+'" type="application/rss+xml" rel="alternate">');
}
});
}
if (wgTitle == wgMainPageTitle)
$(function () {
if (wgNamespaceNumber == 0)
mw.util.addPortletLink('p-lang', '//meta.wikimedia.org/wiki/List_of_Wikipedias',
'Teljes lista', 'interwiki-completelist', 'A Wikipédiák teljes listája');
});
/*
== Cím elrejtése ==
*/
function hideArticleTitle() {
if (document.getElementById("HideTitle")) {
if (skin=="modern") return;
var h1 = document.getElementsByTagName("h1")[0];
if (h1) {
h1.style.display = "none";
}
var siteSub = document.getElementById("siteSub");
if (siteSub) {
siteSub.style.display = "none";
}
}
}
/*
== Képannotációk ==
*/
if (wgNamespaceNumber != -1
&& wgAction && (wgAction == 'view' || wgAction == 'purge')
&& document.URL.search (/[?&]oldid=/) < 0
&& document.URL.search (/[?&]diff=/) < 0
&& mw.config.get('imageAnnotator.disabled', false) != true) {
mwImportScript ('MediaWiki:Gadget-ImageAnnotator.js');
}
/*
== Elrejthető üzenetek ==
*/
function hideElement(e) {
var name = this.id.slice(5); // 'hide-' elhagyása
var element = document.getElementById(name);
var expires = new Date();
expires.setTime( expires.getTime() + (7*24*60*60*1000) ); // 1 hét
setCookie('hide-' + name, '1', expires);
element.style.display = "none";
this.style.display = "none";
return false;
}
function addHideButton(element) {
if (!element) return;
var isHidden = getCookie('hide-' + element.id);
if(isHidden) {
element.style.display = "none";
} else {
var button = document.createElement( "a" );
button.setAttribute( "id", "hide-" + element.id);
button.setAttribute( "class", "hideButton" );
button.setAttribute( "href", "#" );
button.setAttribute( "title", "Üzenet elrejtése egy hétre" );
button.onclick = hideElement;
button.appendChild( document.createTextNode("[elrejt]") );
element.appendChild( button );
}
}
/*
== WIWOSM térkép ==
*/
// Forrás: http://meta.wikimedia.org/w/index.php?title=MediaWiki:OSM.js
// frissítve: 2013. 06. 11.
// részletek: http://wiki.openstreetmap.org/wiki/WIWOSM
// Using OpenStreetMap in Wikipedia.
// (c) 2008 by Magnus Manske
// heavily altered by [[m:User:Danmichaelo]], [[m:User:Hoo man]]
// Released under GPL
window.osm_proj_lang = 'hu'; // project language
mw.loader.using('mediawiki.util', function() {
function openStreetMapToggle() {
var a = $( '#coordinates a' ),
link = '',
url = '',
params;
if (a.length === 0) {
return;
}
if ($('#openstreetmap').length > 0) {
$('#openstreetmap').toggle();
return false;
}
$.each(a, function(index, value) {
if ( value.href.indexOf('geohack') === -1 ) {
return true; // Returning non-false is the same as a continue
}
link = value.href;
return false; // break
});
if (link) {
params = link.match(/params=([^?&]*)/) || link.match(/geohack\/[a-z]{2,5}\/([^?&]*)/)
params = params && params[1]
}
if (!params) {
return false; // No geohack link found
}
url = '//toolserver.org/~kolossos/openlayers/kml-on-ol.php?'
+ 'lang=' + osm_proj_lang
+ '&uselang=' + mw.config.get('wgUserLanguage')
+ '¶ms=' + params
+ '&title=' + mw.util.wikiUrlencode( mw.config.get( 'wgTitle' ) );
if ( window.location.protocol === 'https:' ) {
url += '&secure=1';
}
$('#contentSub').append(
// src has to be passed using .attr as it could contain malicious html!
$('<iframe id="openstreetmap" style="width:100%; height: 350px; clear:both;"></iframe>').attr('src', url)
);
return false;
}
$(document).ready(function() {
var a = $('#coordinates a'),
geohack = false;
if (a.length === 0) {
return;
}
$.each(a, function(index, value) {
if ( value.href.indexOf('geohack') === -1 ) {
return true;
}
if (value.href.indexOf('_globe:') !== -1) {
return true; // no OSM for moon, mars, etc
}
geohack = true;
return false;
});
if (!geohack) {
return;
}
$('#coordinates').append(
$(' <a id="coordinates_map" href="#" style="box-shadow: 0px 0px 5px #C0C0F0; margin-left:7px">'
+'<img src="'+window.location.protocol+'//upload.wikimedia.org/wikipedia/commons/thumb/c/c9/OpenStreetMapLogo.png/17px-OpenStreetMapLogo.png" width="17" alt="osm" />'
+' térkép ▼ </a>'
).click(openStreetMapToggle)
);
});
});
/*
== Képfeltöltés ==
*/
// Nincslicenc sablon beszúrása, ha a semmilyen sablon opciót választotta
$( function () {
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'Upload' ) return;
// User explicitly turned it off
if ( window.noForceLicense !== undefined ) return;
$( 'form[enctype="multipart/form-data"]' ).click( function () {
if ( $( '#wpLicense' ).val() === '' && !/\{\{[^{}]+\}\}/.test( $( '#wpUploadDescription' ).val() ) ) {
$( '#wpUploadDescription' ).val( $( '#wpUploadDescription' ).val() + "\n==Licenc==\n{{nincslicenc}}" );
}
} );
} );
// ne írja át a célfájlnevet forrásfájl kiválasztásakor, ha van wgDestFile paraméter
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload' ) {
mw.config.set( 'wgUploadAutoFill', !$( '#wpDestFile' ).val() );
}
/*
== Legördülő menü és extra gombok az edittools-ba ==
*/
if (wgAction == 'edit' || wgAction == 'submit' || wgPageName == 'Special:Upload') { //scripts specific to editing pages
mw.loader.using( 'mediawiki.action.edit', function() {
var buttons, i, len;
buttons = [
{
'id': "button-redirect",
'imageFile': "//upload.wikimedia.org/wikipedia/en/c/c8/Button_redirect.png",
'speedTip': "Átirányítás",
'tagOpen': "#ÁTIRÁNYÍTÁS [[",
'tagClose': "]]",
'sampleText': "Cél"
},
{
'id': "button-strike",
'imageFile': "//upload.wikimedia.org/wikipedia/en/c/c9/Button_strike.png",
'speedTip': "Áthúzott szöveg",
'tagOpen': "<s>",
'tagClose': "</s>",
'sampleText': "Áthúzott szöveg"
},
{
'id': "button-small",
'imageFile': "//upload.wikimedia.org/wikipedia/en/5/58/Button_small.png",
'speedTip': "Apró betűs szöveg",
'tagOpen': "<small>",
'tagClose': "</small>",
'sampleText': "Apró betűs szöveg"
},
{
'id': "button-teletype",
'imageFile': "//upload.wikimedia.org/wikipedia/commons/3/30/Tt_icon.png",
'speedTip': "Írógép-szöveg",
'tagOpen': "<tt>",
'tagClose': "</tt>",
'sampleText': "Fix szélességű szöveg"
},
{
'id': "button-insert-reflink",
'imageFile': "//upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png",
'speedTip': "Forráshivatkozás",
'tagOpen': "<ref>",
'tagClose': "</ref>",
'sampleText': "Hivatkozás szövegének helye"
},
{
'id': "button-insert-reflist",
'imageFile': "//upload.wikimedia.org/wikipedia/commons/f/fe/Button_refs.png",
'speedTip': "Forráshivatkozás lábrész",
'tagOpen': "{" + "{Jegyzetek}}",
'tagClose': "",
'sampleText': ""
},
{
'id': "button-insert-templatelink",
'imageFile': "//upload.wikimedia.org/wikipedia/commons/e/eb/Button_plantilla.png",
'speedTip': "Sablon",
'tagOpen': "{{",
'tagClose': "}}",
'sampleText': "Példa sablon"
}
];
for ( i = 0, len = buttons.length; i < len; i++ ) {
mw.toolbar.addButton(
buttons[i].imageFile,
buttons[i].speedTip,
buttons[i].tagOpen,
buttons[i].tagClose,
buttons[i].sampleText,
buttons[i].id,
buttons[i].id
);
}
});
}
if (document.URL.indexOf("action=edit") > 0 || document.URL.indexOf("action=submit") > 0 || (wgCanonicalNamespace == "Special" && wgCanonicalSpecialPageName == "Upload")) {
function addCharSubsetMenu() {
var forceAll = false;
var specialchars = document.getElementById('specialchars');
if (!specialchars) return;
var menu = document.getElementById('charSubsetMenu');
if (!menu) {
menu = document.createElement('select');
menu.id = 'charSubsetMenu';
menu.style.display = 'inline';
menu.onchange = function() {
chooseCharSubset(menu.options[menu.selectedIndex].value);
}
} else { // személyreszabott menü teljesre váltásakor
forceAll = true;
var menuChildNodes = [];
for (var i = 0; i < menu.childNodes.length; i++) {
menuChildNodes.push(menu.childNodes[i]);
}
for(var i = 0; i < menuChildNodes.length; i++) {
menu.removeChild(menuChildNodes[i]);
}
}
var specialCharacterTypes = new Object();
var l = document.getElementById('specialchars').getElementsByTagName('p');
for (var i = 0; i < l.length; i++) {
var title = l[i].title;
var opt = document.createElement('option');
opt.appendChild(document.createTextNode(title));
opt.value = i;
specialCharacterTypes[title] = opt;
}
if(typeof(allowedSpecialCharacterTypes) == 'undefined' || forceAll) {
for (var i = 0; i < l.length; i++) {
menu.appendChild(specialCharacterTypes[l[i].title]);
}
} else { // személyreszabott menü
for(var i = 0; i < allowedSpecialCharacterTypes.length; i++) {
if(typeof(specialCharacterTypes[allowedSpecialCharacterTypes[i]]) != 'undefined') {
menu.appendChild(specialCharacterTypes[allowedSpecialCharacterTypes[i]]);
}
}
var showAll = document.createElement('option');
showAll.appendChild(document.createTextNode("több..."));
showAll.style.fontStyle = 'italic';
showAll.value = 999;
menu.appendChild(showAll);
}
if (forceAll) { // select visszaállítása az aktív karakterkészletre
var value = -1;
var l = specialchars.getElementsByTagName('p');
for (var i = 0; i < l.length ; i++) {
if (l[i].style.display == 'inline') {
value = i;
break;
}
}
for (var i = 0; i < menu.options.length; i++) {
if (menu.options[i].value == value) {
menu.selectedIndex = i;
break;
}
}
} else { // első karakterkészlet aktiválása
chooseCharSubset(menu.options[0].value);
}
specialchars.insertBefore(menu, specialchars.firstChild);
}
function chooseCharSubset(s) {
if (s == 999) { // "több..." opció
addCharSubsetMenu();
return;
}
var l = document.getElementById('specialchars').getElementsByTagName('p');
for (var i = 0; i < l.length ; i++) {
l[i].style.display = (i == s) ? 'inline' : 'none';
}
}
$(addCharSubsetMenu);
}
/*
== Extra gombok Vector alatt ==
*/
// UsabilityInitiative toolbar customization
$(function() {
if ( typeof $.wikiEditor != "undefined" ) {
$( '#wpTextbox1' ).bind( 'wikiEditor-toolbar-buildSection-main', function( event, section ) {
if (wgUserLanguage=='hu') {
// change bold/italic icon
var tools = section.groups.format.tools;
if ( !( 'hu' in tools.bold.icon ) ) {
tools.bold.icon['hu'] = 'format-bold-F.png'; // no need for full URL because this one exists in default Vector icon set
}
if ( !( 'hu' in tools.italic.icon ) ) {
tools.italic.icon['hu'] = '//upload.wikimedia.org/wikipedia/commons/6/6a/Toolbaricon_italic_D.png';
}
}
// change signature to en dash
section.groups.insert.tools.signature.action.options.pre = '–\u00a0~~' + '~~';
});
$( '#wpTextbox1' ).bind( 'wikiEditor-toolbar-buildSection-advanced', function( event, section ) {
// localized redirect text
section.groups.insert.tools.redirect.action.options.pre = '#ÁTIRÁNYÍTÁS [[';
});
// special characters
$( '#wpTextbox1' ).bind( 'wikiEditor-toolbar-buildSection-characters', function( event, section ) {
var paren = function(left, right) {
return { label: left + right, action: { type: 'encapsulate', options: { pre: left, post: right } } };
};
var pages = {
basic: {
layout: 'characters',
label: 'Alap',
characters: [ 'á', 'é', 'í', 'ó', 'ö', 'ő', 'ú', 'ü', 'ű', 'Á', 'É', 'Í', 'Ó', 'Ö', 'Ő', 'Ú', 'Ü', 'Ű',
'~', '|', '#', paren('„', '”'), paren('»', '«'), paren('’', '’'), '’', '–', '…', paren('<', '>'), '°', '‰',
'×', '→', '∅', 'µ', '²', '³', '½', '⅓', '⅔', '¼', '¾', '€', '§', '†', '‡', '©', '®', '•', '·', ' ', '‑' ]
}
};
for (i in section.pages) {
pages[i] = section.pages[i];
}
section.pages = pages;
});
}
});
/*
== Ékezetes karakterek bejelentkezéshez ==
*/
function insertText(box, string) {
box.focus();
if (document.selection && document.selection.createRange) { // IE/Opera
var range = document.selection.createRange();
range.text = string;
} else if (box.selectionStart || box.selectionStart == '0') { // Mozilla
var startPos = box.selectionStart;
var endPos = box.selectionEnd;
box.value = box.value.substring(0, startPos) + string + box.value.substring(endPos, box.value.length);
}
}
if (window['wgCanonicalSpecialPageName'] && wgCanonicalSpecialPageName == "Userlogin") {
function installLoginChars() {
window['loginbox'] = document.getElementById('wpName1');
var loginchars = document.getElementById('loginchars');
if (loginchars) {
var hunchars = "áéíóöőúüűÁÉÍÓÖŐÚÜŰ".split('');
for (var i = 0, str = ''; i < hunchars.length; i++) {
str += '<a href="javascript:insertText(loginbox, \'' + hunchars[i] + '\')">' + hunchars[i] + '</a> ';
}
loginchars.innerHTML += str;
loginchars.style.display = "block";
}
}
$(installLoginChars);
}
/*
== Becsukható <div> ==
*/
// ============================================================
// BEGIN Dynamic Navigation Bars (experimantal)
// set up the words in your language
var NavigationBarHide = '▲ becsuk';
var NavigationBarShow = '▼ kinyit';
// 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';
}
}
NavToggle.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';
}
}
NavToggle.firstChild.data = NavigationBarHide;
}
}
// adds show/hide-button to navigation bars
function createNavigationBarToggleButton()
{
var indexNavigationBar = 0;
// iterate over all < div >-elements
for(
var i=0;
NavFrame = document.getElementsByTagName("div")[i];
i++
) {
// if found a navigation bar
if (NavFrame.className == "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);
// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
var NavLength = NavFrame.childNodes.length; //Menet közben valamiért bekerül a végére egy undefined gyerek
for(
var j=0;
j < NavLength;
j++
) {
if (NavFrame.childNodes[j].className == "NavHead") {
NavFrame.childNodes[j].appendChild(NavToggle);
}
}
NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
}
}
// if more Navigation Bars found than Default: hide all
if (NavigationBarShowDefault < indexNavigationBar) {
for(
var i=1;
i<=indexNavigationBar;
i++
) {
toggleNavigationBar(i);
}
}
}
if (!fCreateNavigationBarToggleButton) addLoadEvent(createNavigationBarToggleButton);
var fCreateNavigationBarToggleButton = 1;
// END Dynamic Navigation Bars
// ============================================================
/*
== Becsukható táblázat ==
* Az angol változattól annyiban tér el, hogy 'sticky' class esetén
* megjegyzi a tábla állapotát (lap-szinten, nem tábla-szinten).
* A lapneveket egy sütibe gyűjti -> csak kevés oldalon használd!
* TODO: collapseTable/createCollapseButtons átírása, hogy változót
* használjanak az id-s gányolás helyett, és a megjegyzés lehessen id-alapú
*/
/** Collapsible tables *********************************************************
*
* Description: Allows tables to be collapsed, showing only the header. See
* Wikipedia:NavFrame.
* Maintainers: User:R. Koot
*/
var autoCollapse = 2;
var collapseCaption = "▲ becsuk";
var expandCaption = "▼ kinyit";
// browser detection magic; Gecko < 1.8 does not know visibility:collapse
var gecko_rvi = navigator.userAgent.toLowerCase().indexOf('rv:');
var gecko_rv = (gecko_rvi == -1) ? 0 : parseFloat(navigator.userAgent.toLowerCase().substring(gecko_rvi+3, gecko_rvi+6));
function collapseTable( tableIndex, sticky )
{
var Button = document.getElementById( "collapseButton" + tableIndex );
var Table = document.getElementById( "collapsibleTable" + tableIndex );
if ( !Table || !Button ) {
return false;
}
if (sticky) {
var closedTables = getCookie('closedTables');
if (closedTables == null) closedTables = '';
var pageRE = new RegExp('\\b' + escapeRegexp(wgPageName) + '\\b');
var expires = new Date();
expires.setTime( expires.getTime() + (4*7*24*60*60*1000) ); // 4 hét
}
var Rows = Table.getElementsByTagName( "tr" );
if ( Button.firstChild.data == collapseCaption ) {
if($.client.profile().layout == "gecko" && gecko_rv >= 1.8) {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.visibility = 'collapse';
Rows[i].className += ' row-collapsed';
}
} else {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = 'none';
}
}
Button.firstChild.data = expandCaption;
if (sticky && !closedTables.match(pageRE)) {
setCookie('closedTables', closedTables + ' ' + wgPageName, expires);
}
} else {
if($.client.profile().layout == "gecko" && gecko_rv >= 1.8) {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.visibility = 'visible';
Rows[i].className.replace(/\s*\brow-collapsed\b/g, '');
}
} else {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = Rows[0].style.display;
}
}
$(Table).find('a[id^="collapseButton"]').text(collapseCaption);
Button.firstChild.data = collapseCaption;
if (sticky && closedTables.match(pageRE)) {
closedTables = closedTables.replace(pageRE, '').replace(/ /, ' ').replace(/(^ | $)/, '');
setCookie('closedTables', closedTables, expires);
}
}
}
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" ) ) {
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.setAttribute( "id", "collapseButton" + tableIndex );
if ( hasClass( Tables[i], "sticky" ) ) {
ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ", true);" );
} else {
ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ", false);" );
}
ButtonLink.appendChild( ButtonText );
Button.appendChild( ButtonLink );
var Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0];
/* only add button and increment count if there is a header row to work with */
if (Header) {
Header.insertBefore( Button, Header.childNodes[0] );
tableIndex++;
}
}
}
var closedTables = getCookie('closedTables');
var pageRE = new RegExp('\\b' + escapeRegexp(wgPageName) + '\\b');
var isClosed = (closedTables && closedTables.match(pageRE));
for ( var i = 0; i < tableIndex; i++ ) {
if ( hasClass( NavigationBoxes[i], "sticky" ) ) {
if (isClosed) collapseTable( i );
}
else if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
collapseTable( i );
}
}
}
if (!fCreateCollapseButtons) $( createCollapseButtons );
var fCreateCollapseButtons = 1;
/*
== Címek javítása ==
*/
// 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. But C# is not an equivalent
// wikilink, so C Sharp doesn't have its main title changed)
// Likewise for users who have selected the U.K. date format ("1 March") the
// titles of day-of-the-year articles will appear in that style. Users with any
// other date setting are not affected.
//
// The function looks for a banner like this:
// <div id="RealTitleBanner"> ... <span id="RealTitle">title</span> ... </div>
// An element with id=DisableRealTitle disables the function.
//
var disableRealTitle = 0; // users can set disableRealTitle = 1 locally to disable.
if (wgIsArticle) { // don't display the RealTitle when editing, since it is apparently inconsistent (doesn't show when editing sections, doesn't show when not previewing)
function fixArticleTitle() {
var realTitleBanner = document.getElementById("RealTitleBanner");
var realTitle = document.getElementById("RealTitle");
if (realTitleBanner && realTitle && !document.getElementById("DisableRealTitle") && !disableRealTitle) {
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) {
var localNamespace = wgPageName.split(':')[0];
if (wgCanonicalNamespace == verifyTitle.substr(0, wgCanonicalNamespace.length).replace(/ /g, "_") && verifyTitle.charAt(wgCanonicalNamespace.length) == ":") {
verifyTitle = verifyTitle.substr(wgCanonicalNamespace.length + 1);
} else if (localNamespace == verifyTitle.substr(0, localNamespace.length).replace(/ /g, "_") && verifyTitle.charAt(localNamespace.length) == ":") {
verifyTitle = verifyTitle.substr(localNamespace.length + 1);
} else {
realTitleText = localNamespace.replace(/_/g, " ") + ":" + realTitleText;
realTitleHTML = localNamespace.replace(/_/g, " ") + ":" + realTitleHTML;
}
}
// verify whether wgTitle matches
verifyTitle = verifyTitle.replace(/[\s_]+/g, " "); // underscores and multiple spaces to single spaces
verifyTitle = verifyTitle.replace(/^\s+/, "").replace(/\s+$/, ""); // trim left and right spaces
verifyTitle = verifyTitle.charAt(0).toUpperCase() + verifyTitle.substring(1, verifyTitle.length); // uppercase first character
if (verifyTitle == wgTitle) isPasteable = 1;
var h1 = document.getElementsByTagName("h1")[0];
if (h1 && isPasteable) {
h1.innerHTML = containsTooMuchHTML ? realTitleText : realTitleHTML;
if (!containsTooMuchHTML)
realTitleBanner.style.display = "none";
}
document.title = realTitleText + " - Wikipédia, a szabad enciklopédia";
}
}
// 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;
}
$(fixArticleTitle);
}
/*
== IRC login ==
*/
// this script looks for the element with id "irclogon", and replaces its contents
// with a login form that redirects to the Mibbit IRC gateway
( function () {
if ( mw.config.get( 'wgAction' ) in { edit: 1, submit: 1 } ) {
return;
}
function loadLoginForm() {
$( '#irclogin' ).empty().append(
$( '<form>' ).attr( {
method: 'get',
action: '//webchat.freenode.net/',
target: '_blank',
name: 'loginform'
} ).append(
$( '<input type="text"> ').attr( {
name: 'Nickname',
size: 25
} ).val( nickify( wgUserName ) ).focus( function () {
clear_text(this);
} ),
$( '<input type="submit"> ').val( 'Belépés' ),
$( '<input type="hidden"> ').attr( 'name', 'channels' ).val( '#wikipedia-hu' ),
$( '<input type="hidden"> ').attr( 'name', 'prompt' ).val( '0' )
)
);
}
function nickify( s ) {
if ( s == null ) {
return 'anon' + Math.floor( Math.random() * 100 );
}
s = s.toLowerCase();
s = s.replace(" ", "_");
s = s.replace(/á/g, 'a');
s = s.replace(/é/g, 'e');
s = s.replace(/í/g, 'i');
s = s.replace(/[óő]/g, 'o');
s = s.replace(/[úű]/g, 'u');
s = s.replace(/[^a-z0-9_-]/g, '');
return s || 'badname' + Math.floor( Math.random() * 100 );
}
var irclogin_cleared = 0;
function clear_text( field ) {
if ( irclogin_cleared === 0 ) {
irclogin_cleared = 1;
field.value = '';
}
}
$( loadLoginForm );
} ) ();
/*
== Információs sablon beillesztése a szövegdobozba feltöltéskor, amennyiben az üres ==
*/
function insertInfoTemplate() {
var editbox = document.getElementById('wpUploadDescription');
if (!editbox) return;
if (editbox.value != '') return;
if (location.href.match(/wpForReUpload=1/)) return; // új változat feltöltésekor a szövegmező szerkesztési összefoglalóként funkcionál
editbox.rows = 9; // make it large enough to fit the template
editbox.value = "{{Információ\n"
+ "| leírás = \n"
+ "| forrás = \n"
+ "| dátum = \n"
+ "| helyszín = \n"
+ "| szerző = \n"
+ "| engedély = \n"
+ "| más változatok = \n"
+ "}}";
}
$(insertInfoTemplate);
/*
== Változtatható rendezésű táblázatok: ékezetes betűk, magyar írásmódú számok rendezése ==
*/
// buta, de legalább működik
// rendező kód: http://git.wikimedia.org/blob/mediawiki%2Fcore/master/resources%2Fjquery%2Fjquery.tablesorter.js
// okos, de nem működő kód: https://hu.wikipedia.org/w/index.php?title=MediaWiki:Common.js&diff=prev&oldid=14463042
(function() {
var accented = 'áéíóúöőüűÁÉÍÓÚÖŐÜŰ',
i, basic = 'aeiouoouuAEIOUOOUU',
tableSorterCollation = {};
for (i = 0; i < accented.length; i++) {
tableSorterCollation[accented[i]] = basic[i];
}
mw.config.set( 'tableSorterCollation', tableSorterCollation);
}());
/*
== A Képdia sablon működéséhez szükséges kód ==
*/
function kepValtas(group, remindex, shwindex) {
document.getElementById("kepDiaCs"+group+"Kep"+remindex).style.display="none";
document.getElementById("kepDiaCs"+group+"Kep"+shwindex).style.display="inline";
}
function kepDia(){
if (document.URL.match(/printable/g)) return;
var bc=document.getElementById("bodyContent");
if( !bc ) bc = document.getElementById("mw_contentholder");
if( !bc ) return;
var divs=bc.getElementsByTagName("td");
var i = 0, j = 0;
var units, search;
var currentimage;
var UnitNode;
for (i = 0; i < divs.length ; i++) {
if (divs[i].className != "kepDia") continue;
UnitNode=undefined;
search=divs[i].getElementsByTagName("div");
for (j = 0; j < search.length ; j++) {
if (search[j].className != "kepDiaKepek") continue;
UnitNode=search[j];
break;
}
if (UnitNode==undefined) continue;
units=Array();
for (j = 0 ; j < UnitNode.childNodes.length ; j++ ) {
var temp = UnitNode.childNodes[j];
if (temp.className=="center") units.push(temp);
}
for (j = 0 ; j < units.length ; j++) {
currentimage=units[j];
currentimage.id="kepDiaCs"+i+"Kep"+j;
var imghead = document.createElement("div");
var leftlink;
var rightlink;
if (j != 0) {
leftlink = document.createElement("a");
leftlink.href = "javascript:kepValtas("+i+","+j+","+(j-1)+");";
leftlink.innerHTML="◀";
} else {
leftlink = document.createElement("span");
leftlink.innerHTML=" ";
}
if (j != units.length - 1) {
rightlink = document.createElement("a");
rightlink.href = "javascript:kepValtas("+i+","+j+","+(j+1)+");";
rightlink.innerHTML="▶";
} else {
rightlink = document.createElement("span");
rightlink.innerHTML=" ";
}
var comment = document.createElement("tt");
comment.innerHTML = "("+ (j+1) + "/" + units.length + ")";
with(imghead) {
style.fontSize="110%";
style.fontweight="bold";
appendChild(leftlink);
appendChild(comment);
appendChild(rightlink);
}
currentimage.insertBefore(imghead,currentimage.childNodes[0]);
if (j != 0) currentimage.style.display="none";
}
}
}
$(kepDia);
/*
== Knávom, azaz a kínai nevek átírását váltogató mechanika ==
*
* [[Sablon:Kínai]] stb.
* Eredeti kód: [[User:Chery/kínai.js]]
*/
kinai_primary = 'magyaros';
function kinai_switch() {
$('.kinai-szoveg').each(function kinai_switch_foreach() {
var pinyin = '';
var magyaros = '';
var hanzi = '';
var egyeb = '';
var cimszo = 0;
var hidden = 0;
$('span', this).each(function kinai_switch_inner_foreach() {
switch ($(this).attr('class')) {
case 'pinyin':
pinyin = '<span class="pinyin">' + $(this).html() + '</span>';
break;
case 'magyaros':
magyaros = '<span class="magyaros">' + $(this).html() + '</span>';
break;
case 'hanzi':
hanzi = '<span class="hanzi">' + $(this).html() + '</span>';
break;
case 'egyeb':
egyeb = '<span class="egyeb">' + $(this).html() + '</span>';
break;
case 'cimszo':
cimszo = 1;
break;
case 'hidden':
hidden = 1;
break;
}
})
var str0 = (kinai_primary == 'pinyin') ? magyaros : pinyin;
var str1 = (kinai_primary == 'pinyin') ? pinyin : magyaros;
if (cimszo) {
str0 = '<span class="cimszo"><b>' + str0 + '</b></span>';
}
if (!hidden) {
str0 += ' ';
str0 += (hanzi) ? '(' + hanzi + ', <i>' : '<i>(';
str0 += str1;
str0 += (egyeb) ? ',</i> ' + egyeb + ')' : ')</i>';
} else {
if (hanzi) {
str0 += ' (' + hanzi + ')';
}
str0 += '<span class="hidden">' + str1 + '</span>';
}
$(this).html(str0);
});
if (kinai_primary == 'pinyin') {
kinai_primary = 'magyaros';
localStorage.setItem('kinai-primary', 'magyaros');
} else {
kinai_primary = 'pinyin';
localStorage.setItem('kinai-primary', 'pinyin');
}
}
// Betöltődéskor indítjuk
$(function magyarosKinaiInit() {
// Csak akkor rakjuk ki a fület, ha van a cikkben megjelölt kínai név.
if ( $('.kinai-szoveg').length === 0 ){
return;
}
// Odacsapjuk a fület.
var portletLink = mw.util.addPortletLink('p-cactions', '#', 'p./m.', 'ca-kinai-switch', 'Váltás pinyin és magyaros átírás közt');
$( portletLink ).click( function ( e ) {
e.preventDefault();
kinai_switch();
});
//Meg a kapcsolót a szócikk fölötti szöveghez is.
$("<a href='#'></a>")
.click( function ( e ) {
e.preventDefault();
kinai_switch();
})
.html($('#kinai_switch').clone())
.insertBefore($('#kinai_switch').hide());
// Váltunk is rögtön, hogy kezdetben is a szkript szerint jelenjen meg. Persze ezt szebben is lehetne.
kinai_primary = (localStorage.getItem('kinai-primary') == 'pinyin') ? 'magyaros' : 'pinyin';
kinai_switch();
});
/*
== Kéthasábos forráslista kikapcsolása, ha <4 forrás van ==
*/
if ($.client.profile().layout == "gecko" || $.client.profile().layout == "webkit" || $.client.profile().layout == "presto") {
$(function dynamicMultiColumn() {
$('ol.references').each(function() {
if ($(this).find('li').length < 4) {
$(this).add($(this).parent().parent()).each(function() {
this.style.columnCount = 1;
this.style.MozColumnCount = 1;
this.style.WebkitColumnCount = 1;
});
}
});
});
}
/*
== Keresési kifejezések naplózása névtelenül a Squidek által ==
*/
// Change search forms so they send to an URL which has the search term in the
// path (not just in the query part). This in necessary for getting search
// statistics from the squid logs.
// Based on [[wikt:de:MediaWiki:If-search.js]].
function SubSearch(formId, inputId) {
var form = $('#' + formId);
var input = $('#' + inputId);
if (input.val() == '') {
delimiter = '';
} else {
delimiter = '/';
}
form.attr('action', wgArticlePath.replace('$1', oSEAp + delimiter + encodeURIComponent(input.val())));
// Try to remove <input name="title"> from the <form>
form.find('input[name="title"]:first').remove();
}
function fixSearchForm(formId, inputId) {
$('#' + formId).submit(function() {
SubSearch(formId, inputId);
});
}
$(document).ready(function() {
fixSearchForm('searchform', 'searchInput');
fixSearchForm('search', 'searchText');
fixSearchForm('powersearch', 'powerSearchText');
fixSearchForm('bodySearch', 'bodySearchIput');
if ($('#searchform').attr('action').indexOf(wgScript) > -1) {
oSEAp = $('#searchform').find('input').val();
} else {
oSEAp = $('#searchform').attr('action').replace(/^.*\/([^\/]+)$/, '$1');
}
});
/**********************************************************
* Szerkesztői lapokhoz kapcsolódó függvények *
**********************************************************/
/*
* Visszaadja, hogy a jelenlegi lap névtere a tiltott névterek közé tartozik-e
*/
function isDeniedNamespace() {
// nem akarjuk, hogy ahol nem kell, ott címet lehessen cserélni vagy ikont lehessen pakolni
if (wgNamespaceNumber == 0 || wgNamespaceNumber == 1 || // fő névtér és vitája
wgNamespaceNumber == 6 || wgNamespaceNumber == 7 || // kép és vitája
wgNamespaceNumber == 10 || wgNamespaceNumber == 11 || // sablon és vitája
wgNamespaceNumber == 14 || wgNamespaceNumber == 15 || // kategória és vitája
wgNamespaceNumber == 101 // portálvita
)
{
return true;
} else {
return false;
}
}
/*
* Ikonok elrendezése a cím mellé, ablakátméretezés esetén újrapozícionálás
* az engedélyezett névterekbe tartozó lapokon (lásd az isDeniedNamespace függvényt)
*/
$(document).ready(function() {
if (isDeniedNamespace())
return;
var sarokIcons = [];
/* ikonok repozícionálása */
function reposIcons() {
if (sarokIcons.length == 0) return;
var offset = $('#firstHeading').offset();
var top = offset.top;
var maxheight = $('#firstHeading').height();
var right = offset.left + $('#firstHeading').width();
for (var i = sarokIcons.length -1; i > -1; i--) {
var thisTop = (sarokIcons[i].height > maxheight ?
top - (sarokIcons[i].height - maxheight) / 2 :
top + maxheight/2 - sarokIcons[i].height / 2);
$('#sarokikon' + i)
.css('top', (thisTop < 0 ? 0 : thisTop))
.css('left', right - sarokIcons[i].width);
right = right - sarokIcons[i].width - 5;
}
};
var sarokIconSpans = $('.sarokikon');
if (sarokIconSpans.length == 0) return;
sarokIconSpans.each(function() {
// ugye a div fogja magát és kitolja 100%-ra a width-ét, így nem tudjuk mérni
// a spannál meg a szöveg height-ű lesz egy képet tartalmazó span-is, még ha nagyobb is
// ezért először inline lemérjük a div width-ét
// majd elvesszük az inline css-osztályt, és lemérjük a height-et
var xwidth = $(this).width();
$(this).removeClass('sarokikon');
var xheight = $(this).height();
sarokIcons.push({
html: $(this).html(),
height: xheight,
width: xwidth
});
$(this).remove();
});
if (sarokIcons.length > 0) {
var offset = $('#firstHeading').offset();
var right = offset.left + $('#firstHeading').width();
for (var i = sarokIcons.length -1; i > -1; i--) {
var iconDiv = $('<div></div>')
.addClass('sarokikon_fenn')
.attr('id', 'sarokikon' + i)
.html(sarokIcons[i].html)
.css({
position: 'absolute',
width: sarokIcons[i].width,
height: sarokIcons[i].height,
zIndex: 99
});
switch (skin) {
case "monobook":
iconDiv.appendTo('#globalWrapper');
break;
case "vector":
iconDiv.css('font-size', '0.8em');
iconDiv.appendTo('body');
break;
default:
iconDiv.appendTo('body');
break;
}
right = right - sarokIcons[i].width - 5;
}
reposIcons();
var resizeTimer = null;
$(window).bind('resize', function() {
if (resizeTimer) clearTimeout(resizeTimer);
resizeTimer = setTimeout(reposIcons, 100);
});
}
});
/*
* Cím és alcím cseréje az engedélyezett névterekbe
* tartozó lapokon (lásd az isDeniedNamespace függvényt)
*/
$(document).ready(function() {
if (wgAction != "view" || isDeniedNamespace())
return;
if ($('#sajatcim').length > 0) {
if ($('#sajatcim').hasClass('nincsszerk') == false &&
$('#firstHeading > .mw-editsection').length > 0) {
var movededit =
$('<div>').append(
$("#firstHeading > .mw-editsection")
.eq(0).clone()
).html();
$('#firstHeading').html($('#sajatcim').html() + ' ' + movededit);
} else {
$('#firstHeading').html($('#sajatcim').html());
}
/* a $('title') nem megy IE8 (meg gondolom a korábbiak) alatt */
document.title = $('#sajatcim').html().replace(/<\/?[^>]+>/gi, '') + ' - Wikipédia';
$('#sajatcim').remove();
}
// alcímet csak a júzernévtérben cserélgessünk
if (!(wgNamespaceNumber == 2 || wgNamespaceNumber == 3)) return;
if ($('#sajatalcim').length > 0 && $('#siteSub').length > 0) {
$('#siteSub').html($('#sajatalcim').html());
$('#sajatalcim').remove();
}
});
/*
* Virtuális kategóriák összegyűjtése és megjelenítése az igazi kategóriák mögött a szerkesztői lapokon
* TODO: kategória hozzáadása, ha nincs kat.
*/
$(document).ready(function() {
if (wgAction == "view" && wgNamespaceNumber == 2 && $('#mw-normal-catlinks').length > 0 && $('.kategoria').length > 0) {
var catlinksA = $('<div>').append(
$('#mw-normal-catlinks > a')
.eq(0).clone()
).html();
var oldCats = [];
$('#mw-normal-catlinks > span').each(function() {
oldCats.push(
$('<div>').append(
$(this)
.eq(0).clone()
).html()
);
});
var catOutput = catlinksA + ': ';
for (var i = 0;i<oldCats.length;i++) {
catOutput = catOutput + oldCats[i];
if (i < oldCats.length -1)
catOutput = catOutput + ' | ';
}
$('.kategoria').each(function() {
catOutput = catOutput + ' | ' +
$('<div>').append(
$('<a>').attr('href', '#globalWrapper').html($(this).html())
).html();
$(this).remove();
});
$('#mw-normal-catlinks').html(catOutput);
}
});
var disableUserFonts = false;
var disableUserBackgrounds = false;
/*
* Betűtípus lecserélése szerkesztői lapokon
*/
$(document).ready(function() {
if (wgAction == "view" && !disableUserFonts && (wgNamespaceNumber == 2 || wgNamespaceNumber == 3) && $('#betutipus').length > 0) {
var userFont = $('#betutipus').html();
$('#firstHeading').css('font-family', userFont);
$('#bodyContent').css('font-family', userFont);
$('#betutipus').remove();
}
});
/*
* Háttérszín lecserélése szerkesztői lapokon
*/
$(document).ready(function() {
if (wgAction == "view" && !disableUserBackgrounds && (wgNamespaceNumber == 2 || wgNamespaceNumber == 3) && $('#hatterszin').length > 0) {
$('#content').css('background-color', $('#hatterszin').html());
$('#hatterszin').remove();
}
});
/*
== Erőforrástakarékos üzenet a TranslateWikin való MediaWiki-felület-fordításra ==
*/
$(document).ready(function() {
if (wgNamespaceNumber == 8) {
$('<div></div>')
.addClass('editwarning')
.addClass('plainlinks')
.addClass('translateWikiMessage')
.html('<b>Ha olyan üzenetet fordítasz, amely nem Wikipédia-specifikus, akkor azt a <a href="//translatewiki.net" class="external text" style="color: #002bb8;" title="translatewiki.net" rel="nofollow">Translatewikiben</a> tedd, hogy így minden magyar nyelvű Wikimedia-projekt számára elérhető legyen!</b> (<a href="//translatewiki.net/wiki/' + wgPageName + '/hu" class="external text" style="color: #002bb8;" title="' + wgPageName + ' magyar változatának megtekintése a Translatewikiben" rel="nofollow">→ezen üzenet megtekintése a Translatewikiben</a>, <a href="//translatewiki.net/wiki/' + wgPageName + '/hu?action=edit" class="external text" style="color: #002bb8;" title="' + wgPageName + ' magyar változatának szerkesztése a Translatewikiben" rel="nofollow" style>szerkesztés</a>)')
.appendTo($('#siteSub'));
}
});
/*
== Kinyitható fejezetek az új infoboxokra specializálva ==
*/
$(document).ready(function() {
var ibSectionLinkClick = function(e) {
$this = $(e.target);
var $$id = $this.attr("id").substring(12);
var $parentInfobox = $this.closest('table.ujinfobox');
var $infobar = $("tr.nyitasinfo-" + $$id, $parentInfobox);
if ($this.hasClass("becsukva")) {
$("tr.csoport-" + $$id, $parentInfobox).each(function() {
$(this).css("display", "");
});
$this.html(NavigationBarHide)
.removeClass("becsukva");
if ($infobar.length > 0) {
$infobar.css("display", "none");
}
} else {
$("tr.csoport-" + $$id, $parentInfobox).each(function() {
$(this).css("display", "none");
});
$this.html(NavigationBarShow)
.addClass("becsukva");
if ($infobar.length > 0) {
$infobar.css("display", "");
}
}
return false;
}
$('.nyitolink', $('#bodyContent')).each(function() {
var $this = $(this);
var $$id = $this.attr("id").substring(10);
var $link =
$('<a>').attr("href", "#")
.attr("id", "nyitolink-a-" + $$id)
.css("color", $this.closest("td").css("color"))
.click(ibSectionLinkClick);
if ($this.hasClass("becsukva")) {
$link.html(NavigationBarShow)
.addClass("becsukva");
var $parentInfobox = $this.closest('table.ujinfobox');
$("tr.csoport-" + $$id, $parentInfobox).each(function() {
$(this).css("display", "none");
});
var $infobar = $("tr.nyitasinfo-" + $$id, $parentInfobox);
if ($infobar.length > 0) {
$infobar.css("display", "");
}
} else {
$link.html(NavigationBarHide);
}
$link.appendTo($this);
});
});
/*
== Pozíciós térkép nagyító ==
*/
function poziciosTerkepInit() {
var boxes = getElementsByClassName(document, "poziciosTerkepDoboz");
for (var i=0; i<boxes.length; ++i){
try{
var inner = getElementsByClassName(boxes[i], "poziciosTerkepBelso")[0];
if (inner.getElementsByTagName("img")[0].src.indexOf("/thumb/") == -1) return false;
if ( inner.getElementsByTagName("img")[1] && inner.getElementsByTagName("img")[1].alt == "Háttér"
&& inner.getElementsByTagName("img")[1].src.indexOf("/thumb/") == -1)
return false;
var innerA = inner.getElementsByTagName("a")[0];
innerA.onclick = function() {poziciosTerkepOpen(this); return false;}
innerA.style.cursor = "move";
}catch(e){}/*ha nincs meg, akkor nincs értelme továbbmenni*/
}
function getElementsByClassName(node, cl){
if (node.getElementsByClassName)
return node.getElementsByClassName(cl);
var nodes = [];
var elem = node.getElementsByTagName('DIV');
for (var i = 0; i < elem.length; i++) {
if (new RegExp('\\b'+cl+'\\b').test(elem[i].className))
nodes.push(elem[i]);
}
return nodes;
}
}
function poziciosTerkepOpen(sender) {
//Kicsi pozíciós térkép megkeresése
var outer = sender.parentNode;
while (outer.className != "poziciosTerkepBelso") {
outer = outer.parentNode;
}
//Pozíciós térkép átmásolása
var newDiv = outer.cloneNode(true);
var newImg = new Array();
newImg[0] = newDiv.getElementsByTagName("img")[0];
newImg[0].title = newImg[0].src.match(/\/.\/..\/(.*\.[a-zA-z]{3,4})\/[^\/]*$/)[1];
if (newDiv.getElementsByTagName("img")[1] && newDiv.getElementsByTagName("img")[1].alt == "Háttér"){
newImg[1] = newDiv.getElementsByTagName("img")[1];
newImg[1].title = newImg[1].src.match(/\/.\/..\/(.*\.[a-zA-z]{3,4})\/[^\/]*$/)[1];
}
//A kép eredeti méreteinek lekérdezése
for(var i=0; i<newImg.length; ++i){
if (newImg[i].title.match(/\.[a-zA-z]{3,4}$/) != ".svg") {
var poziciosTerkepAjax = sajax_init_object();
if ( ! poziciosTerkepAjax ) return false;
var url = wgServer + wgScriptPath + '/api.php' + "?action=query&format=xml&titles=Image:"+newImg[i].title+"&prop=imageinfo&iiprop=size";
poziciosTerkepAjax.onreadystatechange = function () {
if (poziciosTerkepAjax.readyState != 4)
return false;
var res = poziciosTerkepAjax.responseText;
var imgWidth = res.match(/width=\"([0-9]*)\"/)[1];
var imgHeight = res.match(/height=\"([0-9]*)\"/)[1];
if (poziciosTerkepKesz && imgWidth < newWidth) {
for(var j=0; j<newImg.length; ++j){
newImg[j].width = imgWidth;
newImg[j].height= imgHeight;
if (newImg[j].title.match(/\.[a-zA-z]{3,4}$/) != ".svg")
newImg[j].src = newImg[j].src.replace(/thumb/, "").replace(/\/[0-9]*px-.*\.[a-zA-z]{3,4}$/, "");
newDiv.style.width = imgWidth+"px";
}
}
};
poziciosTerkepAjax.open('GET', url, true);
poziciosTerkepAjax.send(null);
}
}
//Méretek meghatározása
var oldWidth = outer.clientWidth;
var oldHeight = outer.clientHeight;
var newWidth = Math.round(document.getElementsByTagName("html")[0].clientWidth * 0.90 );
var newHeight = Math.round(document.getElementsByTagName("html")[0].clientHeight * 0.95 );
if (oldHeight/oldWidth*newWidth > newHeight){
newWidth = Math.round(oldWidth/oldHeight*newHeight);
}else{
newHeight = Math.round(oldHeight/oldWidth*newWidth);
}
for(var i=0; i<newImg.length; ++i){
newImg[i].width=newWidth;
newImg[i].height=newHeight;
newImg[i].src = newImg[i].src.replace(new RegExp(oldWidth+"px\-", "g"), newWidth+"px-");
newImg[i].parentNode.style.cssText = "cursor:hand";
}
newDiv.getElementsByTagName("span")[0].style.cssText =
"padding: 1px; font-size:12pt;"+
"text-shadow: -1px -1px 1px white, -1px 0px 1px white, -1px 1px 1px white, 0px -1px 1px white, "+
"0px 1px 1px white, 1px -1px 1px white, 1px 0px 1px white, 1px 1px 1px white;";
newDiv.id="poziciosTerkepNagyitott";
newDiv.style.cssText =
"width: "+newWidth+"px; position: absolute; background-color:white; z-index:102;"
+"top: "+ Math.round(((window.innerHeight || document.getElementsByTagName("html")[0].clientHeight)
-newHeight)/2
+ ((document.body.scrollTop > 0) ? document.body.scrollTop : document.documentElement.scrollTop))+"px;"
+"left: "+ Math.round(((window.innerWidth || document.getElementsByTagName("html")[0].clientWidth)
-newWidth) /2) +"px;"
+"border:solid 1px black;box-shadow:0px 0px 20px #C0C0C0; border-radius: 3px;"
+"-moz-box-shadow:0px 0px 20px #C0C0C0; -moz-border-radius: 3px;";
var closeButton = document.createElement("div");
closeButton.style.cssText = "position:absolute;text-align:right;width:100%;z-index:103;";
closeButton.innerHTML = "<img style='padding:4px;' onclick='poziciosTerkepClose()' "
+"src='//upload.wikimedia.org/wikipedia/commons/d/d4/Button_hide.png' />";
newDiv.insertBefore(closeButton, newDiv.firstChild);
//Kirakjuk
var bodyContent = document.body;//getElementById("bodyContent");
bodyContent.insertBefore(newDiv, bodyContent.firstChild);
var poziciosTerkepKesz = true;
//Háttér elsötétítése
document.body.style.height = "auto";
var scrollHeight = document.body.scrollHeight || document.body.offsetHeight;
document.body.style.height = "100%";
var opacityDiv = document.createElement("div");
opacityDiv.id="poziciosTerkepOpacity";
opacityDiv.onclick = function() {poziciosTerkepClose();};
opacityDiv.style.cssText =
"position:absolute; top:0; background:black; opacity:0.3; filter:alpha(opacity=70);"+
"width:100%; height:"+(scrollHeight+20)+"px;z-index:101";
document.body.appendChild(opacityDiv);
}
function poziciosTerkepClose() {
document.body.removeChild(document.getElementById("poziciosTerkepNagyitott"));
document.body.removeChild(document.getElementById("poziciosTerkepOpacity"));
}
$(function() {
poziciosTerkepInit();
});
/*
== Flagrev bugfix ==
*/
$(function() {
// $('#mw-fr-revisiontag').css("display", "block");
$('#mw-fr-revisiontoggle').attr('title', null);
});
/*
== Figyelmeztető ikon a kezdőlap vitáján, ha hiányzó allapok vannak ==
*/
if (wgPageName == 'Vita:Kezdőlap') {
$('#header-container').bind('tabsetReady', function(e) {
if ($.trim($('#urgent-tasks').text())) {
$('#ts-headerTabs li a:contains("Tennivalók")').append(
$('<img src="//upload.wikimedia.org/wikipedia/commons/c/c0/Exclamation.png"/>').css('margin-left', '5px')
);
}
});
}
/*
== WikEd ki/be kapcsoló függvények ==
*/
// switch off wikEd frame
function switchOffWikEd() {
if (typeof(wikEd) != 'undefined' && wikEd.useWikEd == true) {
var marker_start = "####wiked_cursor_marker_start####";
var marker_end = "####wiked_cursor_marker_end####";
try{
insertTags(marker_start, marker_end, "");
}catch(err){
}
wikEd.UpdateTextarea();
wikEd.SetEditArea(false);
wikEd.useWikEd = false;
wikEd.SetPersistent('wikEdUseClassic', '1', 0, '/');
wikEd.switchOff = true;
var tb = document.getElementById("wpTextbox1");
var tbSelectionStart = tb.value.indexOf(marker_start);
tb.value = tb.value.replace(marker_start,"");
var tbSelectionEnd = tb.value.indexOf(marker_end);
tb.value = tb.value.replace(marker_end,"");
tb.selectionStart = tbSelectionStart;
tb.selectionEnd = tbSelectionEnd;
}
}
/* switch on wikEd frame */
function switchOnWikEd() {
if (typeof(wikEd) != 'undefined' && typeof(wikEd.switchOff) != 'undefined' && wikEd.switchOff === true) {
wikEd.UpdateFrame();
wikEd.SetEditArea(true);
wikEd.useWikEd = true;
wikEd.SetPersistent('wikEdUseClassic', '0', 0, '/');
wikEd.ExecuteHook(wikEd.config.frameHook);
wikEd.switchOff = false;
}
}