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

@@ -4,7 +4,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title data-i18n="title">TrickyAddon</title> <title>TrickyAddon</title>
<link rel="stylesheet" type="text/css" href="/mmrl/insets.css" /> <link rel="stylesheet" type="text/css" href="/mmrl/insets.css" />
<link rel="stylesheet" href="styles/global.css" type="text/css"> <link rel="stylesheet" href="styles/global.css" type="text/css">
<link rel="stylesheet" href="styles/about.css" type="text/css"> <link rel="stylesheet" href="styles/about.css" type="text/css">

View File

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

View File

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

View File

@@ -12,26 +12,22 @@ body {
display: flex; display: flex;
justify-content: center; justify-content: center;
position: fixed; position: fixed;
width: 100%;
bottom: 50px; bottom: 50px;
left: 50%; transition: transform 0.4s ease;
transform: translateX(-50%); z-index: 2;
z-index: 10;
} }
.floating-btn { .floating-btn {
flex-shrink: 0;
background-color: #007bff; background-color: #007bff;
border: none; border: none;
box-shadow: 0 4px 8px #0003; box-shadow: 0 4px 8px #0003;
color: #fff; color: #fff;
display: flex; display: none;
justify-content: center; bottom: 0;
align-items: center;
opacity: 0;
padding: 10px 20px; padding: 10px 20px;
font-size: 22px; font-size: 22px;
font-weight: bold; font-weight: bold;
transition: transform 0.4s ease;
border-radius: 50px 50px; border-radius: 50px 50px;
user-select: none; user-select: none;
} }