Skip to content

Commit

Permalink
Added experimental pastebin support
Browse files Browse the repository at this point in the history
  • Loading branch information
StrawberryMaster committed Apr 13, 2024
1 parent ea91ebf commit 4b4b8a4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions static/js/file_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,25 @@ function mapFromFile(data, type, accessible) {
createMap(parsed, accessible);
}

document.querySelector("#paste-upload").addEventListener("submit", (e) => {
document.querySelector("#paste-upload").addEventListener("submit", async (e) => {
e.preventDefault();

const accessible = document.querySelector("#accessible").checked;

const data = document.querySelector("#paste-upload textarea").value;
let data = document.querySelector("#paste-upload textarea").value;
const type = document.querySelector("#file-format").getAttribute("data-selected").toLowerCase();

// for URLs and pastebin-like services
if (data.startsWith('https://')) {
const response = await fetch(data);
if (response.ok) {
data = await response.text();
} else {
console.error('Unable to fetch data from URL:', response.status);
return;
}
}

mapFromFile(data, type, accessible);
});

Expand Down

0 comments on commit 4b4b8a4

Please sign in to comment.