mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-26 00:58:58 +01:00
double-click
This commit is contained in:
parent
524715b393
commit
61428f2c5d
1 changed files with 53 additions and 42 deletions
95
css/app.js
95
css/app.js
|
@ -278,44 +278,55 @@ function fetchUrls(urls) {
|
||||||
var loopOption = document.getElementById("loopOption");
|
var loopOption = document.getElementById("loopOption");
|
||||||
var speedOption = document.getElementById("speedOption");
|
var speedOption = document.getElementById("speedOption");
|
||||||
|
|
||||||
|
let contextMenuTimer;
|
||||||
|
let doubleClickTimeout = 300;
|
||||||
|
|
||||||
video.addEventListener("contextmenu", function(event) {
|
video.addEventListener("contextmenu", function(event) {
|
||||||
// Check if the video is in fullscreen mode
|
event.preventDefault();
|
||||||
if (!document.fullscreenElement && !document.webkitFullscreenElement && !document.mozFullScreenElement && !document.msFullscreenElement) {
|
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
popupMenu.style.display = "block";
|
clearTimeout(contextMenuTimer);
|
||||||
popupMenu.style.left = event.pageX + "px";
|
|
||||||
popupMenu.style.top = event.pageY + "px";
|
contextMenuTimer = setTimeout(function() {
|
||||||
|
if (!document.fullscreenElement && !document.webkitFullscreenElement && !document.mozFullScreenElement && !document.msFullscreenElement) {
|
||||||
|
popupMenu.style.display = "block";
|
||||||
|
popupMenu.style.left = event.pageX + "px";
|
||||||
|
popupMenu.style.top = event.pageY + "px";
|
||||||
|
}
|
||||||
|
}, doubleClickTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
video.addEventListener("dblclick", function(event) {
|
||||||
|
if (event.button === 2) {
|
||||||
|
clearTimeout(contextMenuTimer);
|
||||||
|
popupMenu.style.display = "none";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Hide the popup menu when clicking outside of it
|
||||||
|
window.addEventListener("click", function(event) {
|
||||||
|
if (event.target !== video) {
|
||||||
|
popupMenu.style.display = "none";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Hide the popup menu when clicking outside of it
|
var loopedIndicator = document.getElementById("loopedIndicator");
|
||||||
window.addEventListener("click", function(event) {
|
loopedIndicator.style.display = "none"; // Initially hide the indicator
|
||||||
if (event.target !== video) {
|
|
||||||
popupMenu.style.display = "none";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var loopedIndicator = document.getElementById("loopedIndicator");
|
|
||||||
|
|
||||||
loopedIndicator.style.display = "none"; // Initially hide the indicator
|
|
||||||
|
|
||||||
loopOption.addEventListener("click", function() {
|
loopOption.addEventListener("click", function() {
|
||||||
const quaindt = new URLSearchParams(window.location.search).get("quality") || "";
|
const quaindt = new URLSearchParams(window.location.search).get("quality") || "";
|
||||||
|
|
||||||
var looped = video.loop;
|
var looped = video.loop;
|
||||||
video.loop = !looped;
|
video.loop = !looped;
|
||||||
|
|
||||||
if (quaindt !== "medium") {
|
if (quaindt !== "medium") {
|
||||||
var loopedaudioelement = document.getElementById("aud");
|
var loopedaudioelement = document.getElementById("aud");
|
||||||
if (loopedaudioelement) {
|
if (loopedaudioelement) {
|
||||||
loopedaudioelement.loop = !looped;
|
loopedaudioelement.loop = !looped;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var displaySpecialText = Math.random() < 0.5;
|
var displaySpecialText = Math.random() < 0.5;
|
||||||
|
|
||||||
if (displaySpecialText) {
|
if (displaySpecialText) {
|
||||||
var specialText = looped ? "Unlooped >.<" : "Looped~ :3 >~<";
|
var specialText = looped ? "Unlooped >.<" : "Looped~ :3 >~<";
|
||||||
|
@ -331,28 +342,28 @@ loopOption.addEventListener("click", function() {
|
||||||
}, 2000);
|
}, 2000);
|
||||||
});
|
});
|
||||||
|
|
||||||
speedOption.addEventListener("click", function() {
|
speedOption.addEventListener("click", function() {
|
||||||
|
var currentSpeed = video.playbackRate;
|
||||||
|
var newSpeed = getNextSpeed(currentSpeed);
|
||||||
|
video.playbackRate = newSpeed;
|
||||||
|
document.getElementById("aud").playbackRate = newSpeed;
|
||||||
|
speedOption.innerHTML = "<i class='fa-light fa-gauge'></i> Speed: " + newSpeed.toFixed(2) + "x";
|
||||||
|
});
|
||||||
|
|
||||||
var currentSpeed = video.playbackRate;
|
function getNextSpeed(currentSpeed) {
|
||||||
var newSpeed = getNextSpeed(currentSpeed);
|
if (currentSpeed === 2) {
|
||||||
video.playbackRate = newSpeed;
|
return 0.25;
|
||||||
document.getElementById("aud").playbackRate = newSpeed;
|
} else if (currentSpeed === 0.25) {
|
||||||
speedOption.innerHTML = "<i class='fa-light fa-gauge'></i> Speed: " + newSpeed.toFixed(2) + "x";
|
return 0.5;
|
||||||
});
|
} else if (currentSpeed === 0.5) {
|
||||||
|
return 0.75;
|
||||||
|
} else if (currentSpeed === 0.75) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getNextSpeed(currentSpeed) {
|
|
||||||
if (currentSpeed === 2) {
|
|
||||||
return 0.25;
|
|
||||||
} else if (currentSpeed === 0.25) {
|
|
||||||
return 0.5;
|
|
||||||
} else if (currentSpeed === 0.5) {
|
|
||||||
return 0.75;
|
|
||||||
} else if (currentSpeed === 0.75) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const GoogleTranslateEndpoint = "https://translate.google.com/_/TranslateWebserverUi/data/batchexecute?rpcids=MkEWBc&rt=c"
|
const GoogleTranslateEndpoint = "https://translate.google.com/_/TranslateWebserverUi/data/batchexecute?rpcids=MkEWBc&rt=c"
|
||||||
// @license-end
|
// @license-end
|
Loading…
Reference in a new issue