Commit 3e974f1a authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Correction bug des caractères ' et " dans les element plus custom

parent 438097a8
Loading
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -32,6 +32,16 @@ $array = "[" . implode(",", $temp) . "]";
</div>

<script>
    function encodeHTMLEntitiesManual(str) {
        const map = {
            '&': '&amp;',
            '<': '&lt;',
            '>': '&gt;',
            '"': '&quot;',
            "'": '&#39;', // Apostrophe
        };
        return str.replace(/[&<>"']/g, match => map[match]);
    }

    function initTinymce() {
        tinymce.remove();
@@ -69,7 +79,7 @@ $array = "[" . implode(",", $temp) . "]";
    $(function () {
        let optionsText = '<?php echo $champ->getOptions(); ?>';
        let fields = readOptions(optionsText);
        let reponses = '<?php echo $reponse; ?>';
        let reponses = "<?php echo str_replace(["'",'"'],["\'", '\"'],$reponse); ?>";

        let dictionnary = [];
        let blob = reponses.split('|');
@@ -80,8 +90,8 @@ $array = "[" . implode(",", $temp) . "]";
        readOptions(optionsText);
        let sid = <?php echo $champ->getId(); ?>;

        console.log("Init du champ : " + sid);
        console.log(dictionnary);
        // console.log("Init du champ : " + sid);
        // console.log(dictionnary);
        if (dictionnary !== ['']) {
            for (let i = 0; i < dictionnary.length; i++) {
                if (dictionnary[i][0] !== "") {
@@ -118,6 +128,8 @@ $array = "[" . implode(",", $temp) . "]";
        return maximum;
    }



    function ajouter_PlusCustom(sid, fields, responses) {
        // console.log(fields);
        let id = sid;
@@ -138,8 +150,7 @@ $array = "[" . implode(",", $temp) . "]";

            texte += "<label for='" + inputId + "'> " + label + ":</label>";

            let temp_reponse = (responses !== undefined && responses[i] !== undefined) ? responses[i] : '';
            // console.log(temp_reponse);
            let temp_reponse = (responses !== undefined && responses[i] !== undefined) ? encodeHTMLEntitiesManual(responses[i]) : '';

            switch (type) {
                case "texte court" :