blob: ca3744fc647118f73e4d35c02223f0a99c28d6f3 [file] [log] [blame]
Felix Meschbergerab2b4f02008-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 Meschbergerd219cc72010-02-19 10:09:34 +000018var licenseButtons = false;
19var licenseDetails = false;
20
Felix Meschberger7b9f7512010-02-23 09:26:00 +000021/*
22 * Fuction called after receiving the license data from the server to insert
23 * it into the licenseDetails div
24 * Because IE does not properly support the white-space:pre CSS setting when
25 * DOM-loading data into a <pre> element, the licenseDetails element is a
26 * <div> into which we insert the data surrounded by <pre>-</pre> tags as
27 * innerHtml. This also works in IE.
28 */
29function insertLicenseData( /* String */ data )
30{
31 licenseDetails.html( "<pre>" + data + "</pre>" );
32}
33
Felix Meschberger321618f2010-02-21 15:43:43 +000034function displayBundle(/* String */ bundleIndex)
Felix Meschbergerab2b4f02008-06-13 05:28:27 +000035{
Felix Meschberger321618f2010-02-21 15:43:43 +000036 var theBundleData = bundleData[bundleIndex];
Felix Meschbergerab2b4f02008-06-13 05:28:27 +000037 if (!theBundleData)
38 {
39 return;
40 }
41
42 var title = theBundleData.title;
43
Felix Meschbergerab2b4f02008-06-13 05:28:27 +000044 if (licenseButtons) {
45
46 var innerHTML = "";
47 for (var name in theBundleData.files)
48 {
49 var entry = theBundleData.files[name];
50 var buttons = "";
Felix Meschberger9efe9ae2010-02-20 18:42:55 +000051 var firstPage = null;
Felix Meschbergerab2b4f02008-06-13 05:28:27 +000052 for (var idx in entry)
53 {
54 var descr = entry[idx];
Felix Meschberger321618f2010-02-21 15:43:43 +000055
56 var link = pluginRoot + "/" + theBundleData.bid;
57 if (descr.jar)
58 {
59 link += descr.jar + "!/"; // inner jar attribute
60 }
61 link += descr.path;
62
Felix Meschberger9efe9ae2010-02-20 18:42:55 +000063 buttons += '<a href="' + link + '">' + descr.url + '</a> ';
Felix Meschberger321618f2010-02-21 15:43:43 +000064
65 if (!firstPage)
66 {
Felix Meschberger9efe9ae2010-02-20 18:42:55 +000067 firstPage = link;
68 }
Felix Meschbergerab2b4f02008-06-13 05:28:27 +000069 }
70 if (buttons)
71 {
Felix Meschbergerd219cc72010-02-19 10:09:34 +000072 // apply i18n
73 name = '__res__' == name ? i18n.resources : i18n.resources_emb.msgFormat( name );
Felix Meschbergerab2b4f02008-06-13 05:28:27 +000074 innerHTML += name + ": " + buttons + "<br />";
75 }
76 }
Felix Meschbergerd219cc72010-02-19 10:09:34 +000077
78 licenseButtons.html("<h1>" + title + "</h1>" + innerHTML);
Felix Meschbergerab2b4f02008-06-13 05:28:27 +000079 }
80
Felix Meschberger9efe9ae2010-02-20 18:42:55 +000081 if (firstPage) {
Felix Meschberger7b9f7512010-02-23 09:26:00 +000082 $.get(firstPage, insertLicenseData);
Felix Meschberger9efe9ae2010-02-20 18:42:55 +000083 } else {
84 licenseDetails.html("");
85 }
86
Felix Meschbergerd219cc72010-02-19 10:09:34 +000087 $("#licenseLeft a").removeClass('ui-state-default ui-corner-all');
Felix Meschberger321618f2010-02-21 15:43:43 +000088 $("#licenseLeft #" +bundleIndex).addClass('ui-state-default ui-corner-all');
Felix Meschberger9efe9ae2010-02-20 18:42:55 +000089
90 $('#licenseButtons a').click(function() {
Felix Meschberger7b9f7512010-02-23 09:26:00 +000091 $.get(this.href, insertLicenseData);
Felix Meschberger9efe9ae2010-02-20 18:42:55 +000092 return false;
93 });
Felix Meschbergerab2b4f02008-06-13 05:28:27 +000094}
95
Felix Meschbergerd219cc72010-02-19 10:09:34 +000096
97$(document).ready(function() {
98 // init elements cache
99 licenseButtons = $("#licenseButtons");
100 licenseDetails = $("#licenseDetails")
101
102 // render list of bundles
103 var txt = "";
104 for(id in bundleData) {
Felix Meschberger321618f2010-02-21 15:43:43 +0000105 txt += '<a id="' + id + '" href="javascript:displayBundle(\'' + id + '\')">' + bundleData[id].title + '</a>';
Felix Meschbergerd219cc72010-02-19 10:09:34 +0000106 }
107 if (txt) {
108 $("#licenseLeft").html(txt);
109 } else {
110 $(".statline").html(i18n.status_none);
111 }
112
113 // display first element
Felix Meschberger321618f2010-02-21 15:43:43 +0000114 displayBundle(0);
Felix Meschbergerd219cc72010-02-19 10:09:34 +0000115});