<commit_before>$(document).ready(function() {
    
    var idUser = 1;
    var sessionId = "token";

    $("#login").on("click", function() {
        console.log("login");
    });

    //EVENT NAVTAB
    $('#navCalendarEvent a').click(function(e) {
        e.preventDefault();
        $(this).tab('show');
    });

   
    //for each element that is classed as 'pull-down', set its margin-top to the difference between its own height and the height of its parent
    $('.pull-down').each(function() {
        $(this).css('margin-top', $(this).parent().height() - $(this).height() - 18);
    });
});

function getFullPartDate(number) {
    return ((number + 1) < 10 ? "0" + (number + 1) : (number + 1));
}

function getRappels(id, sessionId)
{
    var result = SoapManager("RecupererRappel", {"id": id, "token": sessionId});
    var resultat = result.find("Resultat");
    var erreur = result.find("Erreur");
    if (resultat.text() === "true" && erreur.text() === "")
    {
        var array = new Array();
        result.find("Rappels").find("item").each(function(index) {
            var debut = new Date($(this).find('Debut').text().trim() * 1000);
            var fin = new Date($(this).find('Fin').text().trim() * 1000);

            array.push(
                    {
                        "id": $(this).find('Id').text(),
                        "title": $(this).find('Titre').text(),
                        "location": $(this).find('Lieu').text(),
                        "start": {
                            date: debut.getFullYear() + "" + getFullPartDate(debut.getMonth() ) + "" + getFullPartDate(debut.getDate() - 1),
                            time: getFullPartDate(debut.getHours()) + ":" + getFullPartDate(debut.getMinutes())
                        },
                        "end": {
                            date: fin.getFullYear() + "" + getFullPartDate(fin.getMonth()) + "" + getFullPartDate(fin.getDate() - 1).toString(),
                            time: (getFullPartDate(fin.getHours()) + ":" + getFullPartDate(fin.getMinutes())).toString()
                        }
                    }
            );
        });
        return array;
        
    }
    else
    {
        //Erreur
        console.log(erreur.html());
    }
}



function addRappel(id, sessionId, title, location, begin, end)
{
    var result = SoapManager("CreerRappel", {"id": id, "token": sessionId, "titre": title, "lieu": location, "debut": begin, "fin": end});
    var resultat = result.find("Resultat");
    var erreur = result.find("Erreur");
    if (resultat.text() == "true" && erreur.text() == "")
    {
        return 1;
    }
    return 0;
}

