Szerkesztő:Armyyour/monobook.js
Megjelenés
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
- Edge: tartsd nyomva a Ctrl-t, és kattints a Frissítés gombra, vagy nyomj Ctrl–F5-öt
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 =
"<a href=\"javascript:insertTags('%7B%7Bszubcsonk|\~\~\~\~\~%7D%7D','','')\">szubcsonk</a> · " +
"<a href=\"javascript:insertTags('%7B%7Bazonnali|' + prompt() + '%7D%7D','','')\">azonnali</a> · " +
"<a href=\"javascript:insertTags('%7B%7Bjogsértő|url=','%7D%7D','')\">jogsértő</a> · " +
"<a href=\"javascript:SajatReplace()\"><small>saját csere</small></a> . " +
"<a href=\"javascript:customReplaceForm()\">regexp csere</a>";
return boxDiv;
}
function replaceRegexp(replaceWhat, replaceWith, modifiers) {
if (modifiers == null) {
modifiers = "";
}
var txtarea = document.editform.wpTextbox1;
// IE
if(document.selection && !is_gecko) {
var theSelection = document.selection.createRange().text;
txtarea.focus();
theSelection = theSelection.replace(replaceWhat, replaceWith);
document.selection.createRange().text = theSelection;
// Mozilla
} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
// This is probably more complicated than it needs to be
var startPos = txtarea.selectionStart;
var endPos = txtarea.selectionEnd;
var scrollTop=txtarea.scrollTop;
var pattern = new RegExp(replaceWhat, modifiers);
var myText = (txtarea.value).replace(pattern, replaceWith);
txtarea.value = myText;
txtarea.focus();
var cPos=startPos;
txtarea.selectionStart=cPos;
txtarea.selectionEnd=cPos;
txtarea.scrollTop=scrollTop;
// All others
} else {
alert("No support for this browser yet");
return;
}
// reposition cursor if possible
if (txtarea.createTextRange) txtarea.caretPos = document.selection.createRange().duplicate();
}
// Replaces Latin 1 chars with properly encoded Hungarian Latin 2 equivalents
function fixLatin1Chars() {
replaceRegexp("Õ", "Ő", "g");
replaceRegexp("Û", "Ű", "g");
replaceRegexp("õ", "ő", "g");
replaceRegexp("û", "ű", "g");
replaceRegexp("ő", "ő", "g");
replaceRegexp("ű", "ű", "g");
}
// Sajat lista alapjan cserelgetjuk a dolgokat
function SajatReplace() {
replaceRegexp("110 metres hurdles|110 m H", "110 m gát", "g");
replaceRegexp("400 metres hurdles|400 m H", "400 m gát", "g");
replaceRegexp("3000 m steeplechase|3000 m St.", "3000 m akadály", "g");
replaceRegexp("100 metres hurdles|110 m H", "100 m gát", "g");
replaceRegexp("Race walking|10000 m track walk", "10000 m gyaloglás", "g");
replaceRegexp("Relay race|4 X 100 m", "4 X 100 m váltó", "g");
replaceRegexp("High jump", "magasugrás", "g");
replaceRegexp("Pole vault", "rúdugrás", "g");
replaceRegexp("Long jump", "távolugrás", "g");
replaceRegexp("Triple jump", "hármasugrás", "g");
replaceRegexp("Shot put", "súlylökés", "g");
replaceRegexp("Discus throw|Discus", "diszkoszvetés", "g");
replaceRegexp("Javelin throw|Javelin", "gerelyhjítás", "g");
replaceRegexp("Hammer throw|Hammer", "kalapácsvetés", "g");
replaceRegexp("Decathlon", "tízpróba", "g");
replaceRegexp("Heptathlon", "hétpróba", "g");
}
// Replaces English style "" quotes with Hungarian „”
function fixHungarianQuotes() {
replaceRegexp("\"([^\"]*)\"", "„$1”", "mg");
}
// 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];
// alert("Replacing " + enMonths + " with " + huMonth);
// Replace "[[November 15]], [[2005]]" with "[[2005]]. [[november 15]]."
// $1 = "15", $2 = "2005"
replaceRegexp("\\[\\[" + enMonth + " (\\d+)\\]\\],?\\s*\\[\\[(\\d{4})\\]\\]", "[[$2]]. [[" + huMonth + " $1]].", "gm");
}
}
// Replace all occurences of a user-entered regexp with a user entered replacement
function customReplaceForm() {
var form =
'Cseréld ezt a reguláris kifejezést: <input id="customReplaceThis" type="text" size="30"> ' +
'erre: <input id="customReplaceWith" type="text" size="30"> ' +
'<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 myOnloadHook() {
// 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", myOnloadHook, false);
else if (window.attachEvent)
window.attachEvent("onload", myOnloadHook);