blob: f378161f1358a3181c567952cdc992c29abfcebb [file] [log] [blame]
Felix Meschberger407b3eb2008-06-13 05:28:27 +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
Felix Meschbergerd39ce9a2010-02-19 10:09:34 +000018var licenseButtons = false;
19var licenseDetails = false;
20
Felix Meschberger407b3eb2008-06-13 05:28:27 +000021function displayBundle(/* String */ bundleId)
22{
23 var theBundleData = bundleData[bundleId];
24 if (!theBundleData)
25 {
26 return;
27 }
28
29 var title = theBundleData.title;
30
Felix Meschberger407b3eb2008-06-13 05:28:27 +000031 if (licenseButtons) {
32
33 var innerHTML = "";
34 for (var name in theBundleData.files)
35 {
36 var entry = theBundleData.files[name];
37 var buttons = "";
Felix Meschbergercf2b6772010-02-20 18:42:55 +000038 var firstPage = null;
Felix Meschberger407b3eb2008-06-13 05:28:27 +000039 for (var idx in entry)
40 {
41 var descr = entry[idx];
Felix Meschbergerd39ce9a2010-02-19 10:09:34 +000042 var jar = descr.jar ? '&jar=' + descr.jar : ''; // inner jar attribute
Felix Meschbergercf2b6772010-02-20 18:42:55 +000043 var link = pluginRoot + '?bid=' + bundleId + '&url=' + descr.path + jar;
44 buttons += '<a href="' + link + '">' + descr.url + '</a> ';
45 if (!firstPage) {
46 firstPage = link;
47 }
Felix Meschberger407b3eb2008-06-13 05:28:27 +000048 }
49 if (buttons)
50 {
Felix Meschbergerd39ce9a2010-02-19 10:09:34 +000051 // apply i18n
52 name = '__res__' == name ? i18n.resources : i18n.resources_emb.msgFormat( name );
Felix Meschberger407b3eb2008-06-13 05:28:27 +000053 innerHTML += name + ": " + buttons + "<br />";
54 }
55 }
Felix Meschbergerd39ce9a2010-02-19 10:09:34 +000056
57 licenseButtons.html("<h1>" + title + "</h1>" + innerHTML);
Felix Meschberger407b3eb2008-06-13 05:28:27 +000058 }
59
Felix Meschbergercf2b6772010-02-20 18:42:55 +000060 if (firstPage) {
61 licenseDetails.load(firstPage);
62 } else {
63 licenseDetails.html("");
64 }
65
Felix Meschbergerd39ce9a2010-02-19 10:09:34 +000066 $("#licenseLeft a").removeClass('ui-state-default ui-corner-all');
67 $("#licenseLeft #" +bundleId).addClass('ui-state-default ui-corner-all');
Felix Meschbergercf2b6772010-02-20 18:42:55 +000068
69 $('#licenseButtons a').click(function() {
70 licenseDetails.load(this.href);
71 return false;
72 });
Felix Meschberger407b3eb2008-06-13 05:28:27 +000073}
74
Felix Meschbergerd39ce9a2010-02-19 10:09:34 +000075
76$(document).ready(function() {
77 // init elements cache
78 licenseButtons = $("#licenseButtons");
79 licenseDetails = $("#licenseDetails")
80
81 // render list of bundles
82 var txt = "";
83 for(id in bundleData) {
84 txt += '<a id="' + id + '" href="javascript:displayBundle(\'' + id + '\')">' + bundleData[id]['title'] + '</a>';
85 }
86 if (txt) {
87 $("#licenseLeft").html(txt);
88 } else {
89 $(".statline").html(i18n.status_none);
90 }
91
92 // display first element
93 for(i in bundleData) {displayBundle(i);break;}
94});