function removeRappel(id, sessionId, rappelId)
{
    var result = SoapManager("SupprimerRappel", {"id": id, "token": sessionId, "rappelId": rappelId});
    var resultat = result.find("Resultat");
    var erreur = result.find("Erreur");
    if (resultat.text() == "true" && erreur.text() == "")
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

function getContacts(id, sessionId)
{
    var result = SoapManager("RecupererContacts", {"id": id, "token": sessionId});
    var resultat = result.find("Resultat");
    var erreur = result.find("Erreur");
    if (resultat.text() == "true" && erreur.text() == "")
    {
        var array = new Array();
        result.find("Contacts").find("item").each(function(index) {
            array.push(
                {
                    "name": $(this).find('Nom').text(),
                    "email": $(this).find('Email').text(),
                    "phone": $(this).find('Telephone').text(),
                    "location": $(this).find('Adresse').text()
                }
            );
        });
        return array;
    }
    else
    {
        console.log(erreur.html());
    }
}

function addContact(id, sessionId, name, email, phone, location)
{
    var result = SoapManager("AjouterContact", {"id": id, "token": sessionId, "nom": name, "email": email, "telephone": phone, "adresse": location});
    var resultat = result.find("Resultat");
    var erreur = result.find("Erreur");
    if (resultat.text() == "true" && erreur.text() == "")
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

function removeContact(id, sessionId, contactId, type)
{
    var result = SoapManager("SupprimerContact", {"id": id, "token": sessionId, "contactId": contactId, "type": type});
    var resultat = result.find("Resultat");
    var erreur = result.find("Erreur");
    if (resultat.text() == "true" && erreur.text() == "")
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

function validateContact(id, sessionId, contactId)
{
    var result = SoapManager("ValiderContact", {"id": id, "token": sessionId, "contactId": contactId});
    var resultat = result.find("Resultat");
    var erreur = result.find("Erreur");
    if (resultat.text() == "true" && erreur.text() == "")
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

function useTemplates(tmpl, context) {
    var template = Handlebars.compile(tmpl);
    var html = template(context);
    return html;
}


/**
 * 
 * @param {button} button
 * @returns {undefined}
 */
function buttonBehaviourSubmitDefault(button) {
    var message = "Valider";<commit_msg>Modification des appels aux webservices<commit_after>$(document).ready(function() {
    
    var idUser = 1;
    var sessionId = "token";

    $("#login").on("click", function() {
        console.log("login");
    });

    //EVENT NAVTAB
    $('#navCalendarEvent a').click(function(e) {
        e.preventDefault();
        $(this).tab('show');
    });

   
    //for each element that is classed as 'pull-down', set its margin-top to the difference between its own height and the height of its parent
    $('.pull-down').each(function() {
        $(this).css('margin-top', $(this).parent().height() - $(this).height() - 18);
    });
});

function getFullPartDate(number) {
    return ((number + 1) < 10 ? "0" + (number + 1) : (number + 1));
}

function getRappels(id, sessionId)
{
    var result = SoapManager("RecupererRappel", {"id": id, "token": sessionId});
    var resultat = result.find("Resultat");
    var erreur = result.find("Erreur");
    if (resultat.text() === "true" && erreur.text() === "")
    {
        var array = new Array();
        result.find("Rappels").find("item").each(function(index) {
            var debut = new Date($(this).find('Debut').text().trim() * 1000);
            var fin = new Date($(this).find('Fin').text().trim() * 1000);

            array.push(
                    {
                        "id": $(this).find('Id').text(),
                        "title": $(this).find('Titre').text(),
                        "location": $(this).find('Lieu').text(),
                        "start": {
                            date: debut.getFullYear() + "" + getFullPartDate(debut.getMonth() ) + "" + getFullPartDate(debut.getDate() - 1),
                            time: getFullPartDate(debut.getHours()) + ":" + getFullPartDate(debut.getMinutes())
                        },
                        "end": {
                            date: fin.getFullYear() + "" + getFullPartDate(fin.getMonth()) + "" + getFullPartDate(fin.getDate() - 1).toString(),
                            time: (getFullPartDate(fin.getHours()) + ":" + getFullPartDate(fin.getMinutes())).toString()
                        }
                    }
            );
        });
        return array;
        
    }
    else
    {
        //Erreur
        console.log(erreur.html());
    }
}



function addRappel(id, sessionId, title, location, begin, end)
{
    var result = SoapManager("CreerRappel", {"id": id, "token": sessionId, "titre": title, "lieu": location, "debut": begin, "fin": end});
    var resultat = result.find("Resultat");
    var erreur = result.find("Erreur");
    if (resultat.text() == "true" && erreur.text() == "")
    {
        return 1;
    }
    return 0;
}

function removeRappel(id, sessionId, rappelId)
{
    var result = SoapManager("SupprimerRappel", {"id": id, "token": sessionId, "rappelId": rappelId});
    var resultat = result.find("Resultat");
    var erreur = result.find("Erreur");
    if (resultat.text() == "true" && erreur.text() == "")
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

function getContacts(id, sessionId)
{
    var result = SoapManager("RecupererContacts", {"id": id, "token": sessionId});
    var resultat = result.find("Resultat");
    var erreur = result.find("Erreur");
    if (resultat.text() == "true" && erreur.text() == "")
    {
        var array = new Array();
        result.find("Contacts").find("item").each(function(index) {
            array.push(
                {
                    "id": $(this).find('Id').text(),
                    "name": $(this).find('Nom').text(),
                    "email": $(this).find('Email').text(),
                    "phone": $(this).find('Telephone').text(),
                    "location": $(this).find('Adresse').text(),
                    "type": $(this).find('Type').text()
                }
            );
        });
        return array;
    }
    else
    {
        console.log(erreur.html());
    }
}

function addContact(id, sessionId, name, email, phone, location)
{
    var result = SoapManager("AjouterContact", {"id": id, "token": sessionId, "nom": name, "email": email, "telephone": phone, "adresse": location});
    var resultat = result.find("Resultat");
    var erreur = result.find("Erreur");
    if (resultat.text() == "true" && erreur.text() == "")
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

function removeContact(id, sessionId, contactId, type)
{
    var result = SoapManager("SupprimerContact", {"id": id, "token": sessionId, "contactId": contactId, "type": type});
    var resultat = result.find("Resultat");
    var erreur = result.find("Erreur");
    if (resultat.text() == "true" && erreur.text() == "")
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

function validateContact(id, sessionId, contactId, bool)
{
    var result = SoapManager("ValiderContact", {"id": id, "token": sessionId, "contactId": contactId, "valider": bool});
    var resultat = result.find("Resultat");
    var erreur = result.find("Erreur");
    if (resultat.text() == "true" && erreur.text() == "")
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

function getContactRequest(id, sessionId)
{
    var result = SoapManager("RecupererDemandesContact", {"id": id, "token": sessionId});
    var resultat = result.find("Resultat");
    var erreur = result.find("Erreur");
    if (resultat.text() == "true" && erreur.text() == "")
    {
        var array = new Array();
        result.find("Contacts").find("item").each(function(index) {
            array.push(
                {
                    "id": $(this).find('Id').text(),
                    "name": $(this).find('Nom').text(),
                    "type": $(this).find('Type').text()
                }
            );
        });
        return array;
    }
    else
    {
        console.log(erreur.html());
    }
}

function useTemplates(tmpl, context) {
    var template = Handlebars.compile(tmpl);
    var html = template(context);
    return html;
}


/**
 * 
 * @param {button} button
 * @returns {undefined}
 */
function buttonBehaviourSubmitDefault(button) {
    var message = "Valider";
{'fraction_non_alphanumeric': 0.1832140987611237, 'fraction_numerical': 0.005060198918164369, 'mean_word_length': 2.180632630410655, 'pattern_counts': {'":': 82, '<': 5, '<?xml version=': 0, '>': 3, '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': '726132', 'n_tokens_mistral': 3635, 'n_tokens_neox': 3548, 'n_words': 726}