MediaWiki:Monobook.js
A HunyadymWiki wikiből
(Változatok közti eltérés)
(Új oldal, tartalma: „/********************************************************************************************* * Ezek a szkriptek csak Monobook skin alatt futnak le. ...”) |
|||
167. sor: | 167. sor: | ||
addOnloadHook(hideArticleTitle); | addOnloadHook(hideArticleTitle); | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
231. sor: | 182. sor: | ||
} | } | ||
addOnloadHook(alignCoord); | addOnloadHook(alignCoord); | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
/* | /* | ||
411. sor: | 346. sor: | ||
} | } | ||
} | } | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- |
A lap jelenlegi, 2009. április 25., 13:56-kori változata
/********************************************************************************************* * Ezek a szkriptek csak Monobook skin alatt futnak le. * * A nem kifejezetten Monobook-specifikus szkripteket a [[MediaWiki:Common.js]]-be írd! * **********************************************************************************************/ /* == Kiemeltcsillag/lakat igazítása == */ function titleIcons() { var title = document.getElementById('firstHeading'); var protected_icon = document.getElementById('protected-icon'); var featured_icon = document.getElementById('featured-star'); var icon_list = [protected_icon, featured_icon]; for (i=0; i<icon_list.length; i++) { if (!icon_list[i]) continue; title.insertBefore(icon_list[i], title.firstChild); /* ideiglenes kód cache szívások ellen 2009.01, idővel át kell tenni CSS-be*/ icon_list[i].className = 'metadata'; icon_list[i].style.display = 'inline'; icon_list[i].style.position = 'static'; icon_list[i].style.margin = '0 5px 0 0'; /* ideiglenes kód vége */ icon_list[i].className += ' titleIcon'; } } addOnloadHook(titleIcons); /* == Jelzés a kiemelt/jó cikkek interwikije mellé == * 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 = "Ez a cikk kiemelt” státuszt kapott egy más nyelvű Wikipédiában."; } else if ( document.getElementById( InterwikiLinks[i].className + "-ga" ) ) { InterwikiLinks[i].className += " GA"; InterwikiLinks[i].title = "Ez a cikk „jó” státuszt kapott egy más nyelvű Wikipédiában."; } } } } addOnloadHook( LinkFA ); /* == Szerkesztőgombok a cím mögött; extra szerkesztőgomb a főcím mellett == */ // moves section edit links to the right side of the section title // (see also the rules for .editsectionmoved in Monobook.css) // adds section edit link for the lead section next to the main (h1) title // shows the contents of [[MediaWiki:Editintro-section-0]] above the edit box if used // (unless the lead section is the same as the whole article) // var oldEditsectionLinks=true disables the function. if(document.getElementById && document.createElement) { function moveSectionEditLinks() { if(typeof oldEditsectionLinks != 'undefined' && oldEditsectionLinks == true) return; var headings = false; // no need to show info about how to edit the whole page if there are no sections var sectioneditlinks = false; // if there are section edit links, we can safely show the lead section edit link /* move section edit links */ var body = document.getElementById("bodyContent"); // we iterate through headers until we find a section header for(var i=1; i<=6; i++) { var h = body.getElementsByTagName('h'+i); for(var j=0; j<h.length; j++) { var span = h[j].getElementsByTagName('span'); for(var k=0; k<span.length; k++) { if(span[k].className == "mw-headline") headings = true; else if(span[k].className == "editsection") { headings = true; sectioneditlinks = true; if(is_opera) { // Opera doesn't seem to like the class being changed on the fly span[k].style.fontSize = "x-small"; span[k].style.fontWeight = "normal"; span[k].style.cssFloat = span[k].style.styleFloat = "none"; span[k].style.marginLeft = "0.5em"; span[k].style.verticalAlign = "baseline"; span[k].style.lineHeight = "1em"; } span[k].className = "editsectionmoved"; span[k].parentNode.appendChild(document.createTextNode(" ")); span[k].parentNode.appendChild(span[k]); // move behind the heading title } } } } /* add lead section edit link */ var edit = document.getElementById("ca-edit"); if(headings && !sectioneditlinks) return; // if sections are not editable, don't add else if(!headings) { // try to guess whether sections would be editable; don't add if // 1) article is protected or otherwise uneditable // 2) user is viewing page history, edit/move/delete interface, etc. // 3) user is viewing a special page // 4) user is viewing a diff, unless it's a diff to the current revision // 5) user is viewing a permalink to a revision, unless it's the current revision if(!edit || wgAction != "view" || document.location.href.match("/wiki/Speci%C3%A1lis:")) return; var diffMatch = document.location.href.match(/diff=([^&]*)/); var diff = diffMatch ? diffMatch[1] : null; var oldidMatch = document.location.href.match(/oldid=([^&]*)/); var oldid = oldidMatch ? oldidMatch[1] : null; if(oldid && diff) { if(diff != wgCurRevisionId && !(diff == "prev" && oldid == wgCurRevisionId)) return; } else if(oldid) { if(oldid != wgCurRevisionId) return; } // covers most cases, "diff=next&oldid=<last before current>" is impossible to catch } var href = edit.firstChild.href + "§ion=0"; if(headings) href += "&editintro=MediaWiki:Editintro-section-0"; var title = document.getElementsByTagName('h1')[0]; if(!title || title.className != "firstHeading") return; // make sure this is the main title var edit0 = document.createElement('span'); edit0.className = "editsectionmoved"; if(is_opera) { edit0.style.fontSize = "x-small"; edit0.style.fontWeight = "normal"; edit0.style.marginLeft = "0.5em"; edit0.style.verticalAlign = "baseline"; edit0.style.lineHeight = "1em"; } edit0.innerHTML = '[<a title="Bevezető szerkesztése" href="' + href + '">szerkesztés</a>]'; title.appendChild(document.createTextNode(" ")); title.appendChild(edit0); } addOnloadHook(moveSectionEditLinks); } /* == Címek elrejtése == */ function hideArticleTitle() { if (document.getElementById("HideTitle")) { var h1 = document.getElementsByTagName("h1")[0]; if (h1) { h1.style.display = "none"; } var siteSub = document.getElementById("siteSub"); if (siteSub) { siteSub.style.display = "none"; } } } addOnloadHook(hideArticleTitle); /* == Koordináták igazítása == */ function alignCoord() { if(!document.getElementById) return; var bodyContent = document.getElementById('bodyContent'); var coordinates = document.getElementById('coordinates'); if(!coordinates || !bodyContent) return; bodyContent.insertBefore(coordinates, bodyContent.firstChild); coordinates.style.top = 'auto'; } addOnloadHook(alignCoord); /* == Kibővített keresőlap == */ /** 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: "Wikipedia", Template: "/w/index.php?search={searchTerms}" }, google: { ShortName: "Google", Template: "http://www.google.fr/search?hl=" + wgUserLanguage + "&q={searchTerms}&as_sitesearch=" + wgServer.substr(7, wgServer.length - 1 ) }, yahoo: { ShortName: "Yahoo", Template: "http://" + wgUserLanguage + ".search.yahoo.com/search?p={searchTerms}&vs=" + wgServer }, live: { ShortName: "Windows live", Template: "http://search.live.com/results.aspx?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; if (document.forms["search"]) { mainNode = document.forms["search"]; } else { mainNode = document.getElementById("powersearch"); if (!mainNode) return; var mainNode = mainNode.lastChild; if (!mainNode) return; while(mainNode.nodeType == 3) { mainNode = mainNode.previousSibling; } } var firstEngine = "mediawiki"; var choices = document.createElement("div"); choices.setAttribute("id","searchengineChoices"); choices.style.textAlign = "center"; var lsearchbox = document.getElementById("powerSearchText"); 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 = document.createElement("label"); label.htmlFor = "searchengineRadio-"+id; label.appendChild( document.createTextNode( engine.ShortName ) ); choices.appendChild( label ); } } mainNode.appendChild(choices); var input = document.createElement("input"); input.id = "searchengineextraparam"; input.type = "hidden"; mainNode.appendChild(input); 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)); // This part fixes the conflict between external search engines and SubSearch function form.removeAttribute("onsubmit"); if (navigator.appName == 'Microsoft Internet Explorer') form.parentNode.innerHTML = form.parentNode.innerHTML; if (selectedId == 'mediawiki') { if (document.forms["search"]) { form.setAttribute("onsubmit", "SubSearch('search','searchText','/')"); } else { form.setAttribute("onsubmit", "SubSearch('powersearch','powerSearchText','/')"); } } var l = ("" + params).split("&"); for (var i in l) { var p = l[i].split("="); var pValue = p[1]; if (pValue == "{language}") { } else if (pValue == "{searchTerms}") { var input; if (document.forms["search"]) { input = document.getElementById("searchText"); } else { input = document.getElementById("powerSearchText"); } input.name = p[0]; } else { var input = document.getElementById("searchengineextraparam"); input.name = p[0]; input.value = pValue; } } }