aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--radicale_infcloud/web/cache_handler.js63
-rw-r--r--radicale_infcloud/web/data_process.js801
-rw-r--r--radicale_infcloud/web/forms.js37
-rw-r--r--radicale_infcloud/web/index.html1
-rw-r--r--radicale_infcloud/web/interface.js39
5 files changed, 903 insertions, 38 deletions
diff --git a/radicale_infcloud/web/cache_handler.js b/radicale_infcloud/web/cache_handler.js
index e21fb63..4926b20 100644
--- a/radicale_infcloud/web/cache_handler.js
+++ b/radicale_infcloud/web/cache_handler.js
@@ -43,37 +43,40 @@ 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)
- {
- if(!isUserLogged)
- window.location.reload();
- else
- $('#cacheDialog').css('display','block');
- }, false);
+ if(window.applicationCache)
+ {
+ 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)
- {
- clearInterval(globalCacheUpdateInterval);
- globalCacheUpdateInterval=setInterval(function(){window.applicationCache.update();}, 300000);
- //$('#LoginPage .window').css('display', 'inline-block');
- }
- }, false);
+ window.applicationCache.addEventListener('noupdate', function(e)
+ {
+ 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..e71f23e 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};
}
+/* FINDTHIS */
function vcalendarToData(inputCollection, inputEvent, isNew)
{
var vcalendarOrig=inputEvent.vcalendar;
@@ -7793,3 +7787,794 @@ function normalizeVcard(vcardString)
return vcard_out_grouped.join('');
}
+
+/* START stackrpms functions 2022-08-10
+ * duplicated and modified from function vcalendarToData() on line 3443
+ */
+function stringToVevent(inputCollection, vstring, uid, etag, isNew)
+{
+ //vcalendarToData(inputCollection, inputEvent, isNew)
+ //var vcalendarOrig=inputEvent.vcalendar;
+ var vcalendarOrig=vstring;
+ var eventArray=new Array();
+
+ //CHECK CALSCALE
+ var elem=vcalendarOrig.match(vCalendar.pre['contentline_CALSCALE']);
+ if(elem!=null)
+ {
+ calscale=elem[0].match(vCalendar.pre['contentline_parse'])[4];
+ if(calscale!='GREGORIAN')
+ {
+ console.log("Error:'"+uid+"': Unsupported calscale in:"+vcalendarOrig);
+ return false;
+ }
+ }
+ //CHECK VERSION
+ var elemV=vcalendarOrig.match(vCalendar.pre['contentline_VERSION']);
+ if(elemV!=null)
+ {
+ var ver=elemV[0].match(vCalendar.pre['contentline_parse'])[4];
+ if(ver!='2.0')
+ {
+ console.log("Error:'"+uid+"': Unsupported version ("+ver+") in:"+vcalendarOrig);
+ return false;
+ }
+ }
+
+ //FIX TIMEZONE
+ var beginTimeZone=vcalendarOrig.indexOf('BEGIN:VTIMEZONE');
+ var startEndTimeZone=vcalendarOrig.lastIndexOf('END:VTIMEZONE');
+ var endTimeZone=0;
+
+ var rid=uid.substring(0, uid.lastIndexOf('/')+1);
+ var evid=uid.substring(uid.lastIndexOf('/')+1, uid.length);
+
+ var isChange=false,
+ needReload=false;
+
+ if(!isNew)
+ {
+ var events=findEventInArray(uid, true);
+ if(events!='')
+ {
+ if(events.etag!=etag)
+ {
+ for(var i=0; i<events.alertTimeOut.length; i++)
+ clearTimeout(events.alertTimeOut[i]);
+ deleteEventFromArray(uid);
+
+ if($('#show').val()!='')
+ {
+ if($('#show').val()==uid)
+ {
+ if($('#repeatEvent').val()=="true" || $('#recurrenceID').val()!='')
+ {
+ var name=globalCalEvent.title;
+ showEventForm(null, null, {title: name, id:uid}, globalJsEvent, 'show','', true);
+ $('#editAll').css('visibility','hidden');
+ $('#editFuture').css('visibility','hidden');
+ $('#editOnlyOne').css('visibility','hidden');
+ $('#repeatConfirmBoxContent').html('<b>'+name+"</b> "+localization[globalInterfaceLanguage].repeatChangeTxt);
+ $('#repeatConfirmBoxQuestion').html(localization[globalInterfaceLanguage].repeatChangeTxtClose);
+ }
+ else
+ needReload=true;
+ }
+ }
+ isChange=true;
+ }
+ }
+ }
+
+ if((beginTimeZone!=-1) && (startEndTimeZone!=-1))
+ {
+ for(i=(startEndTimeZone+2);i<vcalendarOrig.length;i++)
+ {
+ if(vcalendarOrig.charAt(i)=='\n')
+ {
+ endTimeZone=i+1;
+ break;
+ }
+ }
+ vTimeZone=vcalendarOrig.substring(beginTimeZone, endTimeZone);
+ vcalendar=vcalendarOrig.substring(0, beginTimeZone)+vcalendarOrig.substring(endTimeZone, vcalendarOrig.length);
+ }
+
+ /*
+ vcalendar_element=vcalendar.match(vCalendar.pre['tzone']);
+ if(vcalendar_element!=null)
+ vcalendar=vcalendar.replace(vcalendar_element[0],'');
+ */
+ var recurrence_id_array=new Array();
+ /* FINDTHIS matching for BEGIN:VEVENT */
+ // this one works, but has 3 replace calls!
+ vcalendarOrig = vcalendarOrig.replace(/^\n/gm,'').replace('\n','\r\n').replace(/\r*\n/gm,'\r\n');
+ while(vcalendarOrig.match(vCalendar.pre['vevent'])!=null)
+ {
+ if(vcalendarOrig.substring(vcalendarOrig.indexOf('BEGIN:VEVENT')-2, vcalendarOrig.indexOf('BEGIN:VEVENT'))=='\r\n')
+ {
+ var partEvent=vcalendarOrig.substring(vcalendarOrig.indexOf('BEGIN:VEVENT')-2,vcalendarOrig.indexOf('END:VEVENT')+'END:VEVENT'.length);
+ vcalendarOrig=vcalendarOrig.replace(partEvent, '');
+ }
+ else
+ {
+ var partEvent=vcalendarOrig.substring(vcalendarOrig.indexOf('BEGIN:VEVENT'),vcalendarOrig.indexOf('END:VEVENT')+'END:VEVENT'.length);
+ vcalendarOrig=vcalendarOrig.replace(partEvent, '');
+ partEvent+='\r\n';
+ }
+ var rec_array=partEvent.match(vCalendar.pre['contentline_RECURRENCE_ID']);
+ var uidString=partEvent.match(vCalendar.pre['contentline_UID']);
+
+ if(uidString!=null && rec_array!=null)
+ {
+ recurrence_id_array[recurrence_id_array.length]=rec_array[0].match(vCalendar.pre['contentline_parse'])[4]+';'+uidString[0].match(vCalendar.pre['contentline_parse'])[4];
+ }
+ eventArray[eventArray.length]=partEvent;
+ }
+ if(eventArray.length==0)
+ console.log("Error: '"+uid+"': unable to parse vEvent");
+
+ for(var evIt=0; evIt<eventArray.length; evIt++)
+ {
+ var oo='',
+ note='',
+ start='',
+ end='',
+ title='',
+ location='',
+ all=false,
+ frequency='',
+ interval='',
+ byMonthDay='',
+ byDay='',
+ until='',
+ isUntilDate=false,
+ isRepeat=false,
+ alertTime=new Array(),
+ alertNote=new Array(),
+ alertTimeOut=new Array(),
+ valOffsetFrom='',
+ valOffsetTo='',
+ intOffset=0,
+ tzName='local',
+ realStart='',
+ realEnd='',
+ rec_id='',
+ wkst='',
+ classType='',
+ avail='',
+ hrefUrl='',
+ returnForValue = true,
+ stringUID='',
+ priority="0",
+ status='',
+ pars=new Array();
+ var dtStartTimezone='';
+ var dates = new Array();
+ var vcalendar=eventArray[evIt];
+ var stringUID=vcalendar.match(vCalendar.pre['contentline_UID']);
+ if(stringUID!=null)
+ stringUID=stringUID[0].match(vCalendar.pre['contentline_parse'])[4];
+
+ var exDates=new Array();
+ var exDate=null;
+ var exDate_array=new Array();
+ var vcalendar2=vcalendar+'';
+
+ while(vcalendar2.match(vCalendar.pre['contentline_EXDATE'])!= null)
+ {
+ exDate=vcalendar2.match(vCalendar.pre['contentline_EXDATE']);
+ exDate_array[exDate_array.length]=exDate[0];
+ vcalendar2=vcalendar2.replace(exDate,'\r\n');
+ }
+
+ vcalendar_element=vcalendar.match(vCalendar.pre['contentline_RRULE2']);
+ if(vcalendar_element!=null)
+ {
+ parsed=vcalendar_element[0].match(vCalendar.pre['contentline_parse']);
+ pars=parsed[4].split(';');
+ var parString='';
+
+ if(pars.length>0)
+ isRepeat=true;
+ for(var i=0;i<pars.length;i++)
+ {
+ if(pars[i].indexOf('FREQ=')!=-1)
+ frequency=pars[i].split('=')[1];
+ else if(pars[i].indexOf('INTERVAL=')!=-1)
+ interval=pars[i].split('=')[1];
+ else if(pars[i].indexOf('COUNT=')!=-1)
+ {
+ until=pars[i].split('=')[1];
+ if(until==0)
+ {
+ returnForValue = false;
+ break
+ }
+ else if(isNaN(until))
+ {
+ returnForValue = false;
+ break
+ }
+ }
+ else if(pars[i].indexOf('UNTIL=')!=-1)
+ {
+ isUntilDate=true;
+ until=pars[i].split('=')[1];
+ //if(until.indexOf('T')==-1)
+// until+='T000000Z';
+
+ }
+ else if(pars[i].indexOf('WKST=')!=-1)
+ {
+ wkst=pars[i].split('=')[1].replace(/\d*MO/,1).replace(/\d*TU/,2).replace(/\d*WE/,3).replace(/\d*TH/,4).replace(/\d*FR/,5).replace(/\d*SA/,6).replace(/\d*SU/,0);
+ if(globalSettings.mozillasupport.value!=null && globalSettings.mozillasupport.value)
+ wkst='';
+ }
+ else if(pars[i].indexOf('BYMONTHDAY=')!=-1)
+ byMonthDay=pars[i].split('=')[1];
+ else if(pars[i].indexOf('BYDAY=')!=-1)
+ {
+ byDay=pars[i].split('=')[1];
+ byDay=byDay.replace(/\d*MO/,1).replace(/\d*TU/,2).replace(/\d*WE/,3).replace(/\d*TH/,4).replace(/\d*FR/,5).replace(/\d*SA/,6).replace(/\d*SU/,0).split(',');
+ }
+ }
+ if(!returnForValue)
+ {
+
+ continue;
+ }
+ if(!interval)
+ interval=1;
+ }
+
+ var dayLightStartDate, dayLightEndDate, tzObject;
+ vcalendar_element=vcalendar.match(vCalendar.pre['contentline_DTSTART']);
+ if(vcalendar_element!=null)
+ {
+ parsed=vcalendar_element[0].match(vCalendar.pre['contentline_parse']);
+
+ start=parsed[4];
+ var help1=start;
+
+ if(help1.indexOf("T")==-1)
+ {
+ help1=help1.substring(0, 4)+'-'+help1.substring(4, 6)+'-'+help1.substring(6, 8);
+ all=true;
+ }
+ else
+ {
+ help1=help1.substring(0, 4)+'-'+help1.substring(4, 6)+'-'+help1.substring(6, 8)+'T'+help1.substring(9, 11)+':'+help1.substring(11, 13)+':'+help1.substring(13, 15);
+ all=false;
+ }
+
+ var t=$.fullCalendar.parseDate(help1);
+ if(t==null)
+ return false;
+ if(t.toString()=='Invalid Date')
+ return false;
+
+ if(!all)
+ {
+ parsed_value=vcalendarSplitParam(parsed[3]);
+ for(h=1;h<parsed_value.length;h++)
+ if(parsed_value[h]!='')
+ dtStartTimezone=parsed_value[h];
+ dtStartTimezone=dtStartTimezone.split('=')
+
+ if(start.charAt(start.length-1)=='Z')
+ tzName='UTC';
+ if(dtStartTimezone.length>1 || tzName=='UTC')
+ {
+ if(tzName!='UTC')
+ tzName=$.trim(dtStartTimezone[1]);
+ var finTZ = checkTimezone(tzName);
+ if(finTZ!=null)
+ tzName = finTZ;
+ if(globalSettings.timezonesupport.value && tzName in timezones)
+ {
+ valOffsetFrom=getOffsetByTZ(tzName, t);
+ intOffset=(getLocalOffset(t)*-1*1000)-valOffsetFrom.getSecondsFromOffset()*1000;
+ }
+ }
+ else if(processedTimezones.indexOf(tzName)==-1)
+ {
+ if(timeZonesEnabled.indexOf(tzName)==-1)
+ timeZonesEnabled.push('local');
+ processedTimezones.push('local');
+ }
+ if(tzName!='' && tzName != 'local')
+ if(processedTimezones.indexOf(tzName)==-1)
+ {
+ if(timeZonesEnabled.indexOf(tzName)==-1)
+ timeZonesEnabled.push(tzName);
+ processedTimezones.push(tzName);
+ }
+ }
+ else
+ tzName = globalSessionTimeZone;
+ realStart=$.fullCalendar.parseDate(help1);
+ //inputEvent.start=$.fullCalendar.parseDate(help1);
+ start=$.fullCalendar.parseDate(help1);
+ if(intOffset)
+ {
+ //inputEvent.start.setTime(inputEvent.start.getTime()+intOffset);
+ start.setTime(start.getTime()+intOffset);
+ }
+ if(exDate_array!=null)
+ for(var j=0;j<exDate_array.length;j++)
+ {
+ var exString=(exDate_array[j]+'\r\n').match(vCalendar.pre['contentline_parse'])[4];
+ if(exString.indexOf('T')!=-1 && exString.indexOf('Z')!=-1)
+ var utcTime=exString.parseComnpactISO8601().setSeconds(getLocalOffset(exString.parseComnpactISO8601())*-1);
+ else if(exString.indexOf('T')!=-1 && exString.indexOf('Z')==-1)
+ var utcTime=exString.parseComnpactISO8601();
+ else
+ {
+ if(help1.indexOf('T')!=-1)
+ exString += 'T' + $.fullCalendar.formatDate(start,'HHmmss');
+
+ var utcTime=exString.parseComnpactISO8601();
+ }
+ exDates[exDates.length]=new Date(utcTime).toString();
+ }
+ var valarm=vcalendar.match(vCalendar.pre['valarm']);
+ if(valarm!=null)
+ {
+ vcalendar=vcalendar.replace(valarm[0], '');
+ var alarmString='';
+ var alarmArray=new Array();
+ for(var i=0;i<valarm[0].length;i++)
+ {
+ if(valarm[0].substring(i-'END:VALARM'.length, i)=='END:VALARM')
+ {
+ alarmArray[alarmArray.length]=alarmString+'\r\n';
+ alarmString='';
+ }
+ alarmString+=valarm[0][i];
+ }
+
+ for(var j=0;j<alarmArray.length;j++)
+ {
+ checkA=alarmArray[j].match(vCalendar.re['valarm']);
+ if(checkA!=null)
+ {
+ action=(alarmArray[j]).match(vCalendar.pre['contentline_ACTION']);
+ if(action!=null)
+ parsed=action[0].match(vCalendar.pre['contentline_parse']);
+ else
+ break;
+
+ trigger=alarmArray[j].match(vCalendar.pre['contentline_TRIGGER']);
+ if(trigger!=null)
+ {
+ parsed=(trigger[0]+'\r\n').match(vCalendar.pre['contentline_parse']);
+ if(parsed!=null)
+ {
+ value=parsed[4];
+ var checkD=value.match(vCalendar.pre['date-time-value']);
+ var intOffsetA='';
+ var tzNameA='';
+ if(checkD!=null)
+ {
+ if(parsed[3])
+ var dtStartTimezoneA=parsed[3].split('=');
+ var alarmTimeA=$.fullCalendar.parseDate(value.substring(0, 4)+'-'+value.substring(4, 6)+'-'+value.substring(6, 8)+'T'+value.substring(9, 11)+':'+value.substring(11, 13)+':'+value.substring(13, 15));
+ if(value.charAt(value.length-1)=='Z')
+ tzNameA='UTC';
+ if(dtStartTimezoneA.length>1 || tzNameA=='UTC')
+ {
+ if(tzNameA!='UTC' && dtStartTimezoneA[0]==';TZID')
+ tzNameA=$.trim(dtStartTimezoneA[1]);
+ var finTZ = checkTimezone(tzNameA);
+ if(finTZ!=null)
+ tzNameA = finTZ;
+ if(globalSettings.timezonesupport.value && tzNameA in timezones)
+ {
+ var valOffsetFromA=getOffsetByTZ(tzNameA, alarmTimeA);
+ intOffsetA=getOffsetByTZ(tzName, alarmTimeA).getSecondsFromOffset()*1000-valOffsetFromA.getSecondsFromOffset()*1000;
+ }
+ }
+ else if(processedTimezones.indexOf(tzName)==-1)
+ {
+ if(timeZonesEnabled.indexOf(tzName)==-1)
+ timeZonesEnabled.push('local');
+ processedTimezones.push('local');
+ }
+ if(tzNameA!='' && tzNameA != 'local')
+ if(processedTimezones.indexOf(tzNameA)==-1)
+ {
+ if(timeZonesEnabled.indexOf(tzNameA)==-1)
+ timeZonesEnabled.push(tzNameA);
+ processedTimezones.push(tzNameA);
+ }
+ if(intOffsetA!='')
+ alarmTimeA.setTime(alarmTimeA.getTime()+intOffsetA);
+ alertTime[j]=$.fullCalendar.formatDate(alarmTimeA,"yyyy-MM-dd'T'HH:mm:ss");
+ }
+ else
+ {
+ alertTime[j]=0;
+ if(value.indexOf('W')!=-1)
+ alertTime[j]=parseAlarmWeek(value);
+ else if(value.indexOf('D')!=-1)
+ alertTime[j]=parseAlarmDay(value);
+ else if(value.indexOf('T')!=-1)
+ alertTime[j]=parseAlarmTime(value);
+ if(parsed[4].charAt(0)=="-")
+ alertTime[j]="-"+alertTime[j];
+ else
+ alertTime[j]="+"+alertTime[j];
+ }
+ }
+ }
+ else
+ break;
+
+ noteA=alarmArray[j].match(vCalendar.pre['contentline_NOTE']);
+ if(noteA!=null)
+ {
+ parsed=noteA[0].match(vCalendar.pre['contentline_parse']);
+ alertNote[j]=parsed[4];
+ }
+ else
+ alertNote[j]='Default note';
+ }
+ }
+ }
+
+ vcalendar_element=vcalendar.match(vCalendar.pre['contentline_LOCATION']);
+ if(vcalendar_element!=null)
+ {
+ parsed=vcalendar_element[0].match(vCalendar.pre['contentline_parse']);
+ location=vcalendarUnescapeValue(parsed[4]);
+ }
+
+ vcalendar_element=vcalendar.match(vCalendar.pre['contentline_NOTE']);
+ if(vcalendar_element!=null)
+ {
+ parsed=vcalendar_element[0].match(vCalendar.pre['contentline_parse']);
+ note=vcalendarUnescapeValue(parsed[4]);
+ }
+
+ vcalendar_element=vcalendar.match(vCalendar.pre['contentline_SUMMARY']);
+ if(vcalendar_element!=null)
+ {
+ parsed=vcalendar_element[0].match(vCalendar.pre['contentline_parse']);
+ title=vcalendarUnescapeValue(parsed[4]);
+ }
+
+ vcalendar_element=vcalendar.match(vCalendar.pre['contentline_PRIORITY']);
+ if(vcalendar_element!=null)
+ {
+ parsed=vcalendar_element[0].match(vCalendar.pre['contentline_parse']);
+ priority=vcalendarUnescapeValue(parsed[4]);
+ }
+
+ var index=0;
+ for(var p=0;p<globalResourceCalDAVList.collections.length;p++)
+ if(typeof globalResourceCalDAVList.collections[p].uid !='undefined' && globalResourceCalDAVList.collections[p].uid==uid)
+ {
+ index=p;
+ break;
+ }
+ var firstPart=index.pad(String(globalResourceCalDAVList.collections.length).length);
+
+ var compareString=(firstPart + title).toLowerCase();
+
+
+ vcalendar_element=vcalendar.match(vCalendar.pre['contentline_CLASS']);
+ if(vcalendar_element!=null)
+ {
+ parsed=vcalendar_element[0].match(vCalendar.pre['contentline_parse']);
+ classType=vcalendarUnescapeValue(parsed[4]);
+ }
+
+ vcalendar_element=vcalendar.match(vCalendar.pre['contentline_STATUS']);
+ if(vcalendar_element!=null)
+ {
+ parsed=vcalendar_element[0].match(vCalendar.pre['contentline_parse']);
+ status=vcalendarUnescapeValue(parsed[4]);
+ }
+
+ vcalendar_element=vcalendar.match(vCalendar.pre['contentline_TRANSP']);
+ if(vcalendar_element!=null)
+ {
+ parsed=vcalendar_element[0].match(vCalendar.pre['contentline_parse']);
+ avail=vcalendarUnescapeValue(parsed[4]);
+ }
+
+ vcalendar_element=vcalendar.match(vCalendar.pre['contentline_URL']);
+ if(vcalendar_element!=null)
+ {
+ parsed=vcalendar_element[0].match(vCalendar.pre['contentline_parse']);
+ hrefUrl=vcalendarUnescapeValue(parsed[4]);
+ }
+
+ vcalendar_element=vcalendar.match(vCalendar.pre['contentline_RECURRENCE_ID']);
+ if(vcalendar_element!=null)
+ {
+ parsed=vcalendar_element[0].match(vCalendar.pre['contentline_parse']);
+ var rec=parsed[4];
+ /*if(rec.indexOf("T")==-1)
+ {
+ rec=rec.substring(0, 4)+'/'+rec.substring(4, 6)+'/'+rec.substring(6, 8);
+ var d=$.fullCalendar.parseDate(rec);
+ var da=new Date(d.getTime()-1*24*60*60*1000);
+ var day=da.getDate();
+
+ if(day<10)
+ day='0'+day;
+
+ var month=da.getMonth();
+ month++;
+ if(month<10)
+ month='0'+month;
+
+ rec=da.getFullYear()+'-'+month+'-'+day;
+ }
+ else
+ rec=rec.substring(0, 4)+'-'+rec.substring(4, 6)+'-'+rec.substring(6, 8)+'T'+rec.substring(9, 11)+':'+rec.substring(11, 13)+':'+rec.substring(13, 15);
+ rec_id=$.fullCalendar.parseDate(rec);*/
+ //if(!rec_id || rec_id=='Invalid Date')
+ // rec_id='';
+ rec_id=rec;
+ }
+
+ var isDuration = false;
+ var dur = 0;
+ vcalendar_element=vcalendar.match(vCalendar.pre['contentline_DTEND']);
+ if(vcalendar_element!=null)
+ {
+ parsed=vcalendar_element[0].match(vCalendar.pre['contentline_parse']);
+ end=parsed[4];
+ var help=end;
+ if(help.indexOf("T")==-1)
+ {
+ help=help.substring(0, 4)+'-'+help.substring(4, 6)+'-'+help.substring(6, 8);
+ var d=$.fullCalendar.parseDate(help);
+ var da=new Date(d.getTime());
+ if(help1.indexOf("T")==-1)
+ da.setDate(da.getDate()-1);
+ help=$.fullCalendar.formatDate(da, "yyyy-MM-dd");
+ all=true;
+ if(help1.indexOf("T")!=-1)
+ {
+ all=false;
+ help+='T00:00:00';
+ if(tzName == 'UTC')
+ help+='Z';
+ }
+ }
+ else
+ {
+ help=help.substring(0, 4)+'-'+help.substring(4, 6)+'-'+help.substring(6, 8)+'T'+help.substring(9, 11)+':'+help.substring(11, 13)+':'+help.substring(13, 15);
+ all=false;
+ }
+ }
+ else
+ {
+ var checkDur=vcalendar.match(vCalendar.pre['dur-value']);
+ if(checkDur!=null)
+ {
+ var checkP = (checkDur[0]+'\r\n').match(vCalendar.pre['contentline_parse']);
+ if(checkP != null)
+ {
+ var value=checkP[4];
+
+ var number = 0;
+ if(value.indexOf('W')!=-1)
+ number=parseAlarmWeek(value);
+ else if(value.indexOf('D')!=-1)
+ number=parseAlarmDay(value);
+ else if(value.indexOf('T')!=-1)
+ number=parseAlarmTime(value);
+ if(parsed[4].charAt(0)=="-")
+ number="-"+number;
+ else
+ number="+"+number;
+ dur=parseInt(number.substring(1, number.length-1),10);
+ isDuration = true;
+ }
+ }
+ }
+ if(isDuration)
+ {
+ var st='';
+ if(!all)
+ st = $.fullCalendar.parseDate(help1);
+ else
+ {
+ st = $.fullCalendar.parseDate(help1+'T00:00:00');
+ //date object mindfuck problem
+ st.setMilliseconds(-1);
+ }
+ var durDate = new Date(st.getTime() + dur);
+ help = $.fullCalendar.formatDate(durDate,"yyyy-MM-dd'T'HH:mm:ss");
+ }
+
+ if(typeof help=='undefined' || help=='' || help==null)
+ help=help1;
+ var t1=$.fullCalendar.parseDate(help);
+ if(t1==null)
+ return false;
+ else if(t1.toString()=='Invalid Date')
+ return false;
+
+ if(!all)
+ {
+ if(end.charAt(end.length-1)=='Z')
+ tzName='UTC';
+ if(dtStartTimezone.length>1 || tzName=='UTC')
+ {
+ if(tzName!='UTC')
+ tzName=$.trim(dtStartTimezone[1]);
+ var finTZ = checkTimezone(tzName);
+ if(finTZ!=null)
+ tzName = finTZ;
+ if(globalSettings.timezonesupport.value && tzName in timezones)
+ {
+ valOffsetFrom=getOffsetByTZ(tzName, t1);
+ intOffset=(getLocalOffset(t1)*-1*1000)-valOffsetFrom.getSecondsFromOffset()*1000;
+ }
+ }
+ else if(processedTimezones.indexOf(tzName)==-1)
+ {
+ if(timeZonesEnabled.indexOf(tzName)==-1)
+ timeZonesEnabled.push('local');
+ processedTimezones.push('local');
+ }
+ //realEnd=$.fullCalendar.parseDate(help);
+ //help1+=valOffsetFrom;
+
+ if(tzName!='' && tzName != 'local')
+ if(processedTimezones.indexOf(tzName)==-1)
+ {
+ if(timeZonesEnabled.indexOf(tzName)==-1)
+ timeZonesEnabled.push(tzName);
+ processedTimezones.push(tzName);
+ }
+ }
+ else
+ tzName = globalSessionTimeZone;
+
+ realEnd=$.fullCalendar.parseDate(help);
+ //inputEvent.end=$.fullCalendar.parseDate(help);
+ end=$.fullCalendar.parseDate(help);
+ if(intOffset)
+ {
+ //inputEvent.end.setTime(inputEvent.end.getTime()+intOffset);
+ end.setTime(end.getTime()+intOffset);
+ }
+ }
+ else
+ return false;
+
+ if(globalVisibleCalDAVCollections.indexOf(rid)!=-1 || isChange || isNew)
+ {
+ if(isRepeat)
+ {
+ var futureRLimit = new Date(globalToLoadedLimit.getTime())
+ futureRLimit.setDate(futureRLimit.getDate()+14);
+ var ruleString=vcalendar.match(vCalendar.pre['contentline_RRULE2'])[0].match(vCalendar.pre['contentline_parse'])[4];
+ //inputEvent.isRepeat=true;
+ if(realStart)
+ var varDate=new Date(realStart.getTime());
+ else
+ var varDate=new Date(start.getTime());
+
+ if(realEnd)
+ var varEndDate=new Date(realEnd.getTime());
+ else
+ var varEndDate=new Date(end.getTime());
+
+ var lastGenDate='';
+ var repeatStart=new Date(varDate.getTime());
+ var repeatEnd=new Date(varEndDate.getTime());
+ var untilDate='',realUntilDate='',realUntil='';
+
+ if(until!=='')
+ {
+ if(isUntilDate)
+ {
+ if(until.indexOf('T')!=-1)
+ {
+ var uString = until.substring(0, 4)+'-'+until.substring(4, 6)+'-'+until.substring(6, 8)+'T'+until.substring(9, 11)+':'+until.substring(11, 13)+':'+until.substring(13, 15);
+ var ut=$.fullCalendar.parseDate(uString);
+ if(ut==null)
+ return false;
+ if(ut.toString()=='Invalid Date')
+ return false;
+ if(!all)
+ {
+ if(globalSettings.timezonesupport.value && tzName in timezones)
+ valOffsetFrom=getOffsetByTZ(tzName, ut);
+ if(valOffsetFrom)
+ {
+ var intOffset=valOffsetFrom.getSecondsFromOffset()*1000;
+ ut.setTime(ut.getTime()+intOffset);
+ }
+ }
+ untilDate = new Date(ut.getTime());
+ }
+ else
+ {
+ untilDate=$.fullCalendar.parseDate(until.substring(0, 4)+'-'+until.substring(4, 6)+'-'+until.substring(6, 8));
+ untilDate.setHours(realStart.getHours());
+ untilDate.setMinutes(realStart.getMinutes());
+ untilDate.setSeconds(realStart.getSeconds());
+ }
+
+ realUntil='';
+ }
+ else
+ {
+ untilDate='';
+ realUntil=until;
+
+ }
+ realUntilDate=untilDate;
+ //inputEvent.untilDate=untilDate;
+ }
+ else
+ {
+ untilDate=new Date(futureRLimit.getTime());
+ realUntilDate='';
+ //inputEvent.untilDate='never';
+ }
+ var repeatCount=0, realRepeatCount=0;
+
+ if(true)
+ {
+ if(alertTime.length>0)
+ {
+ var aTime='';
+ var now=new Date();
+ if(!inputCollection.ignoreAlarms)
+ alertTimeOut=setAlertTimeouts(false,alertTime, start, end, {allDay:all, title:title}, true, uid);
+ }
+ realRepeatCount++;
+ var checkRec=isInRecurrenceArray(varDate,stringUID,recurrence_id_array, tzName);
+
+ if(exDates.length>0)
+ if(exDates.indexOf(varDate.toString())!=-1)
+ checkRec=true;
+ if(!checkRec)
+ {
+ repeatCount++;
+ var tmpObj=new items(etag, start, end, title, all, uid, rid, evid, note, inputCollection.displayValue, alertTime, alertNote, realUntilDate, frequency, interval, realUntil, repeatStart, repeatEnd, byMonthDay,repeatCount, realRepeatCount, vcalendar, location, alertTimeOut,tzName, realStart, realEnd, byDay, rec_id,wkst,classType, avail,hrefUrl, compareString,priority,status,ruleString);
+ globalEventList.displayEventsArray[rid].splice(globalEventList.displayEventsArray[rid].length, 0, tmpObj);
+ }
+ }
+
+ var lastGenDate=generateRepeatInstances({
+ untilDate:realUntilDate,
+ repeatStart:varDate,
+ futureRLimit:futureRLimit,
+ stringUID:stringUID,
+ recurrence_id_array:recurrence_id_array,
+ exDates:exDates,
+ alertTime:alertTime,
+ ignoreAlarms:inputCollection.ignoreAlarms,
+ items:new items(etag, varDate, varEndDate, title, all, uid, rid, evid, note, inputCollection.displayValue, alertTime, alertNote, realUntilDate, frequency, interval, realUntil, repeatStart, repeatEnd, byMonthDay, repeatCount, realRepeatCount, vcalendar, location, alertTimeOut, tzName, realStart, realEnd, byDay, rec_id,wkst,classType, avail,hrefUrl,compareString,priority,status,ruleString)
+ });
+ }
+ else
+ {
+ if(!inputCollection.ignoreAlarms)
+ alertTimeOut=setAlertTimeouts(false,alertTime, start, end, {allDay:all, title:title},true,uid);
+
+ var tmpObj=new items(etag, start, end, title, all, uid, rid, evid, note, inputCollection.displayValue, alertTime, alertNote, '', '', '', '', '', '', '', '', '', vcalendar, location, alertTimeOut, tzName, realStart, realEnd, byDay, rec_id,wkst,classType, avail,hrefUrl,compareString,priority,status,ruleString);
+ if(isChange)
+ {
+ if(needReload)
+ showEventForm(null, null, tmpObj, globalJsEvent, 'show', '');
+ }
+ globalEventList.displayEventsArray[rid].splice(globalEventList.displayEventsArray[rid].length, 0, tmpObj);
+ }
+ }
+ }
+ //inputEvent.isDrawn=true;
+ return tmpObj;
+}
+/* END stackrpms functions */
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);
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..745d58d 100644
--- a/radicale_infcloud/web/interface.js
+++ b/radicale_infcloud/web/interface.js
@@ -1289,6 +1289,45 @@ 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;
+ // ripped from data_process.js:1474
+ var newUID=globalEventList.getNewUID();
+ //process_elem=process_elem.replace('##:::##uid##:::##', newUID);
+ fileContents = fileContents.replace(/^UID:.*$/gm,String("UID:"+newUID));
+ // WORKHERE: Could also try adding inputUID+newUID. Not sure if it helps or hurts.
+ newEvent = stringToVevent(coll, fileContents, inputUID, $('#etag').val(), true);
+ console.log(newEvent);
+ console.log("All day:");
+ console.log(newEvent.allDay);
+ console.log(newEvent.allDay);
+ // This was an attempt to populate the form. I found it easier to just send the object to the caldav server right away.
+ // ref: interface.js:2601
+ //showEventForm(null, newEvent.allDay, newEvent, null, 'show', '');
+ // Just call the caldav operation directly.
+ //putVcalendarToCollection(accountUID, inputUID, inputEtag, inputS, delUID, 'vevent', isFormHidden, deleteMode, fixedArr);
+ // putVcalendarToCollection("http://domainjoin@d2-03a/radicale/domainjoin", "http://domainjoin@d2-03a/radicale/domainjoin/4f58b6a8-014f-03b9-ae12-071eb28798de/", "", fileContents, "", 'vevent', undefined, undefined,
+ return putVcalendarToCollection(coll.accountUID, inputUID, "", fileContents, "", 'vevent', false, false, "");
+ // WORKHERE: somehow add this to the globalEventList thing, like adding a brand-new event by hand?
+}
+
function interResourceEdit(op, delUID,isFormHidden)
{
var inputUID='';
bgstack15