From 10830728b2c408ad0a272fda9ceebbcf66c16536 Mon Sep 17 00:00:00 2001 From: Tobias Date: Thu, 9 Feb 2023 12:14:30 +0100 Subject: [PATCH] - updated footer - changed way to show/hide .damage-monitor elements; now works via bootstrap class "d-none" instead of changing "display" attribute - same for modal OK buttons --- css/custom.css | 8 +++++++- index.html | 9 +++++---- js/sr2ini.js | 31 +++++++++++++++---------------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/css/custom.css b/css/custom.css index d3b701f..56f7869 100644 --- a/css/custom.css +++ b/css/custom.css @@ -44,7 +44,6 @@ input:invalid { } .damage-monitor { - display: none; position: absolute; z-index: 20; top: 40px; @@ -75,3 +74,10 @@ input:invalid { .damage-monitor button.active { filter: brightness(91%); } + +footer p { + font-size: x-small; + margin-bottom: .5rem; +} +footer hr { + margin: .5rem 0; diff --git a/index.html b/index.html index da95cd0..92f4429 100644 --- a/index.html +++ b/index.html @@ -63,7 +63,7 @@ @@ -94,16 +94,17 @@
-
diff --git a/js/sr2ini.js b/js/sr2ini.js index 3fdc49d..75ed395 100644 --- a/js/sr2ini.js +++ b/js/sr2ini.js @@ -18,7 +18,7 @@ const COMBATANT_TABLE_ROW = [ ''].join(""); const DAMAGE_MONITOR_HTML = [ -'\n', +'
\n', '\n', '\n', '\n', @@ -84,7 +84,6 @@ function sortTable() { //TODO: don't rely on class out-of-commission being set, check and set it here instead return $(tr).hasClass("out-of-commission") ? 0 : parseInt($(tr).find(".combatantIni").text()); }); -//TODO: maxIni wid nicht vergeben wenn damage > 0 // compute highest ini let iniMax = Math.max.apply(null, iniValues); @@ -139,7 +138,7 @@ function getEffectiveIni(value, damageLevel1, damageLevel2) { else { return NaN; } -//TODO: maybe check here for out-of-commission and return 'dead' or something instead of int +//TODO: maybe check here for out-of-commission and return 'dead' or something instead of integer return effectiveIni < 0 ? 0 : effectiveIni; } @@ -172,8 +171,8 @@ function handleAddButtonClick (e) { // restyle modal $("#combatantModal .modal-title").text("Add Combatant"); - $("#combatantModalAddOkButton").show(); - $("#combatantModalEditOkButton").hide(); + $("#combatantModalAddOkButton").removeClass("d-none"); + $("#combatantModalEditOkButton").addClass("d-none"); // add handler for enter key $("#combatantModal input[id*='combatantModal']").off("keydown"); @@ -190,14 +189,14 @@ function handleAddButtonClick (e) { // click handler for damage buttons; basically toggles visibility of table.damage-monitor function handleDamageButtonClick (e) { // get visibility status at click time - let visAtClick = $(e.target).parents(".damage-dropdown").find(".damage-monitor").css("display"); + let hiddenAtClick = $(e.target).parents(".damage-dropdown").find(".damage-monitor").hasClass("d-none"); // hide all damage monitors - $(".damage-monitor:visible").css("display", "none"); + $(".damage-monitor:visible").addClass("d-none"); // if targeted dm was hidden before, show it now - if ( visAtClick == "none" ) { - $(e.target).parents(".damage-dropdown").find(".damage-monitor").css("display", "block"); + if ( hiddenAtClick ) { + $(e.target).parents(".damage-dropdown").find(".damage-monitor").removeClass("d-none"); } return false; } @@ -261,8 +260,8 @@ function handleEditButtonClick (e) { // restyle modal $("#combatantModal .modal-title").text("Edit Combatant"); - $("#combatantModalAddOkButton").hide(); - $("#combatantModalEditOkButton").show(); + $("#combatantModalAddOkButton").addClass("d-none"); + $("#combatantModalEditOkButton").removeClass("d-none"); // populate modal with values from row $("#combatantModalName").val($tr.find(".combatantName").text()); @@ -290,8 +289,8 @@ function handleEditButtonClick (e) { function handleNewRoundButton (e) { // restyle modal $("#confirmModal .modal-title").text("Start new Round"); - $("#confirmModalNewRoundOkButton").show(); - $("#confirmModalRemoveCombatantOkButton").hide(); + $("#confirmModalNewRoundOkButton").removeClass("d-none"); + $("#confirmModalRemoveCombatantOkButton").addClass("d-none"); // show modal $("#comfirmModal").modal("show"); @@ -302,8 +301,8 @@ function handleNewRoundButton (e) { function handleRemoveButtonClick (e) { // restyle modal $("#confirmModal .modal-title").text("Remove Combatant"); - $("#confirmModalRemoveCombatantOkButton").show(); - $("#confirmModalNewRoundOkButton").hide(); + $("#confirmModalRemoveCombatantOkButton").removeClass("d-none"); + $("#confirmModalNewRoundOkButton").addClass("d-none"); // mark which row is being removed $("#confirmModal").attr("data-row", $(".combatantRow").index($(e.target).parents(".combatantRow"))); @@ -544,7 +543,7 @@ $(document).ready(function(){ // Hide damage monitors after click somewhere else $("html").on("click", function (e) { if ( $(e.target).parents(".damage-monitor").length == 0 ) { - $(".damage-monitor:visible").css("display", "none"); + $(".damage-monitor:visible").addClass("d-none"); } });