-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add filedropper to root - move functions to external JS
- Loading branch information
Showing
8 changed files
with
94 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules/ | ||
dist/ | ||
dist/ | ||
.wrangler/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
@import url("style.css"); | ||
</style> | ||
</head> | ||
<body> | ||
<div class="center" ondrop="dropHandler(event)" ondragover="dragOverHandler(event)"> | ||
<h3>File Drop</h3> | ||
<label for="select-file">Click to browse</label> | ||
<input | ||
type="file" | ||
id="select-file" | ||
onchange="chooseHandler(event)" | ||
> | ||
<ul id="filelist">Uploaded Files:</ul> | ||
</div> | ||
<script src="upload.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const BINURL = "https://b.mmpc.me" | ||
const SIZELIMIT = 1024 * 1024 * 25 // 25MB | ||
|
||
function addFile(binurl, filename) { | ||
const a = document.createElement("a") | ||
a.href = `${binurl}/${filename}` | ||
a.innerText = filename || binurl | ||
document.getElementById("filelist").appendChild(a) | ||
clipboard(a.href) | ||
} | ||
const upload = (body, contentType, fileName, binType = "b") => | ||
fetch(`${BINURL}/${binType}`, { | ||
method: "POST", headers: { "Content-Type": contentType, "File-Name": fileName }, body | ||
}) | ||
.then(async (res) => addFile(`${BINURL}/${binType}/${await res.text()}`, fileName)) | ||
.catch((err) => console.error(err)) | ||
const uploadText = () => upload(document.getElementById("upload_body").value, "text/plain", "text.txt") | ||
const setUrl = () => upload(document.getElementById("dest").value, "", "", "u") | ||
const uploadFile = (file) => upload(file, file.type, file.name) | ||
const fileHandler = (files) => files.forEach((file) => { | ||
if (file.size > SIZELIMIT) alert(`File ${file.name} is too large (${(file.size / 1024 / 1024).toFixed(1)}MB)`) | ||
uploadFile(file) | ||
}) | ||
const dropHandler = (e) => { | ||
e.preventDefault() | ||
fileHandler(e.dataTransfer.files) | ||
}; | ||
const chooseHandler = (e) => fileHandler(e.target.files) | ||
const dragOverHandler = (e) => e.preventDefault() | ||
const clipboard = (str) => navigator.clipboard.writeText(str) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters