2019-04-28 15:27:55 +02:00
|
|
|
var fileobj;
|
2019-10-22 14:19:02 +02:00
|
|
|
function file_dropped(e)
|
2019-04-28 15:27:55 +02:00
|
|
|
{
|
|
|
|
e.preventDefault();
|
|
|
|
fileobj = e.dataTransfer.files[0];
|
2019-10-22 14:19:02 +02:00
|
|
|
upload_file(fileobj);
|
2019-04-28 15:27:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function file_explorer() {
|
|
|
|
document.getElementById('uploadfile').click();
|
2019-04-28 22:30:23 +02:00
|
|
|
document.getElementById('uploadfile').onchange = function()
|
2019-04-28 15:27:55 +02:00
|
|
|
{
|
|
|
|
fileobj = document.getElementById('uploadfile').files[0];
|
2019-10-22 14:19:02 +02:00
|
|
|
upload_file(fileobj);
|
2019-04-28 15:27:55 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function copytoclipboard()
|
|
|
|
{
|
|
|
|
var elm = document.getElementById("divresponse");
|
|
|
|
var selection = window.getSelection();
|
|
|
|
var range = document.createRange();
|
|
|
|
range.selectNodeContents(elm);
|
|
|
|
selection.removeAllRanges();
|
|
|
|
selection.addRange(range);
|
|
|
|
document.execCommand("Copy");
|
|
|
|
}
|
|
|
|
|
2019-10-22 14:19:02 +02:00
|
|
|
function upload_file(file_obj)
|
2019-04-28 15:27:55 +02:00
|
|
|
{
|
2019-04-28 15:44:02 +02:00
|
|
|
var divresponse = document.getElementById('divresponse');
|
|
|
|
divresponse.innerHTML = "Uploading file..." ;
|
2019-10-22 14:19:02 +02:00
|
|
|
const request = async () => {
|
|
|
|
var response = await fetch('/index.php', {
|
|
|
|
method: 'PUT',
|
|
|
|
body: file_obj
|
|
|
|
});
|
|
|
|
var text = await response.text();
|
|
|
|
console.log(text);
|
|
|
|
divresponse.innerHTML = text ;
|
|
|
|
document.getElementById('copytoclipboard').style.visibility = "visible";
|
|
|
|
|
|
|
|
}
|
|
|
|
request();
|
2019-04-28 15:27:55 +02:00
|
|
|
|
|
|
|
}
|
2019-04-28 22:30:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
function change_color_ondrag(event)
|
|
|
|
{
|
|
|
|
if (event === "ondragenter")
|
|
|
|
{
|
|
|
|
var element = document.getElementById('dragzone');
|
|
|
|
element.classList.add("dragover");
|
|
|
|
}
|
|
|
|
else if (event === "ondragleave")
|
|
|
|
{
|
|
|
|
var element = document.getElementById('dragzone');
|
|
|
|
element.classList.remove("dragover");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|