26 lines
565 B
JavaScript
26 lines
565 B
JavaScript
const mapRelay = (obj, oldObj = {}) => {
|
|
const relay = {...oldObj, ...obj}
|
|
|
|
relay.expanded = oldObj.expanded || false
|
|
|
|
return relay
|
|
}
|
|
|
|
function loadTemplateAsync(path) {
|
|
const result = new Promise(resolve => {
|
|
const xhttp = new XMLHttpRequest()
|
|
|
|
xhttp.onreadystatechange = function () {
|
|
if (this.readyState == 4) {
|
|
if (this.status == 200) resolve(this.responseText)
|
|
|
|
if (this.status == 404) resolve(`<div>Page not found: ${path}</div>`)
|
|
}
|
|
}
|
|
|
|
xhttp.open('GET', path, true)
|
|
xhttp.send()
|
|
})
|
|
|
|
return result
|
|
}
|