dudjima / Paramètrage

// ==UserScript==
// @name         Paramètrage
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Mise à jour des paramètres secure.weda.fr
// @author dudjima
// @match        https://secure.weda.fr/FolderSetting/PreferenceForm.aspx*
// @grant        none
// @license MIT
// ==/UserScript==

function select(selectId, optionValToSelect){
    var selectElement = document.getElementById(selectId);
    //Get the options.
    var selectOptions = selectElement.options;
    //Loop through these options using a for loop.
    for (var opt, j = 0; opt = selectOptions[j]; j++) {
        //If the option of value is equal to the option we want to select.
        if (opt.value == optionValToSelect) {
            //Select the option and break out of the for loop.
            selectElement.selectedIndex = j;
            break;
        }
    }
}

(function() {
    'use strict';
    var tableau_coche = ["ContentPlaceHolder1_CheckBoxUserPreferenceSuiteOnTopScreen",
                         "ContentPlaceHolder1_CheckBoxPageNoLimite",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceGrosTitre",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceFileStreamInTitle",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceShowEtiquette",
                         "ContentPlaceHolder1_CheckBoxCabinetPreferenceSignatureCompleteOnEvenement",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceShowImage",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceShowConseilInSynthese",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceAffichePrescriptionIndication",
                         "ContentPlaceHolder1_CheckBoxUserPreferencePrescriptionShowDiagnostic",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceNoSeeNewUser",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceJavaScriptAutoPrint",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceShowSameNomNaissanceUser",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceCloseAfterPrint",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceBufferImpressionShowSelectionFirst",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceBufferImpressionOnlyOwner",

                         "ContentPlaceHolder1_CheckBoxUserPreferenceGrossesseAutoCloture",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceGrossesseCongeReelSecu",

                         "ContentPlaceHolder1_CheckBoxCabinetPreferenceHasMedicamentStop",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceRenouvellementTC",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceShowGeneric",
                         "ContentPlaceHolder1_CheckBoxUserPreferencePrescriptionGras",
                         "ContentPlaceHolder1_CheckBoxUserPreferencePrescritionDciGras",
                         "ContentPlaceHolder1_CheckBoxUserPreferencePrescriptionDciSameLine",
                         "ContentPlaceHolder1_CheckBoxUserPreferencePrescriptionPrintAllergie",


                         //"ContentPlaceHolder1_RadioButtonListUserPreferenceLabelRospCategorie_0",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceAtcdImportant",
                         "ContentPlaceHolder1_CheckBoxUserPreferenceShowAlerteRequete"];

    var tableau_decoche = ["ContentPlaceHolder1_CheckBoxUserPreferenceAtcdHeredite"];

    var tableau_liste = [
        ["ContentPlaceHolder1_DropDownListUserPreferenceLastDestinationUploadEvent","3"],
        ["ContentPlaceHolder1_DropDownListUserPreferenceLabelAtcdTcTri","3"],
        ["ContentPlaceHolder1_DropDownListUserPreferenceLabelAtcdTri","3"],
        ["ContentPlaceHolder1_DropDownListUserPreferenceLabelPrescriptionDciShowMode","3"],
        ["ContentPlaceHolder1_DropDownListUserPreferencePrescriptionDCIHautBas","True"]];

    var textarea_valeursuivi = "Poids\nTaille\nIMC\nTAS\nTAD\nPC\nSatO2\nHbA1C\nFC";

    if (confirm("Parametrer par défaut ?")) {
        for (const id_coche of tableau_coche) {
            document.getElementById(id_coche).checked = true;
        }

        for (const id_decoche of tableau_decoche) {
            document.getElementById(id_decoche).checked = false;
        }
        document.getElementById('ContentPlaceHolder1_TextBoxUserPreferenceSuivi').value = textarea_valeursuivi;
        document.getElementById('ContentPlaceHolder1_TextBoxUserPreferenceEquivalentPC').value = "PC";
        for(const id_liste of tableau_liste){
            console.log("id : " + id_liste[1]);
            select(id_liste[0],id_liste[1]);
        }
    }

})();