From: Jan Schneider Date: Thu, 12 Nov 2009 15:56:09 +0000 (+0100) Subject: We only want one section per application, not per timeobject category. Streamline... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=86bd36f897868cd05871c9f834bbce1f9a0fcd48;p=horde.git We only want one section per application, not per timeobject category. Streamline code a bit. --- diff --git a/kronolith/js/kronolith.js b/kronolith/js/kronolith.js index 60fc0e2b8..c47ac69aa 100644 --- a/kronolith/js/kronolith.js +++ b/kronolith/js/kronolith.js @@ -725,7 +725,7 @@ KronolithCore = { */ updateCalendarList: function() { - var my = 0, shared = 0, ext = {}, extNames = {}, + var my = 0, shared = 0, ext = $H(), extNames = $H(), remote, holidays, api, div; $H(Kronolith.conf.calendars.internal).each(function(cal) { @@ -756,23 +756,21 @@ KronolithCore = { } $H(Kronolith.conf.calendars.external).each(function(cal) { - var api = []; - api[0] = cal.key.substring(0, cal.key.lastIndexOf('/')); - api[1] = cal.key.substring(cal.key.lastIndexOf('/') + 1); - if (typeof ext[api[0]] == 'undefined') { - ext[api[0]] = {}; + var parts = cal.key.split('/'), api = parts.shift(); + if (!ext.get(api)) { + ext.set(api, $H()); } - ext[api[0]][api[1]] = cal.value; - extNames[api[0]] = cal.value.api; + ext.get(api).set(parts.join('/'), cal.value); + extNames.set(api, cal.value.api); }); - $H(ext).each(function(api) { + ext.each(function(api) { $('kronolithExternalCalendars') .insert(new Element('H3') .insert(new Element('A', { 'class': 'kronolithAdd' }) .update('+')) - .insert({ bottom: extNames[api.key].escapeHTML() })) + .insert({ bottom: extNames.get(api.key).escapeHTML() })) .insert(new Element('DIV', { 'id': 'kronolithExternalCalendar' + api.key, 'class': 'kronolithCalendars' })); - $H(api.value).each(function(cal) { + api.value.each(function(cal) { $('kronolithExternalCalendar' + api.key) .insert(new Element('DIV', { 'class': cal.value.show ? 'kronolithCalOn' : 'kronolithCalOff' }) .store('calendar', api.key + '/' + cal.key)