refactor: topbar.js name and order. And remove 'customconfiguration' declaration in index.html

This commit is contained in:
MasterAcnolo
2026-08-15 21:31:07 +02:00
parent 4de05fcd52
commit 524cee1bac
2 changed files with 39 additions and 38 deletions

View File

@@ -56,9 +56,9 @@
<div class="setting-item" id="theme" style="margin-left: 32px;"> <div class="setting-item" id="theme" style="margin-left: 32px;">
<div class="setting-info"> <div class="setting-info">
<div style="display: flex; align-items: center; gap: 10px;"> <div style="display: flex; align-items: center; gap: 10px;">
<span class="setting-title">Thème</span> <span class="setting-title">Theme</span>
<select id="themeSelect" data-key="theme" aria-label="Choisir le thème"> <select id="themeSelect" data-key="theme" aria-label="Choose the theme">
</select> </select>
<button id="refresh-themes-btn" title="Refresh themes" class="refresh-themes-btn"> <button id="refresh-themes-btn" title="Refresh themes" class="refresh-themes-btn">
@@ -306,7 +306,6 @@
<!-- Scripts --> <!-- Scripts -->
<script src="script/toast.js"></script> <script src="script/toast.js"></script>
<script src="script/customConfiguration.js"></script>
<script src="script/clipboardPaste.js"></script> <script src="script/clipboardPaste.js"></script>
<script src="script/custompath.js"></script> <script src="script/custompath.js"></script>
<script src="script/settingsPanel.js"></script> <script src="script/settingsPanel.js"></script>

View File

@@ -5,47 +5,41 @@
* This function is safe to call once DOM is ready. * This function is safe to call once DOM is ready.
* It silently aborts if the API or elements are missing. * It silently aborts if the API or elements are missing.
*/ */
function setupTopbarListeners() { export function initTopBar() {
const { topbarAPI } = window; const { topbarAPI } = window;
if (!topbarAPI) return; if (!topbarAPI) return;
const minBtn = document.getElementById("minimize-btn"); const minBtn = document.getElementById("minimize-btn");
const maxBtn = document.getElementById("maximize-btn");
const closeBtn = document.getElementById("close-btn");
const devtoolsBtn = document.getElementById("devtools-btn");
const logsBtn = document.getElementById("logs-btn");
const websiteBtn = document.getElementById("website-btn");
const wikiBtn = document.getElementById("wiki-btn");
const workshopBtn = document.getElementById("workshop-btn");
if (minBtn) minBtn.onclick = () => topbarAPI.minimize(); if (minBtn) minBtn.onclick = () => topbarAPI.minimize();
const maxBtn = document.getElementById("maximize-btn");
if (maxBtn) maxBtn.onclick = () => topbarAPI.maximize(); if (maxBtn) maxBtn.onclick = () => topbarAPI.maximize();
const closeBtn = document.getElementById("close-btn");
if (closeBtn) closeBtn.onclick = () => topbarAPI.close(); if (closeBtn) closeBtn.onclick = () => topbarAPI.close();
const devtoolsBtn = document.getElementById("devtools-btn");
if (devtoolsBtn) devtoolsBtn.onclick = () => topbarAPI.openDevTools(); if (devtoolsBtn) devtoolsBtn.onclick = () => topbarAPI.openDevTools();
const logsBtn = document.getElementById("logs-btn");
if (logsBtn) logsBtn.onclick = () => topbarAPI.openLogs(); if (logsBtn) logsBtn.onclick = () => topbarAPI.openLogs();
const websiteBtn = document.getElementById("website-btn");
if (websiteBtn) websiteBtn.onclick = () => topbarAPI.openWebsite(); if (websiteBtn) websiteBtn.onclick = () => topbarAPI.openWebsite();
const wikiBtn = document.getElementById("wiki-btn");
if (wikiBtn) wikiBtn.onclick = () => topbarAPI.openWiki(); if (wikiBtn) wikiBtn.onclick = () => topbarAPI.openWiki();
const workshopBtn = document.getElementById("workshop-btn");
if (workshopBtn) workshopBtn.onclick = () => topbarAPI.openWorkshop(); if (workshopBtn) workshopBtn.onclick = () => topbarAPI.openWorkshop();
} }
/** async function attachListeners(){
* Registers topbar event listeners after DOM is fully loaded. try{
*/ const featuresList = await window.electronAPI.getFeatures();
document.addEventListener("DOMContentLoaded", setupTopbarListeners);
/** if (!featuresList.customTopBar) {
* Applies UI layout adjustments depending on feature flags
* provided by the Electron backend.
*
* Specifically handles:
* - hiding custom topbar
* - adjusting layout spacing
* - repositioning theme switcher
*/
(async function applyFeatureLayout() {
const features = await window.electronAPI.getFeatures();
if (!features.customTopBar) {
const topbar = document.getElementById("topbar"); const topbar = document.getElementById("topbar");
const container = document.getElementById("container"); const container = document.getElementById("container");
const themeSwitcher = document.getElementById("theme-switcher"); const themeSwitcher = document.getElementById("theme-switcher");
@@ -54,4 +48,12 @@ document.addEventListener("DOMContentLoaded", setupTopbarListeners);
if (container) container.style.marginTop = "0"; if (container) container.style.marginTop = "0";
if (themeSwitcher) themeSwitcher.style.top = "30px"; if (themeSwitcher) themeSwitcher.style.top = "30px";
} }
})();
} catch (error) {
console.error("Failed to load layout features for topbar:", error);
}
}
initTopBar()
document.addEventListener("DOMContentLoaded", attachListeners)