var PluginCatalogPage = { onPageShow: function () { PluginCatalogPage.reloadList(); }, reloadList: function () { Dashboard.showLoadingMsg(); var promise1 = ApiClient.getAvailablePlugins(); var promise2 = ApiClient.getInstalledPlugins(); $.when(promise1, promise2).done(function (response1, response2) { PluginCatalogPage.populateList(response1[0], response2[0]); }); }, populateList: function (availablePlugins, installedPlugins) { var page = $($.mobile.activePage); availablePlugins = availablePlugins.filter(function (p) { return p.type == "UserInstalled"; }).sort(function (a, b) { return a.name > b.name ? 1 : -1; }); var html = ""; for (var i = 0, length = availablePlugins.length; i < length; i++) { var plugin = availablePlugins[i]; html += "
"; if (plugin.thumbImage) { html += ""; } else { html += ""; } if (plugin.isPremium) { if (plugin.price > 0) { html += "
"; } else { html += "
"; } } var color = plugin.tileColor || LibraryBrowser.getMetroColor(plugin.name); html += "
"; var installedPlugin = installedPlugins.filter(function (ip) { return ip.Name == plugin.name; })[0]; html += "
"; if (installedPlugin) { html += plugin.name + " (Installed)"; } else { html += plugin.name; } html += "
"; html += "
"; html += "
"; } $('#pluginTiles', page).html(html); Dashboard.hideLoadingMsg(); } }; $(document).on('pageshow', "#pluginCatalogPage", PluginCatalogPage.onPageShow);