From cf8b470a2011913d6103d30b74a3087a56e8f885 Mon Sep 17 00:00:00 2001 From: Honey Date: Fri, 27 Feb 2026 21:45:10 +0100 Subject: [PATCH] Changed User View and Ticket View --- public/index.html | 8 +++---- public/ticketview/ticket-shared.js | 2 +- public/user-script.js | 3 ++- public/user.css | 3 +-- public/version.js | 38 +++++++++++++++++++++++------- server.js | 6 +++++ 6 files changed, 43 insertions(+), 17 deletions(-) diff --git a/public/index.html b/public/index.html index eef9bd4..a275fbe 100644 --- a/public/index.html +++ b/public/index.html @@ -5,8 +5,8 @@ Laila Dashboard - Ticket System! - - + +
@@ -133,7 +133,7 @@ - - + + \ No newline at end of file diff --git a/public/ticketview/ticket-shared.js b/public/ticketview/ticket-shared.js index cb9c7d6..cc60816 100644 --- a/public/ticketview/ticket-shared.js +++ b/public/ticketview/ticket-shared.js @@ -55,7 +55,7 @@ export function escapeHtml(str) { export function linkify(text) { const escaped = escapeHtml(text); const urlPattern = /(\bhttps?:\/\/[^\s<]+)/g; - return escaped.replace(urlPattern, '$1'); + return escaped.replace(urlPattern, '$1').replace(/\n/g, '
'); } export function formatDateTime(date) { diff --git a/public/user-script.js b/public/user-script.js index 9d2a502..169bc47 100644 --- a/public/user-script.js +++ b/public/user-script.js @@ -234,10 +234,11 @@ document.addEventListener('DOMContentLoaded', () => { const el = document.createElement('div'); el.className = `ticket status-${statusSafe.replace(/\s+/g, '-')}`; el.innerHTML = ` -

${escapeHtml(ticket.title)} #${ticket.id} Time: (${ticket.total_time} min)

+

${escapeHtml(ticket.title)} #${ticket.id}

${escapeHtml(ticket.description)}

${formatDate(ticket.created_at)} + ${ticket.total_time} min
diff --git a/public/user.css b/public/user.css index a5c334f..be93e1a 100644 --- a/public/user.css +++ b/public/user.css @@ -406,9 +406,8 @@ a:hover, a:focus { } .total-time { - font-size: 0.8em; + font-size: inherit; color: var(--neutral-light); - margin-left: 8px; } /* ===== BADGES ===== */ diff --git a/public/version.js b/public/version.js index df87dbd..75f96d3 100644 --- a/public/version.js +++ b/public/version.js @@ -1,9 +1,29 @@ -// Fetches app version and updates all footer texts -fetch('/api/version') - .then(res => res.json()) - .then(({ version }) => { - document.querySelectorAll('.app-footer-text').forEach(el => { - el.textContent = `Ticket System by Honey v${version} © 2026`; - }); - }) - .catch(() => {}); \ No newline at end of file +// Auto cache-busting: detects version changes and forces reload +(function() { + fetch('/api/version') + .then(res => res.json()) + .then(({ version }) => { + const storedVersion = localStorage.getItem('app_version'); + + // Version changed → force hard reload + if (storedVersion && storedVersion !== version) { + localStorage.setItem('app_version', version); + // Clear caches if available + if ('caches' in window) { + caches.keys().then(names => names.forEach(name => caches.delete(name))); + } + window.location.reload(true); + return; + } + + // Store current version + localStorage.setItem('app_version', version); + + // Update footer + const year = new Date().getFullYear(); + document.querySelectorAll('.app-footer-text').forEach(el => { + el.textContent = `Ticket System by Honey v${version} © ${year}`; + }); + }) + .catch(() => {}); +})(); \ No newline at end of file diff --git a/server.js b/server.js index 156eb4e..54eda4a 100644 --- a/server.js +++ b/server.js @@ -28,6 +28,11 @@ const APP_VERSION = pkg.version || '0.0.0'; app.use(cors()); app.use(express.json()); app.use(express.urlencoded({ extended: false })); +// Never cache version.js — ensures auto cache-busting works +app.get('/version.js', (req, res, next) => { + res.set('Cache-Control', 'no-store, no-cache, must-revalidate'); + next(); +}); app.use(express.static(path.join(__dirname, 'public'))); app.use('/assets', express.static(path.join(__dirname, 'assets'))); @@ -304,6 +309,7 @@ app.get('/api/categories', (_req, res) => { // GET app version app.get('/api/version', (_req, res) => { + res.set('Cache-Control', 'no-store'); res.json({ version: APP_VERSION }); });