- *
- * This file is part of Remote-Touchpad.
- *
- * Remote-Touchpad is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Remote-Touchpad is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Remote-Touchpad. If not, see .
- */
-
package main
import (
"embed"
"io/fs"
"log"
- "mime"
)
//go:embed webdata/*
var webdataFSWithPrefix embed.FS
var webdataFS fs.FS
-var webdataTypes = map[string]string{
- ".css": "text/css; charset=utf-8",
- ".html": "text/html; charset=utf-8",
- ".mjs": "text/javascript; charset=utf-8",
- ".png": "image/png",
- ".woff": "font/woff",
-}
-
func init() {
var err error
webdataFS, err = fs.Sub(webdataFSWithPrefix, "webdata")
if err != nil {
log.Fatal(err)
}
- for ext, typ := range webdataTypes {
- if err := mime.AddExtensionType(ext, typ); err != nil {
- log.Fatal(err)
- }
- }
}
diff --git a/webdata/app/ui.mjs b/webdata/app/ui.mjs
index a21ddf1..5441823 100644
--- a/webdata/app/ui.mjs
+++ b/webdata/app/ui.mjs
@@ -57,13 +57,12 @@ export default class UI {
(target) => target.classList.contains("touch-input"));
document.addEventListener("mousedown", this.#handleMousedown.bind(this));
document.addEventListener("touchend", this.#handleTouchend.bind(this));
- textInput.addEventListener("input", () => { this.#updateTextInput(); });
+ textInput.addEventListener("input", this.#handleTextInput.bind(this));
sendText.addEventListener("click", this.#handleSendText.bind(this));
window.addEventListener("popstate", () => { this.#update(); });
compat.addFullscreenchangeEventListener(() => { this.#update(); });
compat.addPointerlockchangeEventListener(() => { this.#update(); });
for (const button of buttons) {
- button.setAttribute("tabindex", "-1");
button.addEventListener("click", this.#handleButtonClick.bind(this));
}
this.#update();
@@ -98,13 +97,8 @@ export default class UI {
}
}
- #updateTextInput(newValue = null) {
- if (newValue != null) {
- textInput.value = newValue;
- }
+ #handleTextInput() {
sessionStorage.setItem("text-input", textInput.value);
- sendText.textContent = sendText.getAttribute(`data-${textInput.value ? "send" : "back"}-content`);
- textInput.focus();
}
#handleButtonClick(event) {
@@ -118,10 +112,10 @@ export default class UI {
// normalize line endings
const text = textInput.value.replace(/\r\n?/g, "\n");
this.#inputController.keyboardText(text);
- this.#updateTextInput("");
- } else {
- history.back();
+ textInput.value = "";
+ this.#handleTextInput();
}
+ history.back();
}
#showScene(scene) {
@@ -165,7 +159,8 @@ export default class UI {
showTextInput() {
this.#showScene(textInputScene);
- this.#updateTextInput(sessionStorage.getItem("text-input") || "");
+ textInput.value = sessionStorage.getItem("text-input") || "";
+ textInput.focus();
if (history.state != "text-input") {
history.pushState("text-input", "");
}
diff --git a/webdata/index.html b/webdata/index.html
index 52fb46f..a011d0b 100644
--- a/webdata/index.html
+++ b/webdata/index.html
@@ -1,7 +1,7 @@
-
+
Remote Touchpad
@@ -28,7 +28,7 @@
-
+
@@ -95,6 +95,6 @@
-