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="plugincatalog.html" data-role="button" class="ui-btn-active">Plugin Catalog</a>
<a href="pluginupdates.html" data-role="button">Automatic Updates</a> <a href="pluginupdates.html" data-role="button">Automatic Updates</a>
</div> </div>
<div class="viewSettings">
<div class="hide" id="pluginServer" data-role="collapsible" data-content-theme="c" data-collapsed="false" style="margin-top: 2em;" data-theme="a"> <button data-mini="true" data-icon="filter" data-inline="true" onclick="$('#filterPanel', $.mobile.activePage).panel( 'toggle' );">Filter</button>
<h3>Server</h3>
<div id="pluginServerTiles"></div>
</div> </div>
<div class="hide" id="pluginMBTheatre" data-role="collapsible" data-content-theme="c" data-collapsed="false" style="margin-top: 2em;" data-theme="a"> <div id="pluginTiles"></div>
<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> </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> </div>
</body> </body>
</html> </html>

View file

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