diff options
Diffstat (limited to 'radicale_infcloud/web/forms.js')
-rw-r--r-- | radicale_infcloud/web/forms.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/radicale_infcloud/web/forms.js b/radicale_infcloud/web/forms.js index c125820..1f148fe 100644 --- a/radicale_infcloud/web/forms.js +++ b/radicale_infcloud/web/forms.js @@ -31,6 +31,38 @@ function updateTodoFormDimensions(setHeight) } } +function dragOverHandler(event) { + //if (window.console) { + // console.log("dragOverHandler",event); + //} + event.preventDefault(); + event.stopPropagation(); +} + +function dropHandler(event) { + if (event) { + event.preventDefault(); + event.stopPropagation(); + if (window.console) { + console.log("dropHandler",event); + } + if(event.dataTransfer && event.dataTransfer && event.dataTransfer.files.length > 0) { + if(window.console){console.log("files",event.dataTransfer.files);} + for (let f of event.dataTransfer.files) { + if(window.console){console.log("file:",f)}; + let reader = new FileReader(); + reader.readAsText(f); + reader.onload = function(){ + //if(window.console){console.log(reader.result)}; + // Fixing the newlines here prevents having to duplicate the effort multiple times in various places! + uploadFile(reader.result.replace(/\r*\n+/gm,'\r\n')); + }; + reader.onerror = function(){if(window.console){console.log(reader.error)}}; + } + } + } +} + function updateEventFormDimensions(setHeight) { $('#CAEvent').css('width',''); @@ -1590,6 +1622,7 @@ function showEventForm(date, allDay, calEvent, jsEvent, mod, repeatOne, confirmR var color=''; if(mod=='new') { + $('#downloadButton').hide(); var activeCollection = $('#ResourceCalDAVList').find('.resourceCalDAV_item.resourceCalDAV_item_selected'); if(activeCollection.length>0 && !globalResourceCalDAVList.getEventCollectionByUID(activeCollection.attr('data-id')).permissions.read_only) color=rgbToHex(activeCollection.children('.resourceCalDAVColor').css('background-color')); @@ -1681,6 +1714,7 @@ function showEventForm(date, allDay, calEvent, jsEvent, mod, repeatOne, confirmR $('#duplicateButton').hide(); $('#editOptionsButton').hide(); $('#resetButton').hide(); + $('#uploadButton').show(); $('#deleteButton').hide(); if($('#ResourceCalDAVList').find('.resourceCalDAV_item.resourceCalDAV_item_selected').length>0 && $('#event_calendar').find('option[value="'+$('#ResourceCalDAVList').find('.resourceCalDAV_item.resourceCalDAV_item_selected').attr("data-id")+'"]').length>0) @@ -2316,6 +2350,7 @@ function showEventForm(date, allDay, calEvent, jsEvent, mod, repeatOne, confirmR if(mod=='show') { $('#saveButton').hide(); + $('#uploadButton').hide(); $('#resetButton').hide(); $('#deleteButton').hide(); if($('#ResourceCalDAVList').find('[data-id="'+calEvent.res_id+'"]').hasClass("resourceCalDAV_item_ro")) @@ -2844,6 +2879,8 @@ function startEditModeEvent() $('#saveButton').show(); $('#resetButton').show(); $('#deleteButton').show(); + /* Do not show uploadButton; it will be handled elsewhere */ + $('#uploadButton').on("drop",dropHandler(event)); $('#downloadButton').hide(); $('#show').val(''); $('#eventDetailsTable :input[disabled]').prop('disabled', false); |