mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 11:49:25 +00:00
Fix minor issues in client
This commit is contained in:
@@ -67,7 +67,7 @@ let stompClient;
|
||||
applyCanvasSettings(canvasSettings);
|
||||
|
||||
audioUnlockEvents.forEach((eventName) => {
|
||||
window.addEventListener(eventName, () => {
|
||||
globalThis.addEventListener(eventName, () => {
|
||||
if (!pendingAudioUnlock.size) return;
|
||||
pendingAudioUnlock.forEach((controller) => {
|
||||
safePlay(controller);
|
||||
@@ -275,7 +275,7 @@ function setAudioSpeedLabel(percentValue) {
|
||||
}
|
||||
|
||||
function formatDelayLabel(ms) {
|
||||
const numeric = Math.max(0, parseInt(ms, 10) || 0);
|
||||
const numeric = Math.max(0, Number.parseInt(ms, 10) || 0);
|
||||
if (numeric >= 1000) {
|
||||
const seconds = numeric / 1000;
|
||||
const decimals = Number.isInteger(seconds) ? 0 : 1;
|
||||
@@ -376,7 +376,7 @@ if (selectedDeleteBtn) {
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener("keydown", (event) => {
|
||||
globalThis.addEventListener("keydown", (event) => {
|
||||
if (isFormInputElement(event.target)) {
|
||||
return;
|
||||
}
|
||||
@@ -596,11 +596,14 @@ function applyPatch(assetId, patch) {
|
||||
clearMedia(assetId);
|
||||
loopPlaybackState.delete(assetId);
|
||||
}
|
||||
const targetLayer = Number.isFinite(patch.layer)
|
||||
? patch.layer
|
||||
: Number.isFinite(patch.zIndex)
|
||||
? patch.zIndex
|
||||
: null;
|
||||
let targetLayer;
|
||||
if (Number.isFinite(patch.layer)) {
|
||||
targetLayer = patch.layer;
|
||||
} else if (Number.isFinite(patch.zIndex)) {
|
||||
targetLayer = patch.zIndex;
|
||||
} else {
|
||||
targetLayer = null;
|
||||
}
|
||||
if (!isAudio && Number.isFinite(targetLayer)) {
|
||||
const currentOrder = getLayerOrder().filter((id) => id !== assetId);
|
||||
const insertIndex = Math.max(0, currentOrder.length - Math.round(targetLayer));
|
||||
@@ -1093,7 +1096,7 @@ function ensureMedia(asset) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isGifAsset(asset) && "ImageDecoder" in window) {
|
||||
if (isGifAsset(asset) && "ImageDecoder" in globalThis) {
|
||||
const animated = ensureAnimatedImage(asset);
|
||||
if (animated) {
|
||||
mediaCache.set(asset.id, animated);
|
||||
@@ -1567,7 +1570,7 @@ function captureVideoFrame(asset) {
|
||||
}
|
||||
|
||||
function captureGifFrame(asset) {
|
||||
if (!("ImageDecoder" in window)) {
|
||||
if (!("ImageDecoder" in globalThis)) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
return fetch(asset.url)
|
||||
@@ -1857,15 +1860,15 @@ function updateAudioSettingsFromInputs() {
|
||||
const asset = getSelectedAsset();
|
||||
if (!asset || !isAudioAsset(asset)) return;
|
||||
asset.audioLoop = !!audioLoopInput?.checked;
|
||||
const delayMs = clamp(Math.max(0, parseInt(audioDelayInput?.value || "0", 10)), 0, 30000);
|
||||
const delayMs = clamp(Math.max(0, Number.parseInt(audioDelayInput?.value || "0", 10)), 0, 30000);
|
||||
asset.audioDelayMillis = delayMs;
|
||||
setAudioDelayLabel(delayMs);
|
||||
if (audioDelayInput) audioDelayInput.value = delayMs;
|
||||
const nextAudioSpeedPercent = clamp(Math.max(25, parseInt(audioSpeedInput?.value || "100", 10)), 25, 400);
|
||||
const nextAudioSpeedPercent = clamp(Math.max(25, Number.parseInt(audioSpeedInput?.value || "100", 10)), 25, 400);
|
||||
setAudioSpeedLabel(nextAudioSpeedPercent);
|
||||
if (audioSpeedInput) audioSpeedInput.value = nextAudioSpeedPercent;
|
||||
asset.audioSpeed = Math.max(0.25, nextAudioSpeedPercent / 100);
|
||||
const nextAudioPitchPercent = clamp(Math.max(50, parseInt(audioPitchInput?.value || "100", 10)), 50, 200);
|
||||
const nextAudioPitchPercent = clamp(Math.max(50, Number.parseInt(audioPitchInput?.value || "100", 10)), 50, 200);
|
||||
setAudioPitchLabel(nextAudioPitchPercent);
|
||||
if (audioPitchInput) audioPitchInput.value = nextAudioPitchPercent;
|
||||
asset.audioPitch = Math.max(0.5, nextAudioPitchPercent / 100);
|
||||
@@ -2288,7 +2291,7 @@ function endInteraction() {
|
||||
canvas.addEventListener("mouseup", endInteraction);
|
||||
canvas.addEventListener("mouseleave", endInteraction);
|
||||
|
||||
window.addEventListener("resize", () => {
|
||||
globalThis.addEventListener("resize", () => {
|
||||
resizeCanvas();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const canvas = document.getElementById("broadcast-canvas");
|
||||
const obsBrowser = !!window.obsstudio;
|
||||
const obsBrowser = !!globalThis.obsstudio;
|
||||
const supportsAnimatedDecode =
|
||||
typeof ImageDecoder !== "undefined" && typeof createImageBitmap === "function" && !obsBrowser;
|
||||
const canPlayProbe = document.createElement("video");
|
||||
@@ -28,7 +28,7 @@ let layerOrder = [];
|
||||
applyCanvasSettings(canvasSettings);
|
||||
|
||||
audioUnlockEvents.forEach((eventName) => {
|
||||
window.addEventListener(eventName, () => {
|
||||
globalThis.addEventListener(eventName, () => {
|
||||
if (!pendingAudioUnlock.size) return;
|
||||
pendingAudioUnlock.forEach((controller) => safePlay(controller));
|
||||
pendingAudioUnlock.clear();
|
||||
@@ -434,7 +434,7 @@ function isAudioAsset(asset) {
|
||||
}
|
||||
|
||||
function isVideoElement(element) {
|
||||
return element && element.tagName === "VIDEO";
|
||||
return element?.tagName === "VIDEO";
|
||||
}
|
||||
|
||||
function isGifAsset(asset) {
|
||||
@@ -896,7 +896,7 @@ function startRenderLoop() {
|
||||
}, MIN_FRAME_TIME);
|
||||
}
|
||||
|
||||
window.addEventListener("resize", () => {
|
||||
globalThis.addEventListener("resize", () => {
|
||||
resizeCanvas();
|
||||
});
|
||||
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
|
||||
const persistDismissal = () => {
|
||||
try {
|
||||
window.localStorage.setItem(CONSENT_STORAGE_KEY, "true");
|
||||
globalThis.localStorage.setItem(CONSENT_STORAGE_KEY, "true");
|
||||
} catch {}
|
||||
document.cookie = `${CONSENT_STORAGE_KEY}=true; max-age=${COOKIE_MAX_AGE_SECONDS}; path=/; SameSite=Lax`;
|
||||
};
|
||||
|
||||
const hasDismissed = () => {
|
||||
try {
|
||||
if (window.localStorage.getItem(CONSENT_STORAGE_KEY) === "true") {
|
||||
if (globalThis.localStorage.getItem(CONSENT_STORAGE_KEY) === "true") {
|
||||
return true;
|
||||
}
|
||||
} catch {}
|
||||
@@ -41,7 +41,7 @@
|
||||
}
|
||||
persistDismissal();
|
||||
banner.classList.add("cookie-consent-exit");
|
||||
window.setTimeout(() => banner.remove(), 180);
|
||||
globalThis.setTimeout(() => banner.remove(), 180);
|
||||
};
|
||||
|
||||
const renderBanner = () => {
|
||||
|
||||
@@ -47,7 +47,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
searchInput.focus();
|
||||
return;
|
||||
}
|
||||
window.location.href = `/view/${encodeURIComponent(broadcaster)}/broadcast`;
|
||||
globalThis.location.href = `/view/${encodeURIComponent(broadcaster)}/broadcast`;
|
||||
});
|
||||
|
||||
loadChannels();
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
setTimeout(() => toast.remove(), 250);
|
||||
}
|
||||
|
||||
window.showToast = function showToast(message, type = "info", options = {}) {
|
||||
globalThis.showToast = function showToast(message, type = "info", options = {}) {
|
||||
if (!message) return;
|
||||
const normalized = ["success", "error", "warning", "info"].includes(type) ? type : "info";
|
||||
const duration = typeof options.duration === "number" ? options.duration : DEFAULT_DURATION;
|
||||
|
||||
Reference in New Issue
Block a user