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