Add comment on inefficiency
[mkws-moved-to-github.git] / examples / htdocs / mkws-widget-credo.js
1 // ### This works inefficiently by having multiple teams all run the
2 // same search against different sets of targets. A much better
3 // approach would be run a single search, with all these panels
4 // members of the same team, but picking out only the results relevant
5 // to them. That will be more work.
6
7 mkws.registerWidgetType('Credo', function() {
8   var that = this;
9   var s = []
10   s.push('<table>');
11
12   // Main panel: encylopaedia and images on the left, topics on the right
13   s.push('<tr class="front">');
14
15   s.push('<td class="main">');
16   s.push(section('encyclopaedia', 'Topic Page: ### title',
17                  this.subwidget('Reference')));
18   s.push(section('image', 'Images',
19                  this.subwidget('Images', { /* ### config */ })));
20   s.push('</td>');
21
22   s.push('<td class="side">');
23   s.push(section('mindmap', 'Create a Mind Map for ### title',
24                  '### Is there a way to make a mind-map?'));
25   s.push(section('topics', 'Related Topics',
26                  this.subwidget('Facet', { facet: 'subject' })));
27   s.push('</td>');
28
29   s.push('</tr>');
30
31   s.push(sectionRow('entries', 'Credo Entries',
32                     this.subwidget('Records', { /* ### config */ })));
33   s.push(sectionRow('articles', 'Articles',
34                     this.subwidget('Records', { /* ### config */ })));
35   s.push(sectionRow('books', 'Books',
36                     this.subwidget('Records', { /* ### config */ })));
37   s.push(sectionRow('news', 'News',
38                     this.subwidget('Records', { /* ### config */ })));
39   s.push(sectionRow('resources', 'Suggested Resources',
40                     this.subwidget('Records', { /* ### config */ })));
41
42   s.push('</table>');
43
44   this.node.html(s.join(''));
45
46
47   function section(xclass, title, content) {
48     var s = [];
49     s.push('<div class="' + xclass + ' section">');
50     s.push('<div class="title">' + title + '</div>');
51     s.push('<div class="content">' + content + '</div>');
52     s.push('</div>');
53     return s.join('');
54   }
55
56   function sectionRow(xclass, title, content) {
57     var s = [];
58     s.push('<tr>');
59     s.push('<td colspan="2">');
60     s.push(section(xclass, title, content));
61     s.push('</td>');
62     s.push('</tr>');
63     return s.join('');
64   }
65 });