extension: Fix-ups for extension player page
This commit is contained in:
parent
20b07ff147
commit
ba52438c27
|
@ -20,10 +20,7 @@ button {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
background: var(--ruffle-orange);
|
background: var(--ruffle-orange);
|
||||||
color: black;
|
color: black;
|
||||||
}
|
border-top: 1px solid var(--ruffle-blue);
|
||||||
|
|
||||||
button#options-button {
|
|
||||||
border-bottom: 1px solid var(--ruffle-blue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#version-text {
|
#version-text {
|
||||||
|
|
|
@ -22,6 +22,8 @@ const closeModal = document.getElementById("close-modal")!;
|
||||||
const openModal = document.getElementById("open-modal")!;
|
const openModal = document.getElementById("open-modal")!;
|
||||||
const reloadSwf = document.getElementById("reload-swf")!;
|
const reloadSwf = document.getElementById("reload-swf")!;
|
||||||
const metadataModal = document.getElementById("metadata-modal")!;
|
const metadataModal = document.getElementById("metadata-modal")!;
|
||||||
|
const webFormSubmit = document.getElementById("web-form-submit")!;
|
||||||
|
const webURL = document.getElementById("web-url")! as HTMLInputElement;
|
||||||
|
|
||||||
// Default config used by the player.
|
// Default config used by the player.
|
||||||
const defaultConfig = {
|
const defaultConfig = {
|
||||||
|
@ -241,28 +243,31 @@ async function loadSwf(swfUrl: string) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener("pageshow", async () => {
|
async function loadSwfFromHash() {
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
// Hash always starts with #, gotta slice that off
|
// Hash always starts with #, gotta slice that off
|
||||||
const swfUrl = url.hash.length > 1 ? url.hash.slice(1) : null;
|
const swfUrl = url.hash.length > 1 ? url.hash.slice(1) : null;
|
||||||
if (swfUrl) {
|
if (swfUrl) {
|
||||||
|
webURL.value = swfUrl;
|
||||||
await loadSwf(swfUrl);
|
await loadSwf(swfUrl);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener("pageshow", async () => {
|
||||||
|
await loadSwfFromHash();
|
||||||
|
});
|
||||||
|
|
||||||
|
window.addEventListener("hashchange", async () => {
|
||||||
|
await loadSwfFromHash();
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener("DOMContentLoaded", async () => {
|
window.addEventListener("DOMContentLoaded", async () => {
|
||||||
const webFormSubmit = document.getElementById(
|
webFormSubmit.addEventListener("click", function () {
|
||||||
"web-form-submit",
|
if (webURL.value !== "") {
|
||||||
) as HTMLButtonElement;
|
window.location.hash = webURL.value;
|
||||||
if (webFormSubmit) {
|
}
|
||||||
webFormSubmit.addEventListener("click", function () {
|
});
|
||||||
const webURL = document.getElementById(
|
webURL.addEventListener("keydown", (event) =>
|
||||||
"web-url",
|
event.key === "Enter" ? webFormSubmit.click() : undefined,
|
||||||
) as HTMLInputElement;
|
);
|
||||||
if ((webURL?.value || "") !== "") {
|
|
||||||
loadSwf(webURL.value);
|
|
||||||
window.location.href = "#" + webURL.value;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue