var mode = 1; var data_table; var input_search = ""; // merge 2 objects function extend(obj, src) { for (var key in src) { if (src.hasOwnProperty(key)) obj[key] = src[key]; } return obj; } var headers = { bap: "ID\n\t\t\tN\xB0\n\t\t\tPage\n\t\t\tDate\n\t\t\tNom\n\t\t\tPrénom\n\t\t\tPère\n\t\t\tMère\n\t\t\tDomicile\n\t\t\tCommentaires\n\t\t\tParents ⓘ\n\t\t\tDécédé à ⓘ\n\t\t\texterne\n\t\t", mar: "ID\n\t\t\tN\xB0\n\t\t\tPage\n\t\t\tDate\n\t\t\tÉpoux\n\t\t\tPère\n\t\t\tMère\n\t\t\tDomicile\n\t\t\tÉpouse\n\t\t\tPère\n\t\t\tMère\n\t\t\tDomicile\n\t\t\tCommentaires\n\t\t\tEnfants ⓘ\n\t\t", dec: "N\xB0\n\t\t\tPage\n\t\t\tDate\n\t\t\tNom\n\t\t\tPrénom\n\t\t\tPère\n\t\t\tMère\n\t\t\tDomicile\n\t\t\tCommentaires\n\t\t" }; // options spécifiques pour les différents registres var datable_opt_spec_bap = { order: [ [3, "asc"] ], columnDefs: [{ "targets": [0,12], "visible": false, "searchable": false }, { "orderable": false, "targets": 10 },{ "targets":11, //"type":"num", "orderable": true, "searchable": false }], // surbrillance si bapteme autre paroisse "createdRow": function( row, data, dataIndex ) { if ( data[12] == "1" ) { $(row).addClass('externe'); } } } var datable_opt_spec_mar = { order: [ [3, "asc"] ], columnDefs: [{ "targets": [0], "visible": false, "searchable": false }, { "orderable": false, "targets": 13 }] } var datable_opt_spec_dec = { order: [ [2, "asc"] ] } // options globales var datatable_opt = { language: { processing: "Traitement en cours...", search: "Rechercher dans les résultats  :", lengthMenu: "Afficher _MENU_ résultats", info: "Résultats _START_ à _END_ sur _TOTAL_ résultats", infoEmpty: "Résultats 0 à 0 sur 0 résultats", infoFiltered: "(filtré de _MAX_ résultats au total)", infoPostFix: "", loadingRecords: "Chargement en cours...", zeroRecords: "Aucun résultat à afficher", emptyTable: "Aucune donnée disponible dans le tableau", paginate: { first: "Premier", previous: "Précédent", next: "Suivant", last: "Dernier", }, aria: { sortAscending: ": activer pour trier la colonne par ordre croissant", sortDescending: ": activer pour trier la colonne par ordre décroissant" } }, responsive: true, drawCallback: highlight_keywords }; var month_txt = new Array(); month_txt[0] = "janvier"; month_txt[1] = "février"; month_txt[2] = "mars"; month_txt[3] = "avril"; month_txt[4] = "mai"; month_txt[5] = "juin"; month_txt[6] = "juillet"; month_txt[7] = "août"; month_txt[8] = "septembre"; month_txt[9] = "octobre"; month_txt[10] = "novembre"; month_txt[11] = "décembre"; function highlight_keywords() { // keywords of the input results search if ($("#search_input").length) { var text_i = $("#search_input").val().trim(); $("#results").unmark(input_search, { // first unmark all old string "className": "highlight_input" }); if ($("#search_input").val() !== "") { for (var i = 0; i < text_i.split(" ").length; i++) { // mark the new string $("#results").mark(text_i.split(" ")[i], { "className": "highlight_input" }); } } input_search = text_i; } // keywords of the main search $('#results>tbody').find('td').each(function(i, el) { // add id attr as the soundex of the content var soundex_n = soundex($(el).html().split(" ")[0]); $(el).attr("id", soundex_n); }); var text = $("#input-search").val().trim(); var texts = text.split(" "); for (var i = 0; i < texts.length; i++) { if (texts[i].slice(-1) === "+") { texts[i] = texts[i].substring(0, texts[i].length - 1); } $("#results").mark(texts[i], { // mark the exact string "className": "highlight" }); if (texts[i].slice(-1) === "!") { // mark all soudex string var soundex_t = soundex(texts[i].substring(0, texts[i].length - 1)); $('#results>tbody').find('td').each(function(i, el) { var currentTdId = $(el).attr("id"); if (soundex_t === currentTdId) { var instance = new Mark(el); instance.mark($(el).html().split(" ")[0], { "className": "highlight" }); } }) } } } function soundex(name) { if (name === "") return ""; let s = []; let si = 1; let c; // ABCDEFGHIJKLMNOPQRSTUVWXYZ let mappings = "01230120022455012623010202"; s[0] = name[0].toUpperCase(); for (let i = 1, l = name.length; i < l; i++) { c = (name[i].toUpperCase()).charCodeAt(0) - 65; if (c >= 0 && c <= 25) { if (mappings[c] != '0') { if (mappings[c] != s[si - 1]) { s[si] = mappings[c]; si++; } if (si > 3) { break; } } } } if (si <= 3) { while (si <= 3) { s[si] = '0'; si++; } } return s.join(""); } function createCookie(value) { var d = new Date(); d.setTime(d.getTime() + (7 * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); document.cookie = "lang" + "=" + value + "; " + expires + ";path=/"; } function infos() { $.ajax({ type: "POST", url: 'form.php', data: "fonction=dateLimit", success: function(results) { results = JSON.parse(results); Swal.fire({ title: 'Informations', html: "L'indexation a été effectuée par Marc Pauchard à FribourgLes noms de famille sont adaptés à leur forme actuelle. Les prénoms en revanche sont gardés tel quel et en latin. En ce qui concerne les lieux, ils sont standardisés et normalisés. Si aucune indication concernant la paroisse est indiquée, cela indique que le lieu était situé dans la paroisse de Léchelles-Chandon.

Donées disponibles :
Baptêmes : "+results[0]+" à "+results[1]+"
Mariages : "+results[2]+" à "+results[3]+"
Décès : "+results[4]+" à "+results[5]+"

Sources image :
https://static.mycity.travel/manage/uploads/7/40/45972/574616c1abaaad16740d5cf203c07605e71d0d52_3000.jpg
https://upload.wikimedia.org/wikipedia/commons/thumb/5/57/Plaffeien-coat_of_arms.svg/711px-Plaffeien-coat_of_arms.svg.png", type: 'info', customClass: "alert_info" }) } }); } function infos_search() { Swal.fire({ title: 'Informations', html: "Recherche phonétique (!) : Ajoutez un point d'exclamation à la fin du mot.
Par exemple : rämy! ruti! donne les mêmes résultats que raemy rütti
Ne fonctionne pas pour les prénoms

Mot complet (+) : Ajoutez un signe plus à la fin du mot.
Par exemple : joannes+ pour éviter de chercher aussi joannes josephus", type: 'info', customClass: "alert_info_search" }) } function infos_oops() { Swal.fire({ title: 'Informations', html: "Enfant possiblement conçu hors mariageLe baptême a été célébré à moins de neuf mois du mariage des parents", type: 'info', customClass: "alert_info_search" }) } function infos_enfants() { Swal.fire({ title: 'Avertissement', html: "La recherche des enfants d'un couples se fait uniquement dans les registres de baptême indéxés disponibles. La recherche se fait de manière automatique c'est pourquoi il est possible que certains résultats soient erroné. Si vous trouvez une erreur, merci de me la faire parvenir.", type: 'info', }) } function infos_parent() { Swal.fire({ title: 'Avertissement', html: "La recherche de parents se fait uniquement dans les registres de mariage indéxés disponible. La recherche se fait de manière automatique c'est pourquoi il est possible que certains résultats soient erroné. Si vous trouvez une erreur, merci de me la faire parvenir.", type: 'info', }) } function convertDateToText(date) { var environS = ""; if (date.charAt(date.length - 1) === "~") { environS = "~"; date = date.substring(0, date.length - 1); } if (date.split("-")[2] === "00" && date.split("-")[1] !== "00") { // si jour mais pas de mois return environS + month_txt[parseInt(date.split("-")[1]) - 1] + " " + date.split("-")[0] } else if (date.split("-")[1] === "00" && date.split("-")[2] !== "00") { // si mois mais pas de jour return environS + date.split("-")[2] + " ? " + date.split("-")[0]; } else if (date.split("-")[2] === "00" && date.split("-")[1] === "00") { // si aucun des 2 return environS + date.split("-")[0]; } else { // si ok var date = new Date(date); return environS + date.getDate() + " " + month_txt[date.getMonth()] + " " + date.getFullYear(); } } function daysDifference(d0, d1) { var diff = new Date(+(new Date(d1))).setHours(12) - new Date(+(new Date(d0))).setHours(12); var r = Math.round(diff/8.64e7); if(Number.isNaN(r)){ return 0; }else{ return r; } } //https://stackoverflow.com/questions/12251325/javascript-date-to-calculate-age-work-by-the-day-months-years function getAge(dateBText, dateDText) { var now = new Date(dateDText); var yearD = now.getYear(); var monthD = now.getMonth(); var dateD = now.getDate(); var dateB = new Date(dateBText); var yearDob = dateB.getYear(); var monthDob = dateB.getMonth(); var dateDob = dateB.getDate(); var age = {}; var ageString = ""; var yearString = ""; var monthString = ""; var dayString = ""; yearAge = yearD - yearDob; if (monthD >= monthDob) var monthAge = monthD - monthDob; else { yearAge--; var monthAge = 12 + monthD -monthDob; } if (dateD >= dateDob) var dateAge = dateD - dateDob; else { monthAge--; var dateAge = 31 + dateD - dateDob; if (monthAge < 0) { monthAge = 11; yearAge--; } } age = { years: yearAge, months: monthAge, days: dateAge }; if ( age.years > 1 ) yearString = " ans"; else yearString = " an"; if ( age.months> 1 ) monthString = " mois"; else monthString = " mois"; if ( age.days > 1 ) dayString = " jours"; else dayString = " jour"; if((age.years == 0) && (age.months == 0) && (age.days == 0)) return "Le même jour"; if ( (age.years > 0) && (age.months > 0) && (age.days > 0) ) ageString = age.years + yearString + ", " + age.months + monthString + ", et " + age.days + dayString; else if ( (age.years == 0) && (age.months == 0) && (age.days > 0) ) ageString = age.days + dayString; else if ( (age.years > 0) && (age.months == 0) && (age.days == 0) ) ageString = age.years + yearString; else if ( (age.years > 0) && (age.months > 0) && (age.days == 0) ) ageString = age.years + yearString + " et " + age.months + monthString; else if ( (age.years == 0) && (age.months > 0) && (age.days > 0) ) ageString = age.months + monthString + " et " + age.days + dayString; else if ( (age.years > 0) && (age.months == 0) && (age.days > 0) ) ageString = age.years + yearString + " et " + age.days + dayString; else if ( (age.years == 0) && (age.months > 0) && (age.days == 0) ) ageString = age.months + monthString; else ageString = ""; return ageString; } function displayBapt(results) { var html = ""; for (var i = 0; i < results.length; i++) { var date = convertDateToText(results[i][3]); html += "" + results[i][0] + ""; if (results[i][1] === 0) { html += ""; } else { html += "" + results[i][1] + ""; } if (results[i][2] === 0) { html += ""; } else { html += "" + results[i][2] + ""; } if(results[i][14]===1){ html += "" + date + "  ⓘ"; }else{ html += "" + date + ""; } html += "" + results[i][4] + ""; html += "" + results[i][5] + ""; html += "" + results[i][6] + " " + results[i][7] + ""; html += "" + results[i][8] + " " + results[i][9] + ""; html += "" + results[i][10] + ""; html += "" + results[i][11] + ""; if (results[i][12] !== 0) { html += ""; } else { html += ""; } if (results[i][15] !== null) { //html += ""; html += ""+getAge(results[i][3],results[i][15]) +"
"+""; } else { html += ""; } html += "" + results[i][17] + ""; html += ""; } $("#results").html(headers.bap); $("#tbody-results").html(html); $('#results').on('click', 'thead th', function(e) { // listener sur les header var i = data_table.column(this).index(); if (data_table.column(this).index() == 10) { // si le titre de la colonne avec les bouttons infos_parent(); } }); $("[data-toggle='tooltip']").tooltip({html: true}); } function displayMar(results) { var html = ""; for (var i = 0; i < results.length; i++) { var date = convertDateToText(results[i][3]); html += "" + results[i][0] + ""; if (results[i][1] === 0) { html += ""; } else { html += "" + results[i][1] + ""; } if (results[i][2] === 0) { html += ""; } else { html += "" + results[i][2] + ""; } html += "" + date + ""; html += "" + results[i][4] + " " + results[i][5] + ""; html += "" + results[i][6] + " " + results[i][4] + ""; html += "" + results[i][7] + " " + results[i][8] + ""; html += "" + results[i][9] + ""; html += "" + results[i][10] + " " + results[i][11] + ""; html += "" + results[i][12] + " " + results[i][10] + ""; html += "" + results[i][13] + " " + results[i][14] + ""; html += "" + results[i][15] + ""; html += "" + results[i][16] + ""; html += ""; html += ""; } $("#results").html(headers.mar); $("#tbody-results").html(html); $("#results td:nth-child(8)").addClass("border-mar"); // seprateur entre epoux et epouse $('#results').on('click', 'thead th', function(e) { // listener sur les header var i = data_table.column(this).index(); if (data_table.column(this).index() == 13) { // si le titre de la colonne avec les bouttons infos_enfants(); } }); } function displayDec(results) { var html = ""; for (var i = 0; i < results.length; i++) { var date = convertDateToText(results[i][3]); html += ""; if (results[i][1] === 0) { html += ""; } else { html += "" + results[i][1] + ""; } if(results[i][2]===0){ html += ""; }else{ html += "" +results[i][2] + ""; } html += "" + date + ""; html += "" + results[i][4] + ""; html += "" + results[i][5] + ""; html += "" + results[i][6] + " " + results[i][7] + ""; html += "" + results[i][8] + " " + results[i][9] + ""; html += "" + results[i][10] + ""; html += "" + results[i][11] + ""; html += ""; } $("#results").html(headers.dec); $("#tbody-results").html(html); } function search() { var text = $("#input-search").val().trim(); for (var i = 0; i < text.split(" ").length; i++) { if (text.split(" ")[i].length < 3) { Swal.fire({ title: 'Attention !', html: "Veuillez entrer des mots-clés d'au moins 3 lettres", type: 'warning' }) return; } } var dataString; if (mode == 1) { dataString = 'fonction=' + 'searchB' + '&text=' + encodeURIComponent(text); } else if (mode == 2) { dataString = 'fonction=' + 'searchM' + '&text=' + encodeURIComponent(text); } else if (mode == 3) { dataString = 'fonction=' + 'searchD' + '&text=' + encodeURIComponent(text); } $.ajax({ type: "POST", url: 'form.php', data: dataString, success: function(results) { results = JSON.parse(results); if (data_table != null) { data_table.destroy(); $("#results").html(""); } var datatable_opt_tmp = null; if (results && results.length) { if (mode == 1) { displayBapt(results); datatable_opt_tmp = $.extend(true, datatable_opt_tmp, datatable_opt, datable_opt_spec_bap); } else if (mode == 2) { displayMar(results); datatable_opt_tmp = $.extend(true, datatable_opt_tmp, datatable_opt, datable_opt_spec_mar); } else if (mode == 3) { displayDec(results); datatable_opt_tmp = $.extend(true, datatable_opt_tmp, datatable_opt, datable_opt_spec_dec); } data_table = $('#results').DataTable(datatable_opt_tmp); //init data table $('#results_filter label input').attr('id', 'search_input'); // add id to result search bar highlight_keywords(); $("#results").show(); } else { data_table = null; Swal.fire({ title: 'Aucun résultat', html: "Aucun résultat trouvé avec ce(s) mot(s)-clé(s) : " + text, type: 'warning' }) } } }); }; function searchDOfB(idD) { $.ajax({ type: "POST", url: 'form.php', data: 'fonction=searchDOfB' + '&id=' + idD, success: function(results) { results = JSON.parse(results); if (results && results.length) { if (data_table != null) { data_table.destroy(); $("#results").html(""); } displayDec(results); mode = 2; $("input#bapt").prop("checked", false).parent().removeClass("active"); $("input#mar").prop("checked", false).parent().removeClass("active"); $("input#dec").prop("checked", true).parent().addClass("active"); var datatable_opt_tmp = null; datatable_opt_tmp = $.extend(true, datatable_opt_tmp, datatable_opt, datable_opt_spec_dec); data_table = $('#results').DataTable(datatable_opt_tmp); //init data table highlight_keywords(); $("#results").show(); } } }); } function searchMOfB(idM) { $.ajax({ type: "POST", url: 'form.php', data: 'fonction=searchMOfB' + '&id=' + idM, success: function(results) { results = JSON.parse(results); if (results && results.length) { if (data_table != null) { data_table.destroy(); $("#results").html(""); } displayMar(results); mode = 2; $("input#bapt").prop("checked", false).parent().removeClass("active"); $("input#mar").prop("checked", true).parent().addClass("active"); $("input#dec").prop("checked", false).parent().removeClass("active"); var datatable_opt_tmp = null; datatable_opt_tmp = $.extend(true, datatable_opt_tmp, datatable_opt, datable_opt_spec_mar); data_table = $('#results').DataTable(datatable_opt_tmp); //init data table highlight_keywords(); $("#results").show(); } } }); } function searchBOfM(idB) { $.ajax({ type: "POST", url: 'form.php', data: 'fonction=searchBOfM' + '&id=' + idB, success: function(results) { results = JSON.parse(results); if (results && results.length) { if (data_table != null) { data_table.destroy(); $("#results").html(""); } displayBapt(results); mode = 1; $("input#bapt").prop("checked", true).parent().addClass("active"); $("input#mar").prop("checked", false).parent().removeClass("active"); $("input#dec").prop("checked", false).parent().removeClass("active"); var datatable_opt_tmp = null; datatable_opt_tmp = $.extend(true, datatable_opt_tmp, datatable_opt, datable_opt_spec_bap); data_table = $('#results').DataTable(datatable_opt_tmp); //init data table highlight_keywords(); $("#results").show(); } else { Swal.fire({ title: 'Aucun enfant trouvé', html: "Aucun enfant n'a été trouvé pour ce couple dans les registres de baptême de Léchelles-Chandon", type: 'warning' }) } } }); } function log() { var text = $("#input-search").val().trim(); $.ajax({ type: "POST", url: 'form.php', data: 'fonction=log' + '&text=' + encodeURIComponent(text) + '&mode=' + mode, success: function(results) { //console.log(results); } }); }; $(document).ready(function() { var isMobile = false; //initiate as false // device detection if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0, 4))) { isMobile = true; } // show popup if mobile if (isMobile) { $("h1").css("font-size", "5vw"); Swal.fire({ title: 'Attention !', html: "Ce site web n'est pas adapté pour les appareils mobiles. Pour en profiter pleinement, il est vivement conseillé d'utiliser un ordinateur", type: 'warning' }); } // add keyevent on the search bar when enter is pressed $('#input-search').keypress(function(event) { var keycode = (event.keyCode ? event.keyCode : event.which); if (keycode == '13') { search(); log(); } }); // add clickevent to change placeholder according to the mode $('input#bapt').change(function() { mode = 1; $("#input-search").attr("placeholder", "Nom, prénom ou domicile du baptisé"); }); $('input#mar').change(function() { mode = 2; $("#input-search").attr("placeholder", "Noms, prénoms ou domiciles des époux"); }); $('input#dec').change(function() { mode = 3; $("#input-search").attr("placeholder", "Nom, nom de jeune fille, prénom ou domicile du défunt"); }); $('button#stat').click(function() { $('#results').parents('div.dataTables_wrapper').first().fadeOut( "slow", function() {}); $("#search-container").fadeOut( "slow", function() { $("#stats-container").fadeIn( "slow", function() { displayStats(); }); }); }); $('button#return_search').click(function() { $("#stats-container").fadeOut( "slow", function() { $("#search-container").fadeIn( "slow", function() { }); $('#results').parents('div.dataTables_wrapper').first().fadeIn( "slow", function() {}); }); }); }); function customFormatter(val, opt, total) { return Math.round(((opt.w.config.series[0].data[opt.dataPointIndex] / total) * 100) * 10) / 10 + "%"; } function statsGeneral(callback) { $.ajax({ type: "POST", url: 'form.php', data: 'fonction=stats', success: function(results) { results = JSON.parse(results); if (results && results.length) { callback(results); } } }); } function displayStats(){ statsGeneral(function(results) { $("#stats_general").html( "\n\t\t\t\n\t\t\t Nombre\n\t\t\t " + results[0] + "" + "" + results[10] + "" + "" + results[1] + "" + "" + results[2] + "" + ""); $("#stats_general_1").html( "\n\t\t\t\n\t\t\t Moyenne" + "" + Math.round(results[3] * 10) / 10 + "" + "" + Math.round(results[4] * 10) / 10 + "" + "" + Math.round(results[5] * 10) / 10 + "" + ""); $("#stats_general_2").html( "\n\t\t\t\n\t\t\t Nombre" + "" + results[6] + "" + "" + results[7] + "" + "" + results[8] + "" + "" + results[9] + "" + "\n\t\t\t\n\t\t\t Pourcentage" + "" + Math.round(results[6] / results[0] * 100 * 100) / 100 + "%" + "" + Math.round(results[7] / results[ 0] * 100 * 100) / 100 + "%" + "" + Math.round( results[8] / results[1] * 100 * 100) / 100 + "%" + "" + Math.round(results[9] / results[0] * 100 * 100) / 100 + " %\n\t\t\t "); $("#loader_stats_gen").hide(); $("#div_stats_gen").show(); }); statBapPrenom(); statBapNom(); statBapGender(); statBapPrenomDifferentYear(); statBapMonth(); statBapYear(); statMarNom(); statMarPrenom(); statMarYear(); statDecPrenom(); statDecNom(); statDecGender(); statDecYear(); statDecMonth(); } function splitMaleFemale(results){ var arrM = []; var arrF = []; for(var i = 0; i < results[0].length; i++){ var arr2 = results[0][i].split(" "); for(var j = 0; j < arr2.length; j++){ arrM.push(arr2[j]); } } for(var i = 0; i < results[1].length; i++){ var arr2 = results[1][i].split(" "); for(var j = 0; j < arr2.length; j++){ arrF.push(arr2[j]); } } var rM = countOccurences(arrM); var rF = countOccurences(arrF); bubbleSort(rM[1],rM[0]); bubbleSort(rF[1],rF[0]); rM[1].reverse(); rM[0].reverse(); rM[1].length = 10; rM[0].length = 10; rF[1].reverse(); rF[0].reverse(); rF[1].length = 10; rF[0].length = 10; var r = []; r.push(rM); r.push(rF); r.push(results[0].length); r.push(results[1].length); return r; } function countOccurences(arr) { var a = [], b = [], prev; arr.sort(); for ( var i = 0; i < arr.length; i++ ) { if ( arr[i] !== prev ) { a.push(arr[i]); b.push(1); } else { b[b.length-1]++; } prev = arr[i]; } return [a, b]; } function bubbleSort(a,b) { var swapped; do { swapped = false; for (var i=0; i < a.length-1; i++) { if (a[i] > a[i+1]) { var temp = a[i]; a[i] = a[i+1]; a[i+1] = temp; var temp = b[i]; b[i] = b[i+1]; b[i+1] = temp; swapped = true; } } } while (swapped); }