Szerkesztő:Peti610/monobook.js
Megjegyzés: közzététel után frissítened kell a böngésződ gyorsítótárát, hogy lásd a változásokat.
- Firefox / Safari: tartsd lenyomva a Shift gombot és kattints a Frissítés gombra a címsorban, vagy használd a Ctrl–F5 vagy Ctrl–R (Macen ⌘–R) billentyűkombinációt
- Google Chrome: használd a Ctrl–Shift–R (Macen ⌘–Shift–R) billentyűkombinációt
- Internet Explorer / Edge: tartsd nyomva a Ctrl-t, és kattints a Frissítés gombra, vagy nyomj Ctrl–F5-öt
- Opera: Nyomj Ctrl–F5-öt
// -*- mode:java; coding:utf-8 -*-
/*
* Spec. szerkesztősor
*/
function createCustomBar() {
var boxDiv = document.createElement('div');
boxDiv.setAttribute('id', 'customBar');
boxDiv.setAttribute('style', 'margin-bottom:2px;border:1px solid #aaaaaa;padding:3px');
boxDiv.innerHTML =
'<b>Eszközök</b>: ' +
"<a href=\"javascript:fixHungarianQuotes()\"><small>magyar idézőjelek</small></a> · " +
"<a href=\"javascript:translateDatesEnHu()\"><small>dátumok magyarítása</small></a> · " +
"<a href=\"javascript:customReplaceForm()\"><small>egyedi regexp</small></a> · ";
return boxDiv;
}
/////////////////////////////////////////////////////
// Regexp. cserélő //
/////////////////////////////////////////////////////
function replaceRegexp(replaceWhat, replaceWith, modifiers)
{
if (modifiers == null) modifiers = "";
var pattern = new RegExp(replaceWhat, modifiers);
var obj_ta = document.editform.wpTextbox1;
obj_ta.value = obj_ta.value.replace(pattern, replaceWith);
}
// Replaces English style "" quotes with Hungarian „”
function fixHungarianQuotes() {
replaceRegexp("\"([^\"]*)\"", "„$1”", "mg");
}
/////////////////////////////////////////////////////
// Angol dátumok->magyar dátumok //
/////////////////////////////////////////////////////
// Translate dates from English format to Hungarian
// Currently it only handles linkified dates
function translateDatesEnHu() {
var months = [
["January", "január"],
["February", "február"],
["March", "március"],
["April", "április"],
["May", "május"],
["June", "június"],
["July", "július"],
["August", "augusztus"],
["September", "szeptember"],
["October", "október"],
["November", "november"],
["December", "december"]
];
for (var i = 0; i < months.length; i++) {
var enMonth = months[i][0];
var huMonth = months[i][1];
if (i<9) {
s="0" + (i+1);
} else {
s=i+1;
}
// alert("Replacing " + enMonths + " with " + huMonth);
// $1 = "15", $2 = "2005"
replaceRegexp("\\[\\[" + enMonth + " (\\d+)\\]\\],?\\s*\\[\\[(\\d{4})\\]\\]", "[[$2]]. [[" + huMonth + " $1]].", "gm");
replaceRegexp("(\\d+)\\s*" + enMonth + " \\s*(\\d{4})", "[[$2]]. [[" + huMonth + " $1]].", "gm");
replaceRegexp("0?(\\d+)\\." + j + "\\.(\\d+)", "[[$2]]. [[" + huMonth + " $1]].", "gm");
}
}
/////////////////////////////////////////////////////
// Egyéni regexp cserélő űrlap //
/////////////////////////////////////////////////////
function customReplaceForm() {
var form =
'Cseréld ezt a reguláris kifejezést: <input id="customReplaceThis" type="text" size="40"> ' +
'erre: <input id="customReplaceWith" type="text" size="40"> ' +
'<input id="customReplaceCS" type="checkbox"> méretérzékeny <b>::</b> ' +
'<a href="javascript:performCustomReplace()">csere</a>';
insertCustomForm(form);
document.getElementById('customReplaceThis').focus();
}
function performCustomReplace() {
var replaceThis = document.getElementById('customReplaceThis');
var replaceWith = document.getElementById('customReplaceWith');
var cs = document.getElementById('customReplaceCS');
var flags = "gm";
if (!cs.checked) {
flags += "i";
}
replaceRegexp(replaceThis.value, replaceWith.value, flags);
}
function insertCustomForm(formText) {
var customBar = document.getElementById('customBar');
if (customBar == null) return;
var customForm = document.createElement('div');
customForm.setAttribute('id', 'customForm');
customForm.setAttribute('style', 'margin-bottom:2px;border:1px solid #aaaaaa;padding:3px');
customForm.innerHTML =
'<img id="customFormClose" src="http://upload.wikimedia.org/wikipedia/hu/b/bd/Close.png" ' +
'align="right" style="margin:2px" onClick="deleteCustomForm()" ' +
'onmouseover="document.images.namedItem(\'customFormClose\').src=\'http://upload.wikimedia.org/wikipedia/hu/c/cf/Close-hl.png\'" ' +
'onmouseout="document.images.namedItem(\'customFormClose\').src=\'http://upload.wikimedia.org/wikipedia/hu/b/bd/Close.png\'"' +
'onmousedown="document.images.namedItem(\'customFormClose\').src=\'http://upload.wikimedia.org/wikipedia/hu/e/eb/Close-dn.png\'">' +
formText;
var oldForm = document.getElementById('customForm');
if (oldForm != null) {
customBar.parentNode.replaceChild(customForm, oldForm);
} else {
customBar.parentNode.insertBefore(customForm, customBar);
}
}
function deleteCustomForm() {
var customForm = document.getElementById('customForm');
if (customForm != null)
customForm.parentNode.removeChild(customForm);
}
// Initializes edit box
function advEditHook() {
// Textarea positioning doesn't work in Opera
if (is_opera) return;
// Find the element that comes right after the special character box
var textArea = document.getElementsByName('wpTextbox1');
if (textArea.item(0) != null) {
var insertPos = textArea.item(0).nextSibling.nextSibling; // this is a <br/>
var customBar = createCustomBar();
insertPos.parentNode.replaceChild(customBar, insertPos);
// Remove global spec char bar
var specChars = document.getElementById('specChar');
if (specChars != null) {
specChars.parentNode.removeChild(specChars);
}
}
}
if (window.addEventListener != null) window.addEventListener("load", advEditHook, false);
else if (window.attachEvent) window.attachEvent("onload", advEditHook);
importScript('User:Chery/kínai.js');
function letoltesStat() {
var now = new Date();
var yy = now.getYear() + 1900;
var hh = now.getMonth() + 1;
addPortletLink('p-cactions', 'http://stats.grok.se/hu/' + yy + ( hh < 10 ? '0' + hh : hh ) + '/'+wgPageName, 'Stat', 'ca-stat', 'Az oldal letöltési statisztikája');
}
addOnloadHook(letoltesStat);