add document, fix tooltip position issue

This commit is contained in:
2023-03-30 17:26:59 +08:00
parent f5bc42fa20
commit 5406eea20e
15 changed files with 432 additions and 117 deletions

33
main.js
View File

@ -1,8 +1,7 @@
import './css/ui.min.css'
import './style.css'
// import javascriptLogo from './javascript.svg'
import { resolveCheckbox, resolveIcon, resolveTooltip } from './lib/ui'
import { init, r, lang, get, post, upload } from './lib/utility'
import { get } from './lib/utility'
// document.querySelector('#js-logo').src = javascriptLogo
@ -11,7 +10,36 @@ window.consts = {
resver: 20230329
}
function navigate(page) {
get(page, {
accept: 'text/html'
})
.then(r => r.text())
.then(html => {
const range = document.createRange();
range.selectNode(document.body);
const doc = range.createContextualFragment(html);
document.querySelector('#container').replaceChildren(doc);
});
}
document.querySelector('#directory').addEventListener('click', (ev) => {
const page = ev.target.getAttribute('data-page');
if (typeof page === 'string') {
location.hash = page;
navigate(page);
}
});
let page = location.hash;
if (page.length > 1) {
page = page.substring(1);
navigate(page);
}
/*
init(null, {
template: '/res.json',
callback: (result) => console.log(result)
}).then(() => {
// document.querySelector('#create-icon').appendChild(createIcon('fa-solid', 'user-edit'))
@ -35,3 +63,4 @@ init(null, {
.then(blob => document.querySelector('#js-logo').src = URL.createObjectURL(blob));
});
});
*/