Commit 56930c06 authored by Julien Sailly's avatar Julien Sailly
Browse files

fix: validation button

parent 7744eb7e
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
@@ -386,6 +386,7 @@ function validateAllCombination() {
                zoneElement.style.backgroundColor = "rgb(254 202 202)";
                console.log("taille");
                valid = false;
                return;
            }
            zoneElement.childNodes.forEach((elementB) => {
                if (
@@ -395,6 +396,7 @@ function validateAllCombination() {
                    zoneElement.style.backgroundColor = "rgb(254 202 202)";
                    console.log("PB");
                    valid = false;
                    return;
                }
            });
            let children = zoneElement.childNodes;
@@ -403,9 +405,16 @@ function validateAllCombination() {
                    counterCheck++;
                    zoneElement.style.backgroundColor = "rgb(229 231 235)";
                    valid = true;
                    return;
                }
            }
            for (let i = 0; i < children.length; i++) {
                if (children[i].id.split(",")[1] === "PB" && children.length > 2) {
                    zoneElement.style.backgroundColor = "rgb(254 202 202)";
                    console.log("PB");
                    valid = false;
                    return;
                }
                let targetItemsSplit = children[i].id.split(",")[2];
                for (targetItemsSplit in validatePalanqueCombinate) {
                    for (let j = 0; j < children.length; j++) {
@@ -419,11 +428,13 @@ function validateAllCombination() {
                            zoneElement.style.backgroundColor =
                                "rgb(229 231 235)";
                            valid = true;
                            return;
                        }
                    }
                    zoneElement.style.backgroundColor = "rgb(254 202 202)";
                    console.log("combi ", targetItemsSplit);
                    valid = false;
                    return;
                }
            }

@@ -431,24 +442,28 @@ function validateAllCombination() {
            zoneElement.style.backgroundColor = "rgb(229 231 235)";
            console.log("vide");
            valid = false;
            return;
        }
    });
    if (zoneStart.childElementCount == 0 && valid == true) {
        disableVal = false;
    } else {
        disableVal = true;
    }
}

let interval = setInterval(function () {
    updateZoneList();
    validateAllCombination();
    console.log(disableVal);
    disableVal = false;
    document.querySelectorAll("#DropZone > div > div").forEach((element) => {
        if (element.style.backgroundColor === "rgb(254, 202, 202)") {
            disableVal = true;
            return;
        }
    });
}, 250);

validatePalanque.addEventListener("click", function () {
    if (!disableVal) {
        sendPalanque();
        clearInterval(interval);
        // clearInterval(interval);
    }
});