1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

plugin catalog filtering

This commit is contained in:
Techywarrior 2013-04-03 20:56:02 -07:00
parent 74631a28d5
commit 317f06f607
2 changed files with 144 additions and 83 deletions

View file

@ -13,23 +13,39 @@
<a href="plugincatalog.html" data-role="button" class="ui-btn-active">Plugin Catalog</a>
<a href="pluginupdates.html" data-role="button">Automatic Updates</a>
</div>
<div class="hide" id="pluginServer" data-role="collapsible" data-content-theme="c" data-collapsed="false" style="margin-top: 2em;" data-theme="a">
<h3>Server</h3>
<div id="pluginServerTiles"></div>
<div class="viewSettings">
<button data-mini="true" data-icon="filter" data-inline="true" onclick="$('#filterPanel', $.mobile.activePage).panel( 'toggle' );">Filter</button>
</div>
<div class="hide" id="pluginMBTheatre" data-role="collapsible" data-content-theme="c" data-collapsed="false" style="margin-top: 2em;" data-theme="a">
<h3>MB Theatre</h3>
<div id="pluginMBTheatreTiles"></div>
</div>
<div class="hide" id="pluginMBClassic" data-role="collapsible" data-content-theme="c" data-collapsed="false" style="margin-top: 2em;" data-theme="a">
<h3>MB Classic</h3>
<div id="pluginMBClassicTiles"></div>
</div>
<div id="pluginTiles"></div>
</div>
</div>
<div data-role="panel" id="filterPanel" data-position="right" data-display="overlay" data-theme="b" data-position-fixed="true">
<form>
<fieldset data-role="controlgroup">
<legend>
<h3>Application:</h3>
</legend>
<input class="chkStandardFilter" type="checkbox" name="chkServer" id="chkServer" data-theme="c" data-filter="Server">
<label for="chkServer">Media Browser Server</label>
<input class="chkStandardFilter" type="checkbox" name="chkTheatre" id="chkTheatre" data-theme="c" data-filter="MBTheatre">
<label for="chkTheatre">Media Browser Theatre</label>
<input class="chkStandardFilter" type="checkbox" name="chkClassic" id="chkClassic" data-theme="c" data-filter="MBClassic">
<label for="chkClassic">Media Browser Classic</label>
</fieldset>
<fieldset data-role="controlgroup">
<legend>
<h3> </h3>
</legend>
<input class="chkPremiumFilter" type="checkbox" name="chkPremium" id="chkPremium" data-theme="c" data-filter="IsPremium">
<label for="chkPremium">Premium</label>
</fieldset>
</form>
</div>
</div>
</body>
</html>

View file

