mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-23 12:31:24 +01:00
lock unlock in burgs-overview.js
Added a way to check if burgs are locked or unlocked with the lock all button, so it works in any situations about locking.
This commit is contained in:
parent
c12650fe9b
commit
2e4a61f759
2 changed files with 20 additions and 8 deletions
|
|
@ -3284,7 +3284,7 @@
|
|||
<button id="addNewBurg" data-tip="Add a new burg. Hold Shift to add multiple" class="icon-plus"></button>
|
||||
<button id="burgsExport" data-tip="Save burgs-related data as a text file (.csv)" class="icon-download"></button>
|
||||
<button id="burgNamesImport" data-tip="Rename burgs in bulk" class="icon-upload"></button>
|
||||
<button id="burgsonoff" data-tip="Lock / Unlock all burgs" class="icon-lock" value="Off"></button>
|
||||
<button id="burgsonoff" data-tip="Lock / Unlock all burgs" class="icon-lock"></button>
|
||||
<button id="burgsRemoveAll" data-tip="Remove all unlocked burgs except for capitals. To remove a capital remove its state first" class="icon-trash"></button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ function overviewBurgs() {
|
|||
const body = document.getElementById("burgsBody");
|
||||
updateFilter();
|
||||
burgsOverviewAddLines();
|
||||
setlockburgs();
|
||||
$("#burgsOverview").dialog();
|
||||
|
||||
if (modules.overviewBurgs) return;
|
||||
|
|
@ -36,6 +37,12 @@ function overviewBurgs() {
|
|||
document.getElementById("burgsonoff").addEventListener("click", burgsonoff);
|
||||
document.getElementById("burgsRemoveAll").addEventListener("click", triggerAllBurgsRemove);
|
||||
document.getElementById("burgsInvertLock").addEventListener("click", invertLock);
|
||||
document.getElementById("burgsonoff").addEventListener("click", function (toggleIcons) {
|
||||
var target = toggleIcons.target;
|
||||
|
||||
target.classList.toggle("icon-lock");
|
||||
target.classList.toggle("icon-lock-open");
|
||||
}, false);
|
||||
|
||||
function refreshBurgsEditor() {
|
||||
updateFilter();
|
||||
|
|
@ -558,11 +565,16 @@ function overviewBurgs() {
|
|||
pack.burgs.filter(b => b.i && !(b.capital || b.lock)).forEach(b => removeBurg(b.i));
|
||||
burgsOverviewAddLines();
|
||||
}
|
||||
|
||||
function setlockburgs() {
|
||||
(pack.burgs.filter(b => b.lock)).length === pack.burgs.length ? burgsonoff.value = "true" : burgsonoff.value = "false"; //Only true if all of them are locked
|
||||
}
|
||||
|
||||
function invertLock() {
|
||||
pack.burgs = pack.burgs.map(burg => ({...burg, lock: !burg.lock}));
|
||||
burgsOverviewAddLines();
|
||||
}
|
||||
|
||||
function lockAllBurgs() {
|
||||
pack.burgs.forEach(burg => {
|
||||
burg.lock = true;});
|
||||
|
|
@ -571,16 +583,16 @@ function overviewBurgs() {
|
|||
function unlockAllBurgs() {
|
||||
pack.burgs.forEach(burg => {
|
||||
burg.lock = false;});
|
||||
burgsOverviewAddLines();
|
||||
burgsOverviewAddLines();
|
||||
}
|
||||
function burgsonoff(){
|
||||
const currentvalue = document.getElementById('burgsonoff').value;
|
||||
if(currentvalue == "Off"){
|
||||
lockAllBurgs();
|
||||
document.getElementById("burgsonoff").value="On";
|
||||
}else{
|
||||
const currentvalue = document.getElementById('burgsonoff').value;
|
||||
if(currentvalue == "true"){
|
||||
unlockAllBurgs();
|
||||
document.getElementById("burgsonoff").value="Off";
|
||||
document.getElementById("burgsonoff").value="false";
|
||||
}else{
|
||||
lockAllBurgs();
|
||||
document.getElementById("burgsonoff").value="true";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue