MediaWiki:Gadget-indentaVersi.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.
function scriviBox(testo, area, ss, se) {
if (area === undefined || area === "") {
if (mw.config.get('wgCanonicalNamespace') == "Page") {
area = 1;
} else {
area = 0;
}
}
$('textarea')[area].value = testo;
if (ss !== undefined && se !== undefined) {
$('textarea')[area].selectionStart = ss;
$('textarea')[area].selectionEnd = se;
}
}
function indentSelection() {
t=selection();
if (t[0].indexOf("\n")==-1) {
t[1]=t[0]+t[1];
t[0]="";
}
else {
pn=t[0].lastIndexOf("\n");
t[1]=t[0].substring(pn+1)+t[1];
t[0]=t[0].substring(0,pn+1);
}
var t1=t[1].split("\n");
for (var i=0; i<t1.length; i+=1) {
t1[i]=" "+t1[i];}
t[1]=t1.join("\n");
scriviBox(t.join(""),"",t[0].length,t[0].length+t[1].length);
}
function deIndentSelection() {
t=selection();
if (t[0].indexOf("\n")==-1) {
t[1]=t[0]+t[1];
t[0]="";
}
else {
pn=t[0].lastIndexOf("\n");
t[1]=t[0].substring(pn+1)+t[1];
t[0]=t[0].substring(0,pn+1);
}
var t1=t[1].split("\n");
for (var i=0; i<t1.length; i+=1) {
for (j=0; j<5; j+=1) {
if (t1[i].substring(0,1)==" ") t1[i]=t1[i].substring(1);
else break;
}
}
t[1]=t1.join("\n");
scriviBox(t.join(""),"",t[0].length,t[0].length+t[1].length);
}
/* indentaVersi() */
if (typeof $ != 'undefined' && typeof $.fn.wikiEditor != 'undefined') {
$(function() {
$('#wpTextbox1').wikiEditor('addToToolbar', {
'section': 'advanced',
'group': 'format',
'tools': {'section': {
label: 'Indenta i versi selessionà [alt-shift-y]',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/2/25/Btn_toolbar_indent_more.png',
action: {type: 'callback',
execute: function(context){indentSelection();}
}
}}
});
$('[accesskey=y]').removeAttr('accesskey');
$('.wikiEditor-ui-toolbar [title="Indenta i versi selessionà [alt-shift-y]"]').attr('accesskey', 'y');
});
}
/* deindentaVersi() */
if (typeof $ != 'undefined' && typeof $.fn.wikiEditor != 'undefined') {
$(function() {
$('#wpTextbox1').wikiEditor('addToToolbar', {
'section': 'advanced',
'group': 'format',
'tools': {'section': {
label: 'De-indenta i versi selessionà [alt-shift-u]',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/a/ab/Btn_toolbar_indent_less.png',
action: {type: 'callback',
execute: function(context){deIndentSelection();}
}
}}
});
$('[accesskey=u]').removeAttr('accesskey');
$('.wikiEditor-ui-toolbar [title="De-indenta i versi selessionà [alt-shift-u]"]').attr('accesskey', 'u');
});
}