(function ($, document) {
// The base query options
var query = {
TargetSystems: 'Server'
};
function getApps() {
var apps = [];
apps.push({
type: "UserInstalled",
name: "MBKinect",
category: "Voice Control",
isApp: true,
tileColor: "#050810",
thumbImage: "https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/images/mbkinect/thumb.png",
externalUrl: "http://mediabrowser3.com/community/index.php?/topic/850-media-browser-kinect-sensor-plug-in-support/",
isPremium: false
});
return apps;
}
function getAppsPromise() {
var deferred = $.Deferred();
deferred.resolveWith(null, [[getApps()]]);
return deferred.promise();
}
function reloadList(page) {
Dashboard.showLoadingMsg();
var promise1 = query.TargetSystems == "Apps" ? getAppsPromise() : ApiClient.getAvailablePlugins(query);
var promise2 = ApiClient.getInstalledPlugins();
$.when(promise1, promise2).done(function (response1, response2) {
populateList(page, response1[0], response2[0]);
});
}
function populateList(page, availablePlugins, installedPlugins) {
Dashboard.showLoadingMsg();
availablePlugins = availablePlugins.filter(function (p) {
return p.type == "UserInstalled";
}).sort(function (a, b) {
var aName = (a.category || "General") + " " + a.name;
var bame = (b.category || "General") + " " + b.name;
return aName > bame ? 1 : -1;
});
var pluginhtml = '';
var currentCategory;
for (var i = 0, length = availablePlugins.length; i < length; i++) {
var html = '';
var plugin = availablePlugins[i];
var category = plugin.category || "General";
if (category != currentCategory) {
if (currentCategory) {
html += '
';
html += '
';
html += '
';
}
html += '