From 362b17c47cfc20ea85d4d6d2b8741f5df4b8e738 Mon Sep 17 00:00:00 2001 From: Ralph Ocdol Date: Thu, 20 Nov 2025 17:14:51 +0800 Subject: [PATCH] Add Target property to most widgets --- internal/glance/static/js/page.js | 4 +-- internal/glance/static/js/utils.js | 4 +-- .../glance/templates/change-detection.html | 4 +-- .../glance/templates/docker-containers.html | 2 +- internal/glance/templates/forum-posts.html | 4 +-- internal/glance/templates/group.html | 2 +- internal/glance/templates/markets.html | 4 +-- .../glance/templates/monitor-compact.html | 2 +- internal/glance/templates/monitor.html | 2 +- .../templates/reddit-horizontal-cards.html | 4 +-- .../templates/reddit-vertical-cards.html | 4 +-- internal/glance/templates/releases.html | 2 +- internal/glance/templates/repository.html | 14 ++++----- .../glance/templates/rss-detailed-list.html | 4 +-- .../templates/rss-horizontal-cards-2.html | 2 +- .../templates/rss-horizontal-cards.html | 2 +- internal/glance/templates/rss-list.html | 4 +-- .../glance/templates/twitch-channels.html | 6 ++-- .../glance/templates/twitch-games-list.html | 2 +- .../glance/templates/video-card-contents.html | 4 +-- .../templates/videos-vertical-list.html | 4 +-- internal/glance/templates/widget-base.html | 2 +- internal/glance/widget-changedetection.go | 5 ++++ internal/glance/widget-dns-stats.go | 1 + internal/glance/widget-docker-containers.go | 30 +++++++++++++++++-- internal/glance/widget-hacker-news.go | 1 + internal/glance/widget-lobsters.go | 5 ++++ internal/glance/widget-markets.go | 5 ++++ internal/glance/widget-monitor.go | 8 ++++- internal/glance/widget-reddit.go | 6 ++++ internal/glance/widget-releases.go | 5 ++++ internal/glance/widget-repository.go | 5 ++++ internal/glance/widget-rss.go | 5 ++++ internal/glance/widget-torrents.go | 1 + internal/glance/widget-twitch-channels.go | 6 ++++ internal/glance/widget-twitch-top-games.go | 6 ++++ internal/glance/widget-videos.go | 5 ++++ internal/glance/widget.go | 9 ++++++ 38 files changed, 141 insertions(+), 44 deletions(-) diff --git a/internal/glance/static/js/page.js b/internal/glance/static/js/page.js index 0212a4fa..50a93ab8 100644 --- a/internal/glance/static/js/page.js +++ b/internal/glance/static/js/page.js @@ -270,7 +270,7 @@ function setupGroups() { return; } - openURLInNewTab(title.dataset.titleUrl, false); + openURLInNewTab(title.dataset.titleUrl, false, title.dataset.titleTarget); event.preventDefault(); }); } @@ -278,7 +278,7 @@ function setupGroups() { title.addEventListener("click", () => { if (t == current) { if (title.dataset.titleUrl !== undefined) { - openURLInNewTab(title.dataset.titleUrl); + openURLInNewTab(title.dataset.titleUrl, undefined, title.dataset.titleTarget); } return; diff --git a/internal/glance/static/js/utils.js b/internal/glance/static/js/utils.js index a82f97a8..864b5385 100644 --- a/internal/glance/static/js/utils.js +++ b/internal/glance/static/js/utils.js @@ -31,8 +31,8 @@ export function clamp(value, min, max) { // NOTE: inconsistent behavior between browsers when it comes to // whether the newly opened tab gets focused or not, potentially // depending on the event that this function is called from -export function openURLInNewTab(url, focus = true) { - const newWindow = window.open(url, '_blank', 'noopener,noreferrer'); +export function openURLInNewTab(url, focus = true, target = '_blank') { + const newWindow = window.open(url, target, 'noopener,noreferrer'); if (focus && newWindow != null) newWindow.focus(); } diff --git a/internal/glance/templates/change-detection.html b/internal/glance/templates/change-detection.html index 22b7a181..9685d363 100644 --- a/internal/glance/templates/change-detection.html +++ b/internal/glance/templates/change-detection.html @@ -4,10 +4,10 @@