-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
1993 lines (1809 loc) · 89.6 KB
/
main.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
/*
CardDavMATE - the open source CardDAV Web Client
Copyright (C) 2011-2015
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/>.
*/
var globalAddressbookList=new AddressbookList();
var globalResourceCardDAVList=new ResourceCardDAVList();
var globalQs=null;
var globalRefABList=null;
var globalRefABListTable=null;
var globalRefAbListTableHeader=null;
var globalRefABListTableCols=null;
var globalRefABListInnerTableCols=null;
var globalRefAddContact=null;
var globalRefVcardEditor=null; // editor reference stored after each editor cleanup
var globalOrigCardDAVListTemplate=null; // template for clean resource list
var globalOrigABListHeader=null; // template for clean addressbook header
var globalOrigABListItem=null; // template for clean addressbook item
var globalOrigVcardTemplate=null; // template for clean editor object
var globalTranslCardDAVListTemplate=null; // template for translated resource list
var globalTranslCardDAVListHeader=null; // template for translated resource header
var globalTranslCardDAVListItem=null; // template for translated resource item
var globalTranslVcardTemplate=null; // template for translated editor object
var globalCardDAVInitLoad=true;
var globalCardDAVResourceSync=false;
var globalCardDAVCollectionSync=false;
var isCardDAVLoaded=false;
var isCardDAVAvaible=true;
var globalDefaultAddressbookCollectionActiveAll=false;
var globalDefaultAddrCollectionLoadAll=false;
var globalAddressbookNumber=0;
var globalAddressbookNumberCount=0;
var globalABEditorCounter=new Object();
var globalAddressElementOldData=new Object();
var globalAddressbookCollectionsLoading=false;
var globalDisableAnimationMessageHiding='';
if(typeof globalContactPhotoScaleFactor==='undefined')
var globalContactPhotoScaleFactor=1.5;
var globalFixedContactDataColumnsCount = 1;
var globalContactDataColumnDefs = {
'CATEGORIES': {
'property': 'cats',
'minWidth': 90
},
'COMPANY': {
'property': 'company',
'minWidth': 135
},
'DEPARTMENT': {
'property': 'department',
'minWidth': 90
},
'LASTNAME': {
'property': 'lastname',
'minWidth': 90
},
'FIRSTNAME': {
'property': 'firstname',
'minWidth': 45
},
'MIDDLENAME': {
'property': 'middlename',
'minWidth': 45
},
'PREFIX': {
'property': 'prefix',
'minWidth': 27
},
'SUFFIX': {
'property': 'sufix',
'minWidth': 27
},
'NICKNAME': {
'property': 'nickname',
'minWidth': 45
},
'PHONETICLASTNAME': {
'property': 'phoneticLastName',
'minWidth': 90
},
'PHONETICFIRSTNAME': {
'property': 'phoneticFirstName',
'minWidth': 45
},
'BIRTHDAY': {
'property': 'birthday',
'minWidth': 90
},
'JOBTITLE': {
'property': 'title',
'minWidth': 90
},
'NOTETEXT': {
'property': 'note',
'minWidth': 180
},
'ADDRESS': {
'property': 'address',
'filterProperities': {
'TYPE': 'type'
},
'minWidth': 180
},
'PHONE': {
'property': 'phone',
'filterProperities': {
'TYPE': 'type'
},
'minWidth': 90
},
'EMAIL': {
'property': 'email',
'filterProperities': {
'TYPE': 'type'
},
'minWidth': 135
},
'URL': {
'property': 'url',
'filterProperities': {
'TYPE': 'type'
},
'minWidth': 135
},
'DATES': {
'property': 'date',
'filterProperities': {
'TYPE': 'type'
},
'minWidth': 90
},
'RELATED': {
'property': 'related',
'filterProperities': {
'TYPE': 'type'
},
'minWidth': 45
},
'PROFILE': {
'property': 'social',
'filterProperities': {
'TYPE': 'type'
},
'minWidth': 90
},
'IM': {
'property': 'impp',
'filterProperities': {
'TYPE': 'type',
'SERVICE-TYPE': 'serviceType'
},
'minWidth': 90
}
};
globalContactDataColumnLabelVars = {
'Name': 'txtName',
'FirstName': 'pholderGiven',
'LastName': 'pholderFamily',
'MiddleName': 'pholderMiddle',
'NickName': 'pholderNickname',
'Prefix': 'pholderPrefix',
'Suffix': 'pholderSuffix',
'BirthDay': 'pholderBday',
'PhoneticLastName': 'pholderPhFamily',
'PhoneticFirstName': 'pholderPhGiven',
'JobTitle': 'pholderTitle',
'Company': 'pholderOrg',
'Department': 'pholderDepartment',
'Categories': 'txtCategories',
'NoteText': 'pholderNoteVal',
'Address': 'txtAddress',
'AddressWork': 'txtAddressWork',
'AddressHome': 'txtAddressHome',
'AddressOther': 'txtAddressOther',
'Phone': 'txtPhone',
'PhoneWork': 'txtPhoneWork',
'PhoneHome': 'txtPhoneHome',
'PhoneCell': 'txtPhoneCell',
'PhoneMain': 'txtPhoneMain',
'PhonePager': 'txtPhonePager',
'PhoneFax': 'txtPhoneFax',
'PhoneIphone': 'txtPhoneIphone',
'PhoneOther': 'txtPhoneOther',
'Email': 'txtEmail',
'EmailWork': 'txtEmailWork',
'EmailHome': 'txtEmailHome',
'EmailMobileme': 'txtEmailMobileme',
'EmailOther': 'txtEmailOther',
'URL': 'txtUrl',
'URLWork': 'txtUrlWork',
'URLHome': 'txtUrlHome',
'URLHomepage': 'txtUrlHomepage',
'URLOther': 'txtUrlOther',
'Dates': 'txtDates',
'DatesAnniversary': 'txtDatesAnniversary',
'DatesOther': 'txtDatesOther',
'Related': 'txtRelated',
'RelatedManager': 'txtRelatedManager',
'RelatedAssistant': 'txtRelatedAssistant',
'RelatedFather': 'txtRelatedFather',
'RelatedMother': 'txtRelatedMother',
'RelatedParent': 'txtRelatedParent',
'RelatedBrother': 'txtRelatedBrother',
'RelatedSister': 'txtRelatedSister',
'RelatedChild': 'txtRelatedChild',
'RelatedFriend': 'txtRelatedFriend',
'RelatedSpouse': 'txtRelatedSpouse',
'RelatedPartner': 'txtRelatedPartner',
'RelatedOther': 'txtRelatedOther',
'Profile': 'txtProfile',
'ProfileTwitter': 'txtProfileTwitter',
'ProfileFacebook': 'txtProfileFacebook',
'ProfileFlickr': 'txtProfileFlickr',
'ProfileLinkedin': 'txtProfileLinkedin',
'ProfileMyspace': 'txtProfileMyspace',
'ProfileSinaweibo': 'txtProfileSinaweibo',
'IM': 'txtIm',
'IMWork': 'txtImWork',
'IMHome': 'txtImHome',
'IMMobileme': 'txtImMobileme',
'IMOther': 'txtImOther',
'IMAim': 'txtImProtAim',
'IMIcq': 'txtImProtIcq',
'IMIrc': 'txtImProtIrc',
'IMJabber': 'txtImProtJabber',
'IMMsn': 'txtImProtMsn',
'IMYahoo': 'txtImProtYahoo',
'IMFacebook': 'txtImProtFacebook',
'IMGadugadu': 'txtImProtGadugadu',
'IMGoogletalk': 'txtImProtGoogletalk',
'IMQq': 'txtImProtQq',
'IMSkype': 'txtImProtSkype'
};
var globalSettings={
version: {value: (typeof globalSettingsVersion!='undefined' && globalSettingsVersion!=null) ? globalSettingsVersion : 1, locked:false},
resourcealphabetsorting: {value: (typeof globalResourceAlphabetSorting!='undefined' && globalResourceAlphabetSorting!=null) ? globalResourceAlphabetSorting : true, locked:false},
usejqueryauth: {value: (typeof globalUseJqueryAuth!='undefined' && globalUseJqueryAuth!=null) ? globalUseJqueryAuth : false, locked:false},
settingstype: {value: (typeof globalSettingsType!='undefined' && globalSettingsType!=null && globalSettingsType!='') ? globalSettingsType : 'principal-URL', locked:false},
defaultactiveapp: {value: (typeof globalDefaultActiveApp!='undefined' && globalDefaultActiveApp!=null && globalDefaultActiveApp!='') ? globalDefaultActiveApp : null, locked:false},
islastdefaultactiveapp: {value: false, locked:false},
datepickerfirstdayofweek: {value: (typeof globalDatepickerFirstDayOfWeek!='undefined' && globalDatepickerFirstDayOfWeek!=null) ? globalDatepickerFirstDayOfWeek : 1, locked:false},
syncresourcesinterval: {value: (typeof globalSyncResourcesInterval!='undefined' && globalSyncResourcesInterval!=null) ? globalSyncResourcesInterval :300000, locked:false},
datepickerformat: {value: (typeof globalDatepickerFormat!='undefined' && globalDatepickerFormat!=null && globalDatepickerFormat!='') ? globalDatepickerFormat : localization[globalInterfaceLanguage]._default_datepicker_format_, locked:false},
backgroundsync: {value: (typeof globalBackgroundSync!='undefined' && globalBackgroundSync!=null) ? globalBackgroundSync : true, locked:false},
enablekbnavigation: {value: (typeof globalEnableKbNavigation!='undefined' && globalEnableKbNavigation!=null) ? globalEnableKbNavigation : true, locked:false},
rewritetimezonecomponent: {value: (typeof globalRewriteTimezoneComponent!='undefined' && globalRewriteTimezoneComponent!=null) ? globalRewriteTimezoneComponent : true, locked:false},
removeunknowntimezone: {value: (typeof globalRemoveUnknownTimezone!='undefined' && globalRemoveUnknownTimezone!=null) ? globalRemoveUnknownTimezone : false, locked:false},
mozillasupport: {value: (typeof globalMozillaSupport!='undefined' && globalMozillaSupport!=null) ? globalMozillaSupport : false, locked:false},
appleremindersmode: {value: (typeof globalAppleRemindersMode!='undefined' && globalAppleRemindersMode!=null) ? globalAppleRemindersMode : false, locked:false},
titleformatmonth: {value: localization[globalInterfaceLanguage]._default_title_format_month_, locked:false},
titleformatweek: {value: localization[globalInterfaceLanguage]._default_title_format_week_, locked:false},
titleformatday: {value: localization[globalInterfaceLanguage]._default_title_format_day_, locked:false},
titleformattable: {value: localization[globalInterfaceLanguage]._default_title_format_table_, locked:false},
columnformatagenda: {value: localization[globalInterfaceLanguage]._default_column_format_agenda_, locked:false},
activecalendarcollections: {value: (typeof globalActiveCalendarCollections!='undefined' && globalActiveCalendarCollections!=null) ? globalActiveCalendarCollections : new Array(), locked:false},
activetodocollections: {value: (typeof globalActiveTodoCollections!='undefined' && globalActiveTodoCollections!=null) ? globalActiveTodoCollections : new Array(), locked:false},
loadedcalendarcollections: {value: (typeof globalLoadedCalendarCollections!='undefined' && globalLoadedCalendarCollections!=null) ? globalLoadedCalendarCollections : new Array(), locked:false},
loadedtodocollections: {value: (typeof globalLoadedTodoCollections!='undefined' && globalLoadedTodoCollections!=null) ? globalLoadedTodoCollections : new Array(), locked:false},
todolistfilterselected: {value: (typeof globalTodoListFilterSelected!='undefined' && globalTodoListFilterSelected!=null && globalTodoListFilterSelected!='') ? globalTodoListFilterSelected : ['filterAction', 'filterProgress'], locked:false},
activeview: {value: (typeof globalActiveView!='undefined' && globalActiveView!=null && globalActiveView!='') ? globalActiveView : 'multiWeek', locked:false},
islastactiveview: {value: true, locked:false},
calendarselected: {value: (typeof globalCalendarSelected!='undefined' && globalCalendarSelected!=null && globalCalendarSelected!='') ? globalCalendarSelected : '', locked:false},
todocalendarselected: {value: (typeof globalTodoCalendarSelected!='undefined' && globalTodoCalendarSelected!=null && globalTodoCalendarSelected!='') ? globalTodoCalendarSelected : '', locked:false},
timezone: {value: (typeof globalTimeZone!='undefined' && globalTimeZone!=null && globalTimeZone!='') ? globalTimeZone : 'local', locked:false},
islasttimezone: {value: true, locked:false},
openformmode: {value: (typeof globalOpenFormMode!='undefined' && globalOpenFormMode!=null && globalOpenFormMode!='') ? globalOpenFormMode : 'double', locked:false},
calendarstartofbusiness: {value: (typeof globalCalendarStartOfBusiness!='undefined' && globalCalendarStartOfBusiness!=null) ? globalCalendarStartOfBusiness : 8, locked:false},
calendarendofbusiness: {value: (typeof globalCalendarEndOfBusiness!='undefined' && globalCalendarEndOfBusiness!=null) ? globalCalendarEndOfBusiness : 17, locked:false},
defaulteventduration: {value: (typeof globalDefaultEventDuration!='undefined' && globalDefaultEventDuration!=null && globalDefaultEventDuration>=0) ? globalDefaultEventDuration : null, locked:false},
ampmformat: {value: (typeof globalAMPMFormat!='undefined' && globalAMPMFormat!=null) ? globalAMPMFormat : localization[globalInterfaceLanguage]._default_AMPM_format_, locked:false},
timeformatagenda: {value: (typeof globalTimeFormatAgenda!='undefined' && globalTimeFormatAgenda!=null && globalTimeFormatAgenda!='') ? globalTimeFormatAgenda : null, locked:false},
timeformatbasic: {value: (typeof globalTimeFormatBasic!='undefined' && globalTimeFormatBasic!=null && globalTimeFormatBasic!='') ? globalTimeFormatBasic : null, locked:false},
displayhiddenevents: {value: (typeof globalDisplayHiddenEvents!='undefined' && globalDisplayHiddenEvents!=null) ? globalDisplayHiddenEvents : false, locked:false},
timezonesupport: {value: (typeof globalTimeZoneSupport!='undefined' && globalTimeZoneSupport!=null) ? globalTimeZoneSupport : true, locked:false},
timezonesenabled: {value: (typeof globalTimeZonesEnabled!='undefined' && globalTimeZonesEnabled!=null && globalTimeZonesEnabled!='') ? globalTimeZonesEnabled : [], locked:false},
showhiddenalarms: {value: (typeof globalShowHiddenAlarms!='undefined' && globalShowHiddenAlarms!=null) ? globalShowHiddenAlarms : false, locked:false},
ignorecompletedorcancelledalarms: {value: (typeof globalIgnoreCompletedOrCancelledAlarms!='undefined' && globalIgnoreCompletedOrCancelledAlarms!=null) ? globalIgnoreCompletedOrCancelledAlarms : true, locked:false},
weekenddays: {value: (typeof globalWeekendDays!='undefined' && globalWeekendDays!=null && globalWeekendDays!='') ? globalWeekendDays : [0, 6], locked:false},
eventstartpastlimit: {value: (typeof globalEventStartPastLimit!='undefined' && globalEventStartPastLimit!=null) ? globalEventStartPastLimit : 3, locked:false},
todopastlimit: {value: (typeof globalTodoPastLimit!='undefined' && globalTodoPastLimit!=null) ? globalTodoPastLimit : 3, locked:false},
eventstartfuturelimit: {value: (typeof globalEventStartFutureLimit!='undefined' && globalEventStartFutureLimit!=null) ? globalEventStartFutureLimit : 3, locked:false},
compatibility: {value: (typeof globalCompatibility!='undefined' && globalCompatibility!=null && globalCompatibility!='') ? globalCompatibility : {anniversaryOutputFormat: ['apple']}, locked:false},
contactstorefn: {value: (typeof globalContactStoreFN!='undefined' && globalContactStoreFN!=null && globalContactStoreFN!='') ? globalContactStoreFN : ['prefix',' last',' middle',' first',' suffix'], locked:false},
urihandlertel: {value: (typeof globalUriHandlerTel!='undefined' && globalUriHandlerTel!=null && globalUriHandlerTel!='') ? globalUriHandlerTel : 'tel:', locked:false},
urihandleremail: {value: (typeof globalUriHandlerEmail!='undefined' && globalUriHandlerEmail!=null && globalUriHandlerEmail!='') ? globalUriHandlerEmail : 'mailto:', locked:false},
urihandlerurl: {value: (typeof globalUriHandlerUrl!='undefined' && globalUriHandlerUrl!=null && globalUriHandlerUrl!='') ? globalUriHandlerUrl : 'http://', locked:false},
urihandlerprofile: {value: (typeof globalUriHandlerProfile!='undefined' && globalUriHandlerProfile!=null && globalUriHandlerProfile!='') ? globalUriHandlerProfile : {'twitter': 'http://twitter.com/%u', 'facebook': 'http://www.facebook.com/%u', 'flickr': 'http://www.flickr.com/photos/%u', 'linkedin': 'http://www.linkedin.com/in/%u', 'myspace': 'http://www.myspace.com/%u', 'sinaweibo': 'http://weibo.com/n/%u'}, locked:false},
addresscountryequivalence: {value: (typeof globalAddressCountryEquivalence!='undefined' && globalAddressCountryEquivalence!=null && globalAddressCountryEquivalence!='') ? globalAddressCountryEquivalence : [{country: 'de', regex: '^\\W*Deutschland\\W*$'}, {country: 'sk', regex: '^\\W*Slovensko\\W*$'}], locked:false},
addressbookselected: {value: (typeof globalAddressbookSelected!='undefined' && globalAddressbookSelected!=null && globalAddressbookSelected!='') ? globalAddressbookSelected : '', locked:false},
collectiondisplay: {value: (typeof globalCollectionDisplay!='undefined' && globalCollectionDisplay!=null && globalCollectionDisplay!='') ? globalCollectionDisplay : (
(typeof globalGroupContactsByCompanies!='undefined' && globalGroupContactsByCompanies) ?
[{label: '{Name}', value: {company: ['{Company}', ' [{Department}]'], personal: ['{LastName}', ' {MiddleName}', ' {FirstName}']}}, {label: '{JobTitle}', value: ['{JobTitle}']}, {label: '{Email}', value: ['{Email[:0]}']}, {label: '{Phone} 1', value: ['{Phone[:0]}']}, {label: '{Phone} 2', value: ['{Phone[:1]}']}, {label: '{NoteText}', value: ['{NoteText}']}] :
[{label: '{Name}', value: ['{LastName}', ' {MiddleName}', ' {FirstName}']}, {label: '{Company} [{Department}]', value: ['{Company}', ' [{Department}]']}, {label: '{JobTitle}', value: ['{JobTitle}']}, {label: '{Email}', value: ['{Email[:0]}']}, {label: '{Phone} 1', value: ['{Phone[:0]}']}, {label: '{Phone} 2', value: ['{Phone[:1]}']}, {label: '{NoteText}', value: ['{NoteText}']}]
), locked:false},
collectionsort: {value: (typeof globalCollectionSort!='undefined' && globalCollectionSort!=null && globalCollectionSort!='') ? globalCollectionSort : '', locked:false},
defaultaddresscountry: {value: (typeof globalDefaultAddressCountry!='undefined' && globalDefaultAddressCountry!=null && globalDefaultAddressCountry!='') ? globalDefaultAddressCountry :'us', locked:false},
addresscountryfavorites: {value: (typeof globalAddressCountryFavorites!='undefined' && globalAddressCountryFavorites!=null && globalAddressCountryFavorites!='') ? globalAddressCountryFavorites :[], locked:false},
activeaddressbookcollections: {value: (typeof globalActiveAddressbookCollections!='undefined' && globalActiveAddressbookCollections!=null) ? globalActiveAddressbookCollections : new Array(), locked:false},
loadedaddressbookcollections: {value: (typeof globalLoadedAddressbookCollections!='undefined' && globalLoadedAddressbookCollections!=null) ? globalLoadedAddressbookCollections : new Array(), locked:false}
};
function resetSettings()
{
globalSettings={
version: {value: (typeof globalSettingsVersion!='undefined' && globalSettingsVersion!=null) ? globalSettingsVersion : 1, locked:false},
resourcealphabetsorting: {value: (typeof globalResourceAlphabetSorting!='undefined' && globalResourceAlphabetSorting!=null) ? globalResourceAlphabetSorting : true, locked:false},
usejqueryauth: {value: (typeof globalUseJqueryAuth!='undefined' && globalUseJqueryAuth!=null) ? globalUseJqueryAuth : false, locked:false},
settingstype: {value: (typeof globalSettingsType!='undefined' && globalSettingsType!=null && globalSettingsType!='') ? globalSettingsType : 'principal-URL', locked:false},
defaultactiveapp: {value: (typeof globalDefaultActiveApp!='undefined' && globalDefaultActiveApp!=null && globalDefaultActiveApp!='') ? globalDefaultActiveApp : null, locked:false},
islastdefaultactiveapp: {value: false, locked:false},
datepickerfirstdayofweek: {value: (typeof globalDatepickerFirstDayOfWeek!='undefined' && globalDatepickerFirstDayOfWeek!=null) ? globalDatepickerFirstDayOfWeek : 1, locked:false},
syncresourcesinterval: {value: (typeof globalSyncResourcesInterval!='undefined' && globalSyncResourcesInterval!=null) ? globalSyncResourcesInterval :300000, locked:false},
datepickerformat: {value: (typeof globalDatepickerFormat!='undefined' && globalDatepickerFormat!=null && globalDatepickerFormat!='') ? globalDatepickerFormat : localization[globalInterfaceLanguage]._default_datepicker_format_, locked:false},
backgroundsync: {value: (typeof globalBackgroundSync!='undefined' && globalBackgroundSync!=null) ? globalBackgroundSync : true, locked:false},
enablekbnavigation: {value: (typeof globalEnableKbNavigation!='undefined' && globalEnableKbNavigation!=null) ? globalEnableKbNavigation : true, locked:false},
rewritetimezonecomponent: {value: (typeof globalRewriteTimezoneComponent!='undefined' && globalRewriteTimezoneComponent!=null) ? globalRewriteTimezoneComponent : true, locked:false},
removeunknowntimezone: {value: (typeof globalRemoveUnknownTimezone!='undefined' && globalRemoveUnknownTimezone!=null) ? globalRemoveUnknownTimezone : false, locked:false},
mozillasupport: {value: (typeof globalMozillaSupport!='undefined' && globalMozillaSupport!=null) ? globalMozillaSupport : false, locked:false},
appleremindersmode: {value: (typeof globalAppleRemindersMode!='undefined' && globalAppleRemindersMode!=null) ? globalAppleRemindersMode : false, locked:false},
titleformatmonth: {value: localization[globalInterfaceLanguage]._default_title_format_month_, locked:false},
titleformatweek: {value: localization[globalInterfaceLanguage]._default_title_format_week_, locked:false},
titleformatday: {value: localization[globalInterfaceLanguage]._default_title_format_day_, locked:false},
titleformattable: {value: localization[globalInterfaceLanguage]._default_title_format_table_, locked:false},
columnformatagenda: {value: localization[globalInterfaceLanguage]._default_column_format_agenda_, locked:false},
activecalendarcollections: {value: (typeof globalActiveCalendarCollections!='undefined' && globalActiveCalendarCollections!=null) ? globalActiveCalendarCollections : new Array(), locked:false},
activetodocollections: {value: (typeof globalActiveTodoCollections!='undefined' && globalActiveTodoCollections!=null) ? globalActiveTodoCollections : new Array(), locked:false},
loadedcalendarcollections: {value: (typeof globalLoadedCalendarCollections!='undefined' && globalLoadedCalendarCollections!=null) ? globalLoadedCalendarCollections : new Array(), locked:false},
loadedtodocollections: {value: (typeof globalLoadedTodoCollections!='undefined' && globalLoadedTodoCollections!=null) ? globalLoadedTodoCollections : new Array(), locked:false},
todolistfilterselected: {value: (typeof globalTodoListFilterSelected!='undefined' && globalTodoListFilterSelected!=null && globalTodoListFilterSelected!='') ? globalTodoListFilterSelected : ['filterAction', 'filterProgress'], locked:false},
activeview: {value: (typeof globalActiveView!='undefined' && globalActiveView!=null && globalActiveView!='') ? globalActiveView : 'multiWeek', locked:false},
islastactiveview: {value: true, lockedlocked:false},
calendarselected: {value: (typeof globalCalendarSelected!='undefined' && globalCalendarSelected!=null && globalCalendarSelected!='') ? globalCalendarSelected : '', locked:false},
todocalendarselected: {value: (typeof globalTodoCalendarSelected!='undefined' && globalTodoCalendarSelected!=null && globalTodoCalendarSelected!='') ? globalTodoCalendarSelected : '', locked:false},
timezone: {value: (typeof globalTimeZone!='undefined' && globalTimeZone!=null && globalTimeZone!='') ? globalTimeZone : 'local', locked:false},
islasttimezone: {value: true, locked:false},
openformmode: {value: (typeof globalOpenFormMode!='undefined' && globalOpenFormMode!=null && globalOpenFormMode!='') ? globalOpenFormMode : 'double', locked:false},
calendarstartofbusiness: {value: (typeof globalCalendarStartOfBusiness!='undefined' && globalCalendarStartOfBusiness!=null) ? globalCalendarStartOfBusiness : 8, locked:false},
calendarendofbusiness: {value: (typeof globalCalendarEndOfBusiness!='undefined' && globalCalendarEndOfBusiness!=null) ? globalCalendarEndOfBusiness : 17, locked:false},
defaulteventduration: {value: (typeof globalDefaultEventDuration!='undefined' && globalDefaultEventDuration!=null && globalDefaultEventDuration>=0) ? globalDefaultEventDuration : null, locked:false},
ampmformat: {value: (typeof globalAMPMFormat!='undefined' && globalAMPMFormat!=null) ? globalAMPMFormat : localization[globalInterfaceLanguage]._default_AMPM_format_, locked:false},
timeformatagenda: {value: (typeof globalTimeFormatAgenda!='undefined' && globalTimeFormatAgenda!=null && globalTimeFormatAgenda!='') ? globalTimeFormatAgenda : null, locked:false},
timeformatbasic: {value: (typeof globalTimeFormatBasic!='undefined' && globalTimeFormatBasic!=null && globalTimeFormatBasic!='') ? globalTimeFormatBasic : null, locked:false},
displayhiddenevents: {value: (typeof globalDisplayHiddenEvents!='undefined' && globalDisplayHiddenEvents!=null) ? globalDisplayHiddenEvents : false, locked:false},
timezonesupport: {value: (typeof globalTimeZoneSupport!='undefined' && globalTimeZoneSupport!=null) ? globalTimeZoneSupport : true, locked:false},
timezonesenabled: {value: (typeof globalTimeZonesEnabled!='undefined' && globalTimeZonesEnabled!=null && globalTimeZonesEnabled!='') ? globalTimeZonesEnabled : [], locked:false},
showhiddenalarms: {value: (typeof globalShowHiddenAlarms!='undefined' && globalShowHiddenAlarms!=null) ? globalShowHiddenAlarms : false, locked:false},
ignorecompletedorcancelledalarms: {value: (typeof globalIgnoreCompletedOrCancelledAlarms!='undefined' && globalIgnoreCompletedOrCancelledAlarms!=null) ? globalIgnoreCompletedOrCancelledAlarms : true, locked:false},
weekenddays: {value: (typeof globalWeekendDays!='undefined' && globalWeekendDays!=null && globalWeekendDays!='') ? globalWeekendDays : [0, 6], locked:false},
eventstartpastlimit: {value: (typeof globalEventStartPastLimit!='undefined' && globalEventStartPastLimit!=null) ? globalEventStartPastLimit : 3, locked:false},
todopastlimit: {value: (typeof globalTodoPastLimit!='undefined' && globalTodoPastLimit!=null) ? globalTodoPastLimit : 3, locked:false},
eventstartfuturelimit: {value: (typeof globalEventStartFutureLimit!='undefined' && globalEventStartFutureLimit!=null) ? globalEventStartFutureLimit : 3, locked:false},
compatibility: {value: (typeof globalCompatibility!='undefined' && globalCompatibility!=null && globalCompatibility!='') ? globalCompatibility : {anniversaryOutputFormat: ['apple']}, locked:false},
contactstorefn: {value: (typeof globalContactStoreFN!='undefined' && globalContactStoreFN!=null && globalContactStoreFN!='') ? globalContactStoreFN : ['prefix',' last',' middle',' first',' suffix'], locked:false},
urihandlertel: {value: (typeof globalUriHandlerTel!='undefined' && globalUriHandlerTel!=null && globalUriHandlerTel!='') ? globalUriHandlerTel : 'tel:', locked:false},
urihandleremail: {value: (typeof globalUriHandlerEmail!='undefined' && globalUriHandlerEmail!=null && globalUriHandlerEmail!='') ? globalUriHandlerEmail : 'mailto:', locked:false},
urihandlerurl: {value: (typeof globalUriHandlerUrl!='undefined' && globalUriHandlerUrl!=null && globalUriHandlerUrl!='') ? globalUriHandlerUrl : 'http://', locked:false},
urihandlerprofile: {value: (typeof globalUriHandlerProfile!='undefined' && globalUriHandlerProfile!=null && globalUriHandlerProfile!='') ? globalUriHandlerProfile : {'twitter': 'http://twitter.com/%u', 'facebook': 'http://www.facebook.com/%u', 'flickr': 'http://www.flickr.com/photos/%u', 'linkedin': 'http://www.linkedin.com/in/%u', 'myspace': 'http://www.myspace.com/%u', 'sinaweibo': 'http://weibo.com/n/%u'}, locked:false},
addresscountryequivalence: {value: (typeof globalAddressCountryEquivalence!='undefined' && globalAddressCountryEquivalence!=null && globalAddressCountryEquivalence!='') ? globalAddressCountryEquivalence : [{country: 'de', regex: '^\\W*Deutschland\\W*$'}, {country: 'sk', regex: '^\\W*Slovensko\\W*$'}], locked:false},
addressbookselected: {value: (typeof globalAddressbookSelected!='undefined' && globalAddressbookSelected!=null && globalAddressbookSelected!='') ? globalAddressbookSelected : '', locked:false},
collectiondisplay: {value: (typeof globalCollectionDisplay!='undefined' && globalCollectionDisplay!=null && globalCollectionDisplay!='') ? globalCollectionDisplay : (
(typeof globalGroupContactsByCompanies!='undefined' && globalGroupContactsByCompanies) ?
[{label: '{Name}', value: {company: ['{Company}', ' [{Department}]'], personal: ['{LastName}', ' {MiddleName}', ' {FirstName}']}}, {label: '{JobTitle}', value: ['{JobTitle}']}, {label: '{Email}', value: ['{Email[:0]}']}, {label: '{Phone} 1', value: ['{Phone[:0]}']}, {label: '{Phone} 2', value: ['{Phone[:1]}']}, {label: '{NoteText}', value: ['{NoteText}']}] :
[{label: '{Name}', value: ['{LastName}', ' {MiddleName}', ' {FirstName}']}, {label: '{Company} [{Department}]', value: ['{Company}', ' [{Department}]']}, {label: '{JobTitle}', value: ['{JobTitle}']}, {label: '{Email}', value: ['{Email[:0]}']}, {label: '{Phone} 1', value: ['{Phone[:0]}']}, {label: '{Phone} 2', value: ['{Phone[:1]}']}, {label: '{NoteText}', value: ['{NoteText}']}]
), locked:false},
collectionsort: {value: (typeof globalCollectionSort!='undefined' && globalCollectionSort!=null && globalCollectionSort!='') ? globalCollectionSort : '', locked:false},
defaultaddresscountry: {value: (typeof globalDefaultAddressCountry!='undefined' && globalDefaultAddressCountry!=null && globalDefaultAddressCountry!='') ? globalDefaultAddressCountry :'us', locked:false},
addresscountryfavorites: {value: (typeof globalAddressCountryFavorites!='undefined' && globalAddressCountryFavorites!=null && globalAddressCountryFavorites!='') ? globalAddressCountryFavorites :[], locked:false},
activeaddressbookcollections: {value: (typeof globalActiveAddressbookCollections!='undefined' && globalActiveAddressbookCollections!=null) ? globalActiveAddressbookCollections : new Array(), locked:false},
loadedaddressbookcollections: {value: (typeof globalLoadedAddressbookCollections!='undefined' && globalLoadedAddressbookCollections!=null) ? globalLoadedAddressbookCollections : new Array(), locked:false}
};
}
function transformToServer(inSettings)
{
var serverSettings={};
for(var prop in inSettings)
{
serverSettings[prop]=inSettings[prop].value;
}
return serverSettings;
}
var globalWindowFocus=true;
var globalLoginUsername='';
var globalLoginPassword='';
var isUserLogged=false;
var isDelegationLoaded=false;
var globalActiveApp='';
var globalAvailableAppsArray=new Array();
var globalEnableAppSwitch=true;
var globalAppName='CardDavMATE';
var globalVersion='0.13.1';
var globalBuildNo=1442928605;
var globalXMLCache=null;
var globalVersionCheckURL=(location.protocol=='file:' ? 'http:' : location.protocol)+'//www.inf-it.com/versioncheck/'+globalAppName+'/?v='+globalVersion;
var globalXClientHeader=globalAppName+' '+globalVersion+' (Inf-IT CardDAV Web Client)';
var globalResourceNumberCount=0;
var globalResourceNumber=0;
var globalResourceIntervalID=null;
var globalFirstLoadNextApp=false;
var globalObjectLoading=false;
var settingsLoaded=false;
var globalKBNavigationPaddingRate=0.2;
var globalParallelAjaxCallCardDAVEnabled=true;
var globalParallelAjaxCallCalDAVEnabled=true;
var globalCacheUpdateInterval=null;
var isIntegrated=false;
var SVG_select='<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" x="0px" y="0px" width="19px" height="19px" viewBox="0 0 19 19" overflow="visible" enable-background="new 0 0 19 19" xml:space="preserve"><defs></defs><rect x="2" fill="#585858" width="17" height="19"/><polygon fill="#FFFFFF" points="14,7 10.5,13 7,7 "/><rect fill="#FFFFFF" width="2" height="19"/></svg>';
var SVG_select_inv='<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" x="0px" y="0px" width="19px" height="19px" viewBox="0 0 19 19" overflow="visible" enable-background="new 0 0 19 19" xml:space="preserve"><defs></defs><rect x="2" fill="#585858" width="17" height="19"/><polygon fill="#FFFFFF" points="14,13 10.5,7 7,13"/><rect fill="#FFFFFF" width="2" height="19"/></svg>';
var SVG_select_login='<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" x="0px" y="0px" width="19px" height="28px" viewBox="0 0 19 28" overflow="visible" enable-background="new 0 0 19 28" xml:space="preserve"><defs></defs><rect fill="#FFFFFF" width="19" height="28"/></svg>';
var SVG_select_dis='<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" x="0px" y="0px" width="22px" height="19px" viewBox="0 0 22 19" overflow="visible" enable-background="new 0 0 22 19" xml:space="preserve"><defs></defs><rect fill="#FFFFFF" width="22" height="19"/></svg>';
var globalDefinedSettings = new Array();
var globalLoadedPrincipals = new Array();
var globalEnableAllResourceSync = true;
if(typeof isSettingsAvaible == 'undefined')
var globalPreviousSupportedSettings = ['activecalendarcollections','activetodocollections', 'activeaddressbookcollections','todolistfilterselected','activeview','defaultactiveapp','calendarselected', 'todocalendarselected','addressbookselected','timezone', 'loadedtodocollections', 'loadedcalendarcollections', 'loadedaddressbookcollections', 'version'];
var globalSettingsSaving = '';
var globalFirstHideLoader = true;
var globalLoadedCollectionsNumber = 0;
var globalLoadedCollectionsCount = 0;
var ignoreServerSettings=false;
var globalPreventLogoutSync=false;
var globalEmailAddress='';
var globalSettingsVersion=3;
var globalSyncSettingsSave=false;
// Timepicker hack (prevent IE to re-open the datepicker on date click + focus)
var globalTmpTimePickerHackTime=new Object();
function isAvaible(app)
{
return globalAvailableAppsArray.indexOf(app)!=-1
}
function loadAllResources()
{
if(globalResourceIntervalID==null)
netFindResource(globalAccountSettings[0], 0, true, 0);
}
function getAccount(accountUID)
{
// find the original settings for the resource and user
var tmp=accountUID.match(RegExp('^(https?://)([^@/]+(?:@[^@/]+)?)@([^/]+)(.*/)','i'));
var resource_href=tmp[1]+tmp[3]+tmp[4];
var resource_user=tmp[2];
for(var i=0;i<globalAccountSettings.length;i++)
if(globalAccountSettings[i].href==resource_href && globalAccountSettings[i].userAuth.userName==resource_user)
resourceSettings=globalAccountSettings[i];
return resourceSettings;
}
function checkForUnloadedResources()
{
var rex=new RegExp('^(https?://)([^@/]+(?:@[^@/]+)?)@([^/]+)(.*/)', 'i');
for(var i=globalLoadedPrincipals.length-1; i>=0;i--)
{
var resourceCounter = 0;
if(isAvaible('CardDavMATE'))
for(var j=0; j<globalResourceCardDAVList.collections.length;j++)
if(globalResourceCardDAVList.collections[j].uid!=undefined&&globalResourceCardDAVList.collections[j].makeLoaded)
{
var tmp=globalResourceCardDAVList.collections[j].accountUID.match(rex);
var resourceCalDAV_href=tmp[1]+tmp[3]+tmp[4];
if(globalLoadedPrincipals[i]==resourceCalDAV_href)
resourceCounter++;
}
if(isAvaible('CalDavZAP'))
{
for(var j=0; j<globalResourceCalDAVList.collections.length;j++)
if(globalResourceCalDAVList.collections[j].uid!=undefined&&globalResourceCalDAVList.collections[j].makeLoaded)
{
var tmp=globalResourceCalDAVList.collections[j].accountUID.match(rex);
var resourceCalDAV_href=tmp[1]+tmp[3]+tmp[4];
if(globalLoadedPrincipals[i]==resourceCalDAV_href)
resourceCounter++;
}
for(var j=0; j<globalResourceCalDAVList.TodoCollections.length;j++)
if(globalResourceCalDAVList.TodoCollections[j].uid!=undefined&&globalResourceCalDAVList.TodoCollections[j].makeLoaded)
{
var tmp=globalResourceCalDAVList.TodoCollections[j].accountUID.match(rex);
var resourceCalDAV_href=tmp[1]+tmp[3]+tmp[4];
if(globalLoadedPrincipals[i]==resourceCalDAV_href)
resourceCounter++;
}
}
if(resourceCounter==0)
globalLoadedPrincipals.splice(i,1);
}
}
function reloadResources(dontSaveSettings, loadArray)
{
if((isAvaible('CardDavMATE')&&(globalCardDAVInitLoad||globalCardDAVResourceSync)) || (isAvaible('CalDavZAP')&&(globalCalDAVInitLoad||globalCalDAVResourceSync))
|| (isAvaible('Projects')&&!isProjectsLoaded) || (isAvaible('Settings')&&(!isSettingsLoaded || (globalSettingsSaving!=''&&!dontSaveSettings))) || (isAvaible('CalDavZAP')&&(globalLimitLoading!='' || globalLimitTodoLoading!='')))
return false;
if(globalWindowFocus==false)
return false;
globalCardDAVResourceSync=true;
globalCalDAVResourceSync=true;
if(isAvaible('CalDavZAP'))
{
globalCalDAVResourceSync = true;
globalToday.setHours(0);
globalToday.setMinutes(0);
globalToday.setSeconds(0);
globalToday.setMilliseconds(0);
var currentToday=new Date();
currentToday.setHours(0);
currentToday.setMinutes(0);
currentToday.setSeconds(0);
currentToday.setMilliseconds(0);
if(currentToday.getTime()!=globalToday.getTime())
{
if(isAvaible('CalDavZAP'))
$('.date').datepicker('refresh');
if(isAvaible('CardDavMATE'))
$('#vCardEditor').find('input[data-type^="date_"]').datepicker('refresh');
if(isAvaible('Projects'))
$('.project_date').datepicker('refresh');
$('#calendar').fullCalendar('updateToday');
$('#calendar').fullCalendar('gotoDate', currentToday);
$('#todoList').fullCalendar('gotoDate', currentToday);
if(currentToday.getTime()>globalToday.getTime())
{
getNextMonths($('#calendar').fullCalendar('getView').end);
getNextMonthsTodo();
}
else //support for timezone with backward time flow
{
getPrevMonths($('#calendar').fullCalendar('getView').start);
getPrevMonthsTodo();
}
globalToday=currentToday;
}
}
checkForUnloadedResources();
if(!globalEnableAllResourceSync&&(typeof loadArray=='undefined' || loadArray==null))
netFindResource(globalAccountSettings[0], 0, false, 0, globalLoadedPrincipals);
else
netFindResource(globalAccountSettings[0], 0, false, 0, loadArray);
}
function ifLoadCollections()
{
if((isAvaible('CardDavMATE') && (globalCardDAVInitLoad || globalCardDAVResourceSync)) || (isAvaible('CalDavZAP') && (globalCalDAVInitLoad || globalCalDAVResourceSync)))
return false;
var changeCounter = 0;
if(isAvaible('CardDavMATE'))
for(var i=0; i<globalResourceCardDAVList.collections.length;i++)
if(globalResourceCardDAVList.collections[i].uid!=undefined && globalResourceCardDAVList.collections[i].someChanged)
changeCounter++;
if(isAvaible('CalDavZAP'))
{
for(var i=0; i<globalResourceCalDAVList.collections.length;i++)
if(globalResourceCalDAVList.collections[i].uid!=undefined && globalResourceCalDAVList.collections[i].someChanged)
changeCounter++;
for(var i=0; i<globalResourceCalDAVList.TodoCollections.length;i++)
if(globalResourceCalDAVList.TodoCollections[i].uid!=undefined && globalResourceCalDAVList.TodoCollections[i].someChanged)
changeCounter++;
}
if(changeCounter>0 || globalSettingsSaving!='')
loadNextApplication(false);
}
function bindColorPickerClick(newElement)
{
newElement.click(function(event){
var collectionType=null;
var resourceSelectedClass=null;
var resourceItems=null;
if(newElement.parent().hasClass('resourceCalDAV_item'))
{
if(globalEventCollectionsLoading)
return false;
collectionType='event';
resourceSelectedClass='resourceCalDAV_item_selected';
resourceItems=newElement.parent().siblings('.resourceCalDAV_item_selected');
}
else if(newElement.parent().hasClass('resourceCalDAVTODO_item'))
{
if(globalTodoCollectionsLoading)
return false;
collectionType='todo';
resourceSelectedClass='resourceCalDAV_item_selected';
resourceItems=newElement.parent().siblings('.resourceCalDAV_item_selected');
}
else if(newElement.hasClass('resourceCardDAVColor'))
{
if(globalAddressbookCollectionsLoading)
return false;
collectionType='addressbook';
resourceSelectedClass='resourceCardDAV_selected';
resourceItems=newElement.parent().parent().siblings().find('.resourceCardDAV_selected');
}
var showInput = event.shiftKey;
var colorpicker=$(this).siblings('.colorPicker');
if(!$(this).hasClass('hasColorpicker'))
{
$(this).addClass('hasColorpicker');
colorpicker.spectrum({
chooseText: localization[globalInterfaceLanguage].buttonSave,
cancelText: localization[globalInterfaceLanguage].buttonCancel,
color: newElement.css('background-color'),
showInput: showInput,
preferredFormat: 'hex6',
move: function(color)
{
newElement.css('background', color);
},
hide: function(color)
{
if(newElement.css('background-color') != colorpicker.spectrum('get').toRgbString())
newElement.css('background', colorpicker.spectrum('get').toRgbString());
},
change: function(color)
{
newElement.css('background', color);
if(collectionType=='event')
{
var coll = globalResourceCalDAVList.getEventCollectionByUID($(this).parent().attr('data-id'));
netSaveProperty(coll, (typeof globalCalendarColorPropertyXmlns!='undefined'&&globalCalendarColorPropertyXmlns!=null&&globalCalendarColorPropertyXmlns!='' ? globalCalendarColorPropertyXmlns : 'http://apple.com/ns/ical/'), 'calendar-color', color.toHexString())
}
else if(collectionType=='todo')
{
var coll = globalResourceCalDAVList.getTodoCollectionByUID($(this).parent().attr('data-id'));
netSaveProperty(coll, (typeof globalCalendarColorPropertyXmlns!='undefined'&&globalCalendarColorPropertyXmlns!=null&&globalCalendarColorPropertyXmlns!='' ? globalCalendarColorPropertyXmlns : 'http://apple.com/ns/ical/'), 'calendar-color', color.toHexString())
}
else if(collectionType=='addressbook')
{
var coll = globalResourceCardDAVList.getCollectionByUID($(this).parent().attr('data-id'));
netSaveProperty(coll, (typeof globalAddrColorPropertyXmlns!='undefined'&&globalAddrColorPropertyXmlns!=null&&globalAddrColorPropertyXmlns!='' ? globalAddrColorPropertyXmlns : 'http://inf-it.com/ns/ab/'), 'addressbook-color', color.toHexString())
}
}
});
}
else if(showInput!=colorpicker.spectrum('option', 'showInput'))
colorpicker.spectrum('option', 'showInput',showInput);
var container = colorpicker.spectrum('container');
if(container.is(':visible')) {
colorpicker.spectrum('hide');
}
else {
var offset=$(this).offset();
colorpicker.spectrum('show');
if(event.pageY<$(window).height()/2) {
offset.top+=$(this).outerHeight();
container.removeClass('sp-inverse');
}
else {
offset.top-=container.outerHeight();
container.addClass('sp-inverse');
}
container.offset(offset);
}
resourceItems.removeClass(resourceSelectedClass);
newElement.parent().addClass(resourceSelectedClass);
return false;
});
}
function loadNextApplication(forceLoad)
{
if(!globalFirstLoadNextApp)
{
if(isAvaible('CardDavMATE'))
setAddressbookNumber();
if(isAvaible('CalDavZAP'))
setCalendarNumber(true);
globalFirstLoadNextApp=true;
}
if(isAvaible('CardDavMATE') && !globalCardDAVCollectionSync && globalResourceCardDAVList.collections.length>0)
{
globalCardDAVCollectionSync=true;
CardDAVnetLoadCollection(globalResourceCardDAVList.collections[0], forceLoad, false, null, 0, globalResourceCardDAVList.collections,true);
}
else if(isAvaible('CalDavZAP') && !globalCalDAVCollectionSync && globalResourceCalDAVList.collections.length>0)
{
globalCalDAVCollectionSync=true;
CalDAVnetLoadCollection(globalResourceCalDAVList.collections[0], forceLoad, true, 0, globalResourceCalDAVList.collections);
}
else if(isAvaible('Projects') && !globalProjectSync && !isProjectsLoaded && getLoggedUser()!=null)
{
$('#MainLoaderInner').html('Loading projects');
globalProjectSync=true;
if(typeof globalCRMSettings != 'undefined')
netLoadXSLT(globalCRMSettings.XSLTHref);
else
{
console.log("Error: globalCRMSettings is not defined");
loadNextApplication(false);
}
}
else if(isAvaible('Reports') && !globalReportsSync && !isReportsLoaded && getLoggedUser()!=null)
{
$('#MainLoaderInner').html('Loading Reports');
globalReportsSync=true;
if(typeof globalCRMSettings != 'undefined')
netLoadReportList(globalCRMSettings);
else
{
console.log("Error: globalCRMSettings is not defined");
loadNextApplication(false);
}
}
else if(isAvaible('Settings') && !globalSettingsSync && !isSettingsLoaded && getLoggedUser()!=null)
{
globalSettingsSync = true;
if(!isSettingsLoaded)
loadNextApplication(false);
if($('#ResourceSettingsList').children('.resourceSettings_item').length)
$('#ResourceSettingsList').children().eq(0).trigger('click');
}
else
{
if((isAvaible('CalDavZAP') && !isCalDAVLoaded) || (isAvaible('CardDavMATE') && !isCardDAVLoaded))
$('#MainLoader').fadeOut(1200, function(){$('#MainLoader').css('left','50px');});
if(isAvaible('CardDavMATE'))
{
globalCardDAVCollectionSync=false;
if(!isCardDAVLoaded)
isCardDAVLoaded=true;
}
if(isAvaible('CalDavZAP'))
{
globalCalDAVCollectionSync=false;
if(!isCalDAVLoaded)
isCalDAVLoaded=true;
}
if(isAvaible('Projects'))
{
globalProjectSync=false;
isProjectsLoaded = true;
}
if(isAvaible('Reports'))
{
globalReportsSync=false;
isReportsLoaded = true;
}
if(isAvaible('Settings'))
{
globalSettingsSync=false;
isSettingsLoaded = true;
}
}
}
function checkForApplication(inputApp)
{
if(!globalEnableAppSwitch || globalObjectLoading)
return false;
globalEnableAppSwitch=false;
globalActiveApp=inputApp;
var inputID = 'System'+inputApp;
$('.System').not('#'+inputID).each(function(){
$(this).animate({opacity : 0}, 666, function(){
/* XXX - System display:none changes
if($(this).attr('id').indexOf('CalDav')==-1)
$(this).css('display','none');
else*/
$(this).css('visibility','hidden');
});
});
/* XXX - System display:none changes
if(inputID.indexOf('CalDav')==-1)
$('#'+inputID).css('display','block').animate({opacity : 1}, 666, function(){globalEnableAppSwitch=true;});
else*/
$('#'+inputID).css('visibility','visible').animate({opacity : 1}, 666, function(){globalEnableAppSwitch=true;});
}
function getLoggedUser()
{
for(var i=0; i<globalAccountSettings.length;i++)
if(globalAccountSettings[i].href.indexOf(globalLoginUsername)!=-1)
return globalAccountSettings[i];
return globalAccountSettings[0];
}
function login()
{
$('#LoginLoader').fadeTo(1200, 1, function(){
globalLoginUsername=$('#LoginPage').find('[data-type="system_username"]').val();
globalLoginPassword=$('#LoginPage').find('[data-type="system_password"]').val();
loadConfig();
});
}
function logout(forceLogout)
{
if((typeof forceLogout=='undefined' || forceLogout==null ) && (
(isAvaible('CardDavMATE') && (!isCardDAVLoaded || globalCardDAVResourceSync)) ||
(isAvaible('CalDavZAP') && (!isCalDAVLoaded || globalCalDAVResourceSync)) ||
(isAvaible('Projects') && !isProjectsLoaded) ||
(isAvaible('Settings') && (!isSettingsLoaded || (globalSettingsSaving!='' && !dontSaveSettings))) ||
(isAvaible('CalDavZAP') && (globalLimitLoading!='' || globalLimitTodoLoading!=''))
))
{
globalPreventLogoutSync=true;
return false;
}
clearInterval(globalResourceIntervalID);
if(globalFirstLoadNextApp)
globalFirstLoadNextApp=false;
settingsLoaded=false;
ignoreServerSettings=false;
//save settings
checkBeforeClose(false);
globalResourceIntervalID=null;
globalLoginUsername='';
globalLoginPassword='';
globalXMLCache=null;
globalResourceNumber=0;
globalResourceNumberCount=0;
globalLoadedPrincipals=new Array();
globalEmailAddress='';
globalPreventLogoutSync=false;
globalSyncSettingsSave=false;
$(document.documentElement).unbind();
// reset page title
var tmpMatch = document.title.match('^(.*) \\[.*\\]$');
if(tmpMatch!=null)
document.title = tmpMatch[1];
$('#LoginPage').fadeTo(2000, 1, function(){
if(typeof isCalDAVLoaded!='undefined' && isCalDAVLoaded)
{
logoutCalDAV();
isCalDAVLoaded=false;
}
if(typeof isCardDAVLoaded!='undefined' && isCardDAVLoaded)
{
logoutCardDAV();
isCardDAVLoaded=false;
}
if(typeof isProjectsLoaded!='undefined' && isProjectsLoaded)
{
logoutProjects();
isProjectsLoaded = false;
}
if(typeof isReportsLoaded!='undefined' && isReportsLoaded)
{
logoutReports();
isReportsLoaded = false;
}
if(typeof isSettingsLoaded!='undefined' && isSettingsLoaded)
{
logoutSettings();
isSettingsLoaded = false;
}
for(var i=globalAccountSettings.length-1;i>=0;i--)
if(globalAccountSettings[i].type=='network')
globalAccountSettings.splice(i, 1);
if(typeof globalDemoMode=='undefined')
{
$('[data-type="system_username"]').val('').change();
$('[data-type="system_password"]').val('').change();
}
$('.integration_d').hide();
isUserLogged=false;
if(globalSettings.defaultactiveapp.value==null)
{
if(isAvaible('CalDavZAP'))
globalActiveApp='CalDavZAP';
else if(isAvaible('CardDavMATE'))
globalActiveApp='CardDavMATE';
}
else
globalActiveApp=globalSettings.defaultactiveapp.value;
resetSettings();
if(isAvaible('CardDavMATE'))
mainCardDAV();
if(isAvaible('CalDavZAP'))
mainCalDAV();
if(isAvaible('Settings'))
mainSettings();
if(isAvaible('Projects'))
mainProjects();
if(isAvaible('Reports'))
mainReports();
init();
});
}
function init()
{
// browser check
if(($.browser.msie && parseInt($.browser.version, 10)<9) || $.browser.opera)
$('#login_message').css('display','').text(localization[globalInterfaceLanguage].unsupportedBrowser);
if(typeof globalDemoMode!='undefined')
{
if(typeof globalDemoMode.userName!=undefined)
$('[data-type="system_username"]').val(globalDemoMode.userName).change();
if(typeof globalDemoMode.userPassword!=undefined)
$('[data-type="system_password"]').val(globalDemoMode.userPassword).change();
}
loadConfig();
}
function run()
{
isUserLogged=true;
window.onfocus=function(){globalWindowFocus=true;}
window.onblur=function(){if(globalSettings.backgroundsync.value==false) globalWindowFocus=false;}
$('#LoginPage').fadeOut(2000);
if(typeof globalAccountSettings=='undefined')
{
console.log('Error: \'no account configured\': see config.js!');
return false;
}
if(typeof globalNewVersionNotifyUsers=='undefined' || globalNewVersionNotifyUsers!=null)
netVersionCheck();
document.title+=' ['+globalAccountSettings[0].userAuth.userName+']';
// Automatically detect crossDomain settings
var detectedHref=location.protocol+'//'+location.hostname+(location.port ? ':'+location.port : '');
for(var i=0;i<globalAccountSettings.length;i++)
{
if(globalAccountSettings[i].crossDomain==undefined || typeof globalAccountSettings[i].crossDomain!='boolean')
{
if(globalAccountSettings[i].href.indexOf(detectedHref)==0)
globalAccountSettings[i].crossDomain=false;
else
globalAccountSettings[i].crossDomain=true;
console.log("Info: [userAccount: '"+globalAccountSettings[i].href.replace('\/\/', '//'+globalAccountSettings[i].userAuth.userName+'@')+"']: crossDomain set to: '"+(globalAccountSettings[i].crossDomain==true ? 'true' : 'false')+"'");
}
}
if(typeof globalAvailableAppsArray!='undefined' && globalAvailableAppsArray!=null && globalAvailableAppsArray.length>1) {
// show integration banner
$('.integration_d').css('display', 'block');
// show app buttons for available apps only
if(globalAvailableAppsArray.indexOf('CalDavZAP')!=-1)