From 2aadc971db64820241ad99de890dea5039cc3e57 Mon Sep 17 00:00:00 2001 From: Achim Friedland Date: Tue, 16 Apr 2024 03:27:21 +0200 Subject: [PATCH] Fix external links --- src/index.html | 4 ++-- src/ts/chargyApp.ts | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/index.html b/src/index.html index 4b85b02..8c154f3 100644 --- a/src/index.html +++ b/src/index.html @@ -104,7 +104,7 @@
-
Chargy WebApp
+
Chargy WebApp
diff --git a/src/ts/chargyApp.ts b/src/ts/chargyApp.ts index a3c637b..b41bf33 100644 --- a/src/ts/chargyApp.ts +++ b/src/ts/chargyApp.ts @@ -506,21 +506,22 @@ export class ChargyApp { //#region Modify external links to be opened in the external web browser - //const shell = require('electron').shell; const linkButtons = document.getElementsByClassName('linkButton') as HTMLCollectionOf; for (let i = 0; i < linkButtons.length; i++) { const linkButton = linkButtons[i]; - if (linkButton != null) + if (linkButton) { linkButton.onclick = function (this: GlobalEventHandlers, ev: MouseEvent) { + ev.preventDefault(); const link = linkButton.getAttribute("href"); - if (link && (link.startsWith("http://") || link.startsWith("https://"))) { - //shell.openExternal(link); - } + + if (link && (link.startsWith("http://") || link.startsWith("https://"))) + window.open(link, '_blank'); + } }