var PluginsPage = { onPageShow: function () { PluginsPage.reloadList(this); }, reloadList: function (page) { Dashboard.showLoadingMsg(); var promise1 = ApiClient.getInstalledPlugins(); var promise2 = $.getJSON("configurationpages?pageType=PluginConfiguration"); $.when(promise1, promise2).done(function (response1, response2) { PluginsPage.populateList(page, response1[0], response2[0]); }); }, populateList: function (page, plugins, pluginConfigurationPages) { plugins = plugins.sort(function (plugin1, plugin2) { return (plugin1.Name) > (plugin2.Name) ? 1 : -1; }); var html = ""; for (var i = 0, length = plugins.length; i < length; i++) { var plugin = plugins[i]; var configPage = $.grep(pluginConfigurationPages, function (pluginConfigurationPage) { return pluginConfigurationPage.PluginId == plugin.Id; })[0]; html += "
  • "; if (configPage) { html += ""; } else { html += ""; } html += "

    " + plugin.Name + "

    "; html += "

    " + plugin.Version + "

    "; html += "
    "; html += "" + Globalize.translate("Delete") + ""; html += "
  • "; } if (!plugins.length) { html += '
  • '; html += '

    You have no plugins installed.

    '; html += '

    '; html += Globalize.translate("BrowsePluginCatalogMessage"); html += '

    '; html += '
  • '; $('#ulInstalledPlugins', page).html(html); } else { $('#ulInstalledPlugins', page).html(html).listview('refresh'); } Dashboard.hideLoadingMsg(); }, deletePlugin: function (link) { var page = $(link).parents('.page'); var name = link.getAttribute('data-pluginname'); var uniqueid = link.getAttribute('data-id'); var msg = Globalize.translate("UninstallPluginConfirmation").replace("{0}", name); Dashboard.confirm(msg, Globalize.translate("UninstallPluginHeader"), function (result) { if (result) { Dashboard.showLoadingMsg(); ApiClient.uninstallPlugin(uniqueid).done(function () { PluginsPage.reloadList(page); }); } }); } }; $(document).on('pageshow', "#pluginsPage", PluginsPage.onPageShow);