diff options
author | B. Stack <bgstack15@gmail.com> | 2022-08-10 22:35:07 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2022-08-10 22:35:07 -0400 |
commit | 565d576f704c337b82a583d192c77d43bfca2648 (patch) | |
tree | 35b6ea25942e190e48a1878902c0fcbdff8825db /radicale_infcloud/web/forms.js | |
parent | add my preferred contact display settings (diff) | |
download | radicaleinfcloud-565d576f704c337b82a583d192c77d43bfca2648.tar.gz radicaleinfcloud-565d576f704c337b82a583d192c77d43bfca2648.tar.bz2 radicaleinfcloud-565d576f704c337b82a583d192c77d43bfca2648.zip |
WIP: add upload functionality, part 1
The upload button now calls logic, which does a rudimentary upload.
The new item can successfully be saved to the server, but the event
does not immediately show up in the InfCloud view. The user has to
reload the web page to see the new event, which of course is not ideal.
There must be a way to add the new object immediately.
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..4e5a1a9 100644 --- a/radicale_infcloud/web/forms.js +++ b/radicale_infcloud/web/forms.js @@ -31,6 +31,39 @@ function updateTodoFormDimensions(setHeight) } } +function dragOverHandler(event) { + //if (window.console) { + // console.log("dragOverHandler",event); + //} + event.preventDefault(); + event.stopPropagation(); +} + +/* Incomplete import process. The function logs to console but does not use the vcard contents. */ +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)}; + //dataToVcalendar('EDIT' + uploadFile(reader.result) + }; + reader.onerror = function(){if(window.console){console.log(reader.error)}}; + } + } + } +} + function updateEventFormDimensions(setHeight) { $('#CAEvent').css('width',''); @@ -2316,6 +2349,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 +2878,9 @@ function startEditModeEvent() $('#saveButton').show(); $('#resetButton').show(); $('#deleteButton').show(); + /* WORKHERE: hide the uploadButton when editing an existing object */ + $('#uploadButton').show(); + $('#uploadButton').on("drop",dropHandler(event)); $('#downloadButton').hide(); $('#show').val(''); $('#eventDetailsTable :input[disabled]').prop('disabled', false); |