Avoid key collisions when a listTimeObjects provider can export the same timeObject...
authorMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 6 Nov 2009 20:00:32 +0000 (15:00 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 6 Nov 2009 20:00:32 +0000 (15:00 -0500)
for multiple resources (Like Turba exporting Birthdays for more then one address book).

kronolith/js/kronolith.js

index d3e093e..d9a988f 100644 (file)
@@ -761,7 +761,10 @@ KronolithCore = {
             if (typeof ext[api[0]] == 'undefined') {
                 ext[api[0]] = {};
             }
-            ext[api[0]][api[1]] = cal.value;
+            if (typeof ext[api[0]][api[1]] == 'undefined') {
+                ext[api[0]][api[1]] = [];
+            }
+            ext[api[0]][api[1]].push(cal.value);
             extNames[api[0]] = cal.value.api;
         });
         $H(ext).each(function(api) {
@@ -771,13 +774,16 @@ KronolithCore = {
                                 .update('+'))
                         .insert({ bottom: extNames[api.key].escapeHTML() }))
                 .insert(new Element('DIV', { 'id': 'kronolithExternalCalendar' + api.key, 'class': 'kronolithCalendars' }));
-            $H(api.value).each(function(cal) {
-                $('kronolithExternalCalendar' + api.key)
-                    .insert(new Element('DIV', { 'class': cal.value.show ? 'kronolithCalOn' : 'kronolithCalOff' })
-                            .store('calendar', api.key + '/' + cal.key)
-                            .store('calendarclass', 'external')
-                            .setStyle({ backgroundColor: cal.value.bg, color: cal.value.fg })
-                            .update(cal.value.name.escapeHTML()));
+            $H(api.value).each(function(cals) {
+                for (var i = 0; i < cals.value.length; i++) {
+                    var cal = cals.value[i];
+                    $('kronolithExternalCalendar' + api.key)
+                        .insert(new Element('DIV', { 'class': cal.show ? 'kronolithCalOn' : 'kronolithCalOff' })
+                                .store('calendar', api.key + '/' + cal.key)
+                                .store('calendarclass', 'external')
+                                .setStyle({ backgroundColor: cal.bg, color: cal.fg })
+                                .update(cal.name.escapeHTML()));
+                }
             });
         });