mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-22 13:56:27 -08:00
30 lines
1.3 KiB
JavaScript
30 lines
1.3 KiB
JavaScript
|
document.getElementById("uploadButton").addEventListener("click",() => {
|
||
|
let ask = prompt("Input a URL to clone.")
|
||
|
|
||
|
if (ask) {
|
||
|
let opt = getOptionsForUploading()
|
||
|
updateBtnTxt("Requesting clone. Please wait.")
|
||
|
|
||
|
let xmlhttp = new XMLHttpRequest()
|
||
|
|
||
|
xmlhttp.addEventListener("error",function(e) {
|
||
|
updateBtnTxt(`Upload failed.<br/>${e.toString()}`)
|
||
|
console.error(e)
|
||
|
})
|
||
|
|
||
|
xmlhttp.addEventListener("load",function() {
|
||
|
if (xmlhttp.status == 200) {
|
||
|
document.getElementById("CopyTB").value = `https://${location.hostname}/download/${xmlhttp.responseText}`
|
||
|
updateBtnTxt(`Upload complete.<br/><a style="color:blue;font-family:monospace;" href="javascript:document.getElementById('CopyTB').focus();document.getElementById('CopyTB').select();document.execCommand('copy');document.getElementById('CopyTB').blur();">Copy URL</a> <a style="color:blue;font-family:monospace;" href="javascript:prompt('This is your download URL.', document.getElementById('CopyTB').value);null">View URL</a>`)
|
||
|
} else {
|
||
|
updateBtnTxt(`Upload failed.<br/>${xmlhttp.responseText}`)
|
||
|
}
|
||
|
})
|
||
|
|
||
|
xmlhttp.open("POST","/clone")
|
||
|
xmlhttp.send(JSON.stringify({
|
||
|
url: ask,
|
||
|
...opt
|
||
|
}))
|
||
|
}
|
||
|
})
|