From c3673446ade2766cfc2776d4246d942352af85ba Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Wed, 11 Jun 2025 20:02:28 +0200 Subject: [PATCH] refactor: Move container cleaning code to a separate function --- index.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index f4382fb..b8c3fbf 100644 --- a/index.html +++ b/index.html @@ -550,6 +550,12 @@ fillCharacterRoster(); }; + const clearContainer = (cont) => { + while (cont.firstChild) { + cont.removeChild(cont.lastChild); + } + }; + const fillCharacterRoster = () => { var characterIDs = Object.keys(characterRoster).toSorted((idA, idB) => { // Sort by campaign name first @@ -566,9 +572,7 @@ var placeHolder = inpCharacterRoster.options[0]; - while (inpCharacterRoster.firstChild) { - inpCharacterRoster.removeChild(inpCharacterRoster.lastChild); - } + clearContainer(inpCharacterRoster); inpCharacterRoster.appendChild(placeHolder);