tangled
alpha
login
or
join now
me.webbeef.org
/
browser.html
Rewild Your Web
web
browser
dweb
4
fork
atom
overview
issues
pulls
pipelines
misc: load json files using json modules
webbeef.tngl.sh
1 day ago
44564e19
f1cbd939
+10
-16
2 changed files
expand all
collapse all
unified
split
resources
browserhtml
homescreen
index.js
shared
search
engines.js
+6
-4
resources/browserhtml/homescreen/index.js
···
10
10
// Load widgets from JSON
11
11
async function loadWidgets() {
12
12
try {
13
13
-
const response = await fetch("resources/widgets.json");
14
14
-
const widgets = await response.json();
13
13
+
const { default: widgets } = await import("./resources/widgets.json", {
14
14
+
with: { type: "json" },
15
15
+
});
15
16
renderWidgets(widgets);
16
17
} catch (e) {
17
18
console.log("[Homescreen] No widgets configured");
···
33
34
// Load bookmarks from JSON
34
35
async function loadBookmarks() {
35
36
try {
36
36
-
const response = await fetch("resources/bookmarks.json");
37
37
-
const bookmarks = await response.json();
37
37
+
const { default: bookmarks } = await import("./resources/bookmarks.json", {
38
38
+
with: { type: "json" },
39
39
+
});
38
40
renderBookmarks(bookmarks);
39
41
} catch (e) {
40
42
console.error("[Homescreen] Failed to load bookmarks:", e);
+4
-12
resources/browserhtml/shared/search/engines.js
···
2
2
3
3
const PREF_NAME = "browserhtml.search_engine";
4
4
5
5
+
// Load the default search engines resource.
6
6
+
import ENGINES from "//shared.localhost:8888/search/default_engines.json" with { type: "json" };
7
7
+
5
8
export default class SearchEngines extends EventTarget {
6
9
constructor() {
7
10
super();
8
8
-
this.engines = null;
9
11
this.currentEngine = null;
12
12
+
this.engines = ENGINES;
10
13
}
11
14
12
15
async ensureReady() {
13
16
if (this.currentEngine) {
14
14
-
return;
15
15
-
}
16
16
-
17
17
-
// Load the default search engines resource.
18
18
-
try {
19
19
-
let response = await fetch(
20
20
-
"//shared.localhost:8888/search/default_engines.json",
21
21
-
);
22
22
-
this.engines = await response.json();
23
23
-
} catch (e) {
24
24
-
console.error(`Failed to load search engines: ${e}`);
25
17
return;
26
18
}
27
19