Valentin Valchev | 2144f3c | 2012-04-25 12:24:38 +0000 | [diff] [blame] | 1 | /*
|
| 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 |
|
| 18 | var findField = false;
|
| 19 | var findButton = false;
|
| 20 | var findTable = false;
|
| 21 | var findTableBody = false;
|
| 22 | var findTableTemplate = false;
|
| 23 | var dupsTable = false;
|
| 24 | var dupsTableBody = false;
|
| 25 | var dupsTableTemplate = false;
|
| 26 | var statline = false;
|
| 27 |
|
| 28 | function linkBundle(bnd) { return '<a href="{0}/bundles/{1}">{2} ({3})</a>'.msgFormat(appRoot, bnd.bid, bnd.bsn, bnd.bid) }
|
| 29 |
|
| 30 | $(function() {
|
| 31 | findField = $('#findField');
|
| 32 | statline = $('.statline');
|
| 33 |
|
| 34 | findTable = $('#findTable').tablesorter({
|
| 35 | headers:{
|
| 36 | 1:{sorter: false},
|
| 37 | 3:{sorter: false}
|
| 38 | },
|
| 39 | textExtraction:mixedLinksExtraction
|
| 40 | });
|
| 41 | findTableBody = findTable.find('tbody');
|
| 42 | findTableTemplate = findTableBody.find('tr').clone();
|
| 43 | findTableBody.empty();
|
| 44 |
|
| 45 | dupsTable = $('#dupsTable');
|
| 46 | dupsTableBody = dupsTable.find('tbody');
|
| 47 | dupsTableTemplate = dupsTableBody.find('tr').clone();
|
| 48 |
|
| 49 | $('#findButton').click(function() {
|
| 50 | if(!findField.val()) {
|
| 51 | findField.addClass('ui-state-error');
|
| 52 | } else {
|
| 53 | findField.removeClass('ui-state-error');
|
| 54 |
|
| 55 | $.post(pluginRoot, { 'action': 'deps', 'plugin.find' : findField.val() }, function(response) {
|
| 56 | dupsTable.addClass('ui-helper-hidden')
|
| 57 | findTable.removeClass('ui-helper-hidden');
|
| 58 | findTableBody.empty();
|
| 59 | if (response.packages) for(var i in response.packages) {
|
| 60 | var pkg = response.packages[i];
|
| 61 | if (pkg.exporters) for(var i in pkg.exporters) {
|
| 62 | var exp = pkg.exporters[i];
|
| 63 | var tr = findTableTemplate.clone()
|
| 64 | .find('td.pkg').text(pkg.name).end()
|
| 65 | .find('td.ver').text(exp.version).end()
|
| 66 | .find('td.bnd').html(linkBundle(exp)).end()
|
| 67 | .appendTo(findTableBody);
|
| 68 | if (response.maven && response.maven[exp.bid]) {
|
| 69 | var mvn = response.maven[exp.bid];
|
| 70 | mvn['scope'] = 'provided';
|
| 71 | var txt = ''; for (var p in mvn) {
|
| 72 | txt += '\t<' + p + '>' + mvn[p] + '</' + p + '>\n';
|
| 73 | }
|
| 74 | tr.find('td.mvn').text('<dependency>\n' + txt + '</dependency>');
|
| 75 | }
|
| 76 | } else {
|
| 77 | var tr = findTableTemplate.clone()
|
| 78 | .find('td.pkg').text(pkg.name).end()
|
| 79 | .appendTo(findTableBody);
|
| 80 | }
|
| 81 | }
|
| 82 | statline.text(i18n.statusFind.msgFormat(response.packages ? response.packages.length : 0));
|
| 83 | findTable.trigger('update').trigger('applyWidgets')
|
| 84 | }, 'json');
|
| 85 | }
|
| 86 | return false;
|
| 87 | });
|
| 88 |
|
| 89 | $('#findDups').click(function() {
|
| 90 | $.post(pluginRoot, { 'action': 'dups' }, function(response) {
|
| 91 | findTable.addClass('ui-helper-hidden');
|
| 92 | dupsTable.removeClass('ui-helper-hidden')
|
| 93 | dupsTableBody.empty();
|
| 94 | if (response) for(var i in response) {
|
| 95 | var pkg = response[i];
|
| 96 | if (pkg.entries) for (var i in pkg.entries) {
|
| 97 | var exp = pkg.entries[i];
|
| 98 | var td = dupsTableTemplate.clone()
|
| 99 | .find('td.pkg').text(pkg.name).end()
|
| 100 | .find('td.ver').text(exp.version).end()
|
| 101 | .find('td.exp').html(linkBundle(exp)).end();
|
| 102 | if (exp.importers) {
|
| 103 | var txt = ''; for(var j in exp.importers) txt += linkBundle(exp.importers[j]) + '<br/>';
|
| 104 | td.find('td.imp').html( txt );
|
| 105 | }
|
| 106 | if (i==0) {
|
| 107 | td.find('td.pkg').attr('rowspan', pkg.entries.length);
|
| 108 | } else {
|
| 109 | td.find('td.pkg').remove();
|
| 110 | }
|
| 111 | td.appendTo(dupsTableBody);
|
| 112 | }
|
| 113 | }
|
| 114 | statline.text(i18n.statusDups.msgFormat(response ? response.length : 0));
|
| 115 | }, 'json');
|
| 116 |
|
| 117 | return false;
|
| 118 | });
|
| 119 |
|
| 120 | })
|