added upload function

This commit is contained in:
Marlon Portmann committed 2022-11-15 13:18:14 +01:00
1 parent f365ca3592
commit 0e5f580c74
3 files changed
+80 -1

No files matched your search

+40
View File
@@ -39,6 +39,8 @@ $(document).ready(function(){
// idee laden
function ideeAnzeigen(data) {
document.getElementById("idee").innerHTML = "";
@@ -151,6 +153,29 @@ function kommentarErstellen(idee_id) {
});
};
/* function installWidgetPreviewMultiple(widget, list) {
widget.onChange(function(fileGroup) {
list.empty()
if (fileGroup) {
$.when.apply(null, fileGroup.files()).done(function() {
$.each(arguments, function(i, fileInfo) {
var src = fileInfo.cdnUrl + '-/scale_crop/160x160/center/'
list.append($('<div/>', {class: '_item'}).append([$('<img/>', {src: src}), fileInfo.name]))
})
})
}
})
}
$(function() {
$('.image-preview').each(function() {
installWidgetPreviewMultiple(uploadcare.MultipleWidget($(this).children('input')), $(this).children('._list'))
})
})
*/
// Idee formular erstellen
function formularErstellen(koordianten) {
@@ -202,6 +227,21 @@ function formularErstellen(koordianten) {
document.getElementById("form").appendChild(submit_input);
document.getElementById("form").appendChild(koordinaten_lat);
document.getElementById("form").appendChild(koordinaten_lng);
document.getElementById("image-upload").innerHTML = '<input type="hidden" role="uploadcare-uploader" data-public-key="3a3c37e85850c6cfe077" data-multiple="true" data-images-only data-public- data-clearable data-tabs="file camera" data-image-shrink: "1024x1024" data-system-dialog="false"/>';
// get a widget reference
const widget = uploadcare.Widget("[role=uploadcare-uploader]", { multiple: true});
// listen to the "upload completed" event
widget.onUploadComplete(fileGroupInfo => {
// get a information about uploaded group
// check https://uploadcare.com/docs/file-uploader-api/file-groups/#file-group-info
for (var i = 0; i < fileGroupInfo.count; i++) {
console.log("https://ucarecdn.com/" + fileGroupInfo.uuid + "/nth/" + i + "/-/preview/-/quality/smart/-/format/auto/");
}
});
};