diff --git a/modules/builder/main.js b/modules/builder/main.js index 3f7947d..2a0c3fb 100644 --- a/modules/builder/main.js +++ b/modules/builder/main.js @@ -23,19 +23,30 @@ async function startInBuilder() { warningIcon.innerHTML = "!"; for (let iCon = 0; iCon < conditions.length; iCon++) { - //Use clone to remove eventListeners for now - let cur_element = conditionElements[iCon].getElementsByClassName("mediaBox-content")[0]; + // //Use clone to remove eventListeners for now + // let cur_element = conditionElements[iCon].getElementsByClassName("mediaBox-content")[0]; + // let clone_element = cur_element.cloneNode(true); + + // //save the current buttons + // let cur_buttons = cur_element.getElementsByClassName("itemBox-actions")[0]; + // console.log("Found this cur_buttons:", cur_buttons); + // //replace clone buttons with current buttons + // let clone_buttons = clone_element.getElementsByClassName("itemBox-actions")[0]; + // // clone_buttons.parentNode.replaceChild(cur_buttons, clone_buttons); + + // //save current mediaBox-contenthover + // let cur_contenthover = cur_element.getElementsByClassName("mediaBox-contenthover")[0]; + // console.log("Found this contenthover:", cur_contenthover); + // //replace clone + // // let clone_contenthover = clone_element.getElementsByClassName("mediaBox-contenthover")[0]; + // // clone_contenthover.parentNode.replaceChild(cur_contenthover, clone_contenthover); + + // //replace current element with the new clone + // // cur_element.parentNode.replaceChild(clone_element, cur_element); + + let cur_element = conditionElements[iCon].getElementsByClassName("mediaBox-contentmain")[0]; + // console.log("Found this cur_element:", cur_element); let clone_element = cur_element.cloneNode(true); - - //save the current buttons - let cur_buttons = cur_element.getElementsByClassName("itemBox-actions")[0]; - console.log("Found these buttons", cur_buttons); - - //replace clone buttons with current buttons - let clone_buttons = clone_element.getElementsByClassName("itemBox-actions")[0]; - clone_buttons.parentNode.replaceChild(cur_buttons, clone_buttons); - - //replace current element with the new clone cur_element.parentNode.replaceChild(clone_element, cur_element); } @@ -168,8 +179,8 @@ async function startInBuilder() { } let conflictElements = conditionsListElement.getElementsByClassName("possibleConflict") - console.log("found this many possible conflict elements", conflictElements.length); - console.log("list:", conflictElements); + // console.log("found this many possible conflict elements", conflictElements.length); + // console.log("list:", conflictElements); for (let index = 0; index < conflictElements.length; index++) { const element = conflictElements[index]; addHoverEffect(element); diff --git a/modules/helpFunctions/addHoverEffect.js b/modules/helpFunctions/addHoverEffect.js index e98376b..a224036 100644 --- a/modules/helpFunctions/addHoverEffect.js +++ b/modules/helpFunctions/addHoverEffect.js @@ -1,6 +1,6 @@ function addHoverEffect(element) { // console.log("Trying to add hover for ", element); - if(element.classList.contains("conditionExtHoverCheck")){ + if (element.classList.contains("conditionExtHoverCheck")) { // if(element.classList.contains("content-infos")){ // console.log("It's an"); // } @@ -100,22 +100,17 @@ function addHoverEffect(element) { } }; element.addEventListener("click", function (e) { - // console.log("element clicked"); - element.classList.toggle("conditionClicked"); - // console.log("Is clicked?", element.classList.contains("conditionClicked")); - // console.log(element); - if (element.classList.contains("conditionClicked")) { - clickToggle = true; - addConflictClass(); - // console.log("Adding hover effects"); + if (clickToggle) { + if (element.classList.contains("conditionClicked")) { + element.classList.remove("conditionClicked"); + clickToggle = false; + } } else { - clickToggle = false; - - // removeConflictClass(); - // console.log("Removing hover effects"); + element.classList.add("conditionClicked"); + clickToggle = true; + addConflictClass(); } - }, false); element.classList.add("conditionExtHoverCheck");