mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-16 04:58:00 +00:00
v3 preparations
This commit is contained in:
40
web/js/pictshare.js
Normal file
40
web/js/pictshare.js
Normal file
@@ -0,0 +1,40 @@
|
||||
Dropzone.autoDiscover = false;
|
||||
|
||||
$(function () {
|
||||
var myDropzone = new Dropzone("#dropzone");
|
||||
//console.log(myDropzone.options);
|
||||
if (maxUploadFileSize !== undefined)
|
||||
myDropzone.options.maxFilesize = maxUploadFileSize;
|
||||
myDropzone.options.timeout = 0,
|
||||
myDropzone.on("sending", function(file, xhr, formData) {
|
||||
if(document.getElementById("uploadcode"))
|
||||
formData.append("uploadcode", document.getElementById("uploadcode").value);
|
||||
});
|
||||
myDropzone.on('error', function(file, response) {
|
||||
alert("Error: "+response.reason);
|
||||
});
|
||||
myDropzone.on("success", function (file, response) {
|
||||
console.log("raw response: " + response);
|
||||
if (response == null || response == "null")
|
||||
$("#uploadinfo").append("<div class='alert alert-danger' role='alert'><strong>Error uploading " + file.name + "</strong><br/>Reason is unknown :(</div>")
|
||||
else {
|
||||
var o = response;
|
||||
if (o.status == 'ok')
|
||||
$("#uploadinfo").append("<div class='alert alert-success' role='alert'><strong>" + file.name + "</strong> uploaded as <a target='_blank' href='/" + o.hash + "'>" + o.hash + "</a><br/>URL: <a target='_blank' href='" + o.url + "'>" + o.url + "</a> <button class='btn btn-xs' onClick='navigator.clipboard.writeText(\"" + o.url + "\");'>Copy URL</button></div>")
|
||||
else if (o.status == 'err')
|
||||
$("#uploadinfo").append("<div class='alert alert-danger' role='alert'><strong>Error uploading " + file.name + "</strong><br/>Reason: " + o.reason + "</div>")
|
||||
console.log(o)
|
||||
}
|
||||
});
|
||||
|
||||
document.onpaste = function (event) {
|
||||
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
|
||||
for (index in items) {
|
||||
var item = items[index];
|
||||
if (item.kind === 'file') {
|
||||
// adds the file to your dropzone instance
|
||||
myDropzone.addFile(item.getAsFile())
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user