710 lines
23 KiB
JavaScript
710 lines
23 KiB
JavaScript
/* Currently-active calculators */
|
|
const default_set = [ "g25+e2", "g35+e2", "g90+e", "cp400+e" ];
|
|
|
|
/* Hide or show a calculator, by controlling checkbox */
|
|
function toggle_calc(checkbox) {
|
|
const selector = "#calcdb .calc-" + checkbox.dataset.calc;
|
|
document.querySelectorAll(selector).forEach(td => {
|
|
if(checkbox.checked)
|
|
td.style.display = "table-cell";
|
|
else
|
|
td.style.display = "none";
|
|
});
|
|
update_permalink();
|
|
}
|
|
|
|
/* Select a fixed set set */
|
|
function select_set(set) {
|
|
document.querySelectorAll("#calcdb-checkboxes input").forEach(box => {
|
|
box.checked = set.includes(box.dataset.name) || set.includes(box.dataset.calc);
|
|
box.dispatchEvent(new Event("change"));
|
|
});
|
|
update_permalink();
|
|
}
|
|
/* Select all calculators */
|
|
function select_all() {
|
|
document.querySelectorAll("#calcdb-checkboxes input").forEach(box => {
|
|
box.checked = true;
|
|
box.dispatchEvent(new Event("change"));
|
|
});
|
|
update_permalink();
|
|
}
|
|
|
|
/* Udpate permalink and page URL*/
|
|
function update_permalink() {
|
|
var search = [];
|
|
document.querySelectorAll("#calcdb-checkboxes input").forEach(box => {
|
|
if(box.checked) search.push(box.dataset.name);
|
|
});
|
|
|
|
var loc = window.location.href.split("?")[0] + "?" + search.join(",");
|
|
history.pushState({}, "Comparateur Planète Casio", loc);
|
|
document.getElementById("calcdb-permalink").href = loc;
|
|
}
|
|
|
|
/* The browser might load the page with some boxes pre-checked because of
|
|
forms being cached, so upate to make sure the display is consistent */
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const query = window.location.search;
|
|
document.querySelectorAll("#calcdb-checkboxes input").forEach(toggle_calc);
|
|
|
|
/* Also read the query string for a potential fixed set */
|
|
if(!query) return;
|
|
var set = [];
|
|
query.substr(1).split(",").forEach(name => {
|
|
if(name == "current") set = set.concat(default_set);
|
|
else set.push(name);
|
|
});
|
|
select_set(set);
|
|
}, false);
|
|
|
|
var x = 0;
|
|
var y = 0;
|
|
|
|
selectbl = new Array;
|
|
selectbl[0] = "sel";
|
|
selectbl[1] = "sel1";
|
|
selectbl[2] = "sel2";
|
|
selectbl[3] = "sel3";
|
|
selectbl[4] = "sel4";
|
|
selectbl[5] = "sel5";
|
|
selectbl[6] = "sel6";
|
|
selectbl[7] = "selform1";
|
|
selectbl[8] = "selform2";
|
|
selectbl[9] = "selform3";
|
|
|
|
document.onmousemove = position;
|
|
|
|
function hideselects(){
|
|
for(i=0;i<selectbl.length;i++){
|
|
if(document.getElementById(selectbl[i])){
|
|
document.getElementById(selectbl[i]).style.visibility = 'hidden';
|
|
}
|
|
}
|
|
}
|
|
|
|
function showselects(){
|
|
for(i=0;i<selectbl.length;i++){
|
|
if(document.getElementById(selectbl[i])){
|
|
document.getElementById(selectbl[i]).style.visibility = 'visible';
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function position(e)
|
|
{
|
|
x = e.pageX
|
|
y = e.pageY
|
|
}
|
|
|
|
function showinfos(txt)
|
|
{
|
|
hideselects();
|
|
position;
|
|
|
|
info = document.getElementById('infobulle').style;
|
|
|
|
txt = '<table class=\"infobulle\"><tr><td class=\"infobulletitle\">Aide :</td></tr><tr><td class=\"infobulle\">'+txt+'</td></tr></table>';
|
|
document.getElementById('infobulle').innerHTML = txt;
|
|
|
|
info.top = (y+10)+"px";
|
|
info.left = (x+10)+"px";
|
|
if(screen.availWidth <= 1024 && x > 850)
|
|
info.left = x-80;
|
|
|
|
info.visibility = 'visible';
|
|
}
|
|
|
|
|
|
function hideinfos()
|
|
{
|
|
document.getElementById('infobulle').style.visibility = 'hidden';
|
|
showselects();
|
|
}
|
|
|
|
function openimg(name,url)
|
|
{
|
|
linkimg = window.open(url,name,'resizable=yes,toolbar=no,scrollbar=no,width=50,height=50,top=0,left=0');
|
|
}
|
|
|
|
function toggleSpoiler(spoiler, action) {
|
|
var elements = spoiler.getElementsByTagName('div');
|
|
|
|
switch(action) {
|
|
case 'open':
|
|
elements[0].className = 'title off';
|
|
elements[1].className = 'title on';
|
|
elements[2].className = 'on';
|
|
break;
|
|
|
|
case 'close':
|
|
elements[0].className = 'title on';
|
|
elements[1].className = 'title off';
|
|
elements[2].className = 'off';
|
|
break;
|
|
}
|
|
}
|
|
|
|
$(function() {
|
|
|
|
|
|
//Ajout d'un lien sur les images qui sont reduites par min-width
|
|
var virtualImg = new Image();
|
|
$(".news img, .topic img").one('load', function()
|
|
{
|
|
virtualImg.src = $(this).attr('src')
|
|
|
|
|
|
|
|
if($(this).attr('resized')!="true" && $(this).parent().get(0).tagName !="A" && virtualImg.width > $(this).css('max-width').slice(0,-2))
|
|
$(this).wrap('<a href="'+ $(this).attr('src') +'"></a>');
|
|
}).each(function() {
|
|
if(this.complete) $(this).load();
|
|
});
|
|
|
|
//formulaire de notation des programmes
|
|
//vars
|
|
var noteSelectionnee = -1
|
|
var LiensNote = $('.PrgmNote').find('div.boutonsNote').children('a')
|
|
|
|
//events
|
|
LiensNote.click(function() {
|
|
noteSelectionneUpdate($(this).parent().parent(), $(this).attr('note'), true)
|
|
return false;
|
|
})
|
|
LiensNote.mouseover(function() {
|
|
noteSelectionneUpdate($(this).parent().parent(), $(this).attr('note'))
|
|
})
|
|
LiensNote.mouseout(function() {
|
|
noteSelectionneUpdate($(this).parent().parent())
|
|
})
|
|
$('.PrgmNote').children("a.retourNote").click(function() {
|
|
|
|
|
|
|
|
if($('.PrgmNote').children("div").css('display') == 'block')
|
|
$('.PrgmNote').children("div").css('display','none');
|
|
else
|
|
$('.PrgmNote').children("div").css('display','block');
|
|
|
|
return false;
|
|
})
|
|
//fonctions
|
|
noteSelectionneUpdate = function(PrgmNoteDiv, note, clique)
|
|
{
|
|
if(note >= 0)
|
|
{
|
|
PrgmNoteDiv.find(".note").html(note + '/10')
|
|
if(clique){
|
|
PrgmNoteDiv.find(".note").css('font-weight','bold')
|
|
PrgmNoteDiv.find(".note").css('font-style','normal')
|
|
noteSelectionnee = note
|
|
PrgmNoteDiv.find("select").children('option[selected=selected]').removeAttr('selected')
|
|
PrgmNoteDiv.find("select").children('option[value=' + note + ']').attr('selected','selected')
|
|
}
|
|
else
|
|
{
|
|
PrgmNoteDiv.find(".note").css('font-style','italic')
|
|
PrgmNoteDiv.find(".note").css('font-weight','normal')
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(noteSelectionnee < 0)
|
|
{
|
|
PrgmNoteDiv.find(".note").html('')
|
|
}
|
|
else
|
|
{
|
|
PrgmNoteDiv.find(".note").css('font-weight','bold')
|
|
PrgmNoteDiv.find(".note").css('font-style','normal')
|
|
PrgmNoteDiv.find(".note").html(noteSelectionnee + '/10')
|
|
}
|
|
}
|
|
}
|
|
//init
|
|
$('.PrgmNote').find("select").css('display','none')
|
|
$('.PrgmNote').find(".boutonsNote").css('display','block')
|
|
$('.PrgmNote').children("div").css('display','none')
|
|
noteSelectionneUpdate($('.PrgmNote'), $('.PrgmNote').find("option[selected]").attr('value'), true)
|
|
|
|
//addthis retardateur
|
|
var isTimeFinish = false
|
|
var isOut = true;
|
|
function timeFinish(that)
|
|
{
|
|
isTimeFinish = true
|
|
that.mouseover()
|
|
}
|
|
|
|
$('.addthis_button').children('img').mouseenter(function() {
|
|
if(isTimeFinish)
|
|
{
|
|
clearTimeout(timeoutID);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
timeoutID = setTimeout(function(that){timeFinish(that);}, 200, $(this));
|
|
return false;
|
|
}
|
|
})
|
|
$('.addthis_button').children('img').mouseleave(function() {
|
|
isTimeFinish = false;
|
|
clearTimeout(timeoutID);
|
|
return true;
|
|
})
|
|
//antibot JS pour invité
|
|
$(document).ready(function(){
|
|
$('.messageForm').css('display','block');
|
|
$('.messageForm').children('form').append('<input type="hidden" name="jsActive" value="Oui"/>');
|
|
})
|
|
//Editeur - namespace:ed
|
|
//vars
|
|
var ed_boutons = $('.editeur').find('.boutons').find('img,td,span');
|
|
var ed_textarea = $('.editeur').find('textarea');
|
|
var ed_pins = $('.editeur').find('.pinhidden,.pinshow');
|
|
var ed_cross = $('.editeur').find('.cross');
|
|
var ed_inputs = $('.editeur').find('.AskBoxInputText');
|
|
var ed_smileys = $('.editeur').find('.ABsmiley').find('td');
|
|
//speciale IE
|
|
$(".editeur").data('isfocused',false);
|
|
$(".editeur").data('selecStart',0);
|
|
$(".editeur").data('selecEnd',0);
|
|
$(".editeur").data('isPinned',false);
|
|
$(".editeur").data('tag','');
|
|
//events
|
|
$('.editeur').find('.AskBoxBottom').children('img').click(function(){
|
|
ed_addtag($(this).closest(".editeur"));
|
|
});
|
|
$('.editeur').find('.ABprofil').click(function(){
|
|
var formname = $(this).closest('.editeur').data('formname');
|
|
fenetre=window.open('/Fr/compte/liste_des_membres.php?id=ed_'+formname+'_lienMembre','fenetre','resizable=yes,toolbar=no,scrollbars=yes,width=280,height=450,top=0,left=0')
|
|
});
|
|
|
|
ed_cross.click(function()//fermeture de toutes les askbox si on clique ailleur
|
|
{
|
|
close_AskBox($(this).closest(".editeur"),false);
|
|
});
|
|
|
|
$('.editeur').find('.edSelect').change(function(){
|
|
|
|
var tag = $(this).children('option:checked').val();
|
|
if(tag.length > 0)
|
|
add_text($(this).closest('.editeur').find('textarea'),'['+tag+']', '[/'+tag+']', '')
|
|
$(this).children('option').removeAttr('selected');
|
|
$(this).children('option[value=]').attr('selected','selected');
|
|
});
|
|
|
|
ed_pins.click(function(){
|
|
var editeur = $(this).closest(".editeur");
|
|
if(editeur.data('isPinned')==false)
|
|
{
|
|
editeur.data('isPinned',true);
|
|
$(this).css('display','none');
|
|
$(this).parent().children('.pinshow').css('display','block');
|
|
}
|
|
else
|
|
{
|
|
editeur.data('isPinned',false);
|
|
$(this).css('display','none');
|
|
$(this).parent().children('.pinhidden').css('display','block');
|
|
}
|
|
});
|
|
|
|
|
|
ed_boutons.click(function(){
|
|
if($(this).data('type')=='text')
|
|
{
|
|
add_text($(this).closest(".editeur").find('textarea'), $(this).data('avant'),$(this).data('apres'),$(this).data('valeur'));
|
|
}
|
|
else if($(this).data('type')=='askbox')
|
|
{
|
|
show_AskBox($(this).closest(".editeur"), $(this).data('name'))
|
|
}
|
|
});
|
|
|
|
ed_smileys.click(function(){
|
|
if($(this).data('type')=='text')
|
|
{
|
|
add_text($(this).closest(".editeur").find('textarea'), $(this).data('avant'),$(this).data('apres'),$(this).data('valeur'));
|
|
}
|
|
else if($(this).data('type')=='askbox')
|
|
{
|
|
show_AskBox($(this).closest(".editeur"), $(this).data('name'))
|
|
}
|
|
close_AskBox($(this).closest(".editeur"));
|
|
});
|
|
|
|
ed_inputs.keypress(function(e) {
|
|
if(e.which == 13) {
|
|
ed_addtag($(this).closest(".editeur"));
|
|
return false;
|
|
}
|
|
});
|
|
|
|
ed_textarea.focus(function(){
|
|
$(this).closest(".editeur").data('isfocused',true);
|
|
});
|
|
ed_textarea.blur(function(){
|
|
$(this).closest(".editeur").data('isfocused',false);
|
|
});
|
|
//Askbox fonctions
|
|
//affiche une askbox
|
|
function show_AskBox(editeur, AskBoxName)
|
|
{
|
|
close_AskBox(editeur, false,false);
|
|
var AskBox = editeur.children('.AskBox');
|
|
var actualAskBox = AskBox.children('.AskBoxText.AB'+AskBoxName);
|
|
var textarea = editeur.find('textarea')[0];
|
|
var title = "";
|
|
editeur.data('tag',AskBoxName);
|
|
//Get selected text
|
|
var selectedText = '';
|
|
if(typeof document.selection != 'undefined')//IE support
|
|
{
|
|
var range = document.selection.createRange();
|
|
selectedText=range.text;
|
|
}
|
|
else if(typeof textarea.selectionStart != 'undefined')//Firefox, GC support
|
|
{
|
|
selectedText=textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);
|
|
}
|
|
//Open the askbox
|
|
switch(AskBoxName)
|
|
{
|
|
case 'url' :
|
|
var title = "Ajouter un lien";
|
|
var focusOn = null;
|
|
if(selectedText.substring(0,7)=="http://" || selectedText.substring(0,8)=="https://" || selectedText.substring(0,6)=="ftp://")
|
|
{
|
|
actualAskBox.find('.AskBoxInputText[name=ed-urlLien]').val(selectedText);
|
|
focusOn = actualAskBox.find('.AskBoxInputText[name=ed-urlNom]');
|
|
}
|
|
else
|
|
{
|
|
actualAskBox.find('.AskBoxInputText[name=ed-urlNom]').val(selectedText);
|
|
focusOn = actualAskBox.find('.AskBoxInputText[name=ed-urlLien]').val("http://");
|
|
}
|
|
break;
|
|
case 'img' :
|
|
title = "Ajouter une image";
|
|
actualAskBox.find('.AskBoxInputRadio[name=ed-imgType][value=img]').prop('checked', true);
|
|
actualAskBox.find('.AskBoxInputRadio[name=ed-imgAlign][value=center]').prop('checked', true);
|
|
if(selectedText.substring(0,7)=="http://" || selectedText.substring(0,8)=="https://" || selectedText.substring(0,6)=="ftp://")
|
|
{
|
|
focusOn = actualAskBox.find('.AskBoxInputText[name=ed-imgAdresse]').val(selectedText);
|
|
}
|
|
else
|
|
{
|
|
focusOn = actualAskBox.find('.AskBoxInputText[name=ed-imgAdresse]').val("http://");
|
|
}
|
|
break;
|
|
case 'video' :
|
|
title = "Ajouter une vidéo";
|
|
actualAskBox.find('.AskBoxInputRadio[name=ed-videoType][value=video]').prop('checked', true);
|
|
if(selectedText.substring(0,7)=="http://" || selectedText.substring(0,8)=="https://")
|
|
focusOn = actualAskBox.find('.AskBoxInputText[name=ed-videoAdresse]').val(selectedText);
|
|
else
|
|
focusOn = actualAskBox.find('.AskBoxInputText[name=ed-videoAdresse]').val("http://");
|
|
break;
|
|
case 'profil' :
|
|
title = "Ajouter un lien vers un profil";
|
|
focusOn = actualAskBox.find('.AskBoxInputText[name=ed-profilPseudo]').val(selectedText);
|
|
break;
|
|
case 'quote' :
|
|
title = "Citer";
|
|
focusOn = actualAskBox.find('.AskBoxInputText[name=ed-quoteAuteur]');
|
|
break;
|
|
case 'spoiler' :
|
|
title = "Ajouter un spoiler";
|
|
focusOn = actualAskBox.find('.AskBoxInputText[name=ed-spoilerOpen]');
|
|
break;
|
|
case 'progress' :
|
|
title = "Ajouter une barre de progression";
|
|
focusOn = actualAskBox.find('.AskBoxInputText[name=ed-progressTitle]').val(selectedText);
|
|
break;
|
|
case 'smiley' :
|
|
title = "Plus de smileys !";
|
|
AskBox.children('.AskBoxBottom').css('display','none');
|
|
break;
|
|
}
|
|
AskBox.children('.AskBoxTop').children('span').html(title);
|
|
// AskBox.css('display','block');
|
|
editeur.children('.AskBox').show('fast');
|
|
actualAskBox.css('display','block');
|
|
if(focusOn!=null)focusOn.focus();
|
|
}
|
|
// masque tous les askbox(en verifiant s'ils sont pinned si verif=true)
|
|
function close_AskBox(editeur, verif, anim)
|
|
{ if(anim != false)anim = true;
|
|
if(editeur.data('isPinned')==false || verif==false)
|
|
{
|
|
editeur.children('.AskBox').children('.AskBoxBottom').css('display','block');
|
|
if(anim)
|
|
editeur.children('.AskBox').hide('fast');
|
|
else
|
|
editeur.children('.AskBox').css('display','non');
|
|
|
|
editeur.children('.AskBox').children('.AskBoxText').css('display','none');
|
|
editeur.data('tag','');
|
|
editeur.data('isPinned',false);
|
|
editeur.find('.pinshow').css('display','none');
|
|
editeur.find('.pinhidden').css('display','block');
|
|
}
|
|
}
|
|
//Validation des askbox
|
|
function ed_addtag(editeur)
|
|
{
|
|
var tag = editeur.data('tag');
|
|
var valeur='';
|
|
var valeurSup='';
|
|
// var selectionVide=true;
|
|
var cursorAtEnd=false;
|
|
|
|
switch(tag)
|
|
{
|
|
case 'url':
|
|
valeur=editeur.find('.AskBoxInputText[name=ed-urlNom]').val();
|
|
valeurSup=editeur.find('.AskBoxInputText[name=ed-urlLien]').val();
|
|
if(valeur==""){valeur=valeurSup;cursorAtEnd=false;}else cursorAtEnd=true;
|
|
valeurSup="="+valeurSup;
|
|
break;
|
|
case 'img' :
|
|
//adimg
|
|
if(editeur.find('.AskBoxInputRadio[name=ed-imgType]:checked').val() == "adimg")
|
|
tag = "adimg";
|
|
//get value
|
|
valeur=editeur.find('.AskBoxInputText[name=ed-imgAdresse]').val();
|
|
//prepare valeurSup
|
|
valeurSup = "=";
|
|
var premierArg= true;
|
|
var largeur = parseInt(editeur.find('.AskBoxInputText[name=ed-imgWidth]').val());
|
|
if(largeur > 0)//if int
|
|
{
|
|
valeurSup += largeur;
|
|
premierArg = false;
|
|
}
|
|
var hauteur = parseInt(editeur.find('.AskBoxInputText[name=ed-imgHeight]').val());
|
|
if(hauteur > 0)//if int
|
|
{
|
|
valeurSup += "x" + hauteur;
|
|
premierArg = false;
|
|
}
|
|
var align = editeur.find('.AskBoxInputRadio[name=ed-imgAlign]:checked').val()
|
|
if(align.length >0)
|
|
{
|
|
if(premierArg==false){valeurSup += "|"}
|
|
valeurSup += align;
|
|
premierArg = false;
|
|
}
|
|
if(premierArg){valeurSup = ""}
|
|
cursorAtEnd=true;
|
|
break;
|
|
case 'video' :
|
|
valeur=editeur.find('.AskBoxInputText[name=ed-videoAdresse]').val();
|
|
if(editeur.find('.AskBoxInputRadio[name=ed-videoType]:checked').val() == "video tiny")
|
|
tag = "video mini";
|
|
cursorAtEnd=true;
|
|
break;
|
|
case 'profil' :
|
|
valeur = editeur.find('.AskBoxInputText[name=ed-profilPseudo]').val();
|
|
if(valeur.length > 0) cursorAtEnd=true;
|
|
break;
|
|
case 'quote' :
|
|
valeurSup = editeur.find('.AskBoxInputText[name=ed-quoteAuteur]').val();
|
|
if(valeurSup!="")valeurSup="="+valeurSup;
|
|
break;
|
|
case 'spoiler':
|
|
valeurSup = "=" + editeur.find('.AskBoxInputText[name=ed-spoilerOpen]').val() + "|" + editeur.find('.AskBoxInputText[name=ed-spoilerClose]').val();
|
|
if(valeurSup == '=Cliquer pour dérouler|Cliquer pour enrouler')
|
|
valeurSup = "";
|
|
break;
|
|
case 'progress':
|
|
valeur= editeur.find('.AskBoxInputText[name=ed-progressTitle]').val();
|
|
if(valeur.length <=0)
|
|
{
|
|
alert('Le titre de la barre de progression est obligatoire.');
|
|
editeur.find('.AskBoxInputText[name=ed-progressTitle]').focus();
|
|
return;
|
|
}
|
|
valeurSup= parseInt(editeur.find('.AskBoxInputText[name=ed-progressPourcent]').val());
|
|
if(!valeurSup>=1 && !valeurSup<=100)
|
|
{
|
|
alert('Le pourcentage de la barre de progression est obligatoire et doit être compris entre 1 et 100');
|
|
editeur.find('.AskBoxInputText[name=ed-progressPourcent]').focus();
|
|
return;
|
|
}
|
|
valeurSup="="+valeurSup;
|
|
cursorAtEnd=true;
|
|
break;
|
|
}
|
|
//fermeture des askbox
|
|
close_AskBox(editeur);
|
|
//Envoi sur le textarea
|
|
if(cursorAtEnd){add_text(editeur.find('textarea'), '[' + tag + valeurSup + ']'+ valeur +'[/' + tag + ']')}
|
|
else{add_text(editeur.find('textarea'), '[' + tag + valeurSup + ']','[/' + tag + ']',valeur)}
|
|
}
|
|
//IE compatibility
|
|
document.onmouseup = updateIECursorPosition;
|
|
document.onkeydown = updateIECursorPosition;
|
|
function updateIECursorPosition()//IE - detection de la position du curseur pour IE qu'il l'oublie quand on clique autrepart que sur le textarea..
|
|
{
|
|
$('.editeur').each(function(){
|
|
var thisTxtarea = $(this).find('textarea');
|
|
if($(this).data('isfocused') && typeof(thisTxtarea[0].createTextRange) == 'function')
|
|
{
|
|
var range = thisTxtarea[0].createTextRange();
|
|
range.moveToBookmark(document.selection.createRange().getBookmark());
|
|
range.moveEnd('character', thisTxtarea[0].value.length);
|
|
$(".editeur").data('selecStart',(thisTxtarea[0].value.length - range.text.length))
|
|
|
|
var range = thisTxtarea[0].createTextRange();
|
|
range.moveToBookmark(document.selection.createRange().getBookmark());
|
|
range.moveStart('character', - thisTxtarea[0].value.length);
|
|
$(".editeur").data('selecEnd',range.text.length);
|
|
}
|
|
});
|
|
}
|
|
|
|
//general textarea functions
|
|
function add_text(textarea, before, after, valeur)
|
|
{
|
|
selecStart = textarea.data('selecStart');
|
|
selecEnd = textarea.data('selecEnd');
|
|
if(before==null){before='';}
|
|
if(after==null){after='';}
|
|
if(valeur==null){valeur='';}
|
|
if(typeof document.selection != 'undefined')//IE support
|
|
{
|
|
var insText;
|
|
textarea.focus();
|
|
if(selecStart!=null && selecEnd!=null)
|
|
{ var range = document.selection.createRange();
|
|
if (textarea[0].setSelectionRange)
|
|
textarea[0].setSelectionRange(selecStart, selecEnd);
|
|
else if (document.selection) {
|
|
var range = textarea[0].createTextRange();
|
|
range.moveStart('character', selecStart);
|
|
range.moveEnd('character', - textarea[0].value.length + selecEnd);
|
|
range.select();
|
|
}
|
|
}
|
|
|
|
textarea.focus();
|
|
range = document.selection.createRange();
|
|
if(valeur!=''){insText=valeur;}else{insText = range.text;}
|
|
if(after=='' && valeur=='')
|
|
{
|
|
range.text = before;
|
|
range.select();
|
|
}
|
|
else
|
|
{
|
|
range.text = before + insText + after ;
|
|
range.moveStart('character', -after.length -insText.length);
|
|
range.moveEnd('character', -after.length);
|
|
range.select();
|
|
}
|
|
|
|
}
|
|
else if(typeof textarea[0].selectionStart != 'undefined')//Firefox, GC support
|
|
{
|
|
var start = textarea[0].selectionStart;
|
|
var end = textarea[0].selectionEnd;
|
|
var insText;
|
|
if(valeur!='')
|
|
insText=valeur;
|
|
else
|
|
insText = textarea.val().substring(start, end);
|
|
|
|
if(after=='' && valeur=='')
|
|
{
|
|
textarea.val(textarea.val().substr(0, start) + before + textarea.val().substr(end));
|
|
textarea[0].selectionStart = start + before.length;
|
|
textarea[0].selectionEnd = start + before.length;
|
|
}
|
|
else
|
|
{
|
|
textarea.val(textarea.val().substr(0, start) + before + insText + after + textarea.val().substr(end));
|
|
textarea[0].selectionStart = start + before.length;
|
|
textarea[0].selectionEnd = start + before.length + insText.length;
|
|
}
|
|
|
|
textarea.focus();
|
|
}
|
|
else
|
|
{
|
|
textarea.val(before + valeur + after);
|
|
textarea.focus();
|
|
}
|
|
}
|
|
|
|
// Preview button on textarea
|
|
$('.pctextarea_preview').on('shown.bs.modal', function () {
|
|
const message = $(this).parent().find('.editeurTextareaDiv > textarea').val();
|
|
const body = $(this).find('.modal-body');
|
|
$.post('/Fr/forums/preview.php', {message}, function(data, status) {
|
|
body.html(data.preview);
|
|
})
|
|
.fail(function() {
|
|
body.html('<p class="align-center">Erreur pendant la récupération de la prévisualisation.</p>');
|
|
});
|
|
})
|
|
|
|
//fonction citer dans le forum
|
|
$('.lien_citation').click(function(){
|
|
var auteur = $(this).data('membre');
|
|
var id_message = $(this).data('id');
|
|
var textarea = $('textarea[name=message]');
|
|
$.ajax({type: "POST",
|
|
url: '/Fr/forums/quote.php',
|
|
data: {id : id_message}
|
|
}).done(function( msg )
|
|
{
|
|
add_text(textarea,'[quote=' + auteur + ']' + msg + '[/quote]','','');
|
|
});
|
|
});
|
|
|
|
//bouton d'affichage des stats
|
|
$('#stats').click(function(){
|
|
window.open($(this).attr('href'),'connectes','resizable=yes,toolbar=no,scrollbars=yes,width=550,height=300,top=0,left=0')
|
|
return false;
|
|
});
|
|
//Lien de control de la fenetre principale depuis un popoup
|
|
$('.popuplink').click(function(){
|
|
window.opener.location.href=$(this).data('link');return false;
|
|
return false;
|
|
});
|
|
|
|
|
|
/**
|
|
* Confirmation modal
|
|
*
|
|
* Add the 'need-confirm' class to a link to show a prompt asking for confirmation.
|
|
* 'data-confirm-text' attribute can be used to customize the confirm message
|
|
*/
|
|
$('a.need-confirm').click(function(){
|
|
const modal = $('#confirm-modal');
|
|
|
|
// Get text from 'data-confirm-text' arg
|
|
let text = 'Êtes-vous sûr de vouloir continuer ?';
|
|
console.log($(this).data())
|
|
if ($(this).data('confirm-text')) {
|
|
text = $(this).data('confirm-text');
|
|
}
|
|
modal.find('.confirm-modal-text').first().html(text)
|
|
|
|
// Set "Yes" link to original href of $(this)
|
|
modal.find('.confirm-modal-yes').first().attr('href', $(this).attr('href'))
|
|
|
|
// Configure and open modal
|
|
$('#confirm-modal').modal('show');
|
|
|
|
return false;
|
|
});
|
|
});
|
|
|
|
|