diff --git a/index.html b/index.html index f4c9bda7..39e59bf3 100644 --- a/index.html +++ b/index.html @@ -3287,6 +3287,7 @@ + diff --git a/modules/ui/burgs-overview.js b/modules/ui/burgs-overview.js index 97093035..11006a03 100644 --- a/modules/ui/burgs-overview.js +++ b/modules/ui/burgs-overview.js @@ -8,6 +8,7 @@ function overviewBurgs() { const body = document.getElementById("burgsBody"); updateFilter(); burgsOverviewAddLines(); + setLockIcon(); $("#burgsOverview").dialog(); if (modules.overviewBurgs) return; @@ -33,6 +34,8 @@ function overviewBurgs() { document.getElementById("burgsListToLoad").addEventListener("change", function () { uploadFile(this, importBurgNames); }); + document.getElementById("burgsLockAll").addEventListener("click", setLockBurgs); + document.getElementById("burgsLockAll").addEventListener("click", setLockIcon); document.getElementById("burgsRemoveAll").addEventListener("click", triggerAllBurgsRemove); document.getElementById("burgsInvertLock").addEventListener("click", invertLock); @@ -87,7 +90,7 @@ function overviewBurgs() { - ${getCultureOptions( b.culture )} @@ -562,4 +565,41 @@ function overviewBurgs() { pack.burgs = pack.burgs.map(burg => ({...burg, lock: !burg.lock})); burgsOverviewAddLines(); } + + function lockAllBurgs() { + pack.burgs.forEach(burg => { + burg.lock = true; + }); + burgsOverviewAddLines(); + } + + function unlockAllBurgs() { + pack.burgs.forEach(burg => { + burg.lock = false; + }); + burgsOverviewAddLines(); + } + + function setLockBurgs() { + const allLocked = pack.burgs.every(({lock, i, removed}) => lock || !i || removed); + + if (allLocked) { + unlockAllBurgs(); + } else { + lockAllBurgs(); + } + setLockIcon(); + } + + function setLockIcon() { + const allLocked = pack.burgs.every(({lock, i, removed}) => lock || !i || removed); + + if (allLocked) { + burgsLockAll.classList.remove("icon-lock"); + burgsLockAll.classList.add("icon-lock-open"); + } else { + burgsLockAll.classList.add("icon-lock"); + burgsLockAll.classList.remove("icon-lock-open"); + } + } }