blob: feb513d4503fe13f1e454852230a3d1d61c8fe8b [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
Carsten Ziegeler3b17bbf2015-01-05 12:26:20 +000040 _.find('td:eq(1)').text(dataEntry.types);
41 _.find('td:eq(2)').html('<a href="' + bundlePath + dataEntry.bundleId + '">' + dataEntry.bundleSymbolicName + ' (' + dataEntry.bundleId + ')</a>' );
42 _.find('td:eq(3)').text(dataEntry.ranking);
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000043}
44
45function showDetails(id) {
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +000046 $.get(pluginRoot + '/' + id + '.json', null, function(data) {
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000047 renderDetails(data);
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +000048 }, 'json');
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000049}
50
51function hideDetails(id) {
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +000052 $('#img' + id).each(function() {
53 $('#pluginInlineDetails' + id).remove();
54 $(this).
55 removeClass('ui-icon-triangle-1-w').//left
56 removeClass('ui-icon-triangle-1-s').//down
57 addClass('ui-icon-triangle-1-e').//right
58 unbind('click').click(function() {showDetails(id)});
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000059 });
60}
61
62function renderDetails(data) {
63 data = data.data[0];
Carsten Ziegeler3b17bbf2015-01-05 12:26:20 +000064 $('#entry' + data.id + ' > td').eq(1).append('<div id="pluginInlineDetails' + data.id + '"/>');
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +000065 $('#img' + data.id).each(function() {
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000066 if (drawDetails) {
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000067 var ref = window.location.pathname;
68 ref = ref.substring(0, ref.lastIndexOf('/'));
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +000069 $(this).
70 removeClass('ui-icon-triangle-1-e').//right
71 removeClass('ui-icon-triangle-1-s').//down
72 addClass('ui-icon-triangle-1-w').//left
73 attr('title', i18n.back).
74 unbind('click').click(function() {window.location = ref;});
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000075 } else {
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +000076 $(this).
77 removeClass('ui-icon-triangle-1-w').//left
78 removeClass('ui-icon-triangle-1-e').//right
79 addClass('ui-icon-triangle-1-s').//down
80 attr('title', i18n.detailsHide).
81 unbind('click').click(function() {hideDetails(data.id)});
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +000082 }
83 });
Felix Meschbergerde0ceed2010-04-08 08:05:20 +000084 var details = "";
85 if (data.props) {
86 details += renderObjectAsTable(data.props);
87 }
88 if (data.usingBundles) {
89 details += renderUsingBundlesAsTable(data.usingBundles);
90 }
91 if (details) {
92 details = '<table border="0"><tbody>' + details + '</tbody></table>';
93 $('#pluginInlineDetails' + data.id).append( details );
94 }
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +000095}
96
97function renderObjectAsTable(/* Object*/ details) {
98 var txt = '';
99
100 for (var idx in details) {
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000101 var prop = details[idx];
102
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000103 txt += '<tr><td class="aligntop" noWrap="true" style="border:0px none">'
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000104 + prop.key
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000105 + '</td><td class="aligntop" style="border:0px none">';
Valentin Valchevf8370292014-07-14 12:38:23 +0000106 if (typeof prop.value !== 'undefined') {
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000107 if ($.isArray(prop.value)) {
108 var i = 0;
109 for ( var pi in prop.value) {
110 var value = prop.value[pi];
111 if (i > 0) {
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000112 txt = txt + '<br/>';
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000113 }
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000114 txt = txt + value;
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000115 i++;
116 }
117 } else {
118 txt = txt + prop.value;
119 }
120 } else {
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000121 txt = txt + '\u00a0';
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000122 }
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000123 txt = txt + '</td></tr>';
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000124 }
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000125
Felix Meschbergerde0ceed2010-04-08 08:05:20 +0000126 return txt;
127}
128
129function renderUsingBundlesAsTable(/* Object[] */ bundles) {
130 var txt = '';
131
132 for (var idx in bundles) {
133 var bundle = bundles[idx];
134 txt += '<a href="' + bundlePath + '/' + bundle.bundleId + '">'
135 + bundle.bundleSymbolicName + ' (' + bundle.bundleId + ')'
136 + '</a><br/>';
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000137 }
138
Felix Meschbergerde0ceed2010-04-08 08:05:20 +0000139 if (txt) {
140 txt = '<tr><td class="aligntop" noWrap="true" style="border:0px none">'
141 + i18n.usingBundles
142 + '</td><td class="aligntop" style="border:0px none">'
143 + txt
144 + '</td></tr>';
145 }
146
Felix Meschberger2fc6a6e2010-02-18 08:12:37 +0000147 return txt;
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000148}
149
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000150
Valentin Valchevf51fe432010-04-15 12:01:33 +0000151$(document).ready(function() {
152 tableBody = $('#plugin_table tbody');
153 tableEntryTemplate = tableBody.find('tr').clone();
154 tableBody.empty();
155
156 renderData(data);
157
158 $('#plugin_table').tablesorter( {
159 headers : {
Carsten Ziegeler12222fd2014-12-29 13:43:03 +0000160 0 : { sorter : 'digit' },
Carsten Ziegeler3b17bbf2015-01-05 12:26:20 +0000161 3 : { sorter : 'digit' }
Valentin Valchevf51fe432010-04-15 12:01:33 +0000162 },
163 sortList : [ [ 1, 0 ] ],
164 textExtraction : mixedLinksExtraction
Felix Meschbergerd46d5ac2009-11-26 12:28:54 +0000165 });
Valentin Valchevf51fe432010-04-15 12:01:33 +0000166});