misc: code clean up

This commit is contained in:
KOWX712
2025-02-24 03:06:14 +08:00
parent 30c70d01d6
commit 37d78b790e
5 changed files with 21 additions and 32 deletions

View File

@@ -1,4 +1,4 @@
import { execCommand, linkRedirect } from './main.js';
import { linkRedirect } from './main.js';
const telegramLink = document.getElementById('telegram');
const githubLink = document.getElementById('github');

View File

@@ -1,4 +1,4 @@
import { basePath, execCommand, floatingBtn, appsWithExclamation, appsWithQuestion, toast } from './main.js';
import { basePath, execCommand, hideFloatingBtn, appsWithExclamation, appsWithQuestion, toast } from './main.js';
const appTemplate = document.getElementById('app-template').content;
const modeOverlay = document.querySelector('.mode-overlay');
@@ -113,7 +113,7 @@ export async function fetchAppList() {
toast("Failed to fetch app list!");
console.error("Failed to fetch or render app list with names:", error);
}
floatingBtn.style.transform = 'translateY(0)';
hideFloatingBtn(false);
toggleableCheckbox();
if (appListContainer.firstChild !== updateCard) {
appListContainer.insertBefore(updateCard, appListContainer.firstChild);

View File

@@ -15,7 +15,7 @@ const permissionPopup = document.getElementById('permission-popup');
const loadingIndicator = document.querySelector('.loading');
const prompt = document.getElementById('prompt');
const floatingCard = document.querySelector('.floating-card');
export const floatingBtn = document.querySelector('.floating-btn');
const floatingBtn = document.querySelector('.floating-btn');
export const basePath = "set-path";
export const appsWithExclamation = [];
@@ -221,22 +221,13 @@ async function checkMMRL() {
}
// Funtion to adapt floating button hide in MMRL
function hideFloatingBtn(hide = true) {
export function hideFloatingBtn(hide = true) {
if (!hide) {
floatingBtn.style.display = 'block';
setTimeout(() => {
floatingBtn.style.transform = 'translateY(0)';
}, 10);
floatingCard.style.transform = 'translateY(0)';
} else if (typeof ksu !== 'undefined' && ksu.mmrl) {
floatingBtn.style.transform = 'translateY(calc(var(--window-inset-bottom) + 120px))';
setTimeout(() => {
floatingBtn.style.display = 'none';
}, 400);
floatingCard.style.transform = 'translateY(calc(var(--window-inset-bottom) + 120px))';
} else {
floatingBtn.style.transform = 'translateY(120px)';
setTimeout(() => {
floatingBtn.style.display = 'none';
}, 400);
floatingCard.style.transform = 'translateY(120px)';
}
}
@@ -342,10 +333,8 @@ document.addEventListener('DOMContentLoaded', async () => {
updateCheck();
securityPatch();
loadingIndicator.style.display = "none";
floatingBtn.style.opacity = '1';
setTimeout(() => {
hideFloatingBtn(false);
}, 10);
floatingBtn.style.display = 'block';
hideFloatingBtn(false);
document.getElementById("refresh").addEventListener("click", refreshAppList);
document.getElementById("aospkb").addEventListener("click", aospkb);
document.querySelector('.uninstall-container').classList.remove('hidden-uninstall');
@@ -375,5 +364,9 @@ export async function execCommand(command) {
// Function to toast message
export function toast(message) {
ksu.toast(message);
try {
ksu.toast(message);
} catch (error) {
console.error("Failed to show toast:", error);
}
}