Nota: Depois de publicar, poderá ter de contornar a cache do seu navegador para ver as alterações.
- Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
- Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
- Internet Explorer / Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5
- Opera: Pressione Ctrl-F5.
// <pre>
/*************
*** Regex menu framework
*** by [[m:user:Pathoschild]] <http://meta.wikimedia.org/wiki/User:Pathoschild/Scripts/Regex_menu_framework>
*** - adds a sidebar menu of user-defined scripts.
*************/
mw.loader.load('https://meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Regex_menu_framework.js&action=raw&ctype=text/javascript');
/* menu links */
// In the function below, add more lines like "regexTool('link text','function_name()')" to add
// links to the sidebar menu. The function name is the function defined in rfmscripts() below.
function rmflinks() {
regexTool('Custom regex','custom()'); // a default tool which performs regex input in a dynamic form
regexTool('PostOCR','postOCR()');
regexTool('Apostrofi','apostrofi()');
regexTool('Antichizza','antichize()');
regexTool('tilde','tilde()');
}
/* scripts */
// Below, define the functions linked to from rmflinks() above. These functions can use any JavaScript,
// but there is a set of simplified tools documented at
// http://meta.wikimedia.org/wiki/User:Pathoschild/Script:Regex_menu_framework .
/* sidebar code for use with P/c's Regex code */
function DNBset() {
var editbox = document.getElementsByName('wpTextbox1')[0];
editbox.value = editbox.value.replace(/\{\{header\n \| title \=.+\n \| author \= \n \| translator \= \n \| section \= \n \| previous \= \n \| next \= \n \| notes \= \n\}\}\n/, '{{subst:DNBset\n |article= \n |previous= \n |next= \n |volume = \n |contributor = \n |wikipedia = \n |extra_notes= \n |from= \n |to= \n |section= \n}}');
}
function postOCR() {
var editbox = document.getElementsByName('wpTextbox1')[0];
editbox.value = editbox.value.replace(/- /g, '')
.replace(/¬/g, '')
.replace(/ê/g, 'e[m]')
.replace(/v/g, 'u')
.replace(/ĕ/g, 'e[m]')
.replace(/ē/g, 'e[m]')
.replace(/ă/g, 'a[m]')
.replace(/ŏ/g, 'o[m]')
.replace(/õ/g, 'o[m]')
.replace(/ã/g, 'a[m]')
.replace(/â/g, 'a[m]')
.replace(/ fj /g, ' q[ue] ')
.replace(/ fj /g, ' q[ue] ')
.replace(/ũ/g, 'u[n]')
.replace(/ŭ/g, 'u[n]')
.replace(/ì/g, 'i')
.replace(/à/g, 'a')
.replace(/ q /g, ' q[ue] ')
.replace(/[n] /g, '[m] ')
;
}
function apostrofi() {
var editbox = document.getElementsByName('wpTextbox1')[0];
editbox.value = editbox.value.replace(/'/g, '’')
.replace(/’’’/g, '\'\'\'')
.replace(/’’/g, '\'\'')
.replace(/E’ /g, 'È ')
;
}
function antichize() {
var editbox = document.getElementsByName('wpTextbox1')[0];
editbox.value = editbox.value
.replace(/_e/g, 'ẽ')
.replace(/_a/g, 'ã')
.replace(/_o/g, 'õ')
.replace(/_u/g, 'ũ')
.replace(/_i/g, 'ĩ')
.replace(/_c/g, 'ç')
.replace(/\./g, ". ")
.replace(/:/g, ': ')
.replace(/;/g, '; ')
.replace(/,/g, ', ')
.replace(/ /g, " ")
;
}
function tilde() {
var editbox = document.getElementsByName('wpTextbox1')[0];
editbox.value = editbox.value
.replace(/\[m\]/g, '̃')
.replace(/\[n\]/g, '̃')
.replace(/\[ue\]/g, '̃')
;
}
// Script di Filippo_V per aggancio di un pulsante a una funzione js qualsiasi
function pulsantini() {
var toolbar = null;
toolbar = document.getElementById("toolbar");
if (toolbar == null) return;
addToolbarButton('tb-ocr', 'javascript:postOCR()', 'http://upload.wikimedia.org/wikipedia/commons/9/96/Button_ocr_fix.png', '[postOCR]', 'Corregge gli errori comuni di scansione');
addToolbarButton('tb-ocr', 'javascript:apostrofi()','http://upload.wikimedia.org/wikipedia/commons/3/32/Button_apostrophe.PNG', '[apostrofi]', 'Converte gli apostrofi dattilografici in tipografici');;
}
addLoadEvent(pulsantini);
// PULSANTI ADDIZIONALI
// CENTRATO
if (mwCustomEditButtons) {
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/5/5f/Button_center.png",
"speedTip": "center",
"tagOpen": '<center>',
"tagClose": '</center>',
"sampleText": "Testo"};
};
// JOLLY1
if (mwCustomEditButtons) {
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/a/aa/Button_dot1.PNG",
"speedTip": "q[ue]",
"tagOpen": '',
"tagClose": '',
"sampleText": 'q[ue]'};
};
// JOLLY2
if (mwCustomEditButtons) {
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/a/aa/Button_dot1.PNG",
"speedTip": "quality",
"tagOpen": '<includeonly><section begin=quality />',
"tagClose": '<section end=quality /></includeonly>',
"sampleText": '3'};
};
// JOLLY3
if (mwCustomEditButtons) {
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/a/aa/Button_dot1.PNG",
"speedTip": "noinclude",
"tagOpen": '<noinclude>',
"tagClose": '</noinclude>',
"sampleText": ' '};
};
// SEZIONE
if (mwCustomEditButtons) {
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/4/44/Button_comillas_latinas.png",
"speedTip": "Section 1",
"tagOpen": '<section begin=1 />',
"tagClose": '<section end=1 />',
"sampleText": " "};
};
// Template pt
if (mwCustomEditButtons) {
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "http://upload.wikimedia.org/wikipedia/commons/4/4b/Button_class_text.png",
"speedTip": "pt",
"tagOpen": '{{começo de palavra hifenizada|',
"tagClose": '|}}',
"sampleText": " "};
};
// PULSANTI ADDIZIONALI per skin Vector :-)
if ( typeof $ != 'undefined' && typeof $.fn.wikiEditor != 'undefined' ) {
$(document).ready( function() {
/* AutoreCitato*/
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'format',
'tools': {
'Ac': {
label: 'AutoreCitato',
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/6/6d/Button_AC.png',
action: {
type: 'encapsulate',
options: {
pre: "{{AutoreCitato|",
post: "}}"
}
}
}
}
} );
/* ref*/
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'format',
'tools': {
'ref': {
label: 'ref',
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/7/79/Button_reflink.png',
action: {
type: 'encapsulate',
options: {
pre: "<ref>",
post: "</ref>"
}
}
}
}
} );
/* TestoCitato*/
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'format',
'tools': {
'Tc': {
label: 'TestoCitato',
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/4/45/Button_TC.png',
action: {
type: 'encapsulate',
options: {
pre: "{{TestoCitato|",
post: "}}"
}
}
}
}
} );
/* Centrato*/ $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'format',
'tools': {
'Center': {
label: 'Centra',
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/5/5f/Button_center.png',
action: {
type: 'encapsulate',
options: {
pre: "{{Centrato||",
post: "}}"
}
}
}
}
} );
/* Sezione */ $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'format',
'tools': {
'Section': {
label: 'Sezione',
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/4/44/Button_comillas_latinas.png',
action: {
type: 'encapsulate',
options: {
pre: "<section begin=1 />",
post: "<section end=1 />"
}
}
}
}
} );
/* Pt */ $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'format',
'tools': {
'Pt': {
label: 'Pt',
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/4/4b/Button_class_text.png',
action: {
type: 'encapsulate',
options: {
pre: "{{pt||",
post: "}}"
}
}
}
}
} );
/* inizio versi */ $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'format',
'tools': {
'Inizio versi': {
label: 'inizio versi',
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/8/8f/Button_poeme.png',
action: {
type: 'encapsulate',
options: {
pre: "<!-- inizio versi -->",
post: "<!-- fine versi -->"
}
}
}
}
} );
/* inizio poesia */ $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'format',
'tools': {
'inizio poesia': {
label: 'inizio poesia',
type: 'button',
icon: 'http://upload.wikimedia.org/wikipedia/commons/4/4f/Button_verse.png',
action: {
type: 'encapsulate',
options: {
pre: "<!-- inizio poesia -->",
post: ""
}
}
}
}
} );
} );
}
// </pre>