MediaWiki:Gadget-section.js
Ocio: Daspò ver salvà, podaria esare neçesario snetare ła cache dal propio navegadore web par vedare i canbiamenti.
- Firefox / Safari: tegner strucà el boton de łe letare grande Shift e schiciare sora Ricarga, o se nò struca Ctrl-F5 o Ctrl-R (⌘-R so Mac)
- Google Chrome: strucare Ctrl-Shift-R (⌘-Shift-R so on Mac)
- Internet Explorer / Edge: tegner strucà el boton Ctrl e schiciare so Ajorna, o sinò Ctrl-F5
- Opera: Va in tel Menu → Inpostasion (Opera → Prefarense so on Mac) e pò in Privacy & sicuresa → Sneta dati del navegadore → Imajini e file in te ła cache.
//se ci sono già delle section, propone il numero immediatamente successivo alla maggiore
//es. se abbiamo le section 1, 3, 4, propone: 5
function getProssimoNumero() {
nextNum = 1;
prefix = '';
sectionPresenti = $('#wpTextbox1').val().match(/<section\s+begin\=[\"]?[a-zA-Z]*(\d+)[\"]?\s*\/>/gi);
if (sectionPresenti !== null) {
for (i = 0; i < sectionPresenti.length; i++) {
thisNum = parseInt(sectionPresenti[i].replace(/<section\s+begin\=[\"]?[a-zA-Z]*(\d+)[\"]?\s*\/>/, '$1'));
if (thisNum >= nextNum) {
nextNum = thisNum + 1;
prefix = sectionPresenti[i].replace(/<section\s+begin\=[\"]?([a-zA-Z]*)\d+[\"]?\s*\/>/, '$1');
}
}
}
return prefix + nextNum;
}
function marcaSection() {
nome = prompt("Nome da darghe a la section?", getProssimoNumero());
textArea = $('#wpTextbox1');
start = textArea[0].selectionStart;
end = textArea[0].selectionEnd;
selectedText = textArea.val().substring(start, end);
replacement = '<section begin="' + nome + '" />' + selectedText + '<section end="'+ nome + '" />';
textArea.val(textArea.val().substring(0, start) + replacement + textArea.val().substring(end));
}
if ( typeof $ != 'undefined' && typeof $.fn.wikiEditor != 'undefined' ) {$( function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'advanced',
'group': 'format',
'tools': {'section': {
label: 'Zonta na section atorno al testo selessionà',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/9/97/Button_S_italic.png',
action: {type: 'callback',
execute: function(context){marcaSection();} }
}}});});}