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>
<meta charset="utf-8">
<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" href="styles/global.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 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);
}
}

View File

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