<commit_before>// -*- tab-width: 2 -*-

function affiche_ajax(data, status, jqXHR)
{
	aff_ico_sso();
	$(".tooltip").remove();
	$(".popover").remove();
  var maj_tooltip = false;
  $(data).find('section').each( function()
  {
  	switch(this.id)
  	{
  	case "modal":
		  var modal = document.getElementById("modal");
		  if( !modal )
		  {
		    var cont = document.getElementById("contenu");
		    modal = document.createElement("div");
		    modal.id = "modal";
		    modal.className = "modal fade";
		    modal.setAttribute("role", "dialog");
		    modal.tabIndex = "-1";
		    modal.setAttribute("aria-labelledby", "modalLabel");
		    cont.appendChild(modal);
		  }
    	modal.innerHTML =  this.innerHTML;
			$("#modal").modal('show');
			maj_tooltip = true;
  		break;
  	case 'recharger':
  		document.location=this.innerHTML.trim();
  		document.location.reload();
  	case 'maj_tooltips':
			maj_tooltip = true;
  		break;
  	case 'erreur':
  		aff_erreur(this.innerHTML, data);
  		break;
  	case 'javascript':
  		var script = creer_element("script", false, false, document.getElementsByTagName("body")[0], this.innerHTML);
  		script.setAttribute('type', 'text/javascript');
  	default:
    	$('#'+this.id).html( this.innerHTML );
			maj_tooltip = true;
		}
  });
  if( maj_tooltip )
  	maj_tooltips();
}

function aff_erreur(contenu, donnees, icone/*='bug'*/)
{
	if( icone == undefined )
		icone = 'bug';
	var cont = document.getElementById('contenu_jeu');
	var alerte = document.createElement('div');
	alerte.className = 'alert alert-danger alert-dismissable';
	cont.insertBefore(alerte, cont.firstChild);
	alerte.style = 'margin-top: 5px;'
	var btn = document.createElement('button');
	btn.className = 'close';
	btn.setAttribute('aria-hidden', 'true');
	btn.setAttribute('data-dismiss', 'alert');
	btn.type = 'button';
	btn.innerHTML = '&times;';
	alerte.appendChild(btn);
	var ico = document.createElement('a');
	ico.className = 'icone icone-'+icone;
	ico.setAttribute('onclick', '$("#erreur_recu").toggle();');
	ico.style = 'margin-right: 5px;'
	alerte.appendChild(ico);
	var txt = document.createElement('span');
	txt.innerHTML = contenu;
	alerte.appendChild(txt);
	var recept = document.createElement('div');
	recept.innerHTML = donnees;
	recept.id = 'erreur_recu';
	recept.style = 'display: none; border: dashed 1px; margin-top: 5px;';
	alerte.appendChild(recept);
}

function charger(page)
{
	//alert('charger:'+page);
	aff_ico_charger();
  $.get(page, "ajax=1", affiche_ajax);
	return false;
}

function charger_formulaire(id)
{
  var formul = $('#' + id);
  $.ajax({type:formul.attr("method"),url:formul.attr("action")+"&ajax=1",data:formul.serialize(),success:affiche_ajax});
	return false;
}

function verif_charger(url, texte)
{
	if( confirm(texte) )
		charger(url);
	return false;
}

function envoie_texte(dest, id)
{
	var texte = $("#"+id).html().trim();
	$.ajax({type:"post",url:dest+"&ajax=1",data:"texte="+decode_texte(texte),success:affiche_ajax});
	return false;
}

function charger_formulaire_texte(id, id_texte)
{
  var formul = $('#' + id);
	var texte = $("#"+id_texte).html().trim();
  var donnees = formul.serializeArray();
  donnees[donnees.length] = {name:"texte", value:decode_texte(texte)};
  $.ajax({type:"post",url:formul.attr("action")+"&ajax=1",data:donnees,success:affiche_ajax});
	return false;
}<commit_msg>Correction de la messagerie - Problème de conversion des caractères spéciaux HTML dans le message, avant envoi. - Problème d'encodage des paramètres de la requête POST.<commit_after>// -*- tab-width: 2 -*-

