Skip to content

Commit 932ad53

Browse files
committed
automatic browser detection
1 parent 6563b39 commit 932ad53

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

deno.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"@std/random": "jsr:@std/random@^0.1.0",
7474
"@std/regexp": "jsr:@std/regexp@^1.0.1",
7575
"@std/text": "jsr:@std/text@^1.0.12",
76+
"browser-dtector": "npm:browser-dtector@^4.1.0",
7677
"compromise": "npm:compromise@^14.14.3",
7778
"esbuild": "npm:esbuild@^0.25.2"
7879
}

deno.lock

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ <h1>An error has occurred</h1>
202202
<ul>
203203
<li>What did you do before this error occurred.</li>
204204
<li>The following error message: <code id="error-code"></code></li>
205-
<li>The name of your browser and its version.</li>
205+
<li>
206+
Your browser and its version: <span id="browser-details"></span>
207+
</li>
206208
</ul>
207209
<button id="error-close-button">Close</button>
208210
</dialog>

src/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ if (LIVE_RELOAD) {
88
new EventSource("/esbuild")
99
.addEventListener("change", () => location.reload());
1010
}
11+
import BrowserDetector from "browser-dtector";
1112
import { dictionary } from "../dictionary/dictionary.ts";
1213
import { dictionaryParser } from "../dictionary/parser.ts";
1314
import PROJECT_DATA from "../project_data.json" with { type: "json" };
@@ -130,6 +131,9 @@ function main(): void {
130131

131132
const errorBox = document.getElementById("error-box") as HTMLDialogElement;
132133
const errorCode = document.getElementById("error-code") as HTMLElement;
134+
const browserDetails = document.getElementById(
135+
"browser-details",
136+
) as HTMLElement;
133137
const errorCloseButton = document.getElementById(
134138
"error-close-button",
135139
) as HTMLButtonElement;
@@ -147,6 +151,8 @@ function main(): void {
147151
// handle error
148152
addEventListener("error", (event) => {
149153
errorCode.innerText = event.message;
154+
const details = new BrowserDetector(navigator.userAgent).getBrowserInfo();
155+
browserDetails.innerText = `${details.name} ${details.version}`;
150156
errorBox.showModal();
151157
});
152158

0 commit comments

Comments
 (0)