From 85c509e567e050be34252815e944b4e8db9ae914 Mon Sep 17 00:00:00 2001 From: Kumi Date: Mon, 8 Jul 2024 10:28:46 +0200 Subject: [PATCH] refactor(modal): extract iframe URL setting to reusable function Created openUrlInQuizModal function to centralize and reuse the logic for setting the iframe's src attribute and displaying the modal. This change improves code maintainability by reducing redundancy. --- script.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/script.js b/script.js index c872d74..f81acb0 100644 --- a/script.js +++ b/script.js @@ -128,6 +128,12 @@ hideContent(); } + function openUrlInQuizModal(href) { + $("#regular-modal-iframe").attr("src", href); + + $("#regularModal").modal("show"); + } + async function openQuizModal(number) { let href = getFeedbackLinks()[number - 1]; @@ -148,9 +154,7 @@ href = href + "&embed=1&modal=1"; - $("#regular-modal-iframe").attr("src", href); - - $("#regularModal").modal("show"); + openUrlInQuizModal(href); } function closeQuizModal() {