/* CalDavZAP - the open source CalDAV Web Client Copyright (C) 2011-2015 Jan Mate Andrej Lezo Matej Mihalik This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ function handleCalDAVError(isError, inputResource) { var collections=''; collections=globalResourceCalDAVList.collections; for(var i=0; i0) while(low'); newElement.append(headerObject.displayvalue); if(todoString=='') newElement.find('input[type=checkbox]').attr('onclick','resourceChBoxClick(this, \'#\'+$(this).parent().parent().attr(\'id\'), \''+resHeader+'\', false);if(isCalDAVLoaded && $(this).parent().parent().attr(\'id\')== \'ResourceCalDAV'+todoString+'List\'){$(this).prop(\'checked\')?enableResource($(this).parent()):disableResource($(this).parent());}'); else newElement.find('input[type=checkbox]').attr('onclick','resourceChBoxClick(this, \'#\'+$(this).parent().parent().attr(\'id\'), \''+resHeader+'\', false);if(isCalDAVLoaded && $(this).parent().parent().attr(\'id\')== \'ResourceCalDAV'+todoString+'List\'){$(this).prop(\'checked\')?enableResourceTodo($(this).parent()):disableResourceTodo($(this).parent());}'); newElement.css('display', 'none'); newElement=newElement.parent().html(); $('#ResourceCalDAV'+todoString+'List').children().eq(insertIndex).after(newElement); } // insert the resource to interface var newElement = $('#ResourceCalDAV'+todoString+'ListTemplate').find('.resourceCalDAV'+todoString+'_item').clone().wrap('
'); var par=inputResource.uid.split('/'); if(inputResource.permissions.read_only) newElement.addClass('resourceCalDAV_item_ro'); newElement.attr('data-id', inputResource.uid); if(globalCalDAVInitLoad) newElement.addClass('r_operate'); newElement.html("
"+$('
').text(inputResource.displayvalue).html()); newElement.attr('title', $('
').text(inputResource.displayvalue).html()); if(todoString=='') newElement.find('input[type=checkbox]').attr({'data-id':inputResource.uid, 'onclick':'var evt = arguments[0];evt.stopPropagation();collectionChBoxClick(this, \'#\'+$(this).parent().parent().attr(\'id\'), \''+resHeader+'\', \''+resItem+'\', null, false);if(isCalDAVLoaded && $(this).parent().parent().attr(\'id\')== \'ResourceCalDAV'+todoString+'List\'){$(this).prop(\'checked\')?enableCalendar(\''+inputResource.uid+'\'):disableCalendar(\''+inputResource.uid+'\');}'}); else newElement.find('input[type=checkbox]').attr({'data-id':inputResource.uid, 'onclick':'var evt = arguments[0];evt.stopPropagation();collectionChBoxClick(this, \'#\'+$(this).parent().parent().attr(\'id\'), \''+resHeader+'\', \''+resItem+'\', null, false);if(isCalDAVLoaded && $(this).parent().parent().attr(\'id\')== \'ResourceCalDAV'+todoString+'List\'){$(this).prop(\'checked\')?enableCalendarTodo(\''+inputResource.uid+'\'):disableCalendarTodo(\''+inputResource.uid+'\');}'}); newElement.click(function(e){ if(($(this).hasClass('resourceCalDAV_item')&&globalEventCollectionsLoading) || ($(this).hasClass('resourceCalDAVTODO_item')&&globalTodoCollectionsLoading)) return true; if(e.shiftKey) { if(isEvent) enableOne($(this).attr('data-id')); else enableOneTodo($(this).attr('data-id')); } $('#ResourceCalDAV'+todoString+'List .resourceCalDAV_item_selected').removeClass('resourceCalDAV_item_selected'); $(this).addClass('resourceCalDAV_item_selected'); }); if(typeof globalCalendarColorPropertyXmlns== 'undefined' || globalCalendarColorPropertyXmlns== null || globalCalendarColorPropertyXmlns==='' || globalCalendarColorPropertyXmlns!==false) bindColorPickerClick(newElement.find('.resourceCalDAVColor')); $('#ResourceCalDAV'+todoString+'List').children().eq(insertIndex+headerMiss).after(newElement); console.log('inserted inputResource with uid=' + inputResource.uid, newElement) if(inputResource.makeLoaded) { var resDOMHeader=newElement.prevUntil('.resourceCalDAV'+todoString+'_header').last().prev(); if(!resDOMHeader.length) resDOMHeader=newElement.prev(); resDOMHeader.css('display','block'); var rex=vCalendar.pre['accountUidParts']; var tmp=inputResource.accountUID.match(rex); var resourceCalDAV_href=tmp[1]+tmp[3]+tmp[4]; var resourceCalDAV_user=tmp[2]; for(var i=0;i=0;i--) { if(this.collections[i]!=undefined && !this.collections[i].subscription && this.collections[i].timestamp!=undefined && this.collections[i].uid.indexOf(inputUidBase)==0 && this.collections[i].timestamp0) //{ var beforeScroll = $('#main').width()-$('#calendar').width(); $('#calendar').fullCalendar('removeEventSource', this.collections[i].fcSource); var afterScroll = $('#main').width()-$('#calendar').width(); rerenderCalendar(beforeScroll!=afterScroll); //} var item=$('#ResourceCalDAVList').find('.resourceCalDAV_item[data-id^="'+jqueryEscapeSelector(this.collections[i].uid)+'"]'); var item_header=item.prevUntil('.resourceCalDAV_header').last().prev(); if(!item_header.length) item_header=item.prev(); item.remove(); this.collections.splice(i, 1); // if next item is undefined or it is a header and the previous item is header delete it if((this.collections[i]==undefined || this.collections[i].headerOnly==true) && this.collections[i-1].headerOnly==true) { item_header.remove(); this.collections.splice(--i, 1); } else { var firstVisibleCollection=null; for(var vi=i-1;vi>0;vi--) { if(this.collections[vi].headerOnly==true) break; if(this.collections[vi].makeLoaded) { firstVisibleCollection=this.collections[vi]; break; } } if(firstVisibleCollection==null) { for(var vi=i;vi=0;i--) { if(this.TodoCollections[i]!=undefined && !this.TodoCollections[i].subscription && this.TodoCollections[i].timestamp!=undefined && this.TodoCollections[i].uid.indexOf(inputUidBase)==0 && this.TodoCollections[i].timestamp0) //{ var beforeScroll = $('#mainTODO').width()-$('#todoList').width(); $('#todoList').fullCalendar('removeEventSource', this.TodoCollections[i].fcSource); var afterScroll = $('#mainTODO').width()-$('#todoList').width(); rerenderTodo(beforeScroll!=afterScroll); //} var item=$('#ResourceCalDAVTODOList').find('.resourceCalDAVTODO_item[data-id^="'+jqueryEscapeSelector(this.TodoCollections[i].uid)+'"]'); var item_header=item.prevUntil('.resourceCalDAVTODO_header').last().prev(); if(!item_header.length) item_header=item.prev(); item.remove(); this.TodoCollections.splice(i, 1); // if next item is undefined or it is a header and the previous item is header delete it if((this.TodoCollections[i]==undefined || this.TodoCollections[i].headerOnly==true) && this.TodoCollections[i-1].headerOnly==true) { item_header.remove(); this.TodoCollections.splice(--i, 1); } else { var firstVisibleCollection=null; for(var vi=i-1;vi>0;vi--) { if(this.TodoCollections[vi].headerOnly==true) break; if(this.TodoCollections[vi].makeLoaded) { firstVisibleCollection=this.TodoCollections[vi]; break; } } if(firstVisibleCollection==null) { for(var vi=i;vi=0;i--) if(this.collections[i].uid==inputUid) { var uidRemoved=this.collections[i].uid; var item=$('#ResourceCalDAVList').find('[data-id^="'+jqueryEscapeSelector(this.collections[i].uid)+'"]'); var item_prev=item.prev(); item.remove(); this.collections.splice(i, 1); // if next item is undefined or it is a header and the previous item is header delete it if((this.collections[i]==undefined || this.collections[i].headerOnly==true) && i>0 && this.collections[i-1].headerOnly==true) { item_prev.remove(); this.collections.splice(i, 1); } } } else for(var i=this.TodoCollections.length-1;i>=0;i--) if(this.TodoCollections[i].uid==inputUid) { var uidRemoved=this.TodoCollections[i].uid; var item=$('#ResourceCalDAVTODOList').find('[data-id^="'+jqueryEscapeSelector(this.TodoCollections[i].uid)+'"]'); var item_prev=item.prev(); item.remove(); this.TodoCollections.splice(i, 1); // if next item is undefined or it is a header and the previous item is header delete it if((this.TodoCollections[i]==undefined || this.TodoCollections[i].headerOnly==true) && i>0 && this.TodoCollections[i-1].headerOnly==true) { item_prev.remove(); this.TodoCollections.splice(i, 1); } } }; this.getCollectionByUID=function(inputUID) { for(var i=0;i