From 2998c6720286861964968fe10af9cbd77b74b406 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Tue, 28 Apr 2009 15:04:40 +0200 Subject: [PATCH] Fix overwriting instead of merging. --- kronolith/js/src/kronolith.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/kronolith/js/src/kronolith.js b/kronolith/js/src/kronolith.js index f5d67c5d6..e3e13160b 100644 --- a/kronolith/js/src/kronolith.js +++ b/kronolith/js/src/kronolith.js @@ -1010,7 +1010,7 @@ KronolithCore = { * empty cache entries are created so that those dates aren't re-fetched * each time. * - * @param object events A list of calendars and events as return from + * @param object events A list of calendars and events as returned from * an ajax request. * @param string calendar A calendar string or array. * @param string dates A date range in the format yyyymmddyyyymmdd as @@ -1029,32 +1029,33 @@ KronolithCore = { if (!this.ecache.get(calendar[0]).get(calendar[1])) { this.ecache.get(calendar[0]).set(calendar[1], $H()); } + var calHash = this.ecache.get(calendar[0]).get(calendar[1]); // Create empty cache entries for all dates. if (typeof dates != 'undefined') { - var calHash = this.ecache.get(calendar[0]).get(calendar[1]), - day = dates[0].clone(), date; + var day = dates[0].clone(), date; while (!day.isAfter(dates[1])) { date = day.dateString(); if (!calHash.get(date)) { - calHash.set(date, {}); + calHash.set(date, $H()); } day.add(1).day(); } } - // Store calendar string and other useful information in event objects. var cal = calendar.join('|'); $H(events).each(function(date) { + // Store calendar string and other useful information in event + // objects. $H(date.value).each(function(event) { event.value.calendar = cal; event.value.start = Date.parse(event.value.s); event.value.end = Date.parse(event.value.e); }); - }); - // Store events in cache. - this.ecache.get(calendar[0]).set(calendar[1], this.ecache.get(calendar[0]).get(calendar[1]).merge(events)); + // Store events in cache. + calHash.set(date.key, calHash.get(date.key).merge(date.value)); + }); }, /** -- 2.11.0