@ -1,94 +1,139 @@
var PluginCatalogPage = {
(function ($, document) {
onPageShow: function () {
PluginCatalogPage.reloadList();
},
// The base query options
var query = {
IsPremium: false,
TargetSystems: ""
};
reloadList: function () {
function reloadList() {
Dashboard.showLoadingMsg();
Dashboard.showLoadingMsg();
var promise1 = ApiClient.getAvailablePlugins();
var promise2 = ApiClient.getInstalledPlugins();
var promise1 = ApiClient.getAvailablePlugins(query);
var promise2 = ApiClient.getInstalledPlugins();
$.when(promise1, promise2).done(function (response1, response2) {
PluginCatalogPage.populateList(response1[0], response2[0]);
});
},
$.when(promise1, promise2).done(function (response1, response2) {
populateList(response1[0], response2[0]);
});
populateList: function (availablePlugins, installedPlugins) {
Dashboard.hideLoadingMsg();
}
var page = $($.mobile.activePage);
availablePlugins = availablePlugins.filter(function (p) {
return p.type == "UserInstalled";
}).sort(function (a, b) {
return a.name > b.name ? 1 : -1;
});
function populateList(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 += "<div class='posterViewItem'><a href='addPlugin.html?name=" + encodeURIComponent(plugin.name) + "'>";
if (plugin.thumbImage) {
html += "<img src='" + plugin.thumbImage + "' />";
} else {
html += "<img style='background:#444444;' src='css/images/items/list/collection.png' />";
}
if (plugin.isPremium) {
if (plugin.price > 0) {
html += "<div class='premiumBanner'><img src='css/images/supporter/premiumflag.png' /></div>";
} else {
html += "<div class='premiumBanner'><img src='css/images/supporter/supporterflag.png' /></div>";
}
}
var color = plugin.tileColor || LibraryBrowser.getMetroColor(plugin.name);
html += "<div class='posterViewItemText' style='background:" + color + "'>";
var installedPlugin = installedPlugins.filter(function (ip) {
return ip.Name == plugin.name;
})[0];
html += "<div>";
if (installedPlugin) {
html += plugin.name + " (Installed)";
} else {
html += plugin.name;
}
html += "</div>";
html += "</div>";
html += "</a></div>";
}
$('#pluginTiles', page).html(html);
Dashboard.hideLoadingMsg();
}
$(document).on('pageinit', "#pluginCatalogPage", function () {
var page = this;
var serverHtml = '';
var theatreHtml = '';
var classicHtml = '';
for (var i = 0, length = availablePlugins.length; i < length; i++) {
var html = "";
$('.chkStandardFilter', this).on('change', function () {
var plugin = availablePlugins[i];
var filterName = this.getAttribute('data-filter');
var filters = query.TargetSystems || "";
html += "<div class='posterViewItem'><a href='addPlugin.html?name=" + encodeURIComponent(plugin.name) + "'>";
filters = (',' + filters).replace(',' + filterName, '').substring(1);
if (plugin.thumbImage) {
html += "<img src='" + plugin.thumbImage + "' />";
} else {
html += "<img style='background:#444444;' src='css/images/items/list/collection.png' />";
}
if (this.checked) {
filters = filters ? (filters + ',' + filterName) : filterName;
}
if (plugin.isPremium) {
if (plugin.price > 0) {
html += "<div class='premiumBanner'><img src='css/images/supporter/premiumflag.png' /></div>";
} else {
html += "<div class='premiumBanner'><img src='css/images/supporter/supporterflag.png' /></div>";
}
}
query.TargetSystems = filters;
var color = plugin.tileColor || LibraryBrowser.getMetroColor(plugin.name);
reloadList();
});
html += "<div class='posterViewItemText' style='background:" + color + "'>";
$('.chkPremiumFilter', this).on('change', function () {
var installedPlugin = installedPlugins.filter(function (ip) {
return ip.Name == plugin.name;
})[0];
var filterName = this.getAttribute('data-filter');
html += "<div>";
if (installedPlugin) {
html += plugin.name + " (Installed)";
} else {
html += plugin.name;
}
html += "</div>";
if (this.checked) {
query.IsPremium = true;
}else {
query.IsPremium = false;
}
html += "</div>";
reloadList();
});
html += "</a></div>";
}).on('pageshow', "#pluginCatalogPage", function () {
if (plugin.targetSystem == 'Server') {
serverHtml += html;
}else if (plugin.targetSystem == 'MBTheater') {
theatreHtml += html;
}else if (plugin.targetSystem == 'MBClassic') {
classicHtml += html;
}
}
reloadList();
$('#pluginServerTiles', page).html(serverHtml);
$('#pluginMBTheatreTiles', page).html(theatreHtml);
$('#pluginMBClassicTiles', page).html(classicHtml);
// Reset form values using the last used query
if (serverHtml) $('#pluginServer', page).show();
if (theatreHtml) $('#pluginMBTheatre', page).show();
if (classicHtml) $('#pluginMBClassic', page).show();
$('.chkStandardFilter', this).each(function () {
Dashboard.hideLoadingMsg();
}
};
var filters = "," + (query.TargetSystems || "");
var filterName = this.getAttribute('data-filter');
$(document).on('pageshow', "#pluginCatalogPage", PluginCatalogPage.onPageShow);
this.checked = filters.indexOf(',' + filterName) != -1;
}).checkboxradio('refresh');
$('.chkPremiumFilter', this).each(function () {
var filters = query.IsPremium || false;
this.checked = filters;
}).checkboxradio('refresh');
});
})(jQuery, document);