From 6a7ff645fed45fbfe12a53df11609268e8f8625b Mon Sep 17 00:00:00 2001 From: strawberry-raccoon <253751817+strawberry-raccoon@users.noreply.github.com> Date: Tue, 24 Mar 2026 20:53:40 +0000 Subject: [PATCH] Add converting from URL (#11) --- public/script.js | 31 ++++++++++++++++++++++ src/index.tsx | 2 ++ src/pages/root.tsx | 14 ++++++++++ src/pages/url.tsx | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 src/pages/url.tsx diff --git a/public/script.js b/public/script.js index 8b89194..4c4c26e 100644 --- a/public/script.js +++ b/public/script.js @@ -1,4 +1,6 @@ const webroot = document.querySelector("meta[name='webroot']").content; +const urlInput = document.querySelector("#url-input"); +const urlSubmit = document.querySelector("#url-submit"); const fileInput = document.querySelector('input[type="file"]'); const dropZone = document.getElementById("dropzone"); const convertButton = document.querySelector("input[type='submit']"); @@ -33,6 +35,35 @@ dropZone.addEventListener("drop", (e) => { } }); +urlSubmit.addEventListener("click", (e) => { + e.preventDefault(); + handleUrl(urlInput.value); +}); + +function handleUrl(url) { + fetch(`${webroot}/url`, { + method: "POST", + body: JSON.stringify({ url }), + headers: { "Content-Type": "application/json" }, + }) + .then((res) => res.json()) + .then((res) => { + const fileList = document.querySelector("#file-list"); + + const row = document.createElement("tr"); + row.innerHTML = ` +