diff options
author | B. Stack <bgstack15@gmail.com> | 2022-08-12 10:11:29 -0400 |
---|---|---|
committer | B. Stack <bgstack15@gmail.com> | 2022-08-12 10:11:29 -0400 |
commit | c0d9b3a037bc7574f9d8a81a273e74223a85f6f9 (patch) | |
tree | 3935ef685d1a0d9d2522945c2f3406daa2833926 /radicale_infcloud/web | |
parent | restore putVcalendarToCollection, hide dl button (diff) | |
download | radicaleinfcloud-c0d9b3a037bc7574f9d8a81a273e74223a85f6f9.tar.gz radicaleinfcloud-c0d9b3a037bc7574f9d8a81a273e74223a85f6f9.tar.bz2 radicaleinfcloud-c0d9b3a037bc7574f9d8a81a273e74223a85f6f9.zip |
move line-endings fix to forms.js
By moving the line-endings fix to this one source location of
fileContents, we avoid having to modify multiple places where the input
is parsed.
Diffstat (limited to 'radicale_infcloud/web')
-rw-r--r-- | radicale_infcloud/web/cache_handler.js | 67 | ||||
-rw-r--r-- | radicale_infcloud/web/data_process.js | 11 | ||||
-rw-r--r-- | radicale_infcloud/web/forms.js | 3 | ||||
-rw-r--r-- | radicale_infcloud/web/interface.js | 1 |
4 files changed, 37 insertions, 45 deletions
diff --git a/radicale_infcloud/web/cache_handler.js b/radicale_infcloud/web/cache_handler.js index 4926b20..a285d09 100644 --- a/radicale_infcloud/web/cache_handler.js +++ b/radicale_infcloud/web/cache_handler.js @@ -43,40 +43,41 @@ window.applicationCache.addEventListener('updateready', function(){ // Check if a new cache is available on page load. window.addEventListener('load', function(e) { - if(window.applicationCache) - { - window.applicationCache.addEventListener('cached', function(e) - { - if(!isUserLogged) - window.location.reload(); - else - $('#cacheDialog').css('display','block'); - }, false); + // Suppress useless warning/errors about applicationCache not existing. + 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 0e0df93..7f866ed 100644 --- a/radicale_infcloud/web/data_process.js +++ b/radicale_infcloud/web/data_process.js @@ -761,9 +761,7 @@ function getvCalendarstart(inputEvent) { var vcalendar_element='', itsOK=false; - // stackrpms,3 Handle not-to-spec upload of .ics file - // By adjusting line endings, this function can process the fileContents and make it visible on the current view. - var vEvent=inputEvent.vcalendar.replace(/\r*\n+/gm,'\r\n'); + var vEvent=inputEvent.vcalendar; if(vEvent.match(vCalendar.pre['vcalendar'])) { vcalendar_element=vEvent.match(vCalendar.pre['beginVTODO']); @@ -2551,9 +2549,6 @@ function fullVcalendarToData(inputEvent) if(!vcalendar) return false; - // stackrpms,3 Handle not-to-spec upload of .ics file - // By adjusting the line endings, we can now immediately edit newly-imported events. - vcalendar = vcalendar.replace(/\r*\n+/gm,'\r\n'); var vcalendar_full=vcalendar.split('\r\n'); if((parsed=('\r\n'+vcalendar_full[0]+'\r\n').match(vCalendar.pre['contentline_parse']))==null) @@ -3539,9 +3534,6 @@ function getDateFromDay(objComponent, t, disableRecursion,uid) vcalendar=vcalendar.replace(vcalendar_element[0],''); */ var recurrence_id_array=new Array(); - // stackrpms,3 Handle not-to-spec upload of .ics file - // By adjusting line endings, this function can process the fileContents and make it visible on the current view. - vcalendarOrig = vcalendarOrig.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') @@ -7888,7 +7880,6 @@ function stringToVevent(inputCollection, vstring, uid, etag, isNew) var recurrence_id_array=new Array(); /* matching for BEGIN:VEVENT */ - vcalendarOrig = vcalendarOrig.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') diff --git a/radicale_infcloud/web/forms.js b/radicale_infcloud/web/forms.js index ab38864..1f148fe 100644 --- a/radicale_infcloud/web/forms.js +++ b/radicale_infcloud/web/forms.js @@ -54,7 +54,8 @@ function dropHandler(event) { reader.readAsText(f); reader.onload = function(){ //if(window.console){console.log(reader.result)}; - uploadFile(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)}}; } diff --git a/radicale_infcloud/web/interface.js b/radicale_infcloud/web/interface.js index b7a4d4c..ce00437 100644 --- a/radicale_infcloud/web/interface.js +++ b/radicale_infcloud/web/interface.js @@ -1313,7 +1313,6 @@ function uploadFile(fileContents) fileContents = fileContents.replace(/^UID:.*$/gm,String("UID:"+newUID)); newEvent = stringToVevent(coll, fileContents, inputUID, $('#etag').val(), true); //console.log(newEvent); - newEvent.vcalendar = newEvent.vcalendar.replace(/\r*\n+/gm,'\r\n'); putVcalendarToCollection(coll.accountUID, inputUID, "", fileContents, "", 'vevent', false, false, ""); return true; } |