window.addEventListener('DOMContentLoaded', (event) => {
document.getElementsByClassName("submit_btn")[0].addEventListener('click', function(){
const retrait=document.getElementsByClassName("retrait")[0].value ;
const plaintes=document.getElementsByClassName("plaintes")[0].value ;
const depression=document.getElementsByClassName("depression")[0].value ;
const probleme_sociaux=document.getElementsByClassName("probleme_sociaux")[0].value ;
const probleme_pensee=document.getElementsByClassName("probleme_pensee")[0].value ;
const attention =document.getElementsByClassName("attention")[0].value ;
const delinquant=document.getElementsByClassName("delinquant")[0].value ;
const agressif=document.getElementsByClassName("agressif")[0].value ;
const sexuels = document.getElementsByClassName("sexuels ")[0].value ;
const ScoreTable= {
retraitSocial: retrait,
plaintesSomatique: plaintes,
depressionAnxiete: depression,
problemeSociaux: probleme_sociaux ,
problemePensee: probleme_pensee,
Attentionnels: attention,
comport_delinquant: delinquant,
comport_agressif:agressif,
prob_sexuels:sexuels }
console.log("retrait=", retrait) ;
console.log("plaintes somatiques= ", plaintes) ;
console.log("depression =" ,depression ) ;
console.log("problemes sociaux =", probleme_sociaux);
console.log("problemes de pensées =" , probleme_pensee);
console.log("attention = " , attention );
console.log("delinquant= ", delinquant) ;
console.log("agressif=", agressif) ;
console.log("sexuels=",sexuels);
console.log(ScoreTable) ;
function compareQuotients(a, b, c, d, e, f, g, h, i) {
const tableScore = [
{ retrait_Social: a/18 },
{ plaintes_Somatique: b/18 },
{ depression_Anxiete: c/26 },
{ probleme_Sociaux: d/16 },
{ probleme_Pensee: e/14 },
{ problemes_attentionnels: f/22 },
{ probleme_Delinquant: g/24 },
{ probleme_Agressif: h/36 },
{ prob_sexuelsl: i/12 } ];
const n = tableScore.length;
for (let i = 0; i < n-1; i++) {
for (let j = 0; j Object.values(tableScore[j+1])[0]) {
[tableScore[j], tableScore[j+1]] = [tableScore[j+1], tableScore[j]];
}
}
}
return tableScore;
}
const resultat = compareQuotients( retrait,plaintes, depression, probleme_sociaux,probleme_pensee, attention, delinquant, agressif, sexuels);
console.log(resultat);
domaine1= (Object.keys(resultat[resultat.length-1]))[0] ;
domaine2= (Object.keys(resultat[resultat.length-2]))[0] ;
console.log(domaine1) ;
console.log(domaine2) ;
const tableLien = [
{ retrait_Social: "https://auzyhelp.com/1" },
{ plaintes_Somatique: "https://auzyhelp.com/2"},
{ depression_Anxiete: "https://auzyhelp.com/3" },
{ probleme_Sociaux: "https://auzyhelp.com/4" },
{ probleme_Pensee: "https://auzyhelp.com/5" },
{ problemes_attentionnels: "https://auzyhelp.com/6" },
{ probleme_Delinquant: "https://auzyhelp.com/7" },
{ probleme_Agressif: "https://auzyhelp.com/8" },
{ prob_sexuelsl: "https://auzyhelp.com/9" } ];
let a = "'"+ domaine1+"'";
let b = "'"+ domaine2+"'";
let lien1, lien2;;
for (let i = 0; i < tableLien.length; i++) {
const obj = tableLien[i];
if (domaine1 in obj) {
lien1 = obj[domaine1];
}
if (domaine2 in obj) {
lien2= obj[domaine2];
}
}
console.log("lien1 = ", lien1);
console.log( "lien2 = ", lien2);
var link1 = "
" + domaine1 + "
";
var link2 = "
" + domaine2 + "
";
var msg= "vous avez des valeurs maximales dans les domaines suivants "+ link1+" et "+link2;
console.log(msg) ;
const affichage= document.getElementsByClassName("resultat")[0] ;
affichage.value=msg ;
const url1 = document.getElementsByClassName("lien1")[0] ;
const url2 = document.getElementsByClassName("lien2")[0] ;
url1.value= lien1 ;
url2.value=lien2 ;
const d1 = document.getElementsByClassName("echelle1")[0] ;
const d2 = document.getElementsByClassName("echelle2")[0] ;
d1.value = domaine1 ;
d2.value = domaine2;
});
});