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-23 15:38:13 +02:00
|
|
|
filename = e.dataTransfer.files[0].name;
|
|
|
|
upload_file(fileobj,filename);
|
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-23 15:38:13 +02:00
|
|
|
filename = document.getElementById('uploadfile').files[0].name;
|
|
|
|
upload_file(fileobj,filename);
|
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-23 15:38:13 +02:00
|
|
|
function upload_file(file_obj,file_name)
|
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 () => {
|
2019-10-23 15:38:13 +02:00
|
|
|
var response = await fetch('/index.php?name=' + file_name, {
|
2019-10-22 14:19:02 +02:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|