|
@@ -235,15 +235,17 @@ fetchconfig('/sys/lang')
|
|
|
})
|
|
|
.catch(() => {});
|
|
|
|
|
|
-// Hack to include an HTML files. Sadly, does not support
|
|
|
-// including files with <script> tags.
|
|
|
-function inc(url) {
|
|
|
- var me = document.currentScript;
|
|
|
- fetch(url, {redirect: "follow"})
|
|
|
- .then((response) => response.text())
|
|
|
- .then((text) => {
|
|
|
- const p = me.parentElement;
|
|
|
- me.outerHTML = text;
|
|
|
- translate(p);
|
|
|
- });
|
|
|
+// HTML include hack
|
|
|
+class IncHTML extends HTMLElement {
|
|
|
+ constructor() { self = super(); }
|
|
|
+ connectedCallback() {
|
|
|
+ fetch(self.getAttribute('src'))
|
|
|
+ .then ((r) => r.text())
|
|
|
+ .then ((text) => {
|
|
|
+ const p = self.parentElement;
|
|
|
+ self.outerHTML = text;
|
|
|
+ translate(p);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
+customElements.define('x-inc', IncHTML);
|