Felix Meschberger | 407b3eb | 2008-06-13 05:28:27 +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 | |
Felix Meschberger | d39ce9a | 2010-02-19 10:09:34 +0000 | [diff] [blame] | 18 | var licenseButtons = false; |
| 19 | var licenseDetails = false; |
| 20 | |
Felix Meschberger | 407b3eb | 2008-06-13 05:28:27 +0000 | [diff] [blame] | 21 | function displayBundle(/* String */ bundleId) |
| 22 | { |
| 23 | var theBundleData = bundleData[bundleId]; |
| 24 | if (!theBundleData) |
| 25 | { |
| 26 | return; |
| 27 | } |
| 28 | |
| 29 | var title = theBundleData.title; |
| 30 | |
Felix Meschberger | 407b3eb | 2008-06-13 05:28:27 +0000 | [diff] [blame] | 31 | if (licenseButtons) { |
| 32 | |
| 33 | var innerHTML = ""; |
| 34 | for (var name in theBundleData.files) |
| 35 | { |
| 36 | var entry = theBundleData.files[name]; |
| 37 | var buttons = ""; |
| 38 | for (var idx in entry) |
| 39 | { |
| 40 | var descr = entry[idx]; |
Felix Meschberger | d39ce9a | 2010-02-19 10:09:34 +0000 | [diff] [blame] | 41 | var jar = descr.jar ? '&jar=' + descr.jar : ''; // inner jar attribute |
| 42 | buttons += '<a href="' + pluginRoot + '?bid=' + bundleId + '&url=' + descr.path + jar + '" target="licenseDetails">' + descr.url + '</a> '; |
Felix Meschberger | 407b3eb | 2008-06-13 05:28:27 +0000 | [diff] [blame] | 43 | } |
| 44 | if (buttons) |
| 45 | { |
Felix Meschberger | d39ce9a | 2010-02-19 10:09:34 +0000 | [diff] [blame] | 46 | // apply i18n |
| 47 | name = '__res__' == name ? i18n.resources : i18n.resources_emb.msgFormat( name ); |
Felix Meschberger | 407b3eb | 2008-06-13 05:28:27 +0000 | [diff] [blame] | 48 | innerHTML += name + ": " + buttons + "<br />"; |
| 49 | } |
| 50 | } |
Felix Meschberger | d39ce9a | 2010-02-19 10:09:34 +0000 | [diff] [blame] | 51 | |
| 52 | licenseButtons.html("<h1>" + title + "</h1>" + innerHTML); |
Felix Meschberger | 407b3eb | 2008-06-13 05:28:27 +0000 | [diff] [blame] | 53 | } |
| 54 | |
Felix Meschberger | d39ce9a | 2010-02-19 10:09:34 +0000 | [diff] [blame] | 55 | licenseDetails.html(""); |
| 56 | $("#licenseLeft a").removeClass('ui-state-default ui-corner-all'); |
| 57 | $("#licenseLeft #" +bundleId).addClass('ui-state-default ui-corner-all'); |
Felix Meschberger | 407b3eb | 2008-06-13 05:28:27 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Felix Meschberger | d39ce9a | 2010-02-19 10:09:34 +0000 | [diff] [blame] | 60 | |
| 61 | $(document).ready(function() { |
| 62 | // init elements cache |
| 63 | licenseButtons = $("#licenseButtons"); |
| 64 | licenseDetails = $("#licenseDetails") |
| 65 | |
| 66 | // render list of bundles |
| 67 | var txt = ""; |
| 68 | for(id in bundleData) { |
| 69 | txt += '<a id="' + id + '" href="javascript:displayBundle(\'' + id + '\')">' + bundleData[id]['title'] + '</a>'; |
| 70 | } |
| 71 | if (txt) { |
| 72 | $("#licenseLeft").html(txt); |
| 73 | } else { |
| 74 | $(".statline").html(i18n.status_none); |
| 75 | } |
| 76 | |
| 77 | // display first element |
| 78 | for(i in bundleData) {displayBundle(i);break;} |
| 79 | }); |