Felix Meschberger | 9b3c4e0 | 2008-06-02 13:52:15 +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 | */ |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 17 | // ui elements |
| 18 | var uploadDialog = false; |
| 19 | var bundlesTable = false; |
| 20 | var bundlesBody = false; |
| 21 | var bundlesTemplate = false; |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 22 | var bundleOpError = false; |
Valentin Valchev | 46e3c9c | 2012-04-26 12:15:55 +0000 | [diff] [blame] | 23 | var bundleOpSuccess = false; |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 24 | |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 25 | function renderData( eventData, filter ) { |
| 26 | lastBundleData = eventData; |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 27 | var s = eventData.s; |
Carsten Ziegeler | 3566a9f | 2013-01-30 16:20:33 +0000 | [diff] [blame] | 28 | var statline = i18n.statlinePrefix + ' ' + i18n.statlineTotal.msgFormat(s[0]); |
Carsten Ziegeler | 322d874 | 2013-01-30 15:56:09 +0000 | [diff] [blame] | 29 | if ( s[0] == s[1] || s[0] == s[1] + s[2]) { |
| 30 | statline += ' - ' + i18n.statlineAll.msgFormat(s[0]); |
| 31 | } else { |
| 32 | if ( s[1] > 0 ) { |
Carsten Ziegeler | 3566a9f | 2013-01-30 16:20:33 +0000 | [diff] [blame] | 33 | statline += ', ' + i18n.statlineActive.msgFormat(s[1]); |
Carsten Ziegeler | 322d874 | 2013-01-30 15:56:09 +0000 | [diff] [blame] | 34 | } |
| 35 | if ( s[2] > 0 ) { |
Carsten Ziegeler | 3566a9f | 2013-01-30 16:20:33 +0000 | [diff] [blame] | 36 | statline += ', ' + i18n.statlineFragments.msgFormat(s[2]); |
Carsten Ziegeler | 322d874 | 2013-01-30 15:56:09 +0000 | [diff] [blame] | 37 | } |
| 38 | if ( s[3] > 0 ) { |
Carsten Ziegeler | 3566a9f | 2013-01-30 16:20:33 +0000 | [diff] [blame] | 39 | statline += ', ' + i18n.statlineResolved.msgFormat(s[3]); |
Carsten Ziegeler | 322d874 | 2013-01-30 15:56:09 +0000 | [diff] [blame] | 40 | } |
| 41 | if ( s[4] > 0 ) { |
Carsten Ziegeler | 3566a9f | 2013-01-30 16:20:33 +0000 | [diff] [blame] | 42 | statline += ', ' + i18n.statlineInstalled.msgFormat(s[4]); |
Carsten Ziegeler | 322d874 | 2013-01-30 15:56:09 +0000 | [diff] [blame] | 43 | } |
| 44 | } |
| 45 | $('.statline').html(statline); |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 46 | bundlesBody.empty(); |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 47 | for ( var idx in eventData.data ) { |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 48 | if ( currentBundle == null || !drawDetails || currentBundle == eventData.data[idx].id) { |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 49 | entry( eventData.data[idx], filter ); |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 50 | } |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 51 | } |
Carsten Ziegeler | 176aee4 | 2009-12-11 09:19:50 +0000 | [diff] [blame] | 52 | if ( drawDetails && eventData.data.length == 1 ) { |
Valentin Valchev | 8d9f103 | 2010-03-19 07:54:14 +0000 | [diff] [blame] | 53 | $('.filterBox input, .filterBox button').addClass('ui-state-disabled'); |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 54 | renderDetails(eventData.data[0]); |
Carsten Ziegeler | 176aee4 | 2009-12-11 09:19:50 +0000 | [diff] [blame] | 55 | } else if ( currentBundle != null ) { |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 56 | var id = currentBundle; |
| 57 | hideDetails(id); |
| 58 | showDetails(id); |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 59 | } |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 60 | initStaticWidgets(); |
Valentin Valchev | 88dbf70 | 2010-04-14 13:15:06 +0000 | [diff] [blame] | 61 | |
Felix Meschberger | 7efb546 | 2011-12-22 12:53:44 +0000 | [diff] [blame] | 62 | var cv = getCookie("bundlelist"); |
| 63 | if (cv) { |
| 64 | bundlesTable.trigger('sorton', [cv]); |
| 65 | } |
Valentin Valchev | 88dbf70 | 2010-04-14 13:15:06 +0000 | [diff] [blame] | 66 | |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 67 | // show dialog on error |
| 68 | if (eventData.error) bundleOpError.dialog('open').find('pre').text(eventData.error) |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 69 | } |
| 70 | |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 71 | function entry( /* Object */ bundle, filter ) { |
| 72 | var matches = !(filter && typeof filter.test == 'function') ? true : |
Valentin Valchev | 8d9f103 | 2010-03-19 07:54:14 +0000 | [diff] [blame] | 73 | filter.test(bundle.id) || filter.test(bundle.name) || filter.test(bundle.symbolicName) || filter.test(bundle.version) || filter.test(bundle.category); |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 74 | |
| 75 | if (matches) entryInternal( bundle ).appendTo(bundlesBody); |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 76 | } |
| 77 | |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 78 | function hasStart(b) { return (!b.fragment) && (b.stateRaw == 2 || b.stateRaw == 4) } // !isFragment && (installed | resolved) |
| 79 | function hasStop(b) { return (!b.fragment) && (b.stateRaw == 32) } // !isFragment && active |
| 80 | function hasUninstall(b) { return b.stateRaw == 2 || b.stateRaw == 4 || b.stateRaw == 32 } // installed | resolved | active |
| 81 | function stateString(b) { |
| 82 | var s = b.stateRaw; |
| 83 | return b.fragment && s == 4 ? |
| 84 | i18n.state.fragment : // fragment & resolved |
| 85 | i18n.state[s] ? i18n.state[s] : i18n.state.unknown.msgFormat(s) |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 86 | } |
| 87 | |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 88 | function entryInternal( /* Object */ bundle ) { |
| 89 | var tr = bundlesTemplate.clone(); |
| 90 | var id = bundle.id; |
Valentin Valchev | 8d9f103 | 2010-03-19 07:54:14 +0000 | [diff] [blame] | 91 | var name = bundle.name + '<span class="symName">' + bundle.symbolicName + '</span>'; |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 92 | |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 93 | tr.attr('id', 'entry'+id); |
Felix Meschberger | 8285c42 | 2012-03-26 20:10:45 +0000 | [diff] [blame] | 94 | tr.children('td:eq(0)').text(id); |
Valentin Valchev | 16bef4a | 2010-04-15 08:45:47 +0000 | [diff] [blame] | 95 | tr.find('.bIcon').attr('id', 'img'+id).click(function() {showDetails(id)}); |
| 96 | tr.find('.bName').html( drawDetails ? name : '<a href="' + pluginRoot + '/' + id + '">' + name + '</a>' ); |
Felix Meschberger | 8285c42 | 2012-03-26 20:10:45 +0000 | [diff] [blame] | 97 | tr.children('td:eq(2)').text( bundle.version ); |
| 98 | tr.children('td:eq(3)').text( bundle.category ); |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 99 | if (id == 0) { // system bundle has no actions |
Felix Meschberger | 8285c42 | 2012-03-26 20:10:45 +0000 | [diff] [blame] | 100 | tr.children('td:eq(4)').text( stateString(bundle) ); |
| 101 | tr.children('td:eq(5)').find('ul').addClass('ui-helper-hidden'); |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 102 | } else { |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 103 | entrySetupState( bundle, tr, id ); |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 104 | } |
| 105 | return tr; |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 106 | } |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 107 | function entrySetupState( /* Object */ bundle, tr, id) { |
Felix Meschberger | 8285c42 | 2012-03-26 20:10:45 +0000 | [diff] [blame] | 108 | var start = tr.children('td:eq(5)').find('ul li:eq(0)').removeClass('ui-helper-hidden').unbind('click'); |
| 109 | var stop = tr.children('td:eq(5)').find('ul li:eq(1)').removeClass('ui-helper-hidden').unbind('click'); |
| 110 | var refresh = tr.children('td:eq(5)').find('ul li:eq(2)').unbind('click').click(function() {return changeDataEntryState(id, 'refresh')}); |
| 111 | var update = tr.children('td:eq(5)').find('ul li:eq(3)').unbind('click').click(function() {return changeDataEntryState(id, 'update')}); |
| 112 | var remove = tr.children('td:eq(5)').find('ul li:eq(4)').removeClass('ui-helper-hidden').unbind('click'); |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 113 | start = hasStart(bundle) ? |
| 114 | start.click(function() {return changeDataEntryState(id, 'start')}) : |
| 115 | start.addClass('ui-helper-hidden'); |
| 116 | stop = hasStop(bundle) ? |
| 117 | stop.click(function() {return changeDataEntryState(id, 'stop')}) : |
| 118 | stop.addClass('ui-helper-hidden'); |
| 119 | remove = hasUninstall(bundle) ? |
| 120 | remove.click(function() {return changeDataEntryState(id, 'uninstall')}) : |
| 121 | remove.addClass('ui-helper-hidden'); |
Felix Meschberger | 8285c42 | 2012-03-26 20:10:45 +0000 | [diff] [blame] | 122 | tr.children('td:eq(4)').text( stateString(bundle) ); |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 123 | } |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 124 | |
| 125 | function loadData() { |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 126 | $.get(pluginRoot + "/.json", null, renderData, "json"); |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | function changeDataEntryState(/* long */ id, /* String */ action) { |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 130 | $.post(pluginRoot + '/' + id, {'action':action}, function(b) { |
| 131 | var _tr = bundlesBody.find('#entry' + id); |
| 132 | if (1 == b.stateRaw) { // uninstalled |
| 133 | _tr.remove(); |
| 134 | } else { |
| 135 | entrySetupState( b, _tr, id ); |
| 136 | } |
Valentin Valchev | 46e3c9c | 2012-04-26 12:15:55 +0000 | [diff] [blame] | 137 | if ('refresh' == action || 'update' == action) { |
| 138 | bundleOpSuccess.dialog('open'); |
| 139 | // TODO: |
| 140 | |
| 141 | } |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 142 | }, 'json'); |
| 143 | return false; |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | function refreshPackages() { |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 147 | $.post(pluginRoot, {"action": "refreshPackages"}, renderData, "json"); |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | function showDetails( id ) { |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 151 | currentBundle = id; |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 152 | $.get(pluginRoot + "/" + id + ".json", null, function(data) { |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 153 | renderDetails(data.data[0]); |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 154 | }, "json"); |
| 155 | } |
| 156 | |
| 157 | function hideDetails( id ) { |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 158 | currentBundle = null; |
| 159 | $("#img" + id).each(function() { |
| 160 | $("#pluginInlineDetails" + id).remove(); |
| 161 | $(this). |
| 162 | removeClass('ui-icon-triangle-1-w').//left |
| 163 | removeClass('ui-icon-triangle-1-s').//down |
| 164 | addClass('ui-icon-triangle-1-e').//right |
| 165 | attr("title", "Details"). |
| 166 | unbind('click').click(function() {showDetails(id)}); |
| 167 | }); |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | function renderDetails( data ) { |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 171 | $("#entry" + data.id + " > td").eq(1).append("<div id='pluginInlineDetails" + data.id + "'/>"); |
| 172 | $("#img" + data.id).each(function() { |
| 173 | if ( drawDetails ) { |
| 174 | var ref = window.location.pathname; |
| 175 | ref = ref.substring(0, ref.lastIndexOf('/')); |
| 176 | $(this). |
| 177 | removeClass('ui-icon-triangle-1-e').//right |
| 178 | removeClass('ui-icon-triangle-1-s').//down |
| 179 | addClass('ui-icon-triangle-1-w').//left |
| 180 | attr("title", "Back"). |
| 181 | unbind('click').click(function() {window.location = ref}); |
| 182 | } else { |
| 183 | $(this). |
| 184 | removeClass('ui-icon-triangle-1-w').//left |
| 185 | removeClass('ui-icon-triangle-1-e').//right |
| 186 | addClass('ui-icon-triangle-1-s').//down |
| 187 | attr("title", "Hide Details"). |
| 188 | unbind('click').click(function() {hideDetails(data.id)}); |
| 189 | } |
| 190 | }); |
| 191 | $("#pluginInlineDetails" + data.id).append("<table border='0'><tbody></tbody></table>"); |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 192 | var details = data.props; |
| 193 | for (var idx in details) { |
| 194 | var prop = details[idx]; |
Valentin Valchev | 57ba7bc | 2012-08-15 12:48:53 +0000 | [diff] [blame] | 195 | |
| 196 | if (prop.key == 'nfo') { |
| 197 | $.each(prop.value, function(name, bundleInfo) { |
| 198 | var txt = ''; |
| 199 | $.each(bundleInfo, function(idx, ie) { |
| 200 | txt += '<div title="' + makeSafe(ie.description) + '">'; |
| 201 | if (ie.type == 'link' || ie.type == 'resource') { |
| 202 | txt += '<a href="' + ie.value + '">' + ie.name + '</a>'; |
| 203 | } else { |
| 204 | txt += ie.name + " = " + ie.value; |
| 205 | } |
| 206 | txt += '</div>'; |
| 207 | }); |
| 208 | $("#pluginInlineDetails" + data.id + " > table > tbody").append( |
| 209 | renderDetailsEntry(name, txt) ); |
| 210 | }); |
| 211 | } else |
| 212 | $("#pluginInlineDetails" + data.id + " > table > tbody").append( |
| 213 | renderDetailsEntry(prop.key, prop.value) ); |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 214 | } |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 215 | } |
Valentin Valchev | 57ba7bc | 2012-08-15 12:48:53 +0000 | [diff] [blame] | 216 | function makeSafe(text) { |
| 217 | return text.replace(/\W/g, function (chr) { |
| 218 | return '&#' + chr.charCodeAt(0) + ';'; |
| 219 | }); |
| 220 | }; |
| 221 | |
| 222 | function renderDetailsEntry(key, value) { |
| 223 | var key18 = i18n[key] ? i18n[key] : key; |
| 224 | var txt = "<tr><td class='aligntop' noWrap='true' style='border:0px none'>" + key18 + "</td><td class='aligntop' style='border:0px none'>"; |
| 225 | if (value) { |
| 226 | if ( key == 'Bundle Documentation' ) { |
| 227 | txt += "<a href='" + value + "' target='_blank'>" + value + "</a>"; |
| 228 | } else { |
| 229 | if ( $.isArray(value) ) { |
| 230 | var i = 0; |
| 231 | for(var pi in value) { |
| 232 | var xv = value[pi]; |
| 233 | if (i > 0) { txt = txt + "<br/>"; } |
| 234 | var span; |
| 235 | if (xv.substring(0, 6) == "INFO: ") { |
| 236 | txt += "<span class='ui-state-info-text'>" + xv.substring(5) + "</span>"; |
| 237 | } else if (xv.substring(0, 7) == "ERROR: ") { |
| 238 | txt += "<span class='ui-state-error-text'>" + xv.substring(6) + "</span>"; |
| 239 | } else { |
| 240 | txt += xv; |
| 241 | } |
| 242 | i++; |
| 243 | } |
| 244 | } else { |
| 245 | txt += value; |
| 246 | } |
| 247 | } |
| 248 | } else { |
| 249 | txt += "\u00a0"; |
| 250 | } |
| 251 | return txt + "</td></tr>"; |
| 252 | } |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 253 | |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 254 | |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 255 | $(document).ready(function(){ |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 256 | $('.refreshPackages').click(refreshPackages); |
| 257 | $('.reloadButton').click(loadData); |
| 258 | $('.installButton').click(function() { |
| 259 | uploadDialog.dialog('open'); |
| 260 | return false; |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 261 | }); |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 262 | |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 263 | bundleOpError = $('#bundleOpError').dialog({ |
| 264 | autoOpen: false, |
| 265 | modal : true, |
| 266 | width : '80%' |
| 267 | }); |
| 268 | bundleOpError.parent().addClass('ui-state-error'); |
Valentin Valchev | 46e3c9c | 2012-04-26 12:15:55 +0000 | [diff] [blame] | 269 | bundleOpSuccess = $('#bundleOpSuccess').dialog({ |
| 270 | autoOpen: false, |
| 271 | modal : true, |
| 272 | width : '80%' |
| 273 | }); |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 274 | |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 275 | // filter |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 276 | $('.filterApply').click(function() { |
Valentin Valchev | 8d9f103 | 2010-03-19 07:54:14 +0000 | [diff] [blame] | 277 | if ($(this).hasClass('ui-state-disabled')) return; |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 278 | var el = $(this).parent().find('input.filter'); |
| 279 | var filter = el.length && el.val() ? new RegExp(el.val()) : false; |
| 280 | renderData(lastBundleData, filter); |
| 281 | }); |
| 282 | $('.filterForm').submit(function() { |
| 283 | $(this).find('.filterApply').click(); |
| 284 | return false; |
| 285 | }); |
| 286 | $('.filterClear').click(function() { |
Valentin Valchev | 8d9f103 | 2010-03-19 07:54:14 +0000 | [diff] [blame] | 287 | if ($(this).hasClass('ui-state-disabled')) return; |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 288 | $('input.filter').val(''); |
Valentin Valchev | 8d9f103 | 2010-03-19 07:54:14 +0000 | [diff] [blame] | 289 | loadData(); |
| 290 | }); |
| 291 | $('.filterLDAP').click(function() { |
| 292 | if ($(this).hasClass('ui-state-disabled')) return; |
| 293 | var el = $(this).parent().find('input.filter'); |
| 294 | var filter = el.val(); |
| 295 | if (filter) $.get(pluginRoot + '/.json', { 'filter' : filter }, renderData, 'json'); |
Valentin Valchev | e569ba2 | 2010-04-01 09:26:49 +0000 | [diff] [blame] | 296 | return false; |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 297 | }); |
| 298 | |
| 299 | // upload dialog |
| 300 | var uploadDialogButtons = {}; |
| 301 | uploadDialogButtons[i18n.install_update] = function() { |
| 302 | $(this).find('form').submit(); |
| 303 | } |
| 304 | uploadDialog = $('#uploadDialog').dialog({ |
| 305 | autoOpen: false, |
| 306 | modal : true, |
| 307 | width : '50%', |
| 308 | buttons : uploadDialogButtons |
| 309 | }); |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 310 | |
| 311 | // check for cookie |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 312 | bundlesTable = $("#plugin_table").tablesorter({ |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 313 | headers: { |
| 314 | 0: { sorter:"digit" }, |
| 315 | 5: { sorter: false } |
| 316 | }, |
Valentin Valchev | 16bef4a | 2010-04-15 08:45:47 +0000 | [diff] [blame] | 317 | textExtraction:mixedLinksExtraction |
Felix Meschberger | efc5de5 | 2012-12-02 18:44:51 +0000 | [diff] [blame] | 318 | }).bind("sortEnd", function(/* Event */ e) { |
| 319 | var t = e.target.config; |
| 320 | if (t && t.sortList) { |
Felix Meschberger | 7efb546 | 2011-12-22 12:53:44 +0000 | [diff] [blame] | 321 | setCookie("bundlelist", t.sortList); |
| 322 | } |
| 323 | }); |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 324 | bundlesBody = bundlesTable.find('tbody'); |
| 325 | bundlesTemplate = bundlesBody.find('tr').clone(); |
| 326 | |
| 327 | renderData(lastBundleData); |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 328 | }); |
| 329 | |