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 | 1b88617 | 2010-02-21 15:43:43 +0000 | [diff] [blame] | 21 | function displayBundle(/* String */ bundleIndex) |
Felix Meschberger | 407b3eb | 2008-06-13 05:28:27 +0000 | [diff] [blame] | 22 | { |
Felix Meschberger | 1b88617 | 2010-02-21 15:43:43 +0000 | [diff] [blame] | 23 | var theBundleData = bundleData[bundleIndex]; |
Felix Meschberger | 407b3eb | 2008-06-13 05:28:27 +0000 | [diff] [blame] | 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 = ""; |
Felix Meschberger | cf2b677 | 2010-02-20 18:42:55 +0000 | [diff] [blame] | 38 | var firstPage = null; |
Felix Meschberger | 407b3eb | 2008-06-13 05:28:27 +0000 | [diff] [blame] | 39 | for (var idx in entry) |
| 40 | { |
| 41 | var descr = entry[idx]; |
Felix Meschberger | 1b88617 | 2010-02-21 15:43:43 +0000 | [diff] [blame] | 42 | |
| 43 | var link = pluginRoot + "/" + theBundleData.bid; |
| 44 | if (descr.jar) |
| 45 | { |
| 46 | link += descr.jar + "!/"; // inner jar attribute |
| 47 | } |
| 48 | link += descr.path; |
| 49 | |
Felix Meschberger | cf2b677 | 2010-02-20 18:42:55 +0000 | [diff] [blame] | 50 | buttons += '<a href="' + link + '">' + descr.url + '</a> '; |
Felix Meschberger | 1b88617 | 2010-02-21 15:43:43 +0000 | [diff] [blame] | 51 | |
| 52 | if (!firstPage) |
| 53 | { |
Felix Meschberger | cf2b677 | 2010-02-20 18:42:55 +0000 | [diff] [blame] | 54 | firstPage = link; |
| 55 | } |
Felix Meschberger | 407b3eb | 2008-06-13 05:28:27 +0000 | [diff] [blame] | 56 | } |
| 57 | if (buttons) |
| 58 | { |
Felix Meschberger | d39ce9a | 2010-02-19 10:09:34 +0000 | [diff] [blame] | 59 | // apply i18n |
| 60 | name = '__res__' == name ? i18n.resources : i18n.resources_emb.msgFormat( name ); |
Felix Meschberger | 407b3eb | 2008-06-13 05:28:27 +0000 | [diff] [blame] | 61 | innerHTML += name + ": " + buttons + "<br />"; |
| 62 | } |
| 63 | } |
Felix Meschberger | d39ce9a | 2010-02-19 10:09:34 +0000 | [diff] [blame] | 64 | |
| 65 | licenseButtons.html("<h1>" + title + "</h1>" + innerHTML); |
Felix Meschberger | 407b3eb | 2008-06-13 05:28:27 +0000 | [diff] [blame] | 66 | } |
| 67 | |
Felix Meschberger | cf2b677 | 2010-02-20 18:42:55 +0000 | [diff] [blame] | 68 | if (firstPage) { |
| 69 | licenseDetails.load(firstPage); |
| 70 | } else { |
| 71 | licenseDetails.html(""); |
| 72 | } |
| 73 | |
Felix Meschberger | d39ce9a | 2010-02-19 10:09:34 +0000 | [diff] [blame] | 74 | $("#licenseLeft a").removeClass('ui-state-default ui-corner-all'); |
Felix Meschberger | 1b88617 | 2010-02-21 15:43:43 +0000 | [diff] [blame] | 75 | $("#licenseLeft #" +bundleIndex).addClass('ui-state-default ui-corner-all'); |
Felix Meschberger | cf2b677 | 2010-02-20 18:42:55 +0000 | [diff] [blame] | 76 | |
| 77 | $('#licenseButtons a').click(function() { |
| 78 | licenseDetails.load(this.href); |
| 79 | return false; |
| 80 | }); |
Felix Meschberger | 407b3eb | 2008-06-13 05:28:27 +0000 | [diff] [blame] | 81 | } |
| 82 | |
Felix Meschberger | d39ce9a | 2010-02-19 10:09:34 +0000 | [diff] [blame] | 83 | |
| 84 | $(document).ready(function() { |
| 85 | // init elements cache |
| 86 | licenseButtons = $("#licenseButtons"); |
| 87 | licenseDetails = $("#licenseDetails") |
| 88 | |
| 89 | // render list of bundles |
| 90 | var txt = ""; |
| 91 | for(id in bundleData) { |
Felix Meschberger | 1b88617 | 2010-02-21 15:43:43 +0000 | [diff] [blame] | 92 | txt += '<a id="' + id + '" href="javascript:displayBundle(\'' + id + '\')">' + bundleData[id].title + '</a>'; |
Felix Meschberger | d39ce9a | 2010-02-19 10:09:34 +0000 | [diff] [blame] | 93 | } |
| 94 | if (txt) { |
| 95 | $("#licenseLeft").html(txt); |
| 96 | } else { |
| 97 | $(".statline").html(i18n.status_none); |
| 98 | } |
| 99 | |
| 100 | // display first element |
Felix Meschberger | 1b88617 | 2010-02-21 15:43:43 +0000 | [diff] [blame] | 101 | displayBundle(0); |
Felix Meschberger | d39ce9a | 2010-02-19 10:09:34 +0000 | [diff] [blame] | 102 | }); |