Associative PHP arrays are serialized as JSON arrays when empty, instead of
authorJan Schneider <jan@horde.org>
Fri, 20 Feb 2009 17:23:45 +0000 (18:23 +0100)
committerJan Schneider <jan@horde.org>
Fri, 20 Feb 2009 17:26:29 +0000 (18:26 +0100)
objects. $H() only works with objects though.
Michael, have you seen this earlier and solved it differently?

kronolith/js/src/kronolith.js

index 21f18f2..250eb44 100644 (file)
@@ -470,16 +470,18 @@ KronolithCore = {
     _monthCallback: function(r)
     {
         var div;
-        r = r.response;
-        $H(r.events).each(function(date) {
-            $H(date.value).each(function(event) {
-                div = new Element('DIV', { 'class': 'kronolithEvent', 'style': 'background-color:' + event.value.bg + ';color:' + event.value.fg });
-                div.setText(event.value.t)
-                    .observe('mouseover', div.addClassName.curry('kronolithSelected'))
-                    .observe('mouseout', div.removeClassName.curry('kronolithSelected'));
-                $('kronolithMonthDay' + date.key).insert(div);
+
+        if (typeof r.response.events.length == 'undefined') {
+            $H(r.response.events).each(function(date) {
+                $H(date.value).each(function(event) {
+                    div = new Element('DIV', { 'class': 'kronolithEvent', 'style': 'background-color:' + event.value.bg + ';color:' + event.value.fg });
+                    div.setText(event.value.t)
+                        .observe('mouseover', div.addClassName.curry('kronolithSelected'))
+                        .observe('mouseout', div.removeClassName.curry('kronolithSelected'));
+                    $('kronolithMonthDay' + date.key).insert(div);
+                });
             });
-        });
+        }
     },
 
     /**