blob: 531c60012cfa31ef5431c17aeb9f60f3c8490b25 [file] [log] [blame]
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +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 */
Valentin Valchevf51fe432010-04-15 12:01:33 +000017var tableEntryTemplate = false;
18var tableBody = false;
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000019
20function renderData(eventData) {
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +000021 $('.statline').empty().append(i18n.statline.msgFormat(eventData.serviceCount));
22 $('#plugin_table > tbody > tr').remove();
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000023 for ( var idx in eventData.data) {
24 entry(eventData.data[idx]);
25 }
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000026 if (drawDetails) {
27 renderDetails(eventData);
28 }
29}
30
31function entry( /* Object */dataEntry) {
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000032 var id = dataEntry.id;
33 var name = dataEntry.id;
34
Valentin Valchevf51fe432010-04-15 12:01:33 +000035 var _ = tableEntryTemplate.clone().attr('id', 'entry' + id).appendTo(tableBody);
36 _.find('.bIcon').attr('id', 'img' + id).click(function() {
37 showDetails(id);
38 }).after(drawDetails ? name : ('<a href="' + window.location.pathname + '/' + id + '">' + name + '</a>'));
39
40 _.find('td:eq(1)').text(dataEntry.types);
41 _.find('td:eq(2)').html('<a href="' + bundlePath + dataEntry.bundleId + '">' + dataEntry.bundleSymbolicName + ' (' + dataEntry.bundleId + ')</a>' );
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000042}
43
44function showDetails(id) {
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +000045 $.get(pluginRoot + '/' + id + '.json', null, function(data) {
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000046 renderDetails(data);
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +000047 }, 'json');
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000048}
49
50function hideDetails(id) {
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +000051 $('#img' + id).each(function() {
52 $('#pluginInlineDetails' + id).remove();
53 $(this).
54 removeClass('ui-icon-triangle-1-w').//left
55 removeClass('ui-icon-triangle-1-s').//down
56 addClass('ui-icon-triangle-1-e').//right
57 unbind('click').click(function() {showDetails(id)});
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000058 });
59}
60
61function renderDetails(data) {
62 data = data.data[0];
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +000063 $('#entry' + data.id + ' > td').eq(1).append('<div id="pluginInlineDetails' + data.id + '"/>');
64 $('#img' + data.id).each(function() {
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000065 if (drawDetails) {
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000066 var ref = window.location.pathname;
67 ref = ref.substring(0, ref.lastIndexOf('/'));
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +000068 $(this).
69 removeClass('ui-icon-triangle-1-e').//right
70 removeClass('ui-icon-triangle-1-s').//down
71 addClass('ui-icon-triangle-1-w').//left
72 attr('title', i18n.back).
73 unbind('click').click(function() {window.location = ref;});
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000074 } else {
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +000075 $(this).
76 removeClass('ui-icon-triangle-1-w').//left
77 removeClass('ui-icon-triangle-1-e').//right
78 addClass('ui-icon-triangle-1-s').//down
79 attr('title', i18n.detailsHide).
80 unbind('click').click(function() {hideDetails(data.id)});
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000081 }
82 });
Felix Meschbergerde0ceed2010-04-08 08:05:20 +000083 var details = "";
84 if (data.props) {
85 details += renderObjectAsTable(data.props);
86 }
87 if (data.usingBundles) {
88 details += renderUsingBundlesAsTable(data.usingBundles);
89 }
90 if (details) {
91 details = '<table border="0"><tbody>' + details + '</tbody></table>';
92 $('#pluginInlineDetails' + data.id).append( details );
93 }
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +000094}
95
96function renderObjectAsTable(/* Object*/ details) {
97 var txt = '';
98
99 for (var idx in details) {
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000100 var prop = details[idx];
101
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000102 txt += '<tr><td class="aligntop" noWrap="true" style="border:0px none">'
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000103 + prop.key
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000104 + '</td><td class="aligntop" style="border:0px none">';
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000105 if (prop.value) {
106 if ($.isArray(prop.value)) {
107 var i = 0;
108 for ( var pi in prop.value) {
109 var value = prop.value[pi];
110 if (i > 0) {
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000111 txt = txt + '<br/>';
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000112 }
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000113 txt = txt + value;
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000114 i++;
115 }
116 } else {
117 txt = txt + prop.value;
118 }
119 } else {
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000120 txt = txt + '\u00a0';
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000121 }
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000122 txt = txt + '</td></tr>';
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000123 }
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000124
Felix Meschbergerde0ceed2010-04-08 08:05:20 +0000125 return txt;
126}
127
128function renderUsingBundlesAsTable(/* Object[] */ bundles) {
129 var txt = '';
130
131 for (var idx in bundles) {
132 var bundle = bundles[idx];
133 txt += '<a href="' + bundlePath + '/' + bundle.bundleId + '">'
134 + bundle.bundleSymbolicName + ' (' + bundle.bundleId + ')'
135 + '</a><br/>';
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000136 }
137
Felix Meschbergerde0ceed2010-04-08 08:05:20 +0000138 if (txt) {
139 txt = '<tr><td class="aligntop" noWrap="true" style="border:0px none">'
140 + i18n.usingBundles
141 + '</td><td class="aligntop" style="border:0px none">'
142 + txt
143 + '</td></tr>';
144 }
145
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000146 return txt;
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000147}
148
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000149
Valentin Valchevf51fe432010-04-15 12:01:33 +0000150$(document).ready(function() {
151 tableBody = $('#plugin_table tbody');
152 tableEntryTemplate = tableBody.find('tr').clone();
153 tableBody.empty();
154
155 renderData(data);
156
157 $('#plugin_table').tablesorter( {
158 headers : {
159 0 : { sorter : 'digit' }
160 },
161 sortList : [ [ 1, 0 ] ],
162 textExtraction : mixedLinksExtraction
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000163 });
Valentin Valchevf51fe432010-04-15 12:01:33 +0000164});