aboutsummaryrefslogtreecommitdiff
path: root/radicale_infcloud/web
diff options
context:
space:
mode:
Diffstat (limited to 'radicale_infcloud/web')
-rw-r--r--radicale_infcloud/web/cache_handler.js60
-rw-r--r--radicale_infcloud/web/data_process.js10
-rw-r--r--radicale_infcloud/web/forms.js37
-rw-r--r--radicale_infcloud/web/index.html1
-rw-r--r--radicale_infcloud/web/interface.js27
5 files changed, 99 insertions, 36 deletions
diff --git a/radicale_infcloud/web/cache_handler.js b/radicale_infcloud/web/cache_handler.js
index e21fb63..a285d09 100644
--- a/radicale_infcloud/web/cache_handler.js
+++ b/radicale_infcloud/web/cache_handler.js
@@ -43,37 +43,41 @@ window.applicationCache.addEventListener('updateready', function(){
// Check if a new cache is available on page load.
window.addEventListener('load', function(e)
{
- window.applicationCache.addEventListener('cached', function(e)
+ // Suppress useless warning/errors about applicationCache not existing.
+ if(window.applicationCache)
{
- if(!isUserLogged)
- window.location.reload();
- else
- $('#cacheDialog').css('display','block');
- }, false);
+ window.applicationCache.addEventListener('cached', function(e)
+ {
+ if(!isUserLogged)
+ window.location.reload();
+ else
+ $('#cacheDialog').css('display','block');
+ }, false);
- window.applicationCache.addEventListener('updateready', function(e)
- {
- if(!isUserLogged)
- window.location.reload();
- else
- $('#cacheDialog').css('display','block');
- }, false);
+ window.applicationCache.addEventListener('updateready', function(e)
+ {
+ if(!isUserLogged)
+ window.location.reload();
+ else
+ $('#cacheDialog').css('display','block');
+ }, false);
- window.applicationCache.addEventListener('obsolete', function(e)
- {
- if(!isUserLogged)
- window.location.reload();
- else
- $('#cacheDialog').css('display','block');
- }, false);
+ window.applicationCache.addEventListener('obsolete', function(e)
+ {
+ if(!isUserLogged)
+ window.location.reload();
+ else
+ $('#cacheDialog').css('display','block');
+ }, false);
- window.applicationCache.addEventListener('noupdate', function(e)
- {
- if(!isUserLogged)
+ window.applicationCache.addEventListener('noupdate', function(e)
{
- clearInterval(globalCacheUpdateInterval);
- globalCacheUpdateInterval=setInterval(function(){window.applicationCache.update();}, 300000);
- //$('#LoginPage .window').css('display', 'inline-block');
- }
- }, false);
+ if(!isUserLogged)
+ {
+ clearInterval(globalCacheUpdateInterval);
+ globalCacheUpdateInterval=setInterval(function(){window.applicationCache.update();}, 300000);
+ //$('#LoginPage .window').css('display', 'inline-block');
+ }
+ }, false);
+ };
}, false);
diff --git a/radicale_infcloud/web/data_process.js b/radicale_infcloud/web/data_process.js
index bdbf711..69f81d4 100644
--- a/radicale_infcloud/web/data_process.js
+++ b/radicale_infcloud/web/data_process.js
@@ -1067,6 +1067,7 @@ function checkAndFixMultipleUID(vcalendar, isEvent)
}
return eventStringArray;
}
+
function dataToVcalendar(operation, accountUID, inputUID, inputEtag, delUID,isFormHidden, deleteMode)
{
var vevent=false,
@@ -1341,11 +1342,6 @@ function dataToVcalendar(operation, accountUID, inputUID, inputEtag, delUID,isFo
{
if(globalSettings.timezonesupport.value)
sel_option=$('#timezone').val();
- //else
- //{
- // if(inputEvents.length>0)
- // sel_option=inputEvents[0].timeZone;
- //}
if(sel_option=='UTC')
{
@@ -2148,9 +2144,6 @@ function dataToVcalendar(operation, accountUID, inputUID, inputEtag, delUID,isFo
if($('#status').val()!='NONE')
{
-
- //if((value=$('[id="vcalendar_editor"] [data-type="\\%note"]').find('textarea').val())!='')
- //{
if(vCalendar.tplM['contentline_STATUS']!=null && (process_elem=vCalendar.tplM['contentline_STATUS'][0])!=undefined)
{
// replace the object and related objects' group names (+ append the related objects after the processed)
@@ -3447,6 +3440,7 @@ function getDateFromDay(objComponent, t, disableRecursion,uid)
return {offsetFrom:objComponent.tzOffsetFROM, offsetTo: objComponent.tzOffsetTO, startDate: dayLightStartDate};
}
+/* stackrpms: reference function */
function vcalendarToData(inputCollection, inputEvent, isNew)
{
var vcalendarOrig=inputEvent.vcalendar;
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);
diff --git a/radicale_infcloud/web/index.html b/radicale_infcloud/web/index.html
index 39b8583..a8b95e4 100644
--- a/radicale_infcloud/web/index.html
+++ b/radicale_infcloud/web/index.html
@@ -629,6 +629,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<input id="resetButton" type="button" value="Reset" data-type="reset" />
<input id="closeButton" type="button" value="Cancel" data-type="cancel" />
<input id="downloadButton" type="button" value="Download" data-type="download"/>
+ <input id="uploadButton" type="button" value="Import" data-type="upload" ondrop="dropHandler(event)" ondragover="dragOverHandler(event);"/>
<input id="deleteButton" type="button" value="Delete" data-type="delete" onclick="updateEventFormDimensions(true);$('#CAEvent .saveLoader').show();deleteEvent();" />
</td>
</tr>
diff --git a/radicale_infcloud/web/interface.js b/radicale_infcloud/web/interface.js
index e5afb8d..7f7304b 100644
--- a/radicale_infcloud/web/interface.js
+++ b/radicale_infcloud/web/interface.js
@@ -1289,6 +1289,33 @@ function addAndEdit(isFormHidden, deleteMode)
dataToVcalendar('EDIT',origUID, inputUID, $('#etag').val(), '', isFormHidden, deleteMode);
}
+/* START stackrpms 2022-08-10
+ * uploadFile is a clone of addAndEdit
+ */
+function uploadFile(fileContents)
+{
+ var inputUID='';
+ if($('#uid').val()!='')
+ var coll = globalResourceCalDAVList.getEventCollectionByUID($('#uid').val().substring(0, $('#uid').val().lastIndexOf('/')+1));
+ else
+ var coll = globalResourceCalDAVList.getEventCollectionByUID($('#event_calendar').val());
+ var res = getAccount(coll.accountUID);
+ var tmp=res.href.match(vCalendar.pre['hrefRex']);
+ var origUID=tmp[1]+res.userAuth.userName+'@'+tmp[2];
+ if($('#etag').val()!='')
+ inputUID=$('#uid').val();
+ else if($('#event_calendar').val()!='choose')
+ inputUID = $('#event_calendar').val()+'';
+ else
+ return false;
+ // Always generate new UID for imported event
+ var newUID=globalEventList.getNewUID();
+ fileContents = fileContents.replace(/^UID:.*$/gm,String("UID:"+newUID));
+ putVcalendarToCollection(coll.accountUID, inputUID, "", fileContents, "", 'vevent', false, false, "");
+ return true;
+}
+/* STOP stackrpms */
+
function interResourceEdit(op, delUID,isFormHidden)
{
var inputUID='';
bgstack15