65 lines
1.8 KiB
JavaScript
65 lines
1.8 KiB
JavaScript
var fileobj;
|
|
function upload_file(e)
|
|
{
|
|
console.log("droped")
|
|
e.preventDefault();
|
|
fileobj = e.dataTransfer.files[0];
|
|
ajax_file_upload(fileobj);
|
|
}
|
|
|
|
function file_explorer() {
|
|
document.getElementById('uploadfile').click();
|
|
document.getElementById('uploadfile').onchange = function()
|
|
{
|
|
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)
|
|
{
|
|
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";
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
|
|
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");
|
|
}
|
|
}
|
|
|