import loading from 'loading'; import libraryMenu from 'libraryMenu'; import globalize from 'globalize'; import 'cardStyle'; import 'emby-button'; import 'emby-checkbox'; import 'emby-select'; function reloadList(page) { loading.show(); const promise1 = ApiClient.getAvailablePlugins(); const promise2 = ApiClient.getInstalledPlugins(); Promise.all([promise1, promise2]).then(function (responses) { populateList({ catalogElement: page.querySelector('#pluginTiles'), noItemsElement: page.querySelector('#noPlugins'), availablePlugins: responses[0], installedPlugins: responses[1] }); }); } function getHeaderText(category) { category = category.replace(' ', ''); // TODO: Replace with switch if (category === 'Channel') { category = 'Channels'; } else if (category === 'Theme') { category = 'Themes'; } else if (category === 'LiveTV') { category = 'LiveTV'; } else if (category === 'ScreenSaver') { category = 'HeaderScreenSavers'; } return globalize.translate(category); } function populateList(options) { const availablePlugins = options.availablePlugins; const installedPlugins = options.installedPlugins; availablePlugins.forEach(function (plugin, index, array) { plugin.category = plugin.category || 'General'; plugin.categoryDisplayName = getHeaderText(plugin.category); array[index] = plugin; }); availablePlugins.sort(function (a, b) { if (a.category > b.category) { return 1; } else if (b.category > a.category) { return -1; } if (a.name > b.name) { return 1; } else if (b.name > a.name) { return -1; } return 0; }); let currentCategory = null; let html = ''; for (let i = 0; i < availablePlugins.length; i++) { const plugin = availablePlugins[i]; const category = plugin.categoryDisplayName; if (category != currentCategory) { if (currentCategory) { html += ''; html += ''; } html += '