Usor:Alex brollo/monobook.js

E Wikisource

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press 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('A capo','acapo()');
        regexTool('Correzione doppio capo','acapo2()');

}
 
/* 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, '\'\'')
	.replace(/e’/g, 'e’ ')
        .replace(/e’  /g, 'e’ ')
        .replace(/E’ /g, 'È ')
	.replace(/v’ /g, 'v’')
	.replace(/n’ /g, 'n’')
	.replace(/s’ /g, 's’')
	.replace(/t’ /g, 't’')
	.replace(/m’ /g, 'm’')
	.replace(/l’ /g, 'l’')
        .replace(/ P /g, ' l’')
        .replace(/ Y /g, ' l’')
	.replace(/eh’ /g, 'ch’')
	.replace(/ alia /g, ' alla ')
	.replace(/ piu /g, ' più ')
	.replace(/ perche /g, ' perchè ')
	.replace(/lP/g, 'll’')
	.replace(/I’/g, 'l’')
	.replace(/1’/g, 'l’')
	.replace(/ :/g, ': ')
        .replace(/([dlznt])’ /g, "$1’")
        .replace(/[(\[] /g, " $1")
        .replace(/ \n/g, '\n')
	.replace(/-\n/g, '')
        .replace(/ ,/g, ", ")
        .replace(/ ;/g, "; ")
        .replace(/ !/g, "! ")
        .replace(/ \?/g, "? ")
        .replace(/ \./g, ". ")
        .replace(/ :/g, ": ")
        .replace(/« /g, "«")
        .replace(/ »/g, "»")
        ;
}
function apostrofi() {
	var editbox = document.getElementsByName('wpTextbox1')[0];
	editbox.value = editbox.value.replace(/'/g, '’')
	.replace(/’’’/g, '\'\'\'')
	.replace(/’’/g, '\'\'')
	.replace(/E’ /g, 'È ')

        ;
}

function acapo() {
	var editbox = document.getElementsByName('wpTextbox1')[0];
	editbox.value = editbox.value.replace(/\n\n/g, '<acapo>')
	.replace(/-\n/g, '')
        .replace(/\n/g, ' ')
	.replace(/<acapo>/g, '\n\n')
	.replace(/E’ /g, 'È ')

        ;
}

function acapo2() {
	var editbox = document.getElementsByName('wpTextbox1')[0];
	editbox.value = editbox.value.replace(/\n\n\n/g, '\n')
        .replace(/\n\n/g, '\n')
        ;
}







// Elenco dei tool da caricare.

var toLoad="ref  noinc";


//Monobook Modulare
//Lancia il vero monobook
// Vedi [[Wikisource:Monobook.js/MonobookCompleto.js]]
// 
document.writeln('<script type="text/javascript" src="/w/index.php?title=Wikisource:Monobook.js/MonobookCompleto.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');

// 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');
addToolbarButton('tb-ocr', 'javascript:acapo()','http://upload.wikimedia.org/wikipedia/commons/1/13/Button_enter.png', '[a capo]', 'Sistema gli acapo nei testi OCR in PROSA');  
}
addLoadEvent(pulsantini);


function ModifySidebar(action, section, name, link) {
    try {
        switch (section) {
          case "languages":
            var target = "p-lang";
            break;
          case "toolbox":
            var target = "p-tb";
            break;
          case "navigation":
            var target = "p-navigation";
            break;
          default:
            var target = "p-" + section;
            break;
        }
 
        if (action == "add") {
            var node = document.getElementById(target)
                               .getElementsByTagName('div')[0]
                               .getElementsByTagName('ul')[0];
 
            var aNode = document.createElement('a');
            var liNode = document.createElement('li');
 
            aNode.appendChild(document.createTextNode(name));
            aNode.setAttribute('href', link);
            liNode.appendChild(aNode);
            liNode.className='plainlinks';
            node.appendChild(liNode);
        }
 
        if (action == "remove") {
            var list = document.getElementById(target)
                               .getElementsByTagName('div')[0]
                               .getElementsByTagName('ul')[0];
 
            var listelements = list.getElementsByTagName('li');
 
            for (var i = 0; i < listelements.length; i++) {
                if (listelements[i].getElementsByTagName('a')[0].innerHTML == name ||
                    listelements[i].getElementsByTagName('a')[0].href == link) {
 
                    list.removeChild(listelements[i]);
                }
            }
        }
 
    } catch(e) {
      // lets just ignore what's happened
      return;
    }
}
 
function CustomizeModificationsOfSidebar() {
    ModifySidebar("remove", "toolbox", "Carica un file", "http://it.wikisource.org/wiki/Speciale:Carica");
}
 
$(CustomizeModificationsOfSidebar);
// POPUP DI LUPIN [[User:Lupin/popups.js]]
// document.write('<script type="text/javascript" src="' 
//             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' 
//             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
// FUNZIONE BASE PER GLI SCRIPT DI IPORK
function inc(file) {
   document.write('<script type="text/javascript" src="/w/index.php?title='+ file +'&action=raw&ctype=text/javascript&dontcountme=s"></script>');
}
inc("Utente:IPork/controllo versioni.js");
var nomeutente= "Aubrey";



// RICERCA AVANZATA
inc("Utente:IPork/ricerca.js");


// MENU A SINISTRA
inc("Utente:IPork/menusinistra.js");


var opzPannelliOriginali = 0;
var opzAmministratore = 0;
var opzModificaIntro = 0;
var opzLinksPersonali =0;

//SAL
//inc("Utente:IPork/SAL.js");

// PULSANTI ADDIZIONALI

 
// AUTORECITATO VERSIONE MARZO 2009
if (mwCustomEditButtons) {
 mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/6/6d/Button_AC.png",
     "speedTip": "AutoreCitato",
     "tagOpen": '{{AutoreCitato|',
     "tagClose": '}}',
     "sampleText": "Nome autore"};
};
 
// TESTOCITATO
if (mwCustomEditButtons) {
 mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/4/45/Button_TC.png",
     "speedTip": "Tc",
     "tagOpen": '{{Tc|',
     "tagClose": '}}',
     "sampleText": "Nome testo"};
};

// Template TEMPLATE
if (mwCustomEditButtons) {
 mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/4/4b/Button_class_text.png",
     "speedTip": "pt",
     "tagOpen": '{{pt|',
     "tagClose": '}}',
     "sampleText": "Nome_template"};
};



// CENTRATO
if (mwCustomEditButtons) {
 mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/5/5f/Button_center.png",
     "speedTip": "centrato",
     "tagOpen": '{{Centrato|',
     "tagClose": '}}',
     "sampleText": "Testo"};
};



// 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": "Sezione"};
};


// « »
if (mwCustomEditButtons) {
mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/4/44/Button_comillas_latinas.png",
     "speedTip": "«»",
     "tagOpen": '«',
     "tagClose": '»',
     "sampleText": " "};
};
//SMALLCAPS
if (mwCustomEditButtons) {
mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/a/a2/SmallcapsButton.png",
     "speedTip": "Sc",
     "tagOpen": '{{Sc|',
     "tagClose": '}}',
     "sampleText": "Testo"};
};

//POEM+MS
if (mwCustomEditButtons) {
mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/f/ff/Button_arrow_right.png",
     "speedTip": "poem + ms 0.7",
     "tagOpen": '{{ms|font=0.7pc}}<poem> \n',
     "tagClose": '</poem></div>',
     "sampleText": "Versi"};
};

//MS
if (mwCustomEditButtons) {
mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/commons/2/25/Button_indention.gif",
     "speedTip": "ms",
     "tagOpen": '<div style="margin-left:5em;">',
     "tagClose": '</div>',
     "sampleText": "ms"};
};