web-ft/script.js

65 lines
1.8 KiB
JavaScript
Raw Normal View History

2019-04-28 15:27:55 +02:00
var fileobj;
function upload_file(e)
{
console.log("droped")
2019-04-28 15:27:55 +02:00
e.preventDefault();
fileobj = e.dataTransfer.files[0];
ajax_file_upload(fileobj);
}
function file_explorer() {
document.getElementById('uploadfile').click();
document.getElementById('uploadfile').onchange = function()
2019-04-28 15:27:55 +02:00
{
fileobj = document.getElementById('uploadfile').files[0];
ajax_file_upload(fileobj);
};
}
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");
}
function ajax_file_upload(file_obj)
{
2019-04-28 15:44:02 +02:00
var divresponse = document.getElementById('divresponse');
divresponse.innerHTML = "Uploading file..." ;
$.ajax(
{
type: 'PUT',
url: 'index.php',
contentType: false,
processData: false,
data: file_obj,
success:function(response)
{;
divresponse.innerHTML = response ;
document.getElementById('copytoclipboard').style.visibility = "visible";
}
});
2019-04-28 15:27:55 +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");
}
}