This commit is contained in:
KazushiM
2023-02-01 10:08:08 +08:00
parent 9cfe812247
commit 69f7919c3c
4 changed files with 25 additions and 10 deletions

File diff suppressed because one or more lines are too long

2
pages/dist/main.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -28,7 +28,7 @@
border-right-width: var(--border-width);
}
nav[role="tab-control"] > button:not(.secondary) {
nav[role="tab-control"] > button:not(.outline) {
pointer-events: none;
cursor: default;
}
@@ -374,8 +374,8 @@
<body>
<nav role="tab-control">
<button class="" id="tab_all" data-filter="0" disabled>Show All</button>
<button class="outline secondary" id="tab_erista" data-filter="1" disabled>For Erista</button>
<button class="outline secondary" id="tab_mariko" data-filter="2" disabled>For Mariko</button>
<button class="outline" id="tab_erista" data-filter="1" disabled>For Erista</button>
<button class="outline" id="tab_mariko" data-filter="2" disabled>For Mariko</button>
</nav>
<form id="form">
<label for="file">

View File

@@ -39,7 +39,7 @@ class CustEntry {
validate(): boolean {
let tip = new ErrorToolTip(this.id);
tip.clear();
if (Number.isNaN(this.value) || !this.value) {
if (Number.isNaN(this.value) || this.value === undefined) {
tip.setMsg(`Invalid value: Not a number`);
tip.show();
return false;
@@ -313,7 +313,7 @@ function SaveCust(buffer) {
CustTable.forEach(i => {
i.updateValueFromElement();
if (!i.validate() || !i.value) {
if (!i.validate()) {
document.getElementById(i.id)!.focus();
throw new Error(`Invalid ${i.name}`);
}
@@ -323,10 +323,10 @@ function SaveCust(buffer) {
}
switch (i.size) {
case 2:
view.setUint16(i.offset, i.value, true);
view.setUint16(i.offset, i.value!, true);
break;
case 4:
view.setUint32(i.offset, i.value, true);
view.setUint32(i.offset, i.value!, true);
break;
default:
document.getElementById(i.id)!.focus();
@@ -362,7 +362,7 @@ function CustNavTabsInit() {
i.removeAttribute("disabled");
let platform = Number(i.getAttribute("data-filter")!) as CustPlatform;
i.addEventListener('click', (_evt) => {
const unfocusedClasses = ["outline", "secondary"];
const unfocusedClasses = ["outline"];
i.classList.remove(...unfocusedClasses);
custNavTabs.filter(j => j != i).forEach(k => k.classList.add(...unfocusedClasses));
@@ -513,7 +513,22 @@ async function fetchRelease(): Promise<ReleaseInfo | void> {
}
}
const isElementVisible = (element: HTMLElement): boolean => {
let rect = element.getBoundingClientRect();
return (
rect.top > 0 &&
rect.left > 0 &&
rect.bottom - rect.height < (window.innerHeight || document.documentElement.clientHeight) &&
rect.right - rect.width < (window.innerWidth || document.documentElement.clientWidth)
);
};
async function updateDownloadUrls() {
// Wait until download buttons are visible
while (!isElementVisible(document.getElementById("download_btn_grid")!)) {
await new Promise(r => setTimeout(r, 1000));
};
const updateHref = (id: string, name: string, url: string) => {
let element = document.getElementById(id)!;
element.innerHTML = name;