From 105371cb076ef2a08f7e44eb794bde0df79429ee Mon Sep 17 00:00:00 2001 From: ReturnFI <151555003+ReturnFI@users.noreply.github.com> Date: Wed, 24 Sep 2025 19:38:47 +0000 Subject: [PATCH] refactor: Externalize all template --- core/scripts/webpanel/templates/base.html | 146 +- core/scripts/webpanel/templates/config.html | 101 +- core/scripts/webpanel/templates/index.html | 78 +- core/scripts/webpanel/templates/settings.html | 1205 +---------------- core/scripts/webpanel/templates/users.html | 336 +---- 5 files changed, 68 insertions(+), 1798 deletions(-) diff --git a/core/scripts/webpanel/templates/base.html b/core/scripts/webpanel/templates/base.html index 9d4fe2b..d465ebe 100644 --- a/core/scripts/webpanel/templates/base.html +++ b/core/scripts/webpanel/templates/base.html @@ -23,7 +23,9 @@ {% block stylesheets %}{% endblock %} - +
@@ -201,147 +203,9 @@ - - - function updateIcon(enabled) { - darkModeIcon.removeClass("fa-moon fa-sun") - .addClass(enabled ? "fa-sun" : "fa-moon"); - } - - const versionUrl = "{{ url_for('get_version_info') }}"; - $.ajax({ - url: versionUrl, - type: 'GET', - success: function (response) { - $('#panel-version').text(`Version: ${response.current_version || 'N/A'}`); - }, - error: function (error) { - console.error("Error fetching version:", error); - $('#panel-version').text('Version: Error'); - } - }); - - function shouldCheckForUpdates() { - const lastCheck = localStorage.getItem('lastUpdateCheck'); - const updateDismissed = localStorage.getItem('updateDismissed'); - const now = Date.now(); - const checkInterval = 24 * 60 * 60 * 1000; - - if (!lastCheck) return true; - if (updateDismissed && now - parseInt(updateDismissed) < 2 * 60 * 60 * 1000) return false; - - return now - parseInt(lastCheck) > checkInterval; - } - - function showUpdateBar(version, changelog) { - $('#updateMessage').text(`Version ${version} is now available`); - - const converter = new showdown.Converter(); - const htmlChangelog = changelog ? converter.makeHtml(changelog) : '

No changelog available.

'; - $('#changelogText').html(htmlChangelog); - - $('#updateBar').slideDown(300); - - $('#viewRelease').off('click').on('click', function(e) { - e.preventDefault(); - window.open('https://github.com/ReturnFI/Blitz/releases/latest', '_blank'); - }); - - $('#showChangelog').off('click').on('click', function() { - const $content = $('#changelogContent'); - const $icon = $(this).find('i'); - - if ($content.is(':visible')) { - $content.slideUp(250); - $icon.removeClass('fa-chevron-up').addClass('fa-chevron-down'); - $(this).css('opacity', '0.8'); - } else { - $content.slideDown(250); - $icon.removeClass('fa-chevron-down').addClass('fa-chevron-up'); - $(this).css('opacity', '1'); - } - }); - - $('.dropdown-toggle').dropdown(); - - $('#remindLater').off('click').on('click', function(e) { - e.preventDefault(); - $('#updateBar').slideUp(350); - }); - - $('#skipVersion').off('click').on('click', function(e) { - e.preventDefault(); - localStorage.setItem('dismissedVersion', version); - localStorage.setItem('updateDismissed', Date.now().toString()); - $('#updateBar').slideUp(350); - }); - - $('#closeUpdateBar').off('click').on('click', function() { - $('#updateBar').slideUp(350); - }); - } - - function checkForUpdates() { - if (!shouldCheckForUpdates()) return; - - const checkVersionUrl = "{{ url_for('check_version_info') }}"; - $.ajax({ - url: checkVersionUrl, - type: 'GET', - timeout: 10000, - success: function (response) { - localStorage.setItem('lastUpdateCheck', Date.now().toString()); - - if (response.is_latest) { - localStorage.removeItem('updateDismissed'); - return; - } - - const dismissedVersion = localStorage.getItem('dismissedVersion'); - if (dismissedVersion === response.latest_version) return; - - showUpdateBar(response.latest_version, response.changelog); - }, - error: function (xhr, status, error) { - if (status !== 'timeout') { - console.warn("Update check failed:", error); - } - localStorage.setItem('lastUpdateCheck', Date.now().toString()); - } - }); - } - - setTimeout(checkForUpdates, 2000); - }); - {% block javascripts %}{% endblock %} diff --git a/core/scripts/webpanel/templates/config.html b/core/scripts/webpanel/templates/config.html index 26f5b68..ad93c22 100644 --- a/core/scripts/webpanel/templates/config.html +++ b/core/scripts/webpanel/templates/config.html @@ -4,10 +4,12 @@ {% block content %}
-
+
- - + +
@@ -18,94 +20,5 @@ - - -{% endblock %} + +{% endblock %} \ No newline at end of file diff --git a/core/scripts/webpanel/templates/index.html b/core/scripts/webpanel/templates/index.html index e9b4475..497b44b 100644 --- a/core/scripts/webpanel/templates/index.html +++ b/core/scripts/webpanel/templates/index.html @@ -13,7 +13,9 @@
-
+
@@ -190,77 +192,5 @@ {% endblock %} {% block javascripts %} - + {% endblock %} \ No newline at end of file diff --git a/core/scripts/webpanel/templates/settings.html b/core/scripts/webpanel/templates/settings.html index ed88cb2..20e5f0f 100644 --- a/core/scripts/webpanel/templates/settings.html +++ b/core/scripts/webpanel/templates/settings.html @@ -13,7 +13,46 @@
-
+
@@ -555,1169 +594,7 @@ {% endblock %} {% block javascripts %} - - - - + {% endblock %} \ No newline at end of file diff --git a/core/scripts/webpanel/templates/users.html b/core/scripts/webpanel/templates/users.html index 01baf6a..a9aa5c9 100644 --- a/core/scripts/webpanel/templates/users.html +++ b/core/scripts/webpanel/templates/users.html @@ -35,7 +35,16 @@
-
+
@@ -455,328 +464,5 @@ {% block javascripts %} - - + {% endblock %} \ No newline at end of file