Utilisateur:Abecido/theatre.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.
importScript('Utilisateur:Abecido/perso.js') ;
importScript('Utilisateur:Abecido/persoD.js') ;
importScript('Utilisateur:Abecido/didasc.js') ;
myhtml='<table id="table_theatre_abecido" style="position:fixed; top:50px; left:10px; height:250px; border:solid 1px; z-index:101; background-color:white; font-size:1em;">\
<tr><td>';
myhtml=myhtml+'<a class="theatre" href="javascript:void()" onclick="perso()">personnage 1</a></td></tr><tr><td> ';
myhtml=myhtml+'<a class="theatre" href="javascript:void()" onclick="persoD()">personnageD 2</a></td></tr><tr><td> ';
myhtml=myhtml+'<a class="theatre" href="javascript:void()" onclick="didasc()">didascalie 3</a></td></tr><tr ><td> ';
myhtml=myhtml+'<a class="theatre" href="javascript:void()" onclick="';
myhtml=myhtml+"ab2_insertTags('alinéa');return false"+'">alinea</a></td></tr><tr><td> ';
myhtml=myhtml+'<a class="theatre" href="javascript:void()" onclick="';
myhtml=myhtml+"ab2_insertTags('acteurs');return false"+'">acteurs 4</a></td></tr><><td> ';
myhtml=myhtml+'<a class="theatre" href="javascript:void()" onclick="';
myhtml=myhtml+"ab2_insertTags('scène');return false"+'">scène 5</a></td></tr><tr><td> ';
myhtml=myhtml+'<a class="theatre" href="javascript:void()" onclick="';
myhtml=myhtml+"ab2_insertTags('nld');return false"+'">nld, Sévigné</a></td></tr><tr><td> ';
myhtml=myhtml+'<a class="theatre" href="javascript:void()" onclick="';
myhtml=myhtml+"ab2_insertTags('poem');return false"+'">poem</a></td></tr><tr><td> ';
myhtml=myhtml+'<a class="theatre" href="javascript:void()" onclick="';
myhtml=myhtml+"ab2_insertTags('cach');return false"+'">cach</a></td></tr><tr><td> ';
myhtml=myhtml+'<a class="theatre" href="javascript:void()" onclick="';
myhtml=myhtml+"ab2_insertTags('acte');return false"+'">acte</a></td></tr><tr><td> ';
myhtml=myhtml+"</td></tr></table>";
$("body").append(myhtml);
$("#table_theatre_abecido").draggable();
if(document.cookie.length === 0){
theatre=0;
} else {
theatre = parseInt(document.cookie.match("divtheatre=([^;]+)")[1]);
}
if(theatre === 0 ){
$("#table_theatre_abecido").hide();
} else {
$("#table_theatre_abecido").show();
}
function ab2_insertTags(tag){
tagdelta=0;
pos_cursor=0;
var start = $('#wpTextbox1').prop("selectionStart");
var end = $('#wpTextbox1').prop("selectionEnd");
if (tag == 'acteurs') {
tagstart="{{acteurs|";
tagend="}}"
pos_cursor=start;
} else if (tag == 'alinéa'){
tagstart="{{alinéa|";
tagend="|2|-1|fs=90%}}";
}else if (tag == 'scène'){
tagstart="{{scène|";
tagend="}}";
pos_cursor=start;
}else if (tag == 'nld'){
tagstart="{{nld|";
tagend="|border-top:1px solid black;}}}}";
}else if (tag == 'acte'){
tagstart="{{acte|";
tagend="}}";
pos_cursor=start;
}else if (tag == 'poem'){
tagstart="<poem>";
tagend="</poem>";
}else if (tag == 'cach'){
tagstart="{{cach|";
tagend="}}";
tagdelta=-2;
nrom=calculrom()
}else if (tag == 'rom-maj'){
tagstart="{{rom-maj|";
tagend="|}}";
tagdelta=-2;
}
else {
tagstart = "Erreur";
}
if(start==end){
end=start+$('#wpTextbox1').val().substr(start).indexOf('\n');
}
var str = $('#wpTextbox1').val().substring(start,end);
if ((tag=='rom') || (tag=='rom-maj')){
wstr=' '+str+' ';
tagstart=romain(wstr);
tagstart=tagstart.trim();
resplit=tagstart.split('|');
tagstart=resplit[0]+"|";
tagend='|'+resplit[2];
}
rstr=$('#wpTextbox1').val();
if( tagstart != 'Erreur'){
rstr=rstr.substring(0,start)+tagstart+str+tagend+rstr.substring(end,rstr.length);
}
$('#wpTextbox1').val(rstr);
$('#wpTextbox1').focus();
if(pos_cursor==0){
pos_cursor=end+tagstart.length + tagend.length + tagdelta;
}
$('#wpTextbox1').prop("selectionStart",parseInt(pos_cursor));
$('#wpTextbox1').prop("selectionEnd",parseInt(pos_cursor));
}
if (mw.config.get("wgAction") == "edit" || mw.config.get("wgAction") == "submit") {
document.addEventListener("keydown",
function (event) {
if (event.key === "1" && event.altKey && event.ctrlKey) {
event.preventDefault();
perso();
}
if (event.key === "2" && event.altKey && event.ctrlKey) {
event.preventDefault();
persoD();
}
if (event.key === "3" && event.altKey && event.ctrlKey) {
event.preventDefault();
didasc();
}
if (event.key === "4" && event.altKey && event.ctrlKey) {
event.preventDefault();
ab2_insertTags('acteurs');
}
if (event.key === "5" && event.altKey && event.ctrlKey) {
event.preventDefault();
ab2_insertTags('scène');
}
});
}