/* CardDavMATE - the open source CardDAV 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 handleCardDAVError(isError, inputResource) { var collections=''; collections=globalResourceCardDAVList.collections; for(var i=0; i we need to remove and reinsert it { nameChanged=true; makeActive=$('#ResourceCardDAVList').find('[data-id='+jqueryEscapeSelector(inputCollection.uid)+']').hasClass('resourceCardDAV_selected'); makeChecked=$('#ResourceCardDAVList').find('[data-id='+jqueryEscapeSelector(inputCollection.uid)+']').find('input[type=checkbox]').not('.unloadCheck').prop('checked'); makeIndeterminate=$('#ResourceCardDAVList').find('[data-id='+jqueryEscapeSelector(inputCollection.uid)+']').find('input[type=checkbox]').not('.unloadCheck').prop('indeterminate'); // here get the list of vcard groups with the current state (we need to re-add them to the interface) $('#ResourceCardDAVList').find('.group[data-id^='+jqueryEscapeSelector(inputCollection.uid)+']').not('[data-id='+jqueryEscapeSelector(inputCollection.uid)+']').each( function(index, element) { makeContactGroups.push({uid: $(element).attr('data-id'), isActive: $(element).hasClass('resourceCardDAV_selected'), isChecked: $(element).find('input[type=checkbox]').prop('checked')}); } ); // the collection name is changed and must be moved to correct place (we first remove it and then reinsert) this.removeResource(inputCollection.uid, false); break; } } if(!globalCardDAVInitLoad&&!nameChanged) { var uidParts=inputCollection.uid.match(RegExp('^(https?://)([^@/]+(?:@[^@/]+)?)@(.*)')); var checkHref = uidParts[1]+uidParts[3]; var isLoaded=false; if(typeof globalCrossServerSettingsURL!='undefined'&&globalCrossServerSettingsURL!=null&globalCrossServerSettingsURL) { var uidParts=inputCollection.uid.match(RegExp('/([^/]+/[^/]+/)$')); var tmpParts = uidParts[1].match('^(.*/)([^/]+)/$'); var checkHref3=decodeURIComponent(tmpParts[1])+tmpParts[2]+'/'; var found=false; for(var l=0;l0) while(low0) return false; else { globalAddressbookList.applyABFilter(collectionChBoxClick(this, \'#ResourceCardDAVList\', \'.resourceCardDAV_header\', \'.resourceCardDAV\', \'.contact_group\', true), false); }'}); newElement.find('.resourceCardDAV').append(inputCollection.displayvalue); newElement.find('.resourceCardDAV').attr('title',inputCollection.displayvalue); $('#ResourceCardDAVList').children().eq(insertIndex+headerMiss).after(newElement); if(inputCollection.makeLoaded) { var resDOMHeader=newElement.prevUntil('.resourceCardDAV_header').last().prev(); if(!resDOMHeader.length) resDOMHeader=newElement.prev(); resDOMHeader.css('display','block'); var rex=vCard.pre['accountUidParts']; var tmp=inputCollection.accountUID.match(rex); var resourceCalDAV_href=tmp[1]+tmp[3]+tmp[4]; var resourceCalDAV_user=tmp[2]; for(var i=0;i0) for(var i=0;i=0;i--) if(this.collections[i].uid==inputCollectionUID) { var uidRemoved=this.collections[i].uid; var item=$('#ResourceCardDAVList').find('.resourceCardDAV[data-id^="'+jqueryEscapeSelector(this.collections[i].uid)+'"]'); var item_prev=item.parent().prev(); var item_was_selected=item.hasClass('resourceCardDAV_selected'); if(activateNextIfNeeded && item_was_selected) { // select the nearest candidate to load if((i+1)<=(this.collections.length-1)) { if(this.collections[i+1].headerOnly!=true) nextCandidateToActive=this.collections[i+1]; else if((i+2)<=(this.collections.length-1)) nextCandidateToActive=this.collections[i+2]; } if(nextCandidateToActive==null && (i-1)>0) { if(this.collections[i-1].headerOnly!=true) nextCandidateToActive=this.collections[i-1]; else if((i-2)>0) nextCandidateToActive=this.collections[i-2]; } } // remove the item item.parent().remove(); this.collections.splice(i,1); // if the next item is undefined or is header, and the previous item is header, then delete the header if((this.collections[i]==undefined || this.collections[i].headerOnly==true) && this.collections[i-1].headerOnly==true) { item_prev.remove(); this.collections.splice(--i,1); } // make another resource active if(activateNextIfNeeded && nextCandidateToActive!=null) this.resourceOrGroupClick(nextCandidateToActive.uid); break; } } // DONE this.removeOldResources=function(inputUidBase, inputTimestamp) { for(var i=this.collections.length-1;i>=0;i--) if(this.collections[i].timestamp!=undefined && this.collections[i].uid.indexOf(inputUidBase)==0 && this.collections[i].timestamp0 && 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