function affiche_ajax(data, status, jqXHR)
{
	aff_ico_sso();
	$(".tooltip").remove();
	$(".popover").remove();
  var maj_tooltip = false;
  $(data).find('section').each( function()
  {
  	switch(this.id)
  	{
  	case "modal":
		  var modal = document.getElementById("modal");
		  if( !modal )
		  {
		    var cont = document.getElementById("contenu");
		    modal = document.createElement("div");
		    modal.id = "modal";
		    modal.className = "modal fade";
		    modal.setAttribute("role", "dialog");
		    modal.tabIndex = "-1";
		    modal.setAttribute("aria-labelledby", "modalLabel");
		    cont.appendChild(modal);
		  }
    	modal.innerHTML =  this.innerHTML;
			$("#modal").modal('show');
			maj_tooltip = true;
  		break;
  	case 'recharger':
  		document.location=this.innerHTML.trim();
  		document.location.reload();
  	case 'maj_tooltips':
			maj_tooltip = true;
  		break;
  	case 'erreur':
  		aff_erreur(this.innerHTML, data);
  		break;
  	case 'javascript':
  		var script = creer_element("script", false, false, document.getElementsByTagName("body")[0], this.innerHTML);
  		script.setAttribute('type', 'text/javascript');
  	default:
    	$('#'+this.id).html( this.innerHTML );
			maj_tooltip = true;
		}
  });
  if( maj_tooltip )
  	maj_tooltips();
}

function aff_erreur(contenu, donnees, icone/*='bug'*/)
{
	if( icone == undefined )
		icone = 'bug';
	var cont = document.getElementById('contenu_jeu');
	var alerte = document.createElement('div');
	alerte.className = 'alert alert-danger alert-dismissable';
	cont.insertBefore(alerte, cont.firstChild);
	alerte.style = 'margin-top: 5px;'
	var btn = document.createElement('button');
	btn.className = 'close';
	btn.setAttribute('aria-hidden', 'true');
	btn.setAttribute('data-dismiss', 'alert');
	btn.type = 'button';
	btn.innerHTML = '&times;';
	alerte.appendChild(btn);
	var ico = document.createElement('a');
	ico.className = 'icone icone-'+icone;
	ico.setAttribute('onclick', '$("#erreur_recu").toggle();');
	ico.style = 'margin-right: 5px;'
	alerte.appendChild(ico);
	var txt = document.createElement('span');
	txt.innerHTML = contenu;
	alerte.appendChild(txt);
	var recept = document.createElement('div');
	recept.innerHTML = donnees;
	recept.id = 'erreur_recu';
	recept.style = 'display: none; border: dashed 1px; margin-top: 5px;';
	alerte.appendChild(recept);
}

function charger(page)
{
	//alert('charger:'+page);
	aff_ico_charger();
  $.get(page, "ajax=1", affiche_ajax);
	return false;
}

function charger_formulaire(id)
{
  var formul = $('#' + id);
  $.ajax({type:formul.attr("method"),url:formul.attr("action")+"&ajax=1",data:formul.serialize(),success:affiche_ajax});
	return false;
}

function verif_charger(url, texte)
{
	if( confirm(texte) )
		charger(url);
	return false;
}

function envoie_texte(dest, id)
{
	var html = $("#"+id).html().trim();
	var bbcodehtml = decode_texte(html);
	var texte = $('<div>').html(bbcodehtml).text();
	$.ajax({type:"post",url:dest+"&ajax=1",data:"texte="+encodeURIComponent(texte),success:affiche_ajax});
	return false;
}

function charger_formulaire_texte(id, id_texte)
{
  var formul = $('#' + id);
	var texte = $("#"+id_texte).html().trim();
  var donnees = formul.serializeArray();
  donnees[donnees.length] = {name:"texte", value:decode_texte(texte)};
  $.ajax({type:"post",url:formul.attr("action")+"&ajax=1",data:donnees,success:affiche_ajax});
	return false;
}
{'fraction_non_alphanumeric': 0.18619698058950396, 'fraction_numerical': 0.0031631919482386773, 'mean_word_length': 4.720394736842105, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3673113', 'n_tokens_mistral': 2568, 'n_tokens_neox': 2503, 'n_words': 435}