Defensive coding in mkws-googleurl Handlebars helper.
[mkws-moved-to-github.git] / examples / htdocs / mkws-widget-credo.js
index 036f896..90ac5f9 100644 (file)
@@ -5,7 +5,13 @@
 //      http://eofdreams.com/fish.html
 //
 Handlebars.registerHelper('mkws-googleurl', function(obj) {
-  return mkws.getParameterByName('q', obj[0]);
+  if (!obj) {
+    return "obj undefined";
+  } else if (!obj[0]) {
+    return "obj[0] undefined, JSON=" + $.toJSON(obj);
+  } else {
+    return mkws.getParameterByName('q', obj[0]);
+  }
 });
 
 
@@ -58,13 +64,13 @@ mkws.registerWidgetType('Credo', function() {
   s.push(sectionRow('entries', 'Credo Entries',
                     this.subwidget('Records', { _team: 'main' })));
   s.push(sectionRow('articles', 'Articles',
-                    this.subwidget('Records', { _team: 'art', targetfilter: 'categories=articles' })));
+                    this.subwidget('Records', { _team: 'articles', targetfilter: 'categories=articles' })));
   s.push(sectionRow('books', 'Books',
-                    1 || this.subwidget('Records', { /* ### config */ })));
+                    this.subwidget('Records', { _team: 'books', targetfilter: 'categories=books' })));
   s.push(sectionRow('news', 'News',
-                    1 || this.subwidget('Records', { /* ### config */ })));
+                    this.subwidget('Records', { _team: 'news', targetfilter: 'categories=news' })));
   s.push(sectionRow('resources', 'Suggested Resources',
-                    1 || this.subwidget('Records', { /* ### config */ })));
+                    "### Not yet implemented"));
 
   s.push('</table>');