Utente:Luigi62/PersonalButtons.js
Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.
- Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
- Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
- Internet Explorer / Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5
- Opera: premi Ctrl-F5.
/*var ss=function(){
var textarea=alex.activeElement; // elemento dom wpTextbox1
var txt=$(textarea).val();
var s=[];
s[0]=txt.substring(0,textarea.selectionStart);
s[1]=txt.substring(textarea.selectionStart,textarea.selectionEnd);
s[2]=txt.substring(textarea.selectionEnd);
return s;
};
// riscrive wpTextbox1 e ristabilisce il focus/la selezione attiva
// riceve un array tipo [testo precedente, testo selezionato, testo seguente]
var sw=function(t) {
var textarea=alex.activeElement; // elemento dom wpTextbox1=$("#wpTextbox1")[0]; // elemento dom wpTextbox1
textarea.value=t.join("");
textarea.selectionStart=t[0].length;
textarea.selectionEnd= t[0].length + t[1].length;
textarea.focus();
}
var newSections=function () {
var s=ss();
if (s[2].indexOf("<section end=s2 />")==-1) {
s[0]="<section begin=s1 />"+s[0]+"<section end=s1 />";
s[2]="<section begin=s2 />"+s[2]+"<section end=s2 />";
}
else {
s[0]=s[0]+"<section end=s2 />";
s[2]="<section begin=s3 />"+s[2].replace("<section end=s2 />","<section end=s3 />");
}
s[0].value=s[0]+s[1]+s[2];
//scriviBox(s.join(""));
sw(s);
};
*/
newButton("sections", "newSections()", "es","splitta in sezioni");
newButton("Nop","incapsula('{{Nop}}','')","es","Nop");