mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
pass page instead of using $.mobile.activePage
This commit is contained in:
parent
5bc5d6a4e3
commit
d2dab35770
1 changed files with 87 additions and 91 deletions
|
@ -1,139 +1,135 @@
|
|||
(function ($, document) {
|
||||
|
||||
// The base query options
|
||||
var query = {
|
||||
IsPremium: false,
|
||||
TargetSystems: ""
|
||||
};
|
||||
// The base query options
|
||||
var query = {
|
||||
IsPremium: false,
|
||||
TargetSystems: ""
|
||||
};
|
||||
|
||||
function reloadList() {
|
||||
function reloadList(page) {
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
var promise1 = ApiClient.getAvailablePlugins(query);
|
||||
var promise2 = ApiClient.getInstalledPlugins();
|
||||
var promise1 = ApiClient.getAvailablePlugins(query);
|
||||
var promise2 = ApiClient.getInstalledPlugins();
|
||||
|
||||
$.when(promise1, promise2).done(function (response1, response2) {
|
||||
populateList(response1[0], response2[0]);
|
||||
});
|
||||
$.when(promise1, promise2).done(function (response1, response2) {
|
||||
populateList(page, response1[0], response2[0]);
|
||||
});
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
}
|
||||
Dashboard.hideLoadingMsg();
|
||||
}
|
||||
|
||||
function populateList(availablePlugins, installedPlugins) {
|
||||
function populateList(page, 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;
|
||||
});
|
||||
availablePlugins = availablePlugins.filter(function (p) {
|
||||
return p.type == "UserInstalled";
|
||||
}).sort(function (a, b) {
|
||||
return a.name > b.name ? 1 : -1;
|
||||
});
|
||||
|
||||
var html = "";
|
||||
var html = "";
|
||||
|
||||
for (var i = 0, length = availablePlugins.length; i < length; i++) {
|
||||
for (var i = 0, length = availablePlugins.length; i < length; i++) {
|
||||
|
||||
var plugin = availablePlugins[i];
|
||||
var plugin = availablePlugins[i];
|
||||
|
||||
html += "<div class='posterViewItem'><a href='addPlugin.html?name=" + encodeURIComponent(plugin.name) + "'>";
|
||||
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.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>";
|
||||
}
|
||||
}
|
||||
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);
|
||||
var color = plugin.tileColor || LibraryBrowser.getMetroColor(plugin.name);
|
||||
|
||||
html += "<div class='posterViewItemText' style='background:" + color + "'>";
|
||||
html += "<div class='posterViewItemText' style='background:" + color + "'>";
|
||||
|
||||
var installedPlugin = installedPlugins.filter(function (ip) {
|
||||
return ip.Name == plugin.name;
|
||||
})[0];
|
||||
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>";
|
||||
if (installedPlugin) {
|
||||
html += plugin.name + " (Installed)";
|
||||
} else {
|
||||
html += plugin.name;
|
||||
}
|
||||
html += "</div>";
|
||||
|
||||
html += "</div>";
|
||||
html += "</div>";
|
||||
|
||||
html += "</a></div>";
|
||||
html += "</a></div>";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$('#pluginTiles', page).html(html);
|
||||
$('#pluginTiles', page).html(html);
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
}
|
||||
Dashboard.hideLoadingMsg();
|
||||
}
|
||||
|
||||
$(document).on('pageinit', "#pluginCatalogPage", function () {
|
||||
$(document).on('pageinit', "#pluginCatalogPage", function () {
|
||||
|
||||
var page = this;
|
||||
var page = this;
|
||||
|
||||
$('.chkStandardFilter', this).on('change', function () {
|
||||
|
||||
$('.chkStandardFilter', this).on('change', function () {
|
||||
var filterName = this.getAttribute('data-filter');
|
||||
var filters = query.TargetSystems || "";
|
||||
|
||||
var filterName = this.getAttribute('data-filter');
|
||||
var filters = query.TargetSystems || "";
|
||||
filters = (',' + filters).replace(',' + filterName, '').substring(1);
|
||||
|
||||
filters = (',' + filters).replace(',' + filterName, '').substring(1);
|
||||
if (this.checked) {
|
||||
filters = filters ? (filters + ',' + filterName) : filterName;
|
||||
}
|
||||
|
||||
if (this.checked) {
|
||||
filters = filters ? (filters + ',' + filterName) : filterName;
|
||||
}
|
||||
query.TargetSystems = filters;
|
||||
|
||||
query.TargetSystems = filters;
|
||||
reloadList(page);
|
||||
});
|
||||
|
||||
reloadList();
|
||||
});
|
||||
$('.chkPremiumFilter', this).on('change', function () {
|
||||
|
||||
$('.chkPremiumFilter', this).on('change', function () {
|
||||
if (this.checked) {
|
||||
query.IsPremium = true;
|
||||
} else {
|
||||
query.IsPremium = false;
|
||||
}
|
||||
|
||||
var filterName = this.getAttribute('data-filter');
|
||||
reloadList(page);
|
||||
});
|
||||
|
||||
if (this.checked) {
|
||||
query.IsPremium = true;
|
||||
}else {
|
||||
query.IsPremium = false;
|
||||
}
|
||||
}).on('pageshow', "#pluginCatalogPage", function () {
|
||||
|
||||
reloadList();
|
||||
});
|
||||
reloadList(this);
|
||||
|
||||
}).on('pageshow', "#pluginCatalogPage", function () {
|
||||
// Reset form values using the last used query
|
||||
|
||||
reloadList();
|
||||
$('.chkStandardFilter', this).each(function () {
|
||||
|
||||
// Reset form values using the last used query
|
||||
var filters = "," + (query.TargetSystems || "");
|
||||
var filterName = this.getAttribute('data-filter');
|
||||
|
||||
$('.chkStandardFilter', this).each(function () {
|
||||
this.checked = filters.indexOf(',' + filterName) != -1;
|
||||
|
||||
var filters = "," + (query.TargetSystems || "");
|
||||
var filterName = this.getAttribute('data-filter');
|
||||
}).checkboxradio('refresh');
|
||||
|
||||
this.checked = filters.indexOf(',' + filterName) != -1;
|
||||
$('.chkPremiumFilter', this).each(function () {
|
||||
|
||||
}).checkboxradio('refresh');
|
||||
var filters = query.IsPremium || false;
|
||||
|
||||
$('.chkPremiumFilter', this).each(function () {
|
||||
this.checked = filters;
|
||||
|
||||
var filters = query.IsPremium || false;
|
||||
|
||||
this.checked = filters;
|
||||
|
||||
}).checkboxradio('refresh');
|
||||
});
|
||||
}).checkboxradio('refresh');
|
||||
});
|
||||
|
||||
})(jQuery, document);
|
Loading…
Add table
Add a link
Reference in a new issue