You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.6 KiB

// i dont know how to java script. if you do know how to,
// want to rewrite this into proper java script,
// and can do so without introducing any dependencies etc,
// email me at v-contrib @ xenua dot me
document.addEventListener('load', () => {
let replaceMe = document.querySelector("#scriptReplaceTarget");
// TODO
})
window.addEventListener('paste', (event) => {
handleDataTransfer(event.clipboardData);
});
handleDataTransfer = (data) => {
if (data.clipboardData.items) {
let item = data.clipboardData.items[0];
if (item.kind === 'string') {
item.getAsString((thing) => {
try {
let url = new URL(thing);
promptUser("you pasted a valid link; do you want to create a short link?", () => {
createShortLink(url);
}, () => {
initTextArea(thing);
});
} catch (e) {
initTextArea(thing);
}
})
} else {
uploadFile(item.getAsFile());
}
}
}
promptUser = (promptText, yesAction, noAction) => {
}
initTextArea = (initialContents) => {
}
uploadFile = (file) => {
}
onDropHandler = (event) => {
}
onDragEnterHandler = (event) => {
if (event.target.classList.contains("dropzone")) {
event.target.classList.add("dragover");
}
}
onDragLeaveHandler = (event) => {
if (event.target.classList.contains("dropzone")) {
event.target.classList.remove("dragover");
}
}
createShortLink = (url) => {
}