Skip to content

Commit 919d941

Browse files
committed
Add gen_utils.js
1 parent f2536ab commit 919d941

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

static/gen_utils.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function fetchApplyLayout(layoutUrl, containerId) {
2+
window.addEventListener("DOMContentLoaded", async () => {
3+
var layout = await fetch(layoutUrl);
4+
var parser = new DOMParser();
5+
var doc = parser.parseFromString(await layout.text(), 'text/html');
6+
var container = doc.getElementById(containerId);
7+
container.innerHTML = document.body.innerHTML;
8+
document.replaceChild(
9+
document.adoptNode(doc.documentElement),
10+
document.documentElement
11+
);
12+
})
13+
}
14+
15+
function tryRedirectToLower() {
16+
var currentURL = window.location.href;
17+
var lowerCaseURL = currentURL.toLowerCase();
18+
if (currentURL != lowerCaseURL) {
19+
location.replace(lowerCaseURL);
20+
}
21+
}

0 commit comments

Comments
 (0)