blob: 76c8655df8828a7f73e1ae20971cb61f31c2e6a1 [file] [log] [blame]
Carsten Ziegelerd524ac92008-10-23 16:44:07 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18function header( /* int */ columns )
19{
20 document.write( "<table class='content' cellpadding='0' cellspacing='0' width='100%'>" );
21
22 document.write( "<tr class='content'>" );
23 document.write( "<td colspan='" + columns + "' class='content'>&nbsp;</th>" );
24 document.write( "</tr>" );
25
26 document.write( "<tr class='content'>" );
Carsten Ziegeler46fb24e2008-10-24 08:04:31 +000027 document.write( "<th class='content' width='20%'>Topic</th>" );
Carsten Ziegelerd524ac92008-10-23 16:44:07 +000028 document.write( "<th class='content'>Properties</th>" );
29 document.write( "</tr>" );
30
31}
32
33
34function error( /* int */ columns, /* String */ message )
35{
36 document.write( "<tr class='content'>" );
37 document.write( "<td class='content'>&nbsp;</td>" );
38 document.write( "<td class='content' colspan='" + (columns - 1) + "'>" + message + "</td>" );
39 document.write( "</tr>" );
40}
41
42
43function data( /* Array of Object */ dataArray )
44{
45 // render components
46 if (dataArray.length == 1)
47 {
48 entry( dataArray[0], true );
49 }
50 else {
51 for ( var idx in dataArray )
52 {
53 entry( dataArray[idx] );
54 }
55 }
56}
57
58
59function footer( /* int */ columns )
60{
61 document.write( "<tr class='content'>" );
62 document.write( "<td colspan='" + columns + "' class='content'>&nbsp;</th>" );
63 document.write( "</tr>" );
64
65 document.write( "</table>" );
66}
67
68
69function entry( /* Object */ dataEntry, /* boolean */ singleEntry )
70{
71 var trElement = tr( null, { id: "entry" + dataEntry.id } );
72 entryInternal( trElement, dataEntry, singleEntry );
73 document.write( serialize( trElement ) );
74}
75
76
77function entryInternal( /* Element */ parent, /* Object */ dataEntry, /* boolean */ singleEntry )
78{
79
80 var id = dataEntry.id;
81 var topic = dataEntry.topic;
82 var properties = dataEntry.properties;
83
84 parent.appendChild( td( "content", { width: "20%"}, [ text( topic ) ] ) );
85
86 var tableE = createElement("table");
87 var bodyE = createElement("tbody");
88 tableE.appendChild(bodyE);
89
90 for( var p in dataEntry.properties ) {
Carsten Ziegeler7ba2bfe2008-10-24 05:23:56 +000091 bodyE.appendChild(tr(null, null, [td(null, null, [text(p)] ),
92 td(null, null, [text(dataEntry.properties[p])])]));
Carsten Ziegelerd524ac92008-10-23 16:44:07 +000093 }
94
95 parent.appendChild( td( "content", null, [tableE] ) );
96}
97
98
99
100function renderEvents( /* Array of Data Objects */ bundleData )
101{
102
103 // topic and properties
104 var columns = 2;
105
106 header( columns );
107
108 if (bundleData.error)
109 {
110 error( columns, bundleData.error );
111 }
112 else
113 {
114 data ( bundleData.data );
115 }
116
117 footer( columns );
118}