-
Notifications
You must be signed in to change notification settings - Fork 5
/
webdav_protocol.js
2839 lines (2673 loc) · 134 KB
/
webdav_protocol.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
CalDavZAP - the open source CalDAV Web Client
Copyright (C) 2011-2014
Jan Mate <[email protected]>
Andrej Lezo <[email protected]>
Matej Mihalik <[email protected]>
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 <http://www.gnu.org/licenses/>.
*/
// VersionCheck (check for new version)
function netVersionCheck()
{
$.ajax({
type: 'GET',
url: globalVersionCheckURL,
cache: false,
crossDomain: false,
timeout: 30000,
error: function(objAJAXRequest, strError){
console.log("Error: [netVersionCheck: '"+globalVersionCheckURL+"'] code: '"+objAJAXRequest.status+"'");
return false;
},
beforeSend: function(req) {
req.setRequestHeader('X-client', globalXClientHeader);
},
contentType: 'text/xml; charset=utf-8',
processData: true,
data: '',
dataType: 'xml',
complete: function(xml, textStatus)
{
if(textStatus!='success')
return false;
var count=0;
var tmp=$(xml.responseXML).find('updates').find(globalAppName.toLowerCase());
var type=tmp.attr('type');
var home=tmp.attr('homeURL');
var version_txt=tmp.attr('version');
if(type==undefined || type=='' || home==undefined || home=='' || version_txt==undefined || version_txt=='')
return false;
var version=version_txt.match(RegExp('^([0-9]+)\.([0-9]+)\.([0-9]+)(?:\.([0-9]+))?$'));
if(version==null)
return false;
if(version[4]==null)
version[4]='0';
var version_int=parseInt(parseInt(version[1],10).pad(2)+parseInt(version[2],10).pad(2)+parseInt(version[3],10).pad(2)+parseInt(version[4],10).pad(2),10);
var current_version=globalVersion.match(RegExp('^([0-9]+)\.([0-9]+)\.([0-9]+)(?:\.([0-9]+))?'));
if(current_version[4]==null)
current_version[4]='0';
var current_version_int=parseInt(parseInt(current_version[1],10).pad(2)+parseInt(current_version[2],10).pad(2)+parseInt(current_version[3],10).pad(2)+parseInt(current_version[4],10).pad(2),10);
if(current_version_int<version_int)
{
var showNofication=false;
if(globalNewVersionNotifyUsers.length==0)
showNofication=true;
else
{
for(var i=0;i<globalAccountSettings.length;i++)
if(globalNewVersionNotifyUsers.indexOf(globalAccountSettings[i].userAuth.userName)!=-1)
{
showNofication=true;
break;
}
}
if(showNofication==true)
{
$('div.update_h').html(localization[globalInterfaceLanguage].updateNotification.replace('%name%',globalAppName).replace('%new_ver%','<span id="newversion" class="update_h"></span>').replace('%curr_ver%', '<span id="version" class="update_h"></span>').replace('%url%', '<span id="homeurl" class="update_h" onclick=""></span>'));
$('div.update_h').find('span#version').text(globalVersion);
$('div.update_h').find('span#newversion').text(version_txt);
$('div.update_h').find('span#homeurl').attr('onclick','window.open(\''+home+'\')');
$('div.update_h').find('span#homeurl').text(home);
setTimeout(function(){
var orig_width=$('div.update_d').width();
$('div.update_d').css('width', '0px');
$('div.update_d').css('display','');
$('div.update_d').animate({width: '+='+orig_width+'px'}, 500);
},5000);
}
}
}
});
}
// Load the configuration from XML file
function netCheckAndCreateConfiguration(configurationURL)
{
$.ajax({
type: 'PROPFIND',
url: configurationURL.href,
cache: false,
crossDomain: (typeof configurationURL.crossDomain=='undefined' ? true : configurationURL.crossDomain),
xhrFields: {
withCredentials: (typeof configurationURL.withCredentials=='undefined' ? false : configurationURL.withCredentials)
},
timeout: configurationURL.timeOut,
error: function(objAJAXRequest, strError){
console.log("Error: [netCheckAndCreateConfiguration: '"+configurationURL.href+"'] code: '"+objAJAXRequest.status+"'"+(objAJAXRequest.status==0 ? ' - see http://www.inf-it.com/'+globalAppName.toLowerCase()+'/misc/readme_network.txt' : ''));
$('#LoginLoader').fadeOut(1200);
return false;
},
beforeSend: function(req){
if(globalSettings.usejqueryauth!=true && globalLoginUsername!='' && globalLoginPassword!='')
req.setRequestHeader('Authorization', basicAuth(globalLoginUsername,globalLoginPassword));
req.setRequestHeader('X-client', globalXClientHeader);
req.setRequestHeader('Depth', '0');
},
username: (globalSettings.usejqueryauth==true ? globalLoginUsername : null),
password: (globalSettings.usejqueryauth==true ? globalLoginPassword : null),
contentType: 'text/xml; charset=utf-8',
processData: true,
data: '<?xml version="1.0" encoding="utf-8"?><D:propfind xmlns:D="DAV:"><D:prop><D:current-user-principal/></D:prop></D:propfind>',
dataType: 'xml',
complete: function(xml, textStatus)
{
if(textStatus!='success')
return false;
var count=0;
if($(xml.responseXML).children().filterNsNode('multistatus').children().filterNsNode('response').children().filterNsNode('propstat').children().filterNsNode('status').text().match(RegExp('200 OK$')))
{
if(typeof globalAccountSettings=='undefined')
globalAccountSettings=[];
globalAccountSettings[globalAccountSettings.length]=$.extend({}, configurationURL);
globalAccountSettings[globalAccountSettings.length-1].type='network';
globalAccountSettings[globalAccountSettings.length-1].href=configurationURL.href+globalLoginUsername+'/';
globalAccountSettings[globalAccountSettings.length-1].userAuth={userName: globalLoginUsername, userPassword: globalLoginPassword};
count++;
if(configurationURL.additionalResources!=undefined && configurationURL.additionalResources.length>0)
{
for(var i=0;i<configurationURL.additionalResources.length;i++)
{
if(globalLoginUsername!=configurationURL.additionalResources[i])
{
globalAccountSettings[globalAccountSettings.length]=$.extend({}, configurationURL);
globalAccountSettings[globalAccountSettings.length-1].type='network';
globalAccountSettings[globalAccountSettings.length-1].href=configurationURL.href+configurationURL.additionalResources[i]+'/';
globalAccountSettings[globalAccountSettings.length-1].userAuth={userName: globalLoginUsername, userPassword: globalLoginPassword};
count++;
}
}
}
}
if(count)
{
var delCount=0, delegIndex=0;
for(var i=0; i<globalAccountSettings.length;i++)
if((typeof globalAccountSettings[i].delegation =='boolean' && globalAccountSettings[i].delegation) || (globalAccountSettings[i].delegation instanceof Array && globalAccountSettings[i].delegation.length>0))
delegIndex=i;
for(var i=0; i<globalAccountSettings.length;i++)
{
if((typeof globalAccountSettings[i].delegation =='boolean' && globalAccountSettings[i].delegation) || (globalAccountSettings[i].delegation instanceof Array && globalAccountSettings[i].delegation.length>0))
{
delCount++;
DAVresourceDelegation(globalAccountSettings[i], i, delegIndex);
}
}
if(delCount==0)
{
// start the client
if(isAvaible('CardDavMATE'))
runCardDAV();
if(isAvaible('CalDavZAP'))
runCalDAV();
if(isAvaible('Projects'))
runProjects();
if(isAvaible('Settings'))
runSettings();
globalResourceNumber=globalAccountSettings.length;
loadAllResources();
}
}
else
$('#LoginLoader').fadeOut(1200);
}
});
}
// Load the configuration from XML file
function netLoadConfiguration(configurationURL)
{
$.ajax({
type: 'GET',
url: configurationURL.href,
cache: false,
crossDomain: (typeof configurationURL.crossDomain=='undefined' ? true : configurationURL.crossDomain),
xhrFields: {
withCredentials: (typeof configurationURL.withCredentials=='undefined' ? false : configurationURL.withCredentials)
},
timeout: configurationURL.timeOut,
error: function(objAJAXRequest, strError){
console.log("Error: [loadConfiguration: '"+configurationURL.href+"'] code: '"+objAJAXRequest.status+"'"+(objAJAXRequest.status==0 ? ' - see http://www.inf-it.com/'+globalAppName.toLowerCase()+'/misc/readme_network.txt' : ''));
$('#LoginLoader').fadeOut(1200);
return false;
},
beforeSend: function(req) {
if(globalSettings.usejqueryauth!=true && globalLoginUsername!='' && globalLoginPassword!='')
req.setRequestHeader('Authorization', basicAuth(globalLoginUsername,globalLoginPassword));
req.setRequestHeader('X-client', globalXClientHeader);
},
username: (globalSettings.usejqueryauth==true ? globalLoginUsername : null),
password: (globalSettings.usejqueryauth==true ? globalLoginPassword : null),
contentType: 'text/xml; charset=utf-8',
processData: true,
data: '',
dataType: 'xml',
complete: function(xml, textStatus)
{
if(textStatus!='success')
return false;
if(typeof globalAccountSettings=='undefined')
globalAccountSettings=[];
var count=0;
var rex=new RegExp('^re(\\|[^:]*|):(.+)$');
$(xml.responseXML).children('resources').children('resource').each(
function(index, element)
{
if($(element).children().filterNsNode('type').children().filterNsNode('addressbook').length==1 || $(element).children().filterNsNode('type').children().filterNsNode('calendar').length==1)
{
// numeric/text options
var href=$(element).children('href').text();
var tmp=$(element).children('hreflabel').text();
var hreflabel=(tmp!='' && tmp!='null' ? tmp : null);
var username=$(element).children('userauth').children('username').text();
var password=$(element).children('userauth').children('password').text();
var timeout=$(element).children('timeout').text();
var locktimeout=$(element).children('locktimeout').text();
// array options
var collectionTypes=new Array();
if($(element).children().filterNsNode('type').children().filterNsNode('addressbook').length==1)
collectionTypes[collectionTypes.length]='addressbook';
if($(element).children().filterNsNode('type').children().filterNsNode('calendar').length==1)
collectionTypes[collectionTypes.length]='calendar';
// boolean options
var tmp=$(element).children('showheader').text();
var showHeader=((tmp=='false' || tmp=='no' || tmp=='0') ? false : true);
var tmp=$(element).children('withcredentials').text();
var withcredentials=((tmp=='true' || tmp=='yes' || tmp=='1') ? true : false);
var tmp=$(element).children('crossdomain').text();
var crossdomain=((tmp=='false' || tmp=='no' || tmp=='0') ? false : true);
var tmp=$(element).find('settingsaccount').text();
var settingsaccount=((tmp=='true' || tmp=='yes' || tmp=='1') ? true : false);
var tmp=$(element).find('checkcontenttype').text();
var checkcontenttype=((tmp=='false' || tmp=='no' || tmp=='0') ? false : true);
var tmp=$(element).find('ignorebound').text();
var ignorebound=((tmp=='true' || tmp=='yes' || tmp=='1') ? true : false);
// special options
var forcereadonly=null;
var tmp=$(element).children('forcereadonly');
if(tmp.text()=='true')
var forcereadonly=true;
else
{
var tmp_ro=[];
tmp.children('collection').each(
function(index, element)
{
if((matched=$(element).text().match(rex))!=null && matched.length==3)
tmp_ro[tmp_ro.length]=new RegExp(matched[2], matched[1].substring(matched[1].length>0 ? 1 : 0));
else
tmp_ro[tmp_ro.length]=$(element).text();
}
);
if(tmp_ro.length>0)
var forcereadonly=tmp_ro;
}
var delegation=false;
var tmp=$(element).children('delegation');
if(tmp.text()=='true')
var delegation=true;
else
{
var tmp_de=[];
tmp.children('resource').each(
function(index, element)
{
if((matched=$(element).text().match(rex))!=null && matched.length==3)
tmp_de[tmp_de.length]=new RegExp(matched[2], matched[1].substring(matched[1].length>0 ? 1 : 0));
else
tmp_de[tmp_de.length]=$(element).text();
}
);
if(tmp_de.length>0)
var delegation=tmp_de;
}
var ignoreAlarms=false;
var tmp=$(element).children('ignorealarms');
if(tmp.text()=='true')
var ignoreAlarms=true;
else
{
var tmp_ia=[];
tmp.children('collection').each(
function(index, element)
{
if((matched=$(element).text().match(rex))!=null && matched.length==3)
tmp_ia[tmp_ia.length]=new RegExp(matched[2], matched[1].substring(matched[1].length>0 ? 1 : 0));
else
tmp_ia[tmp_ia.length]=$(element).text();
}
);
if(tmp_ia.length>0)
var ignoreAlarms=tmp_ia;
}
var backgroundCalendars=[];
var tmp=$(element).children('backgroundcalendars');
if(tmp.text()!='')
{
tmp.children('collection').each(
function(index, element)
{
if((matched=$(element).text().match(rex))!=null && matched.length==3)
backgroundCalendars[backgroundCalendars.length]=new RegExp(matched[2], matched[1].substring(matched[1].length>0 ? 1 : 0));
else
backgroundCalendars[backgroundCalendars.length]=$(element).text();
}
);
}
globalAccountSettings[globalAccountSettings.length]={type: 'network', href: href, hrefLabel: hreflabel, crossDomain: crossdomain, showHeader: showHeader, settingsAccount: settingsaccount, checkContentType: checkcontenttype, forceReadOnly: forcereadonly, withCredentials: withcredentials, userAuth: {userName: username, userPassword: password}, timeOut: timeout, lockTimeOut: locktimeout, delegation: delegation, ignoreAlarms: ignoreAlarms, backgroundCalendars: backgroundCalendars, collectionTypes: collectionTypes, ignoreBound: ignorebound};
count++;
}
}
);
if(count)
{
var delCount=0, delegIndex=0;
for(var i=0; i<globalAccountSettings.length; i++)
if((typeof globalAccountSettings[i].delegation =='boolean' && globalAccountSettings[i].delegation) || (globalAccountSettings[i].delegation instanceof Array && globalAccountSettings[i].delegation.length>0))
delegIndex=i;
for(var i=0; i<globalAccountSettings.length;i++)
{
if((typeof globalAccountSettings[i].delegation =='boolean' && globalAccountSettings[i].delegation) || (globalAccountSettings[i].delegation instanceof Array && globalAccountSettings[i].delegation.length>0))
{
delCount++;
DAVresourceDelegation(globalAccountSettings[i], i, delegIndex);
}
}
if(delCount==0)
{
// start the client
if(isAvaible('CardDavMATE'))
{
runCardDAV();
}
if(isAvaible('CalDavZAP'))
runCalDAV();
if(isAvaible('Projects'))
runProjects();
if(isAvaible('Settings'))
runSettings();
globalResourceNumber = globalAccountSettings.length;
loadAllResources();
}
}
else
$('#LoginLoader').fadeOut(1200);
}
});
}
// Save the client settings (stored as DAV property on server)
function netSaveSettings(inputResource, inputSettings, isFormSave)
{
var re=new RegExp('^(https?://)([^/]+)', 'i');
var tmp=inputResource.href.match(re);
var baseHref=tmp[1]+tmp[2];
var uidBase=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2];
var saveHref = inputResource.href;
if(globalSettings.settingstype!='' && globalSettings.settingstype!=null)
{
if(globalSettings.settingstype=='addressbook-home-set')
saveHref = inputResource.abhref;
else if(globalSettings.settingstype=='calendar-home-set')
saveHref = inputResource.cahref;
}
$.ajax({
type: 'PROPPATCH',
url: saveHref,
cache: false,
crossDomain: (typeof inputResource.crossDomain=='undefined' ? true: inputResource.crossDomain),
xhrFields: {
withCredentials: (typeof inputResource.withCredentials=='undefined' ? false: inputResource.withCredentials)
},
timeout: inputResource.timeOut,
error: function(objAJAXRequest, strError){
console.log("Error: [netSaveSettings: '"+uidBase+"'] code: '"+objAJAXRequest.status+"'"+(objAJAXRequest.status==0 ? ' (this error code usually means network connection error, or your browser is trying to make a cross domain query, but it is not allowed by the destination server or the browser itself)': ''));
if(isAvaible('Settings'))
show_editor_loader_messageSettings('message_error', localization[globalInterfaceLanguage].errSettingsSaved);
return false;
},
beforeSend: function(req){
if(globalSettings.usejqueryauth!=true && inputResource.userAuth.userName!='' && inputResource.userAuth.userPassword!='')
req.setRequestHeader('Authorization', basicAuth(inputResource.userAuth.userName, inputResource.userAuth.userPassword));
req.setRequestHeader('X-client', globalXClientHeader);
req.setRequestHeader('Depth', '0');
},
username: (globalSettings.usejqueryauth==true ? inputResource.userAuth.userName : null),
password: (globalSettings.usejqueryauth==true ? inputResource.userAuth.userPassword : null),
contentType: 'text/xml',
processData: true,
data: '<?xml version="1.0" encoding="utf-8"?><D:propertyupdate xmlns:D="DAV:"><D:set><D:prop><I:settings xmlns:I="http://inf-it.com/ns/dav/">'+JSON.stringify(inputSettings)+'</I:settings></D:prop></D:set></D:propertyupdate>',
dataType: 'xml',
complete: function(xml, textStatus)
{
switch(textStatus)
{
case 'success':
if(isAvaible('Settings')&&isFormSave)
{
if((isAvaible('CardDavMATE')&&globalCardDAVResourceSync) || (isAvaible('CalDavZAP')&&globalCalDAVResourceSync))
{
var myInt = setInterval(function(){
if((isAvaible('CardDavMATE')&&!globalCardDAVResourceSync) && (isAvaible('CalDavZAP')&&!globalCalDAVResourceSync))
{
clearInterval(myInt);
applySettings(getChangedSettings(globalSettings, inputSettings));
globalSettings = inputSettings;
}
},100);
}
else
{
applySettings(getChangedSettings(globalSettings, inputSettings));
globalSettings = inputSettings;
}
}
break;
default:
break;
}
}
});
}
function DAVresourceDelegation(inputResource, index, lastIndex)
{
globalCalDAVResourceSync=false;
var re=new RegExp('^(https?://)([^/]+)', 'i');
var tmp=inputResource.href.match(re);
var baseHref=tmp[1]+tmp[2];
var uidBase=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2];
$.ajax({
type: 'REPORT',
url: inputResource.href,
cache: false,
crossDomain: (typeof inputResource.crossDomain=='undefined' ? true: inputResource.crossDomain),
xhrFields:
{
withCredentials: (typeof inputResource.withCredentials=='undefined' ? false: inputResource.withCredentials)
},
timeout: inputResource.timeOut,
error: function(objAJAXRequest, strError)
{
console.log("Error: [DAVresourceDelegation: '"+uidBase+"'] code: '"+objAJAXRequest.status+"'"+(objAJAXRequest.status==0 ? ' (this error code usually means network connection error, or your browser is trying to make a cross domain query, but it is not allowed by the destination server or the browser itself)': ''));
},
beforeSend: function(req)
{
if(globalSettings.usejqueryauth!=true && inputResource.userAuth.userName!='' && inputResource.userAuth.userPassword!='')
req.setRequestHeader('Authorization', basicAuth(inputResource.userAuth.userName, inputResource.userAuth.userPassword));
req.setRequestHeader('X-client', globalXClientHeader);
req.setRequestHeader('Depth', '0');
},
username: (globalSettings.usejqueryauth==true ? inputResource.userAuth.userName : null),
password: (globalSettings.usejqueryauth==true ? inputResource.userAuth.userPassword : null),
contentType: 'text/xml',
processData: true,
data: '<?xml version="1.0" encoding="utf-8"?><A:expand-property xmlns:A="DAV:"><A:property name="calendar-proxy-read-for" namespace="http://calendarserver.org/ns/"><A:property name="email-address-set" namespace="http://calendarserver.org/ns/"/><A:property name="displayname" namespace="DAV:"/><A:property name="calendar-user-address-set" namespace="urn:ietf:params:xml:ns:caldav"/></A:property><A:property name="calendar-proxy-write-for" namespace="http://calendarserver.org/ns/"><A:property name="email-address-set" namespace="http://calendarserver.org/ns/"/><A:property name="displayname" namespace="DAV:"/><A:property name="calendar-user-address-set" namespace="urn:ietf:params:xml:ns:caldav"/></A:property></A:expand-property>',
dataType: 'xml',
complete: function(xml, textStatus)
{
if(textStatus!='success')
return false;
if(typeof globalAccountSettings=='undefined')
globalAccountSettings=[];
var hostPart=tmp[0];
var propElement=$(xml.responseXML).children().filterNsNode('multistatus').children().filterNsNode('response').children().filterNsNode('propstat').children().filterNsNode('prop');
var searchR=new Array();
searchR[searchR.length]=$(propElement).children().filterNsNode('calendar-proxy-read-for');
searchR[searchR.length]=$(propElement).children().filterNsNode('calendar-proxy-write-for');
for(var m=0; m<searchR.length; m++)
{
searchR[m].children().filterNsNode('response').children().filterNsNode('href').each(
function(index, element)
{
var href=$(element).text();
var found=false;
for(var i=0; i<globalAccountSettings.length; i++)
if(decodeURIComponent(globalAccountSettings[i].href)==(hostPart+href))
found=true;
if(!found)
{
var enabled=false;
if(inputResource.delegation instanceof Array && inputResource.delegation.length>0)
{
for(var j=0; j<inputResource.delegation.length; j++)
if(typeof inputResource.delegation[j]=='string')
{
var index=href.indexOf(inputResource.delegation[j]);
if(index!=-1)
if(href.length==(index+inputResource.delegation[j].length))
enabled=true;
}
else if(typeof inputResource.delegation[j]=='object')
{
if(href.match(inputResource.delegation[j])!=null)
enabled=true;
}
}
else
enabled=true;
if(enabled)
{
globalAccountSettings[globalAccountSettings.length]=$.extend({}, inputResource);
globalAccountSettings[globalAccountSettings.length-1].type=inputResource.type;
globalAccountSettings[globalAccountSettings.length-1].href=decodeURIComponent(hostPart+href);
globalAccountSettings[globalAccountSettings.length-1].userAuth={userName: inputResource.userAuth.userName, userPassword: inputResource.userAuth.userPassword};
}
}
}
);
}
if(index==lastIndex)
{
// start the client
if(isAvaible('CardDavMATE'))
runCardDAV();
if(isAvaible('CalDavZAP'))
runCalDAV();
if(isAvaible('Projects'))
runProjects();
if(isAvaible('Settings'))
runSettings();
globalResourceNumber=globalAccountSettings.length;
loadAllResources();
}
}
});
}
function netFindResource(inputResource, inputResourceIndex, forceLoad, indexR)
{
if(indexR<globalAccountSettings.length)
{
globalResourceNumberCount++;
if((isAvaible('CardDavMATE')&&globalCardDAVInitLoad) || (isAvaible('CalDavZAP')&&globalCalDAVInitLoad) || (isAvaible('Projects')&&!isProjectsLoaded) || (isAvaible('Settings')&&!isSettingsLoaded))
$('#MainLoaderInner').html(localization[globalInterfaceLanguage].loadingResources.replace('%act%', globalResourceNumberCount).replace('%total%', globalResourceNumber));
}
if(typeof inputResource!='undefined' && typeof inputResource.collectionTypes!='undefined' && inputResource.collectionTypes!=null && (inputResource.collectionTypes.indexOf('calendar')==-1) && inputResource.collectionTypes.indexOf('addressbook')==-1)
{
indexR++;
netFindResource(globalAccountSettings[indexR], inputResourceIndex, forceLoad, indexR);
return false;
}
if(indexR>=globalAccountSettings.length && settingsLoaded)
{
if(globalResourceIntervalID==null)
globalResourceIntervalID=setInterval(reloadResources, globalSettings.syncresourcesinterval);
globalCalDAVResourceSync=false;
globalCardDAVResourceSync=false;
var rexo=new RegExp('^(https?://)([^@/]+(?:@[^@/]+)?)@(.*)');
var rex=new RegExp('^(https?://)(.*)', 'i');
if(isAvaible('CalDavZAP'))
{
var cals=globalResourceCalDAVList.TodoCollections;
var calendarsArray=new Array();
for(var i=0;i<cals.length;i++)
if(cals[i].uid!=undefined)
calendarsArray[calendarsArray.length]={displayValue:cals[i].displayvalue,uid:cals[i].uid, permissions_read_only:cals[i].permissions.read_only,makeLoaded:cals[i].makeLoaded};
calendarsArray.sort(customResourceCompare);
globalResourceCalDAVList.sortedTodoCollections = calendarsArray;
var cals=globalResourceCalDAVList.collections;
calendarsArray=new Array();
for(var i=0;i<cals.length;i++)
if(cals[i].uid!=undefined)
calendarsArray[calendarsArray.length]={displayValue:cals[i].displayvalue,uid:cals[i].uid, permissions_read_only:cals[i].permissions.read_only, makeLoaded:cals[i].makeLoaded};
calendarsArray.sort(customResourceCompare);
globalResourceCalDAVList.sortedCollections = calendarsArray;
if(isAvaible('Settings') && globalSettingsSaving && !globalFirstHideLoader)
{
globalFirstHideLoader = true;
globalSettingsSaving=false;
setTimeout(function(){
$('#SettingsFormOverlay').hide();
$('#SettingsFormOverlay').find('.saveLoaderInfo').text('');
$('.settingsButtons, #ResourceSettingsListOverlay').css('display','none');
},globalHideInfoMessageAfter);
}
}
if((isAvaible('CalDavZAP') && !isCalDAVLoaded) || (isAvaible('CardDavMATE') && !isCardDAVLoaded))
{
if(isAvaible('CalDavZAP'))
{
if(!globalDefaultCalendarCollectionActiveAll)
{
for(var i=0;i<globalSettings.activecalendarcollections.length;i++)
{
var uidPart=globalSettings.activecalendarcollections[i].match(rex)[1];
var uidPart2=globalSettings.activecalendarcollections[i].match(rex)[2];
if(globalLoginUsername!='')
var uidPart3=globalLoginUsername;
else
var uidPart3=globalAccountSettings[0].userAuth.userName;
var uid = uidPart+uidPart3+'@'+uidPart2;
if($('#ResourceCalDAVList input[data-id="'+uid+'"]').length>0)
{
$('#ResourceCalDAVList input[data-id="'+uid+'"]').trigger('click');
globalVisibleCalDAVCollections.splice(globalVisibleCalDAVCollections.length, 0, uid);
}
}
if(globalSettings.activecalendarcollections.length>0 && globalVisibleCalDAVCollections.length==0)
globalDefaultCalendarCollectionActiveAll = true;
}
if(globalDefaultCalendarCollectionActiveAll)
for(var i=0;i<globalResourceCalDAVList.collections.length;i++)
{
if(globalResourceCalDAVList.collections[i].uid!=undefined)
{
$('#ResourceCalDAVList input[data-id="'+globalResourceCalDAVList.collections[i].uid+'"]').trigger('click');
globalVisibleCalDAVCollections.splice(globalVisibleCalDAVCollections.length, 0, globalResourceCalDAVList.collections[i].uid);
}
}
if(!globalDefaultTodoCalendarCollectionActiveAll)
{
for(var i=0;i<globalSettings.activetodocollections.length;i++)
{
var uidPart=globalSettings.activetodocollections[i].match(rex)[1];
var uidPart2=globalSettings.activetodocollections[i].match(rex)[2];
if(globalLoginUsername!='')
var uidPart3=globalLoginUsername;
else
var uidPart3=globalAccountSettings[0].userAuth.userName;
var uid = uidPart+uidPart3+'@'+uidPart2;
if($('#ResourceCalDAVTODOList input[data-id="'+uid+'"]').length>0)
{
$('#ResourceCalDAVTODOList input[data-id="'+uid+'"]').trigger('click');
globalVisibleCalDAVTODOCollections.splice(globalVisibleCalDAVTODOCollections.length, 0, uid);
}
}
if(globalSettings.activetodocollections.length>0 && globalVisibleCalDAVTODOCollections.length==0)
globalDefaultTodoCalendarCollectionActiveAll = true;
}
if(globalDefaultTodoCalendarCollectionActiveAll)
for(var i=0;i<globalResourceCalDAVList.TodoCollections.length;i++)
{
if(globalResourceCalDAVList.TodoCollections[i].uid!=undefined)
{
$('#ResourceCalDAVTODOList input[data-id="'+globalResourceCalDAVList.TodoCollections[i].uid+'"]').trigger('click');
globalVisibleCalDAVTODOCollections.splice(globalVisibleCalDAVTODOCollections.length, 0, globalResourceCalDAVList.TodoCollections[i].uid);
}
}
if($('#ResourceCalDAVList .resourceCalDAV_item[data-id]:visible').length==0 && globalResourceCalDAVList.collections.length>1)
{
$('#ResourceCalDAVList .resourceCalDAV_item[data-id="'+globalResourceCalDAVList.collections[1].uid+'"]').css('display','block');
globalResourceCalDAVList.collections[1].makeLoaded=true;
var uidParts=globalResourceCalDAVList.collections[1].uid.match(rexo);
globalSettings.loadedcalendarcollections.push(uidParts[1]+uidParts[3]);
var str=globalResourceCalDAVList.collections[1].href.substring(0, globalResourceCalDAVList.collections[1].href.length-1);
if(!globalResourceCalDAVList.collections[1].subscription)
var str2=str.substring(0, str.lastIndexOf('/'));
else
var str2='subscribed';
$('#ResourceCalDAVList').find('.resourceCalDAV_header[data-id^="'+str2+'"]').css('display','block');
$('#ResourceCalDAVList').find('.resourceCalDAV_header[data-id^="'+str2+'"] input').trigger('click');
}
if($('#ResourceCalDAVTODOList .resourceCalDAVTODO_item[data-id]:visible').length==0 && globalResourceCalDAVList.TodoCollections.length>1)
{
$('#ResourceCalDAVTODOList .resourceCalDAVTODO_item[data-id="'+globalResourceCalDAVList.TodoCollections[1].uid+'"]').css('display','block')
globalResourceCalDAVList.TodoCollections[1].makeLoaded=true;
var uidParts=globalResourceCalDAVList.TodoCollections[1].uid.match(rexo);
globalSettings.loadedtodocollections.push(uidParts[1]+uidParts[3]);
var str=globalResourceCalDAVList.TodoCollections[1].href.substring(0, globalResourceCalDAVList.TodoCollections[1].href.length-1);
if(!globalResourceCalDAVList.TodoCollections[1].subscription)
var str2=str.substring(0, str.lastIndexOf('/'));
else
var str2='subscribed';
$('#ResourceCalDAVTODOList').find('.resourceCalDAVTODO_header[data-id^="'+str2+'"]').css('display','block');
$('#ResourceCalDAVTODOList').find('.resourceCalDAVTODO_header[data-id^="'+str2+'"] input').trigger('click');
}
$('#ResourceCalDAVList .resourceCalDAV_header[data-id]').each(function(ind, elm){
var nextVisible = $(elm).nextUntil('.resourceCalDAV_header').filter(':visible');
if(nextVisible.hasClass('resourceCalDAV_header') || nextVisible.length==0)
{
$(elm).css('display','none');
}
});
$('#ResourceCalDAVTODOList .resourceCalDAVTODO_header[data-id]').each(function(ind, elm){
var nextVisible = $(elm).nextUntil('.resourceCalDAVTODO_header').filter(':visible');
if(nextVisible.hasClass('resourceCalDAVTODO_header') || nextVisible.length==0)
$(elm).css('display','none');
});
}
if(isAvaible('CardDavMATE'))
{
if($('#ResourceCardDAVList .resourceCardDAV_item:visible').length==0 && globalResourceCardDAVList.collections.length>1)
{
$('#ResourceCardDAVList .resourceCardDAV_item .resourceCardDAV[data-id="'+globalResourceCardDAVList.collections[1].uid+'"]').parent().css('display','block')
globalResourceCardDAVList.collections[1].makeLoaded=true;
var uidParts=globalResourceCardDAVList.collections[1].uid.match(rexo);
globalSettings.loadedaddressbookcollections.push(uidParts[1]+uidParts[3]);
}
}
selectActiveCalendar();
loadNextApplication(true);
}
if(isAvaible('CalDavZAP'))
{
setCalendarNumber(false);
selectActiveCalendar();
}
ifLoadCollections();
return false;
}
else if(indexR>=globalAccountSettings.length && !settingsLoaded)
{
console.log("Error: [netFindResource: 'Could not load resources']");
return false;
}
var re=new RegExp('^(https?://)([^/]+)','i');
var tmp=inputResource.href.match(re);
var uidBase=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2];
var settingsXML = '';
if(inputResource.href.indexOf(globalLoginUsername)!=-1 && inputResource.settingsAccount && (globalSettings.settingstype=='' || globalSettings.settingstype==null || (globalSettings.settingstype!='' && globalSettings.settingstype!=null && globalSettings.settingstype=='principal-URL')))
{
settingsXML = '<I:settings xmlns:I="http://inf-it.com/ns/dav/"/>';
}
var baseHref=tmp[1]+tmp[2];
$.ajax({
type: 'PROPFIND',
url: inputResource.href,
cache: false,
crossDomain: (typeof inputResource.crossDomain=='undefined' ? true : inputResource.crossDomain),
xhrFields: {
withCredentials: (typeof inputResource.withCredentials=='undefined' ? false : inputResource.withCredentials)
},
timeout: inputResource.timeOut,
error: function(objAJAXRequest, strError){
console.log("Error: [netFindResource: '"+uidBase+"'] code: '"+objAJAXRequest.status+"'"+(objAJAXRequest.status==0 ? ' - see http://www.inf-it.com/'+globalAppName.toLowerCase()+'/misc/readme_network.txt' : ''));
indexR++;
if(indexR==globalAccountSettings.length)
{
$('#MainLoader').fadeOut(1200);
}
netFindResource(globalAccountSettings[indexR], inputResourceIndex, forceLoad, indexR);
return false;
},
beforeSend: function(req) {
if(globalSettings.usejqueryauth!=true && inputResource.userAuth.userName!='' && inputResource.userAuth.userPassword!='')
req.setRequestHeader('Authorization', basicAuth(inputResource.userAuth.userName,inputResource.userAuth.userPassword));
req.setRequestHeader('X-client', globalXClientHeader);
req.setRequestHeader('Depth', '0');
if((isAvaible('CardDavMATE') && (!globalCardDAVInitLoad && !globalCardDAVResourceSync)) || (isAvaible('CalDavZAP') && (!globalCalDAVInitLoad && !globalCalDAVResourceSync))||(isAvaible('Projects') && isProjectsLoaded))
/* XXX - System display:none changes */
if(isAvaible('Settings') && $('#SystemSettings').css('visibility')=='visible' && $('.resourceSettings.resourceSettings_selected').attr('data-type')=='Password')
{
indexR++;
if(indexR==globalAccountSettings.length)
{
$('#MainLoader').fadeOut(1200);
}
netFindResource(globalAccountSettings[indexR], inputResourceIndex, forceLoad, indexR);
return false;
}
},
username: (globalSettings.usejqueryauth==true ? inputResource.userAuth.userName : null),
password: (globalSettings.usejqueryauth==true ? inputResource.userAuth.userPassword : null),
contentType: 'text/xml; charset=utf-8',
processData: true,
data: '<?xml version="1.0" encoding="utf-8"?><D:propfind xmlns:D="DAV:"><D:prop>'+settingsXML+'<D:current-user-privilege-set/><D:displayname/><D:resourcetype/><L:calendar-home-set xmlns:L="urn:ietf:params:xml:ns:caldav"/><R:addressbook-home-set xmlns:R="urn:ietf:params:xml:ns:carddav"/></D:prop></D:propfind>',
dataType: 'xml',
complete: function(xml, textStatus)
{
if(textStatus!='success')
return false;
if(!settingsLoaded && inputResource.href.indexOf(globalLoginUsername)!=-1 && inputResource.settingsAccount && (globalSettings.settingstype=='' || globalSettings.settingstype==null || (globalSettings.settingstype!='' && globalSettings.settingstype!=null && globalSettings.settingstype=='principal-URL')))
{
var settings=$(xml.responseXML).children().filterNsNode('multistatus').children().filterNsNode('response').children().filterNsNode('propstat').children().filterNsNode('prop').children().filterNsNode('settings').text();
if(settings!='')
{
if(!ignoreServerSettings)
loadSettings(settings);
else
{
loadSettings(JSON.stringify(globalSettings));
console.log('Ignoring server settings: '+'\n'+settings);
}
}
else
{
if(isAvaible('CalDavZAP'))
{
globalDefaultCalendarCollectionActiveAll = true;
globalDefaultTodoCalendarCollectionActiveAll = true;
globalDefaultTodoCalendarCollectionLoadAll = true;
globalDefaultCalendarCollectionLoadAll = true;
}
if(isAvaible('CardDavMATE'))
{
globalDefaultAddressbookCollectionActiveAll = true;
globalDefaultAddrCollectionLoadAll = true;
}
loadSettings(JSON.stringify(globalSettings));
}
}
var response=$(xml.responseXML).children().filterNsNode('multistatus').children().filterNsNode('response');
var addressbook_home=response.children().filterNsNode('propstat').children().filterNsNode('prop').children().filterNsNode('addressbook-home-set').children().filterNsNode('href').text();
if(addressbook_home=='') // addressbook-home-set has no 'href' value -> SabreDav
addressbook_home=response.children().filterNsNode('href').text().replace('/principals/users/caldav.php','/caldav.php');
if(addressbook_home.match(RegExp('^https?://','i'))!=null) // absolute URL returned
inputResource.abhref=addressbook_home;
else // relative URL returned
inputResource.abhref=baseHref+addressbook_home;
var calendar_home=response.children().filterNsNode('propstat').children().filterNsNode('prop').children().filterNsNode('calendar-home-set').children().filterNsNode('href').text();
if(calendar_home=='') // addressbook-home-set has no 'href' value -> SabreDav
calendar_home=response.children().filterNsNode('href').text().replace('/principals/users/caldav.php','/caldav.php');
if(calendar_home.match(RegExp('^https?://','i'))!=null) // absolute URL returned
inputResource.cahref=calendar_home;
else // relative URL returned
inputResource.cahref=baseHref+calendar_home;
if(isAvaible('CardDavMATE') && isAvaible('CalDavZAP'))
{
if(inputResource.abhref == inputResource.cahref)
netLoadResource(inputResource, inputResource.abhref, false, inputResourceIndex, forceLoad, indexR);
else
netLoadResource(inputResource, inputResource.abhref, true, inputResourceIndex, forceLoad, indexR);
}
else if(isAvaible('CardDavMATE'))
netLoadResource(inputResource, inputResource.abhref, false, inputResourceIndex, forceLoad, indexR);
else if(isAvaible('CalDavZAP'))
netLoadResource(inputResource, inputResource.cahref, false, inputResourceIndex, forceLoad, indexR);
}
});
}
function netLoadResource(inputResource, inputHref, hrefMode, inputResourceIndex, forceLoad, indexR)
{
if(!isAvaible('CardDavMATE') || !globalCardDAVInitLoad || (globalCardDAVInitLoad && typeof inputResource.addressbookNo=='undefined'))
inputResource.addressbookNo=0;
if(!isAvaible('CalDavZAP') || !globalCalDAVInitLoad || (globalCalDAVInitLoad && typeof inputResource.calendarNo=='undefined' && typeof inputResource.todoNo=='undefined'))
{
inputResource.calendarNo=0;
inputResource.todoNo=0;
}
var re=new RegExp('^(https?://)([^/]+)','i');
var tmp=inputResource.abhref.match(re);
var baseHref=tmp[1]+tmp[2];
var uidBase=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2];
var tmp=inputResource.href.match(RegExp('^(https?://)(.*)','i'));
var origUID=tmp[1]+inputResource.userAuth.userName+'@'+tmp[2];
if(typeof globalSubscribedCalendars!='undefined' && globalSubscribedCalendars!=null && typeof inputResource.calendars!='undefined' && inputResource.calendars!=null && inputResource.calendars.length>0)
{
var tmp1=inputResource.href.match(RegExp('^(https?://)(.*)', 'i'));
var origUID1=tmp1[1]+inputResource.userAuth.userName+'@'+tmp1[2];
var resultTimestamp=new Date().getTime();
for(var k=0; k<globalSubscribedCalendars.calendars.length; k++)
{
var color=globalSubscribedCalendars.calendars[k].color;
if(color=='')
{
var par=(uidBase+globalSubscribedCalendars.calendars[k].href).split('/');
var hash=hex_sha256(hex_sha256(par[par.length-3]+'/'+par[par.length-2]+'/'));
var hex=hash.substring(0, 6);
while(checkColorBrightness(hex)>=252)
hex=hex_sha256(hex_sha256(hash)).substring(0, 6);
color='#'+hex;
}
var syncRequired=true;
var uidPArts=(uidBase+'/'+globalSubscribedCalendars.calendars[k].href+'/').split('/');
if(globalSubscribedCalendars.calendars[k].typeList.indexOf('vevent')!=-1)
{
var uidParts=(uidBase+'/'+globalSubscribedCalendars.calendars[k].href+'/').match(RegExp('^(https?://)([^@/]+(?:@[^@/]+)?)@(.*)'));
var checkHref=uidParts[1]+uidParts[3];
if(!isHrefSet)
{
saveHref=uidBase+href;
isHrefSet=true;
}
if(!globalDefaultCalendarCollectionLoadAll)
var toBeLoad=(globalSettings.loadedcalendarcollections.indexOf(checkHref)!=-1);
else
{
if(globalCalDAVInitLoad)
globalSettings.loadedcalendarcollections.push(checkHref);
var toBeLoad=true;
}
globalResourceCalDAVList.insertResource({makeLoaded: toBeLoad, typeList: globalSubscribedCalendars.calendars[k].typeList, listType: 'vevent', syncRequired: syncRequired, ecolor: color, timestamp: resultTimestamp, uid: uidBase+'/'+globalSubscribedCalendars.calendars[k].href+'/', timeOut: inputResource.timeOut, displayvalue: globalSubscribedCalendars.calendars[k].displayName, userAuth: globalSubscribedCalendars.calendars[k].userAuth, resourceIndex: indexR, url: baseHref, accountUID: origUID1, href: globalSubscribedCalendars.calendars[k].href, hrefLabel: globalSubscribedCalendars.hrefLabel, showHeader: globalSubscribedCalendars.showHeader, permissions: {full: [], read_only: true}, crossDomain: inputResource.crossDomain, withCredentials: inputResource.withCredentials, interval: null, waitInterval: null, displayEventsArray: new Array(), pastUnloaded: '', fcSource: null, subscription: true, newlyAdded:toBeLoad, urlArray: new Array(), ignoreAlarms: globalSubscribedCalendars.calendars[k].ignoreAlarm, webdav_bind: false}, indexR, true);
if(inputResource!=undefined)
inputResource.calendarNo++;
syncRequired=false;
}
if(globalSubscribedCalendars.calendars[k].typeList.indexOf('vtodo')!=-1)
{
var uidParts=(uidBase+'/'+globalSubscribedCalendars.calendars[k].href+'/').match(RegExp('^(https?://)([^@/]+(?:@[^@/]+)?)@(.*)'));
var checkHref=uidParts[1]+uidParts[3];
if(!isHrefSet)
{
saveHref=uidBase+href;
isHrefSet=true;
}
if(!globalDefaultTodoCalendarCollectionLoadAll)
var toBeLoad=(globalSettings.loadedtodocollections.indexOf(checkHref)!=-1);
else
{
var toBeLoad=true;
if(globalCalDAVInitLoad)
globalSettings.loadedtodocollections.push(checkHref);
}
globalResourceCalDAVList.insertResource({makeLoaded: toBeLoad, typeList: globalSubscribedCalendars.calendars[k].typeList, listType:'vtodo', syncRequired: syncRequired, ecolor: color, timestamp: resultTimestamp, uid: uidBase+'/'+globalSubscribedCalendars.calendars[k].href+'/', timeOut: inputResource.timeOut, displayvalue: globalSubscribedCalendars.calendars[k].displayName, userAuth: globalSubscribedCalendars.calendars[k].userAuth, resourceIndex: indexR, url: baseHref, accountUID: origUID1, href: globalSubscribedCalendars.calendars[k].href, hrefLabel: globalSubscribedCalendars.hrefLabel, showHeader: globalSubscribedCalendars.showHeader, permissions: {full: [], read_only: true}, crossDomain: inputResource.crossDomain, withCredentials: inputResource.withCredentials, interval: null, waitInterval: null, displayEventsArray: new Array(), pastUnloaded: '', fcSource: null, subscription: true, newlyAdded: toBeLoad, urlArray: new Array(), ignoreAlarms: globalSubscribedCalendars.calendars[k].ignoreAlarm, webdav_bind: false}, indexR, false);
if(inputResource!=undefined)
inputResource.todoNo++;
}
}
if(typeof globalResourceErrorCounter!='undefined' && globalResourceErrorCounter!=null)
{
globalResourceErrorCounter--;
if((globalResourceErrorCounter==0) && ($('.r_error').length==0))
$('#SystemCalDavZAP .fc-header-center').removeClass('r_error_all');
}
//recursive call for resource loading
indexR++;
netFindResource(globalAccountSettings[indexR], inputResourceIndex, forceLoad, indexR);
return true;
}
var settingsXML='';
if(inputResource.href.indexOf(globalLoginUsername)!=-1 && inputResource.settingsAccount && globalSettings.settingstype!='' && globalSettings.settingstype!=null)
if((globalSettings.settingstype=='addressbook-home-set' && inputResource.abhref==inputHref) || (globalSettings.settingstype=='calendar-home-set' && inputResource.cahref==inputHref))
settingsXML='<I:settings xmlns:I="http://inf-it.com/ns/dav/"/>';
$.ajax({
type: 'PROPFIND',
url: inputHref,
cache: false,
crossDomain: (typeof inputResource.crossDomain=='undefined' ? true : inputResource.crossDomain),
xhrFields: