Utilisateur:Abecido/section.js
Note : après avoir enregistré vos modifications, il se peut que vous deviez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
- Firefox / Safari : Maintenez la touche Maj (Shift) en cliquant sur le bouton Actualiser ou pressez Ctrl-F5 ou Ctrl-R (⌘-R sur un Mac) ;
- Google Chrome : Appuyez sur Ctrl-Maj-R (⌘-Shift-R sur un Mac) ;
- Internet Explorer : Maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5 ;
- Opera : Allez dans Menu → Settings (Opera → Préférences sur un Mac) et ensuite à Confidentialité & sécurité → Effacer les données d'exploration → Images et fichiers en cache.
/*myhtml='<table id="table_section_abecido" \
style="position:fixed; top:50px; left:0px; height:50px; border:solid 1px; z-index:101; background-color:white;">\
<tr><td>\
<button id="ab_plusun" onclick="ab_plusun()" >+1</button></tr><tr><td>\
<button id="ab_moinsun" onclick="ab_moinsun()" >-1</button></tr><tr><td>\
<button id="ab_instop" onclick="ab_intop()" >top</button></tr><tr><td>\
<button id="ab_insplace" onclick="ab_inplace()" >place</button></tr><tr><td>\
<textarea id="nosection" rows="1" cols="5" maxlength="5" style="font-size:150%;"></textarea>\
</td></tr></table>'
$("body").append(myhtml);
$("#table_section_abecido").draggable();
*/
if(document.cookie.length === 0){
document.cookie="nosection=0;";
} else {
section = document.cookie.match("nosection=([^;]+)")[1];
elem=document.getElementById('nosection');
elem.value=section;
}
function ab_plusun(){
var start = $('#wpTextbox1').prop("selectionStart");
var end = $('#wpTextbox1').prop("selectionEnd");
section = parseInt(document.getElementById("nosection").value) +1;
document.getElementById('nosection').value=parseInt(section);
document.cookie='nosection='+section+';';
$('#wpTextbox1').focus();
$('#wpTextbox1').prop("selectionStart",parseInt(start));
$('#wpTextbox1').prop("selectionEnd",parseInt(end));
}
function ab_moinsun(){
var start = $('#wpTextbox1').prop("selectionStart");
var end = $('#wpTextbox1').prop("selectionEnd");
section = parseInt(document.getElementById("nosection").value) -1;
document.getElementById('nosection').value=parseInt(section);
document.cookie='nosection='+section+';';
$('#wpTextbox1').focus();
$('#wpTextbox1').prop("selectionStart",parseInt(start));
$('#wpTextbox1').prop("selectionEnd",parseInt(end));
}
function ab_intop(){
var section = document.getElementById("nosection").value;
var txt = '## '+section+' ##\n'+$('#wpTextbox1').prop('value');
$('#wpTextbox1').prop('value',txt);
$('#wpTextbox1').focus();
var pos =txt.match(/[\n]/).index;
if (pos === undefined){pos=txt.length-1}
$('#wpTextbox1').prop("selectionStart",pos);
$('#wpTextbox1').prop("selectionEnd",pos);
}
function ab_inplace(){
var section = document.getElementById("nosection").value;
var txt = $('#wpTextbox1').prop("value");
var start = $('#wpTextbox1').prop("selectionStart");
var end = $('#wpTextbox1').prop("selectionEnd");
txt = txt.substring(0,start)+"## "+section+" ##\n{{brn|1}}"+txt.substring(end,txt.length);
$('#wpTextbox1').prop('value', txt);
$('#wpTextbox1').focus();
pos = parseInt(end) + 16 + section.toString().length;
$('#wpTextbox1').prop("selectionStart",pos);
$('#wpTextbox1').prop("selectionEnd",pos);
}
function ab_newtop(str){
var txt=str;
var pos1=txt.search(/\n/);
var txt1="{{c|"+txt.substring(0,pos1)+"|fs=90%}}\n";
var txt2=txt.substring(pos1+1,txt.length);
var pos2=txt2.search(/\n/);
var txt3='{{droite|'+txt2.substring(0,pos2)+"|fs=85%}}\n{{brn|1}}\n";
var txt4=txt1+txt3+txt2.substring(pos2+1,txt2.length);
return txt4
}
function ab_newx(){
ab_plusun();
var section = document.getElementById("nosection").value;
var libs ="## "+section+" ##\n";
var txt = $('#wpTextbox1').prop("value");
var start = $('#wpTextbox1').prop("selectionStart");
var end = $('#wpTextbox1').prop("selectionEnd");
var txt2=txt.substring(start,txt.length);
txt4=txt.substring(0,start)+libs+ab_newtop(txt2)
$('#wpTextbox1').prop('value',txt4)
$('#wpTextbox1').prop("selectionStart",parseInt(start));
$('#wpTextbox1').prop("selectionEnd",parseInt(end));
}