Updated tauri configuration
This commit is contained in:
+12
@@ -1,9 +1,11 @@
|
||||
const { invoke } = window.__TAURI__.core;
|
||||
|
||||
// ── State ──────────────────────────────────────────────
|
||||
let connected = false;
|
||||
let timerStart = null;
|
||||
let timerInterval = null;
|
||||
|
||||
// ── Elements ───────────────────────────────────────────
|
||||
const appIdInput = document.getElementById("appId");
|
||||
const statusInput = document.getElementById("statusInput");
|
||||
const detailsInput = document.getElementById("detailsInput");
|
||||
@@ -18,6 +20,7 @@ const previewStatus = document.getElementById("previewStatus");
|
||||
const previewDetails = document.getElementById("previewDetails");
|
||||
const previewTime = document.getElementById("previewTime");
|
||||
|
||||
// ── Connection ─────────────────────────────────────────
|
||||
async function toggleConnection() {
|
||||
if (connected) {
|
||||
try {
|
||||
@@ -66,6 +69,7 @@ function setConnected(state) {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Activity ───────────────────────────────────────────
|
||||
async function setActivity() {
|
||||
const status = statusInput.value.trim();
|
||||
const details = detailsInput.value.trim();
|
||||
@@ -76,6 +80,7 @@ async function setActivity() {
|
||||
|
||||
try {
|
||||
await invoke("set_activity", { status, details, showTime, elapsedSeconds });
|
||||
// Update preview timer to reflect the spoofed offset
|
||||
if (elapsedSeconds > 0) {
|
||||
timerStart = Date.now() - (elapsedSeconds * 1000);
|
||||
}
|
||||
@@ -96,6 +101,7 @@ async function clearActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Preview ────────────────────────────────────────────
|
||||
function updatePreview(status, details, showTime) {
|
||||
previewTitle.textContent = appIdInput.value ? "Your App Name" : "—";
|
||||
|
||||
@@ -127,6 +133,7 @@ function resetPreview() {
|
||||
previewTime.classList.add("hidden");
|
||||
}
|
||||
|
||||
// Live-update the preview as you type
|
||||
statusInput.addEventListener("input", () => {
|
||||
if (previewStatus.textContent || statusInput.value) {
|
||||
previewStatus.textContent = statusInput.value || "";
|
||||
@@ -140,10 +147,12 @@ detailsInput.addEventListener("input", () => {
|
||||
}
|
||||
});
|
||||
|
||||
// Submit on Enter from either input
|
||||
statusInput.addEventListener("keydown", (e) => { if (e.key === "Enter" && connected) setActivity(); });
|
||||
detailsInput.addEventListener("keydown", (e) => { if (e.key === "Enter" && connected) setActivity(); });
|
||||
appIdInput.addEventListener("keydown", (e) => { if (e.key === "Enter" && !connected) toggleConnection(); });
|
||||
|
||||
// ── Timer ──────────────────────────────────────────────
|
||||
function startTimer() {
|
||||
stopTimer();
|
||||
timerInterval = setInterval(() => {
|
||||
@@ -167,6 +176,7 @@ function stopTimer() {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Help Modal ─────────────────────────────────────────
|
||||
function openHelp() {
|
||||
document.getElementById("helpModal").classList.remove("hidden");
|
||||
}
|
||||
@@ -175,10 +185,12 @@ function closeHelp() {
|
||||
document.getElementById("helpModal").classList.add("hidden");
|
||||
}
|
||||
|
||||
// Close help on Escape
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.key === "Escape") closeHelp();
|
||||
});
|
||||
|
||||
// ── Toast ──────────────────────────────────────────────
|
||||
function toast(msg, type = "neutral") {
|
||||
const container = document.getElementById("toastContainer");
|
||||
const colors = {
|
||||
|
||||
Reference in New Issue
Block a user