Кнопки меняют и текст и цвет при переключении

This commit is contained in:
Dauren777 2026-06-04 10:08:29 +00:00
parent 769f02f424
commit a127271971

View File

@ -132,7 +132,7 @@ var vioHTML="";for(var i=0;i<vrc;i++)vioHTML+=mkV(i+1);document.getElementById("
document.getElementById("vr").onclick=function(e){if(e.target.classList.contains("rvb")){var n=parseInt(e.target.getAttribute("data-row"));removeVR(n)}};
document.getElementById("d4").onchange=function(){var o=document.getElementById("do");o.style.display=this.checked?"block":"none";o.classList.toggle("vs",this.checked)};
function setO(t){var os=document.getElementById("os"),od=document.getElementById("od");if(!os||!od)return;if(t==="safe"){os.style.background="#EDF7F0";os.style.borderColor="#2D6A4F";os.style.color="#2D6A4F";od.style.background="#fff";od.style.borderColor="#E2E6EB";od.style.color="#5B6573"}else{os.style.background="#fff";os.style.borderColor="#E2E6EB";os.style.color="#5B6573";od.style.background="#FFEBED";od.style.borderColor="#E63946";od.style.color="#E63946"}}
function setO(t){var os=document.getElementById("os"),od=document.getElementById("od");if(!os||!od)return;if(t==="safe"){os.style.background="#EDF7F0";os.style.borderColor="#2D6A4F";os.style.color="#2D6A4F";os.textContent="✅ ВСЕ БЕЗОПАСНО";od.style.background="#fff";od.style.borderColor="#E2E6EB";od.style.color="#5B6573";od.textContent="☐ ЕСТЬ ОПАСНО"}else{os.style.background="#fff";os.style.borderColor="#E2E6EB";os.style.color="#5B6573";os.textContent="☐ ВСЕ БЕЗОПАСНО";od.style.background="#FFEBED";od.style.borderColor="#E63946";od.style.color="#E63946";od.textContent="⚠️ ЕСТЬ ОПАСНО"}}
function toggleAllSafe(id){var cb=document.getElementById("ascb-"+id),tog=document.getElementById("as-"+id);if(!cb||!tog)return;var is=!cb.checked;cb.checked=is;if(is){tog.classList.add("ac2");var cat=CATS.find(function(c){return c.id===id});if(cat)cat.items.forEach(function(_,i){var e=document.getElementById("cb-"+id+"-"+i);if(e){e.checked=false;e.parentElement.classList.remove("ck")}var o=document.getElementById("other-"+id);if(o){o.style.display="none";o.classList.remove("vs")}})}else{tog.classList.remove("ac2")}updateCatTotal(id)}
function onCheckItem(id,idx){var cb=document.getElementById("cb-"+id+"-"+idx);if(!cb)return;if(cb.checked){cb.parentElement.classList.add("ck");document.getElementById("ascb-"+id).checked=false;document.getElementById("as-"+id).classList.remove("ac2")}else{cb.parentElement.classList.remove("ck")}var cat=CATS.find(function(c){return c.id===id});if(cat&&cat.items[idx]==="Другое"){var o=document.getElementById("other-"+id);if(o){if(cb.checked){o.style.display="block";o.classList.add("vs")}else{o.style.display="none";o.classList.remove("vs")}}}updateCatTotal(id)}
function updateCatTotal(id){var cat=CATS.find(function(c){return c.id===id});if(!cat)return;var cnt=0;cat.items.forEach(function(_,i){if(document.getElementById("cb-"+id+"-"+i)&&document.getElementById("cb-"+id+"-"+i).checked)cnt++});var te=document.getElementById("total-"+id);if(te){te.textContent=cnt;if(cnt===0)te.classList.add("zr");else te.classList.remove("zr")}var b=document.getElementById("badge-"+id);if(b){if(cnt===0){b.textContent="ВСЕ БЕЗОПАСНО";b.classList.add("as")}else{b.textContent="Нарушений: "+cnt;b.classList.remove("as")}}}