deminify all library related pages
This commit is contained in:
parent
d4ea091ab5
commit
5fc92c915f
4 changed files with 600 additions and 244 deletions
|
@ -3,146 +3,258 @@ define(["globalize", "dom", "emby-checkbox", "emby-select", "emby-input"], funct
|
|||
|
||||
function populateLanguages(parent) {
|
||||
return ApiClient.getCultures().then(function(languages) {
|
||||
populateLanguagesIntoSelect(parent.querySelector("#selectLanguage"), languages), populateLanguagesIntoList(parent.querySelector(".subtitleDownloadLanguages"), languages)
|
||||
})
|
||||
populateLanguagesIntoSelect(parent.querySelector("#selectLanguage"), languages);
|
||||
populateLanguagesIntoList(parent.querySelector(".subtitleDownloadLanguages"), languages);
|
||||
});
|
||||
}
|
||||
|
||||
function populateLanguagesIntoSelect(select, languages) {
|
||||
var html = "";
|
||||
html += "<option value=''></option>";
|
||||
for (var i = 0, length = languages.length; i < length; i++) {
|
||||
for (var i = 0; i < languages.length; i++) {
|
||||
var culture = languages[i];
|
||||
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + "</option>"
|
||||
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + "</option>";
|
||||
}
|
||||
select.innerHTML = html
|
||||
select.innerHTML = html;
|
||||
}
|
||||
|
||||
function populateLanguagesIntoList(element, languages) {
|
||||
for (var html = "", i = 0, length = languages.length; i < length; i++) {
|
||||
var html = "";
|
||||
for (var i = 0; i < languages.length; i++) {
|
||||
var culture = languages[i];
|
||||
html += '<label><input type="checkbox" is="emby-checkbox" class="chkSubtitleLanguage" data-lang="' + culture.ThreeLetterISOLanguageName.toLowerCase() + '" /><span>' + culture.DisplayName + "</span></label>"
|
||||
html += '<label><input type="checkbox" is="emby-checkbox" class="chkSubtitleLanguage" data-lang="' + culture.ThreeLetterISOLanguageName.toLowerCase() + '" /><span>' + culture.DisplayName + "</span></label>";
|
||||
}
|
||||
element.innerHTML = html
|
||||
element.innerHTML = html;
|
||||
}
|
||||
|
||||
function populateCountries(select) {
|
||||
return ApiClient.getCountries().then(function(allCountries) {
|
||||
var html = "";
|
||||
html += "<option value=''></option>";
|
||||
for (var i = 0, length = allCountries.length; i < length; i++) {
|
||||
for (var i = 0; i < allCountries.length; i++) {
|
||||
var culture = allCountries[i];
|
||||
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + "</option>"
|
||||
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + "</option>";
|
||||
}
|
||||
select.innerHTML = html
|
||||
select.innerHTML = html;
|
||||
})
|
||||
}
|
||||
|
||||
function populateRefreshInterval(select) {
|
||||
var html = "";
|
||||
html += "<option value='0'>" + globalize.translate("Never") + "</option>", html += [30, 60, 90].map(function(val) {
|
||||
return "<option value='" + val + "'>" + globalize.translate("EveryNDays", val) + "</option>"
|
||||
}).join(""), select.innerHTML = html
|
||||
html += "<option value='0'>" + globalize.translate("Never") + "</option>";
|
||||
html += [30, 60, 90].map(function(val) {
|
||||
return "<option value='" + val + "'>" + globalize.translate("EveryNDays", val) + "</option>";
|
||||
}).join("");
|
||||
select.innerHTML = html;
|
||||
}
|
||||
|
||||
function renderMetadataReaders(page, plugins) {
|
||||
var html = "",
|
||||
elem = page.querySelector(".metadataReaders");
|
||||
var html = "";
|
||||
var elem = page.querySelector(".metadataReaders");
|
||||
|
||||
if (plugins.length < 1) return elem.innerHTML = "", elem.classList.add("hide"), !1;
|
||||
html += '<h3 class="checkboxListLabel">' + globalize.translate("LabelMetadataReaders") + "</h3>", html += '<div class="checkboxList paperList checkboxList-paperList">';
|
||||
for (var i = 0, length = plugins.length; i < length; i++) {
|
||||
html += '<h3 class="checkboxListLabel">' + globalize.translate("LabelMetadataReaders") + "</h3>";
|
||||
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
||||
for (var i = 0; i < plugins.length; i++) {
|
||||
var plugin = plugins[i];
|
||||
html += '<div class="listItem localReaderOption sortableOption" data-pluginname="' + plugin.Name + '">', html += '<i class="listItemIcon md-icon">live_tv</i>', html += '<div class="listItemBody">', html += '<h3 class="listItemBodyText">', html += plugin.Name, html += "</h3>", html += "</div>", i > 0 ? html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate("ButtonUp") + '" class="btnSortableMoveUp btnSortable" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_up</i></button>' : plugins.length > 1 && (html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate("ButtonDown") + '" class="btnSortableMoveDown btnSortable" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_down</i></button>'), html += "</div>"
|
||||
html += '<div class="listItem localReaderOption sortableOption" data-pluginname="' + plugin.Name + '">';
|
||||
html += '<i class="listItemIcon md-icon">live_tv</i>';
|
||||
html += '<div class="listItemBody">';
|
||||
html += '<h3 class="listItemBodyText">';
|
||||
html += plugin.Name;
|
||||
html += "</h3>";
|
||||
html += "</div>";
|
||||
if (i > 0) {
|
||||
html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate("ButtonUp") + '" class="btnSortableMoveUp btnSortable" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_up</i></button>';
|
||||
} else if (plugins.length > 1) {
|
||||
html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate("ButtonDown") + '" class="btnSortableMoveDown btnSortable" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_down</i></button>';
|
||||
}
|
||||
html += "</div>";
|
||||
}
|
||||
return html += "</div>", html += '<div class="fieldDescription">' + globalize.translate("LabelMetadataReadersHelp") + "</div>", plugins.length < 2 ? elem.classList.add("hide") : elem.classList.remove("hide"), elem.innerHTML = html, !0
|
||||
html += "</div>";
|
||||
html += '<div class="fieldDescription">' + globalize.translate("LabelMetadataReadersHelp") + "</div>";
|
||||
if (plugins.length < 2) {
|
||||
elem.classList.add("hide");
|
||||
} else {
|
||||
elem.classList.remove("hide");
|
||||
}
|
||||
elem.innerHTML = html;
|
||||
return true;
|
||||
}
|
||||
|
||||
function renderMetadataSavers(page, metadataSavers) {
|
||||
var html = "",
|
||||
elem = page.querySelector(".metadataSavers");
|
||||
if (!metadataSavers.length) return elem.innerHTML = "", elem.classList.add("hide"), !1;
|
||||
html += '<h3 class="checkboxListLabel">' + globalize.translate("LabelMetadataSavers") + "</h3>", html += '<div class="checkboxList paperList checkboxList-paperList">';
|
||||
for (var i = 0, length = metadataSavers.length; i < length; i++) {
|
||||
var html = "";
|
||||
var elem = page.querySelector(".metadataSavers");
|
||||
if (!metadataSavers.length) return elem.innerHTML = "", elem.classList.add("hide"), false;
|
||||
html += '<h3 class="checkboxListLabel">' + globalize.translate("LabelMetadataSavers") + "</h3>";
|
||||
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
||||
for (var i = 0; i < metadataSavers.length; i++) {
|
||||
var plugin = metadataSavers[i];
|
||||
html += '<label><input type="checkbox" data-defaultenabled="' + plugin.DefaultEnabled + '" is="emby-checkbox" class="chkMetadataSaver" data-pluginname="' + plugin.Name + '" ' + !1 + "><span>" + plugin.Name + "</span></label>"
|
||||
html += '<label><input type="checkbox" data-defaultenabled="' + plugin.DefaultEnabled + '" is="emby-checkbox" class="chkMetadataSaver" data-pluginname="' + plugin.Name + '" ' + false + "><span>" + plugin.Name + "</span></label>";
|
||||
}
|
||||
return html += "</div>", html += '<div class="fieldDescription" style="margin-top:.25em;">' + globalize.translate("LabelMetadataSaversHelp") + "</div>", elem.innerHTML = html, elem.classList.remove("hide"), !0
|
||||
html += "</div>";
|
||||
html += '<div class="fieldDescription" style="margin-top:.25em;">' + globalize.translate("LabelMetadataSaversHelp") + "</div>";
|
||||
elem.innerHTML = html;
|
||||
elem.classList.remove("hide");
|
||||
return true;
|
||||
}
|
||||
|
||||
function getMetadataFetchersForTypeHtml(availableTypeOptions, libraryOptionsForType) {
|
||||
var html = "",
|
||||
plugins = availableTypeOptions.MetadataFetchers;
|
||||
if (plugins = getOrderedPlugins(plugins, libraryOptionsForType.MetadataFetcherOrder || []), !plugins.length) return html;
|
||||
html += '<div class="metadataFetcher" data-type="' + availableTypeOptions.Type + '">', html += '<h3 class="checkboxListLabel">' + globalize.translate("LabelTypeMetadataDownloaders", availableTypeOptions.Type) + "</h3>", html += '<div class="checkboxList paperList checkboxList-paperList">';
|
||||
for (var i = 0, length = plugins.length; i < length; i++) {
|
||||
var html = "";
|
||||
var plugins = availableTypeOptions.MetadataFetchers;
|
||||
|
||||
plugins = getOrderedPlugins(plugins, libraryOptionsForType.MetadataFetcherOrder || []);
|
||||
if (!plugins.length) return html;
|
||||
|
||||
html += '<div class="metadataFetcher" data-type="' + availableTypeOptions.Type + '">';
|
||||
html += '<h3 class="checkboxListLabel">' + globalize.translate("LabelTypeMetadataDownloaders", availableTypeOptions.Type) + "</h3>";
|
||||
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
||||
for (var i = 0; i < plugins.length; i++) {
|
||||
var plugin = plugins[i];
|
||||
html += '<div class="listItem metadataFetcherItem sortableOption" data-pluginname="' + plugin.Name + '">';
|
||||
var isChecked = libraryOptionsForType.MetadataFetchers ? -1 !== libraryOptionsForType.MetadataFetchers.indexOf(plugin.Name) : plugin.DefaultEnabled,
|
||||
checkedHtml = isChecked ? ' checked="checked"' : "";
|
||||
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkMetadataFetcher" data-pluginname="' + plugin.Name + '" ' + checkedHtml + "><span></span></label>", html += '<div class="listItemBody">', html += '<h3 class="listItemBodyText">', html += plugin.Name, html += "</h3>", html += "</div>", i > 0 ? html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate("ButtonUp") + '" class="btnSortableMoveUp btnSortable" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_up</i></button>' : plugins.length > 1 && (html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate("ButtonDown") + '" class="btnSortableMoveDown btnSortable" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_down</i></button>'), html += "</div>"
|
||||
var isChecked = libraryOptionsForType.MetadataFetchers ? -1 !== libraryOptionsForType.MetadataFetchers.indexOf(plugin.Name) : plugin.DefaultEnabled;
|
||||
var checkedHtml = isChecked ? ' checked="checked"' : "";
|
||||
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkMetadataFetcher" data-pluginname="' + plugin.Name + '" ' + checkedHtml + "><span></span></label>";
|
||||
html += '<div class="listItemBody">';
|
||||
html += '<h3 class="listItemBodyText">';
|
||||
html += plugin.Name;
|
||||
html += "</h3>";
|
||||
html += "</div>";
|
||||
i > 0 ? html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate("ButtonUp") + '" class="btnSortableMoveUp btnSortable" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_up</i></button>' : plugins.length > 1 && (html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate("ButtonDown") + '" class="btnSortableMoveDown btnSortable" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_down</i></button>'), html += "</div>"
|
||||
}
|
||||
return html += "</div>", html += '<div class="fieldDescription">' + globalize.translate("LabelMetadataDownloadersHelp") + "</div>", html += "</div>"
|
||||
html += "</div>";
|
||||
html += '<div class="fieldDescription">' + globalize.translate("LabelMetadataDownloadersHelp") + "</div>";
|
||||
html += "</div>";
|
||||
return html;
|
||||
}
|
||||
|
||||
function getTypeOptions(allOptions, type) {
|
||||
for (var allTypeOptions = allOptions.TypeOptions || [], i = 0, length = allTypeOptions.length; i < length; i++) {
|
||||
var allTypeOptions = allOptions.TypeOptions || [];
|
||||
for (var i = 0; i < allTypeOptions.length; i++) {
|
||||
var typeOptions = allTypeOptions[i];
|
||||
if (typeOptions.Type === type) return typeOptions
|
||||
if (typeOptions.Type === type) return typeOptions;
|
||||
}
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
|
||||
function renderMetadataFetchers(page, availableOptions, libraryOptions) {
|
||||
for (var html = "", elem = page.querySelector(".metadataFetchers"), i = 0, length = availableOptions.TypeOptions.length; i < length; i++) {
|
||||
var html = "";
|
||||
var elem = page.querySelector(".metadataFetchers");
|
||||
for (var i = 0; i < availableOptions.TypeOptions.length; i++) {
|
||||
var availableTypeOptions = availableOptions.TypeOptions[i];
|
||||
html += getMetadataFetchersForTypeHtml(availableTypeOptions, getTypeOptions(libraryOptions, availableTypeOptions.Type) || {})
|
||||
html += getMetadataFetchersForTypeHtml(availableTypeOptions, getTypeOptions(libraryOptions, availableTypeOptions.Type) || {});
|
||||
}
|
||||
return elem.innerHTML = html, html ? (elem.classList.remove("hide"), page.querySelector(".fldAutoRefreshInterval").classList.remove("hide"), page.querySelector(".fldMetadataLanguage").classList.remove("hide"), page.querySelector(".fldMetadataCountry").classList.remove("hide")) : (elem.classList.add("hide"), page.querySelector(".fldAutoRefreshInterval").classList.add("hide"), page.querySelector(".fldMetadataLanguage").classList.add("hide"), page.querySelector(".fldMetadataCountry").classList.add("hide")), !0
|
||||
elem.innerHTML = html;
|
||||
if (html) {
|
||||
elem.classList.remove("hide");
|
||||
page.querySelector(".fldAutoRefreshInterval").classList.remove("hide");
|
||||
page.querySelector(".fldMetadataLanguage").classList.remove("hide");
|
||||
page.querySelector(".fldMetadataCountry").classList.remove("hide");
|
||||
} else {
|
||||
elem.classList.add("hide");
|
||||
page.querySelector(".fldAutoRefreshInterval").classList.add("hide");
|
||||
page.querySelector(".fldMetadataLanguage").classList.add("hide");
|
||||
page.querySelector(".fldMetadataCountry").classList.add("hide");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function renderSubtitleFetchers(page, availableOptions, libraryOptions) {
|
||||
try {
|
||||
var html = "",
|
||||
elem = page.querySelector(".subtitleFetchers"),
|
||||
html = "",
|
||||
plugins = availableOptions.SubtitleFetchers;
|
||||
if (plugins = getOrderedPlugins(plugins, libraryOptions.SubtitleFetcherOrder || []), !plugins.length) return html;
|
||||
html += '<h3 class="checkboxListLabel">' + globalize.translate("LabelSubtitleDownloaders") + "</h3>", html += '<div class="checkboxList paperList checkboxList-paperList">';
|
||||
for (var i = 0, length = plugins.length; i < length; i++) {
|
||||
var plugin = plugins[i];
|
||||
html += '<div class="listItem subtitleFetcherItem sortableOption" data-pluginname="' + plugin.Name + '">';
|
||||
var isChecked = libraryOptions.DisabledSubtitleFetchers ? -1 === libraryOptions.DisabledSubtitleFetchers.indexOf(plugin.Name) : plugin.DefaultEnabled,
|
||||
checkedHtml = isChecked ? ' checked="checked"' : "";
|
||||
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkSubtitleFetcher" data-pluginname="' + plugin.Name + '" ' + checkedHtml + "><span></span></label>", html += '<div class="listItemBody">', html += '<h3 class="listItemBodyText">', html += plugin.Name, html += "</h3>", "Open Subtitles" === plugin.Name && (html += '<div class="listItemBodyText secondary">', html += globalize.translate("OpenSubtitleInstructions"), html += "</div>"), html += "</div>", i > 0 ? html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate("ButtonUp") + '" class="btnSortableMoveUp btnSortable" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_up</i></button>' : plugins.length > 1 && (html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate("ButtonDown") + '" class="btnSortableMoveDown btnSortable" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_down</i></button>'), html += "</div>"
|
||||
var html = "";
|
||||
var elem = page.querySelector(".subtitleFetchers");
|
||||
|
||||
var plugins = availableOptions.SubtitleFetchers;
|
||||
plugins = getOrderedPlugins(plugins, libraryOptions.SubtitleFetcherOrder || []);
|
||||
if (!plugins.length) return html;
|
||||
|
||||
html += '<h3 class="checkboxListLabel">' + globalize.translate("LabelSubtitleDownloaders") + "</h3>";
|
||||
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
||||
for (var i = 0; i < plugins.length; i++) {
|
||||
var plugin = plugins[i];
|
||||
html += '<div class="listItem subtitleFetcherItem sortableOption" data-pluginname="' + plugin.Name + '">';
|
||||
var isChecked = libraryOptions.DisabledSubtitleFetchers ? -1 === libraryOptions.DisabledSubtitleFetchers.indexOf(plugin.Name) : plugin.DefaultEnabled;
|
||||
var checkedHtml = isChecked ? ' checked="checked"' : "";
|
||||
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkSubtitleFetcher" data-pluginname="' + plugin.Name + '" ' + checkedHtml + "><span></span></label>";
|
||||
html += '<div class="listItemBody">';
|
||||
html += '<h3 class="listItemBodyText">';
|
||||
html += plugin.Name;
|
||||
html += "</h3>";
|
||||
if (plugin.Name === "Open Subtitles") {
|
||||
html += '<div class="listItemBodyText secondary">';
|
||||
html += globalize.translate("OpenSubtitleInstructions");
|
||||
html += "</div>";
|
||||
}
|
||||
html += "</div>", html += '<div class="fieldDescription">' + globalize.translate("SubtitleDownloadersHelp") + "</div>", elem.innerHTML = html
|
||||
} catch (err) {
|
||||
alert(err)
|
||||
html += "</div>";
|
||||
if (i > 0) {
|
||||
html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate("ButtonUp") + '" class="btnSortableMoveUp btnSortable" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_up</i></button>';
|
||||
} else if (plugins.length > 1) {
|
||||
html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate("ButtonDown") + '" class="btnSortableMoveDown btnSortable" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_down</i></button>';
|
||||
}
|
||||
html += "</div>";
|
||||
}
|
||||
html += "</div>";
|
||||
html += '<div class="fieldDescription">' + globalize.translate("SubtitleDownloadersHelp") + "</div>";
|
||||
elem.innerHTML = html;
|
||||
}
|
||||
|
||||
function getImageFetchersForTypeHtml(availableTypeOptions, libraryOptionsForType) {
|
||||
var html = "",
|
||||
plugins = availableTypeOptions.ImageFetchers;
|
||||
if (plugins = getOrderedPlugins(plugins, libraryOptionsForType.ImageFetcherOrder || []), !plugins.length) return html;
|
||||
html += '<div class="imageFetcher" data-type="' + availableTypeOptions.Type + '">', html += '<div class="flex align-items-center" style="margin:1.5em 0 .5em;">', html += '<h3 class="checkboxListLabel" style="margin:0;">' + globalize.translate("HeaderTypeImageFetchers", availableTypeOptions.Type) + "</h3>";
|
||||
var html = "";
|
||||
var plugins = availableTypeOptions.ImageFetchers;
|
||||
|
||||
plugins = getOrderedPlugins(plugins, libraryOptionsForType.ImageFetcherOrder || []);
|
||||
if (!plugins.length) return html;
|
||||
|
||||
html += '<div class="imageFetcher" data-type="' + availableTypeOptions.Type + '">';
|
||||
html += '<div class="flex align-items-center" style="margin:1.5em 0 .5em;">';
|
||||
html += '<h3 class="checkboxListLabel" style="margin:0;">' + globalize.translate("HeaderTypeImageFetchers", availableTypeOptions.Type) + "</h3>";
|
||||
var supportedImageTypes = availableTypeOptions.SupportedImageTypes || [];
|
||||
(supportedImageTypes.length > 1 || 1 === supportedImageTypes.length && "Primary" !== supportedImageTypes[0]) && (html += '<button is="emby-button" class="raised btnImageOptionsForType" type="button" style="margin-left:1.5em;font-size:90%;"><span>' + globalize.translate("HeaderFetcherSettings") + "</span></button>"), html += "</div>", html += '<div class="checkboxList paperList checkboxList-paperList">';
|
||||
for (var i = 0, length = plugins.length; i < length; i++) {
|
||||
if (supportedImageTypes.length > 1 || 1 === supportedImageTypes.length && "Primary" !== supportedImageTypes[0]) {
|
||||
html += '<button is="emby-button" class="raised btnImageOptionsForType" type="button" style="margin-left:1.5em;font-size:90%;"><span>' + globalize.translate("HeaderFetcherSettings") + "</span></button>";
|
||||
}
|
||||
html += "</div>";
|
||||
html += '<div class="checkboxList paperList checkboxList-paperList">';
|
||||
for (var i = 0; i < plugins.length; i++) {
|
||||
var plugin = plugins[i];
|
||||
html += '<div class="listItem imageFetcherItem sortableOption" data-pluginname="' + plugin.Name + '">';
|
||||
var isChecked = libraryOptionsForType.ImageFetchers ? -1 !== libraryOptionsForType.ImageFetchers.indexOf(plugin.Name) : plugin.DefaultEnabled,
|
||||
checkedHtml = isChecked ? ' checked="checked"' : "";
|
||||
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkImageFetcher" data-pluginname="' + plugin.Name + '" ' + checkedHtml + "><span></span></label>", html += '<div class="listItemBody">', html += '<h3 class="listItemBodyText">', html += plugin.Name, html += "</h3>", html += "</div>", i > 0 ? html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate("ButtonUp") + '" class="btnSortableMoveUp btnSortable" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_up</i></button>' : plugins.length > 1 && (html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate("ButtonDown") + '" class="btnSortableMoveDown btnSortable" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_down</i></button>'), html += "</div>"
|
||||
var isChecked = libraryOptionsForType.ImageFetchers ? -1 !== libraryOptionsForType.ImageFetchers.indexOf(plugin.Name) : plugin.DefaultEnabled;
|
||||
var checkedHtml = isChecked ? ' checked="checked"' : "";
|
||||
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkImageFetcher" data-pluginname="' + plugin.Name + '" ' + checkedHtml + "><span></span></label>";
|
||||
html += '<div class="listItemBody">';
|
||||
html += '<h3 class="listItemBodyText">';
|
||||
html += plugin.Name;
|
||||
html += "</h3>";
|
||||
html += "</div>";
|
||||
if (i > 0) {
|
||||
html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate("ButtonUp") + '" class="btnSortableMoveUp btnSortable" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_up</i></button>';
|
||||
} else if (plugins.length > 1) {
|
||||
html += '<button type="button" is="paper-icon-button-light" title="' + globalize.translate("ButtonDown") + '" class="btnSortableMoveDown btnSortable" data-pluginindex="' + i + '"><i class="md-icon">keyboard_arrow_down</i></button>';
|
||||
}
|
||||
html += "</div>";
|
||||
}
|
||||
return html += "</div>", html += '<div class="fieldDescription">' + globalize.translate("LabelImageFetchersHelp") + "</div>", html += "</div>"
|
||||
html += "</div>";
|
||||
html += '<div class="fieldDescription">' + globalize.translate("LabelImageFetchersHelp") + "</div>";
|
||||
html += "</div>";
|
||||
return html;
|
||||
}
|
||||
|
||||
function renderImageFetchers(page, availableOptions, libraryOptions) {
|
||||
for (var html = "", elem = page.querySelector(".imageFetchers"), i = 0, length = availableOptions.TypeOptions.length; i < length; i++) {
|
||||
var html = "";
|
||||
var elem = page.querySelector(".imageFetchers");
|
||||
for (var i = 0; i < availableOptions.TypeOptions.length; i++) {
|
||||
var availableTypeOptions = availableOptions.TypeOptions[i];
|
||||
html += getImageFetchersForTypeHtml(availableTypeOptions, getTypeOptions(libraryOptions, availableTypeOptions.Type) || {})
|
||||
html += getImageFetchersForTypeHtml(availableTypeOptions, getTypeOptions(libraryOptions, availableTypeOptions.Type) || {});
|
||||
}
|
||||
return elem.innerHTML = html, html ? (elem.classList.remove("hide"), page.querySelector(".chkDownloadImagesInAdvanceContainer").classList.remove("hide"), page.querySelector(".chkSaveLocalContainer").classList.remove("hide")) : (elem.classList.add("hide"), page.querySelector(".chkDownloadImagesInAdvanceContainer").classList.add("hide"), page.querySelector(".chkSaveLocalContainer").classList.add("hide")), !0
|
||||
elem.innerHTML = html;
|
||||
if (html) {
|
||||
elem.classList.remove("hide");
|
||||
page.querySelector(".chkDownloadImagesInAdvanceContainer").classList.remove("hide");
|
||||
page.querySelector(".chkSaveLocalContainer").classList.remove("hide");
|
||||
} else {
|
||||
elem.classList.add("hide");
|
||||
page.querySelector(".chkDownloadImagesInAdvanceContainer").classList.add("hide");
|
||||
page.querySelector(".chkSaveLocalContainer").classList.add("hide");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function populateMetadataSettings(parent, contentType, isNewLibrary) {
|
||||
|
@ -151,15 +263,30 @@ define(["globalize", "dom", "emby-checkbox", "emby-select", "emby-input"], funct
|
|||
LibraryContentType: contentType,
|
||||
IsNewLibrary: isNewLibrary
|
||||
})).then(function(availableOptions) {
|
||||
currentAvailableOptions = availableOptions, parent.availableOptions = availableOptions, renderMetadataSavers(parent, availableOptions.MetadataSavers), renderMetadataReaders(parent, availableOptions.MetadataReaders), renderMetadataFetchers(parent, availableOptions, {}), renderSubtitleFetchers(parent, availableOptions, {}), renderImageFetchers(parent, availableOptions, {}), availableOptions.SubtitleFetchers.length ? parent.querySelector(".subtitleDownloadSettings").classList.remove("hide") : parent.querySelector(".subtitleDownloadSettings").classList.add("hide")
|
||||
currentAvailableOptions = availableOptions;
|
||||
parent.availableOptions = availableOptions;
|
||||
renderMetadataSavers(parent, availableOptions.MetadataSavers);
|
||||
renderMetadataReaders(parent, availableOptions.MetadataReaders);
|
||||
renderMetadataFetchers(parent, availableOptions, {});
|
||||
renderSubtitleFetchers(parent, availableOptions, {});
|
||||
renderImageFetchers(parent, availableOptions, {});
|
||||
availableOptions.SubtitleFetchers.length ? parent.querySelector(".subtitleDownloadSettings").classList.remove("hide") : parent.querySelector(".subtitleDownloadSettings").classList.add("hide")
|
||||
}).catch(function() {
|
||||
return Promise.resolve()
|
||||
return Promise.resolve();
|
||||
})
|
||||
}
|
||||
|
||||
function adjustSortableListElement(elem) {
|
||||
var btnSortable = elem.querySelector(".btnSortable");
|
||||
elem.previousSibling ? (btnSortable.classList.add("btnSortableMoveUp"), btnSortable.classList.remove("btnSortableMoveDown"), btnSortable.querySelector("i").innerHTML = "keyboard_arrow_up") : (btnSortable.classList.remove("btnSortableMoveUp"), btnSortable.classList.add("btnSortableMoveDown"), btnSortable.querySelector("i").innerHTML = "keyboard_arrow_down")
|
||||
if (elem.previousSibling) {
|
||||
btnSortable.classList.add("btnSortableMoveUp");
|
||||
btnSortable.classList.remove("btnSortableMoveDown");
|
||||
btnSortable.querySelector("i").innerHTML = "keyboard_arrow_up";
|
||||
} else {
|
||||
btnSortable.classList.remove("btnSortableMoveUp");
|
||||
btnSortable.classList.add("btnSortableMoveDown");
|
||||
btnSortable.querySelector("i").innerHTML = "keyboard_arrow_down";
|
||||
}
|
||||
}
|
||||
|
||||
function showImageOptionsForType(type) {
|
||||
|
@ -176,16 +303,16 @@ define(["globalize", "dom", "emby-checkbox", "emby-select", "emby-input"], funct
|
|||
function onImageFetchersContainerClick(e) {
|
||||
var btnImageOptionsForType = dom.parentWithClass(e.target, "btnImageOptionsForType");
|
||||
if (btnImageOptionsForType) {
|
||||
return void showImageOptionsForType(dom.parentWithClass(btnImageOptionsForType, "imageFetcher").getAttribute("data-type"))
|
||||
return void showImageOptionsForType(dom.parentWithClass(btnImageOptionsForType, "imageFetcher").getAttribute("data-type"));
|
||||
}
|
||||
onSortableContainerClick.call(this, e)
|
||||
onSortableContainerClick.call(this, e);
|
||||
}
|
||||
|
||||
function onSortableContainerClick(e) {
|
||||
var btnSortable = dom.parentWithClass(e.target, "btnSortable");
|
||||
if (btnSortable) {
|
||||
var li = dom.parentWithClass(btnSortable, "sortableOption"),
|
||||
list = dom.parentWithClass(li, "paperList");
|
||||
var li = dom.parentWithClass(btnSortable, "sortableOption");
|
||||
var list = dom.parentWithClass(li, "paperList");
|
||||
if (btnSortable.classList.contains("btnSortableMoveDown")) {
|
||||
var next = li.nextSibling;
|
||||
next && (li.parentNode.removeChild(li), next.parentNode.insertBefore(li, next.nextSibling))
|
||||
|
@ -198,35 +325,78 @@ define(["globalize", "dom", "emby-checkbox", "emby-select", "emby-input"], funct
|
|||
}
|
||||
|
||||
function bindEvents(parent) {
|
||||
parent.querySelector(".metadataReaders").addEventListener("click", onSortableContainerClick), parent.querySelector(".subtitleFetchers").addEventListener("click", onSortableContainerClick), parent.querySelector(".metadataFetchers").addEventListener("click", onSortableContainerClick), parent.querySelector(".imageFetchers").addEventListener("click", onImageFetchersContainerClick)
|
||||
parent.querySelector(".metadataReaders").addEventListener("click", onSortableContainerClick);
|
||||
parent.querySelector(".subtitleFetchers").addEventListener("click", onSortableContainerClick);
|
||||
parent.querySelector(".metadataFetchers").addEventListener("click", onSortableContainerClick);
|
||||
parent.querySelector(".imageFetchers").addEventListener("click", onImageFetchersContainerClick);
|
||||
}
|
||||
|
||||
function embed(parent, contentType, libraryOptions) {
|
||||
currentLibraryOptions = {
|
||||
TypeOptions: []
|
||||
}, currentAvailableOptions = null;
|
||||
var isNewLibrary = null == libraryOptions;
|
||||
return isNewLibrary && parent.classList.add("newlibrary"), new Promise(function(resolve, reject) {
|
||||
};
|
||||
currentAvailableOptions = null;
|
||||
var isNewLibrary = null === libraryOptions;
|
||||
isNewLibrary && parent.classList.add("newlibrary");
|
||||
return new Promise(function(resolve, reject) {
|
||||
var xhr = new XMLHttpRequest;
|
||||
xhr.open("GET", "components/libraryoptionseditor/libraryoptionseditor.template.html", !0), xhr.onload = function(e) {
|
||||
xhr.open("GET", "components/libraryoptionseditor/libraryoptionseditor.template.html", true);
|
||||
xhr.onload = function(e) {
|
||||
var template = this.response;
|
||||
parent.innerHTML = globalize.translateDocument(template), populateRefreshInterval(parent.querySelector("#selectAutoRefreshInterval"));
|
||||
parent.innerHTML = globalize.translateDocument(template);
|
||||
populateRefreshInterval(parent.querySelector("#selectAutoRefreshInterval"));
|
||||
var promises = [populateLanguages(parent), populateCountries(parent.querySelector("#selectCountry"))];
|
||||
Promise.all(promises).then(function() {
|
||||
return setContentType(parent, contentType).then(function() {
|
||||
libraryOptions && setLibraryOptions(parent, libraryOptions), bindEvents(parent), resolve()
|
||||
})
|
||||
})
|
||||
}, xhr.send()
|
||||
})
|
||||
libraryOptions && setLibraryOptions(parent, libraryOptions);
|
||||
bindEvents(parent);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
};
|
||||
xhr.send();
|
||||
});
|
||||
}
|
||||
|
||||
function setAdvancedVisible(parent, visible) {
|
||||
for (var elems = parent.querySelectorAll(".advanced"), i = 0, length = elems.length; i < length; i++) visible ? elems[i].classList.remove("advancedHide") : elems[i].classList.add("advancedHide")
|
||||
var elems = parent.querySelectorAll(".advanced");
|
||||
for (var i = 0; i < elems.length; i++) {
|
||||
visible ? elems[i].classList.remove("advancedHide") : elems[i].classList.add("advancedHide");
|
||||
}
|
||||
}
|
||||
|
||||
function setContentType(parent, contentType) {
|
||||
return "homevideos" === contentType || "photos" === contentType ? parent.querySelector(".chkEnablePhotosContainer").classList.remove("hide") : parent.querySelector(".chkEnablePhotosContainer").classList.add("hide"), "tvshows" !== contentType && "movies" !== contentType && "homevideos" !== contentType && "musicvideos" !== contentType && "mixed" !== contentType && contentType ? parent.querySelector(".chapterSettingsSection").classList.add("hide") : parent.querySelector(".chapterSettingsSection").classList.remove("hide"), "tvshows" === contentType ? (parent.querySelector(".chkImportMissingEpisodesContainer").classList.remove("hide"), parent.querySelector(".chkAutomaticallyGroupSeriesContainer").classList.remove("hide"), parent.querySelector(".fldSeasonZeroDisplayName").classList.remove("hide"), parent.querySelector("#txtSeasonZeroName").setAttribute("required", "required")) : (parent.querySelector(".chkImportMissingEpisodesContainer").classList.add("hide"), parent.querySelector(".chkAutomaticallyGroupSeriesContainer").classList.add("hide"), parent.querySelector(".fldSeasonZeroDisplayName").classList.add("hide"), parent.querySelector("#txtSeasonZeroName").removeAttribute("required")), "books" === contentType || "boxsets" === contentType || "playlists" === contentType || "music" === contentType ? parent.querySelector(".chkEnableEmbeddedTitlesContainer").classList.add("hide") : parent.querySelector(".chkEnableEmbeddedTitlesContainer").classList.remove("hide"), populateMetadataSettings(parent, contentType)
|
||||
if (contentType === "homevideos" || contentType === "photos") {
|
||||
parent.querySelector(".chkEnablePhotosContainer").classList.remove("hide");
|
||||
} else {
|
||||
parent.querySelector(".chkEnablePhotosContainer").classList.add("hide");
|
||||
}
|
||||
|
||||
if (contentType !== "tvshows" && contentType !== "movies" && contentType !== "homevideos" && contentType !== "musicvideos" && contentType !== "mixed") {
|
||||
parent.querySelector(".chapterSettingsSection").classList.add("hide");
|
||||
} else {
|
||||
parent.querySelector(".chapterSettingsSection").classList.remove("hide");
|
||||
}
|
||||
|
||||
if (contentType === "tvshows") {
|
||||
parent.querySelector(".chkImportMissingEpisodesContainer").classList.remove("hide");
|
||||
parent.querySelector(".chkAutomaticallyGroupSeriesContainer").classList.remove("hide");
|
||||
parent.querySelector(".fldSeasonZeroDisplayName").classList.remove("hide");
|
||||
parent.querySelector("#txtSeasonZeroName").setAttribute("required", "required");
|
||||
} else {
|
||||
parent.querySelector(".chkImportMissingEpisodesContainer").classList.add("hide");
|
||||
parent.querySelector(".chkAutomaticallyGroupSeriesContainer").classList.add("hide");
|
||||
parent.querySelector(".fldSeasonZeroDisplayName").classList.add("hide");
|
||||
parent.querySelector("#txtSeasonZeroName").removeAttribute("required");
|
||||
}
|
||||
|
||||
if (contentType === "books" || contentType === "boxsets" || contentType === "playlists" || contentType === "music") {
|
||||
parent.querySelector(".chkEnableEmbeddedTitlesContainer").classList.add("hide");
|
||||
} else {
|
||||
parent.querySelector(".chkEnableEmbeddedTitlesContainer").classList.remove("hide");
|
||||
}
|
||||
|
||||
return populateMetadataSettings(parent, contentType);
|
||||
}
|
||||
|
||||
function setSubtitleFetchersIntoOptions(parent, options) {
|
||||
|
@ -234,64 +404,87 @@ define(["globalize", "dom", "emby-checkbox", "emby-select", "emby-input"], funct
|
|||
return !elem.checked
|
||||
}), function(elem) {
|
||||
return elem.getAttribute("data-pluginname")
|
||||
}), options.SubtitleFetcherOrder = Array.prototype.map.call(parent.querySelectorAll(".subtitleFetcherItem"), function(elem) {
|
||||
});
|
||||
|
||||
options.SubtitleFetcherOrder = Array.prototype.map.call(parent.querySelectorAll(".subtitleFetcherItem"), function(elem) {
|
||||
return elem.getAttribute("data-pluginname")
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function setMetadataFetchersIntoOptions(parent, options) {
|
||||
for (var sections = parent.querySelectorAll(".metadataFetcher"), i = 0, length = sections.length; i < length; i++) {
|
||||
var section = sections[i],
|
||||
type = section.getAttribute("data-type"),
|
||||
typeOptions = getTypeOptions(options, type);
|
||||
typeOptions || (typeOptions = {
|
||||
Type: type
|
||||
}, options.TypeOptions.push(typeOptions)), typeOptions.MetadataFetchers = Array.prototype.map.call(Array.prototype.filter.call(section.querySelectorAll(".chkMetadataFetcher"), function(elem) {
|
||||
return elem.checked
|
||||
var sections = parent.querySelectorAll(".metadataFetcher");
|
||||
for (var i = 0; i < sections.length; i++) {
|
||||
var section = sections[i];
|
||||
var type = section.getAttribute("data-type");
|
||||
var typeOptions = getTypeOptions(options, type);
|
||||
if (!typeOptions) {
|
||||
typeOptions = {
|
||||
Type: type
|
||||
};
|
||||
options.TypeOptions.push(typeOptions);
|
||||
}
|
||||
typeOptions.MetadataFetchers = Array.prototype.map.call(Array.prototype.filter.call(section.querySelectorAll(".chkMetadataFetcher"), function(elem) {
|
||||
return elem.checked;
|
||||
}), function(elem) {
|
||||
return elem.getAttribute("data-pluginname")
|
||||
}), typeOptions.MetadataFetcherOrder = Array.prototype.map.call(section.querySelectorAll(".metadataFetcherItem"), function(elem) {
|
||||
return elem.getAttribute("data-pluginname")
|
||||
})
|
||||
return elem.getAttribute("data-pluginname");
|
||||
});
|
||||
|
||||
typeOptions.MetadataFetcherOrder = Array.prototype.map.call(section.querySelectorAll(".metadataFetcherItem"), function(elem) {
|
||||
return elem.getAttribute("data-pluginname");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function setImageFetchersIntoOptions(parent, options) {
|
||||
for (var sections = parent.querySelectorAll(".imageFetcher"), i = 0, length = sections.length; i < length; i++) {
|
||||
var section = sections[i],
|
||||
type = section.getAttribute("data-type"),
|
||||
typeOptions = getTypeOptions(options, type);
|
||||
typeOptions || (typeOptions = {
|
||||
Type: type
|
||||
}, options.TypeOptions.push(typeOptions)), typeOptions.ImageFetchers = Array.prototype.map.call(Array.prototype.filter.call(section.querySelectorAll(".chkImageFetcher"), function(elem) {
|
||||
var sections = parent.querySelectorAll(".imageFetcher");
|
||||
for (var i = 0; i < sections.length; i++) {
|
||||
var section = sections[i];
|
||||
var type = section.getAttribute("data-type");
|
||||
var typeOptions = getTypeOptions(options, type);
|
||||
if (!typeOptions) {
|
||||
typeOptions = {
|
||||
Type: type
|
||||
};
|
||||
options.TypeOptions.push(typeOptions);
|
||||
}
|
||||
|
||||
typeOptions.ImageFetchers = Array.prototype.map.call(Array.prototype.filter.call(section.querySelectorAll(".chkImageFetcher"), function(elem) {
|
||||
return elem.checked
|
||||
}), function(elem) {
|
||||
return elem.getAttribute("data-pluginname")
|
||||
}), typeOptions.ImageFetcherOrder = Array.prototype.map.call(section.querySelectorAll(".imageFetcherItem"), function(elem) {
|
||||
});
|
||||
|
||||
typeOptions.ImageFetcherOrder = Array.prototype.map.call(section.querySelectorAll(".imageFetcherItem"), function(elem) {
|
||||
return elem.getAttribute("data-pluginname")
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function setImageOptionsIntoOptions(parent, options) {
|
||||
for (var originalTypeOptions = (currentLibraryOptions || {}).TypeOptions || [], i = 0, length = originalTypeOptions.length; i < length; i++) {
|
||||
var originalTypeOption = originalTypeOptions[i],
|
||||
typeOptions = getTypeOptions(options, originalTypeOption.Type);
|
||||
typeOptions || (typeOptions = {
|
||||
Type: type
|
||||
}, options.TypeOptions.push(typeOptions)), originalTypeOption.ImageOptions && (typeOptions.ImageOptions = originalTypeOption.ImageOptions)
|
||||
var originalTypeOptions = (currentLibraryOptions || {}).TypeOptions || [];
|
||||
for (var i = 0; i < originalTypeOptions.length; i++) {
|
||||
var originalTypeOption = originalTypeOptions[i];
|
||||
var typeOptions = getTypeOptions(options, originalTypeOption.Type);
|
||||
|
||||
if (!typeOptions) {
|
||||
typeOptions = {
|
||||
Type: type
|
||||
};
|
||||
options.TypeOptions.push(typeOptions);
|
||||
}
|
||||
originalTypeOption.ImageOptions && (typeOptions.ImageOptions = originalTypeOption.ImageOptions);
|
||||
}
|
||||
}
|
||||
|
||||
function getLibraryOptions(parent) {
|
||||
var options = {
|
||||
EnableArchiveMediaFiles: !1,
|
||||
EnableArchiveMediaFiles: false,
|
||||
EnablePhotos: parent.querySelector(".chkEnablePhotos").checked,
|
||||
EnableRealtimeMonitor: parent.querySelector(".chkEnableRealtimeMonitor").checked,
|
||||
ExtractChapterImagesDuringLibraryScan: parent.querySelector(".chkExtractChaptersDuringLibraryScan").checked,
|
||||
EnableChapterImageExtraction: parent.querySelector(".chkExtractChapterImages").checked,
|
||||
DownloadImagesInAdvance: parent.querySelector("#chkDownloadImagesInAdvance").checked,
|
||||
EnableInternetProviders: !0,
|
||||
EnableInternetProviders: true,
|
||||
ImportMissingEpisodes: parent.querySelector("#chkImportMissingEpisodes").checked,
|
||||
SaveLocalMetadata: parent.querySelector("#chkSaveLocal").checked,
|
||||
EnableAutomaticSeriesGrouping: parent.querySelector(".chkAutomaticallyGroupSeries").checked,
|
||||
|
@ -311,29 +504,66 @@ define(["globalize", "dom", "emby-checkbox", "emby-select", "emby-input"], funct
|
|||
}),
|
||||
TypeOptions: []
|
||||
};
|
||||
return options.LocalMetadataReaderOrder = Array.prototype.map.call(parent.querySelectorAll(".localReaderOption"), function(elem) {
|
||||
|
||||
options.LocalMetadataReaderOrder = Array.prototype.map.call(parent.querySelectorAll(".localReaderOption"), function(elem) {
|
||||
return elem.getAttribute("data-pluginname")
|
||||
}), options.SubtitleDownloadLanguages = Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll(".chkSubtitleLanguage"), function(elem) {
|
||||
});
|
||||
options.SubtitleDownloadLanguages = Array.prototype.map.call(Array.prototype.filter.call(parent.querySelectorAll(".chkSubtitleLanguage"), function(elem) {
|
||||
return elem.checked
|
||||
}), function(elem) {
|
||||
return elem.getAttribute("data-lang")
|
||||
}), setSubtitleFetchersIntoOptions(parent, options), setMetadataFetchersIntoOptions(parent, options), setImageFetchersIntoOptions(parent, options), setImageOptionsIntoOptions(parent, options), options
|
||||
});
|
||||
setSubtitleFetchersIntoOptions(parent, options);
|
||||
setMetadataFetchersIntoOptions(parent, options);
|
||||
setImageFetchersIntoOptions(parent, options);
|
||||
setImageOptionsIntoOptions(parent, options);
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
function getOrderedPlugins(plugins, configuredOrder) {
|
||||
return plugins = plugins.slice(0), plugins.sort(function(a, b) {
|
||||
plugins = plugins.slice(0);
|
||||
plugins.sort(function(a, b) {
|
||||
return a = configuredOrder.indexOf(a.Name), b = configuredOrder.indexOf(b.Name), a < b ? -1 : a > b ? 1 : 0
|
||||
}), plugins
|
||||
});
|
||||
return plugins;
|
||||
}
|
||||
|
||||
function setLibraryOptions(parent, options) {
|
||||
currentLibraryOptions = options, currentAvailableOptions = parent.availableOptions, parent.querySelector("#selectLanguage").value = options.PreferredMetadataLanguage || "", parent.querySelector("#selectCountry").value = options.MetadataCountryCode || "", parent.querySelector("#selectAutoRefreshInterval").value = options.AutomaticRefreshIntervalDays || "0", parent.querySelector("#txtSeasonZeroName").value = options.SeasonZeroDisplayName || "Specials", parent.querySelector(".chkEnablePhotos").checked = options.EnablePhotos, parent.querySelector(".chkEnableRealtimeMonitor").checked = options.EnableRealtimeMonitor, parent.querySelector(".chkExtractChaptersDuringLibraryScan").checked = options.ExtractChapterImagesDuringLibraryScan, parent.querySelector(".chkExtractChapterImages").checked = options.EnableChapterImageExtraction, parent.querySelector("#chkDownloadImagesInAdvance").checked = options.DownloadImagesInAdvance, parent.querySelector("#chkSaveLocal").checked = options.SaveLocalMetadata, parent.querySelector("#chkImportMissingEpisodes").checked = options.ImportMissingEpisodes, parent.querySelector(".chkAutomaticallyGroupSeries").checked = options.EnableAutomaticSeriesGrouping, parent.querySelector("#chkEnableEmbeddedTitles").checked = options.EnableEmbeddedTitles, parent.querySelector("#chkSkipIfGraphicalSubsPresent").checked = options.SkipSubtitlesIfEmbeddedSubtitlesPresent, parent.querySelector("#chkSaveSubtitlesLocally").checked = options.SaveSubtitlesWithMedia, parent.querySelector("#chkSkipIfAudioTrackPresent").checked = options.SkipSubtitlesIfAudioTrackMatches, parent.querySelector("#chkRequirePerfectMatch").checked = options.RequirePerfectSubtitleMatch, Array.prototype.forEach.call(parent.querySelectorAll(".chkMetadataSaver"), function(elem) {
|
||||
currentLibraryOptions = options;
|
||||
currentAvailableOptions = parent.availableOptions;
|
||||
parent.querySelector("#selectLanguage").value = options.PreferredMetadataLanguage || "";
|
||||
parent.querySelector("#selectCountry").value = options.MetadataCountryCode || "";
|
||||
parent.querySelector("#selectAutoRefreshInterval").value = options.AutomaticRefreshIntervalDays || "0";
|
||||
parent.querySelector("#txtSeasonZeroName").value = options.SeasonZeroDisplayName || "Specials";
|
||||
parent.querySelector(".chkEnablePhotos").checked = options.EnablePhotos;
|
||||
parent.querySelector(".chkEnableRealtimeMonitor").checked = options.EnableRealtimeMonitor;
|
||||
parent.querySelector(".chkExtractChaptersDuringLibraryScan").checked = options.ExtractChapterImagesDuringLibraryScan;
|
||||
parent.querySelector(".chkExtractChapterImages").checked = options.EnableChapterImageExtraction;
|
||||
parent.querySelector("#chkDownloadImagesInAdvance").checked = options.DownloadImagesInAdvance;
|
||||
parent.querySelector("#chkSaveLocal").checked = options.SaveLocalMetadata;
|
||||
parent.querySelector("#chkImportMissingEpisodes").checked = options.ImportMissingEpisodes;
|
||||
parent.querySelector(".chkAutomaticallyGroupSeries").checked = options.EnableAutomaticSeriesGrouping;
|
||||
parent.querySelector("#chkEnableEmbeddedTitles").checked = options.EnableEmbeddedTitles;
|
||||
parent.querySelector("#chkSkipIfGraphicalSubsPresent").checked = options.SkipSubtitlesIfEmbeddedSubtitlesPresent;
|
||||
parent.querySelector("#chkSaveSubtitlesLocally").checked = options.SaveSubtitlesWithMedia;
|
||||
parent.querySelector("#chkSkipIfAudioTrackPresent").checked = options.SkipSubtitlesIfAudioTrackMatches;
|
||||
parent.querySelector("#chkRequirePerfectMatch").checked = options.RequirePerfectSubtitleMatch;
|
||||
Array.prototype.forEach.call(parent.querySelectorAll(".chkMetadataSaver"), function(elem) {
|
||||
elem.checked = options.MetadataSavers ? -1 !== options.MetadataSavers.indexOf(elem.getAttribute("data-pluginname")) : "true" === elem.getAttribute("data-defaultenabled")
|
||||
}), Array.prototype.forEach.call(parent.querySelectorAll(".chkSubtitleLanguage"), function(elem) {
|
||||
});
|
||||
Array.prototype.forEach.call(parent.querySelectorAll(".chkSubtitleLanguage"), function(elem) {
|
||||
elem.checked = !!options.SubtitleDownloadLanguages && -1 !== options.SubtitleDownloadLanguages.indexOf(elem.getAttribute("data-lang"))
|
||||
}), renderMetadataReaders(parent, getOrderedPlugins(parent.availableOptions.MetadataReaders, options.LocalMetadataReaderOrder || [])), renderMetadataFetchers(parent, parent.availableOptions, options), renderImageFetchers(parent, parent.availableOptions, options), renderSubtitleFetchers(parent, parent.availableOptions, options)
|
||||
});
|
||||
renderMetadataReaders(parent, getOrderedPlugins(parent.availableOptions.MetadataReaders, options.LocalMetadataReaderOrder || []));
|
||||
renderMetadataFetchers(parent, parent.availableOptions, options);
|
||||
renderImageFetchers(parent, parent.availableOptions, options);
|
||||
renderSubtitleFetchers(parent, parent.availableOptions, options);
|
||||
}
|
||||
var currentLibraryOptions, currentAvailableOptions;
|
||||
|
||||
var currentLibraryOptions;
|
||||
var currentAvailableOptions;
|
||||
|
||||
return {
|
||||
embed: embed,
|
||||
setContentType: setContentType,
|
||||
|
|
|
@ -39,16 +39,21 @@
|
|||
|
||||
<div class="metadataReaders hide advanced" style="margin-bottom: 2em;">
|
||||
</div>
|
||||
|
||||
<div class="metadataFetchers hide" style="margin-bottom: 2em;">
|
||||
</div>
|
||||
|
||||
<div class="selectContainer fldAutoRefreshInterval hide advanced" style="margin: 2em 0;">
|
||||
<select is="emby-select" id="selectAutoRefreshInterval" label="${LabelAutomaticallyRefreshInternetMetadataEvery}"></select>
|
||||
<div class="fieldDescription">${MessageEnablingOptionLongerScans}</div>
|
||||
</div>
|
||||
|
||||
<div class="metadataSavers hide" style="margin-bottom: 2em;">
|
||||
</div>
|
||||
|
||||
<div class="imageFetchers hide advanced" style="margin-bottom: 2em;">
|
||||
</div>
|
||||
|
||||
<div class="checkboxContainer checkboxContainer-withDescription chkSaveLocalContainer hide">
|
||||
<label>
|
||||
<input is="emby-checkbox" type="checkbox" id="chkSaveLocal" />
|
||||
|
|
|
@ -2,15 +2,16 @@ define(["loading", "dialogHelper", "dom", "components/libraryoptionseditor/libra
|
|||
"use strict";
|
||||
|
||||
function addMediaLocation(page, path, networkSharePath) {
|
||||
var virtualFolder = currentOptions.library,
|
||||
refreshAfterChange = currentOptions.refresh;
|
||||
var virtualFolder = currentOptions.library;
|
||||
var refreshAfterChange = currentOptions.refresh;
|
||||
ApiClient.addMediaPath(virtualFolder.Name, path, networkSharePath, refreshAfterChange).then(function() {
|
||||
hasChanges = !0, refreshLibraryFromServer(page)
|
||||
hasChanges = true;
|
||||
refreshLibraryFromServer(page);
|
||||
}, function() {
|
||||
require(["toast"], function(toast) {
|
||||
toast(Globalize.translate("ErrorAddingMediaPathToVirtualFolder"))
|
||||
})
|
||||
})
|
||||
toast(Globalize.translate("ErrorAddingMediaPathToVirtualFolder"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function updateMediaLocation(page, path, networkSharePath) {
|
||||
|
@ -19,17 +20,18 @@ define(["loading", "dialogHelper", "dom", "components/libraryoptionseditor/libra
|
|||
Path: path,
|
||||
NetworkPath: networkSharePath
|
||||
}).then(function() {
|
||||
hasChanges = !0, refreshLibraryFromServer(page)
|
||||
hasChanges = true;
|
||||
refreshLibraryFromServer(page);
|
||||
}, function() {
|
||||
require(["toast"], function(toast) {
|
||||
toast(Globalize.translate("ErrorAddingMediaPathToVirtualFolder"))
|
||||
})
|
||||
})
|
||||
toast(Globalize.translate("ErrorAddingMediaPathToVirtualFolder"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function onRemoveClick(btnRemovePath, location) {
|
||||
var button = btnRemovePath,
|
||||
virtualFolder = currentOptions.library;
|
||||
var button = btnRemovePath;
|
||||
var virtualFolder = currentOptions.library;
|
||||
require(["confirm"], function(confirm) {
|
||||
confirm({
|
||||
title: Globalize.translate("HeaderRemoveMediaLocation"),
|
||||
|
@ -39,32 +41,44 @@ define(["loading", "dialogHelper", "dom", "components/libraryoptionseditor/libra
|
|||
}).then(function() {
|
||||
var refreshAfterChange = currentOptions.refresh;
|
||||
ApiClient.removeMediaPath(virtualFolder.Name, location, refreshAfterChange).then(function() {
|
||||
hasChanges = !0, refreshLibraryFromServer(dom.parentWithClass(button, "dlg-libraryeditor"))
|
||||
hasChanges = true;
|
||||
refreshLibraryFromServer(dom.parentWithClass(button, "dlg-libraryeditor"));
|
||||
}, function() {
|
||||
require(["toast"], function(toast) {
|
||||
toast(Globalize.translate("DefaultErrorMessage"))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
toast(Globalize.translate("DefaultErrorMessage"));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function onListItemClick(e) {
|
||||
var listItem = dom.parentWithClass(e.target, "listItem");
|
||||
if (listItem) {
|
||||
var index = parseInt(listItem.getAttribute("data-index")),
|
||||
pathInfos = (currentOptions.library.LibraryOptions || {}).PathInfos || [],
|
||||
pathInfo = null == index ? {} : pathInfos[index] || {},
|
||||
originalPath = pathInfo.Path || (null == index ? null : currentOptions.library.Locations[index]),
|
||||
btnRemovePath = dom.parentWithClass(e.target, "btnRemovePath");
|
||||
var index = parseInt(listItem.getAttribute("data-index"));
|
||||
var pathInfos = (currentOptions.library.LibraryOptions || {}).PathInfos || [];
|
||||
var pathInfo = null == index ? {} : pathInfos[index] || {};
|
||||
var originalPath = pathInfo.Path || (null == index ? null : currentOptions.library.Locations[index]);
|
||||
var btnRemovePath = dom.parentWithClass(e.target, "btnRemovePath");
|
||||
if (btnRemovePath) return void onRemoveClick(btnRemovePath, originalPath);
|
||||
showDirectoryBrowser(dom.parentWithClass(listItem, "dlg-libraryeditor"), originalPath, pathInfo.NetworkPath)
|
||||
showDirectoryBrowser(dom.parentWithClass(listItem, "dlg-libraryeditor"), originalPath, pathInfo.NetworkPath);
|
||||
}
|
||||
}
|
||||
|
||||
function getFolderHtml(pathInfo, index) {
|
||||
var html = "";
|
||||
return html += '<div class="listItem listItem-border lnkPath" data-index="' + index + '" style="padding-left:.5em;">', html += '<div class="' + (pathInfo.NetworkPath ? "listItemBody two-line" : "listItemBody") + '">', html += '<h3 class="listItemBodyText">', html += pathInfo.Path, html += "</h3>", pathInfo.NetworkPath && (html += '<div class="listItemBodyText secondary">' + pathInfo.NetworkPath + "</div>"), html += "</div>", html += '<button type="button" is="paper-icon-button-light" class="listItemButton btnRemovePath" data-index="' + index + '"><i class="md-icon">remove_circle</i></button>', html += "</div>"
|
||||
html += '<div class="listItem listItem-border lnkPath" data-index="' + index + '" style="padding-left:.5em;">';
|
||||
html += '<div class="' + (pathInfo.NetworkPath ? "listItemBody two-line" : "listItemBody") + '">';
|
||||
html += '<h3 class="listItemBodyText">';
|
||||
html += pathInfo.Path;
|
||||
html += "</h3>";
|
||||
if (pathInfo.NetworkPath) {
|
||||
html += '<div class="listItemBodyText secondary">' + pathInfo.NetworkPath + "</div>";
|
||||
}
|
||||
html += "</div>";
|
||||
html += '<button type="button" is="paper-icon-button-light" class="listItemButton btnRemovePath" data-index="' + index + '"><i class="md-icon">remove_circle</i></button>';
|
||||
html += "</div>";
|
||||
return html;
|
||||
}
|
||||
|
||||
function refreshLibraryFromServer(page) {
|
||||
|
@ -72,8 +86,11 @@ define(["loading", "dialogHelper", "dom", "components/libraryoptionseditor/libra
|
|||
var library = result.filter(function(f) {
|
||||
return f.Name === currentOptions.library.Name
|
||||
})[0];
|
||||
library && (currentOptions.library = library, renderLibrary(page, currentOptions))
|
||||
})
|
||||
if (library) {
|
||||
currentOptions.library = library;
|
||||
renderLibrary(page, currentOptions);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderLibrary(page, options) {
|
||||
|
@ -82,11 +99,17 @@ define(["loading", "dialogHelper", "dom", "components/libraryoptionseditor/libra
|
|||
return {
|
||||
Path: p
|
||||
}
|
||||
})), "boxsets" === options.library.CollectionType ? page.querySelector(".folders").classList.add("hide") : page.querySelector(".folders").classList.remove("hide"), page.querySelector(".folderList").innerHTML = pathInfos.map(getFolderHtml).join("")
|
||||
}));
|
||||
if (options.library.CollectionType === 'boxsets') {
|
||||
page.querySelector(".folders").classList.add("hide");
|
||||
} else {
|
||||
page.querySelector(".folders").classList.remove("hide");
|
||||
}
|
||||
page.querySelector(".folderList").innerHTML = pathInfos.map(getFolderHtml).join("");
|
||||
}
|
||||
|
||||
function onAddButtonClick() {
|
||||
showDirectoryBrowser(dom.parentWithClass(this, "dlg-libraryeditor"))
|
||||
showDirectoryBrowser(dom.parentWithClass(this, "dlg-libraryeditor"));
|
||||
}
|
||||
|
||||
function showDirectoryBrowser(context, originalPath, networkPath) {
|
||||
|
@ -98,7 +121,8 @@ define(["loading", "dialogHelper", "dom", "components/libraryoptionseditor/libra
|
|||
path: originalPath,
|
||||
networkSharePath: networkPath,
|
||||
callback: function(path, networkSharePath) {
|
||||
path && (originalPath ? updateMediaLocation(context, originalPath, networkSharePath) : addMediaLocation(context, path, networkSharePath)), picker.close()
|
||||
path && (originalPath ? updateMediaLocation(context, originalPath, networkSharePath) : addMediaLocation(context, path, networkSharePath));
|
||||
picker.close();
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -110,40 +134,67 @@ define(["loading", "dialogHelper", "dom", "components/libraryoptionseditor/libra
|
|||
}
|
||||
|
||||
function initEditor(dlg, options) {
|
||||
renderLibrary(dlg, options), dlg.querySelector(".btnAddFolder").addEventListener("click", onAddButtonClick), dlg.querySelector(".folderList").addEventListener("click", onListItemClick), dlg.querySelector(".chkAdvanced").addEventListener("change", onToggleAdvancedChange), libraryoptionseditor.embed(dlg.querySelector(".libraryOptions"), options.library.CollectionType, options.library.LibraryOptions).then(function() {
|
||||
onToggleAdvancedChange.call(dlg.querySelector(".chkAdvanced"))
|
||||
})
|
||||
renderLibrary(dlg, options);
|
||||
dlg.querySelector(".btnAddFolder").addEventListener("click", onAddButtonClick);
|
||||
dlg.querySelector(".folderList").addEventListener("click", onListItemClick);
|
||||
dlg.querySelector(".chkAdvanced").addEventListener("change", onToggleAdvancedChange);
|
||||
libraryoptionseditor.embed(dlg.querySelector(".libraryOptions"), options.library.CollectionType, options.library.LibraryOptions).then(function() {
|
||||
onToggleAdvancedChange.call(dlg.querySelector(".chkAdvanced"));
|
||||
});
|
||||
}
|
||||
|
||||
function onDialogClosing() {
|
||||
var dlg = this,
|
||||
libraryOptions = libraryoptionseditor.getLibraryOptions(dlg.querySelector(".libraryOptions"));
|
||||
libraryOptions = Object.assign(currentOptions.library.LibraryOptions || {}, libraryOptions), ApiClient.updateVirtualFolderOptions(currentOptions.library.ItemId, libraryOptions)
|
||||
var dlg = this;
|
||||
var libraryOptions = libraryoptionseditor.getLibraryOptions(dlg.querySelector(".libraryOptions"));
|
||||
libraryOptions = Object.assign(currentOptions.library.LibraryOptions || {}, libraryOptions);
|
||||
ApiClient.updateVirtualFolderOptions(currentOptions.library.ItemId, libraryOptions);
|
||||
}
|
||||
|
||||
function onDialogClosed() {
|
||||
loading.hide(), hasChanges = !0, currentDeferred.resolveWith(null, [hasChanges])
|
||||
loading.hide();
|
||||
hasChanges = true;
|
||||
currentDeferred.resolveWith(null, [hasChanges]);
|
||||
}
|
||||
|
||||
function editor() {
|
||||
this.show = function(options) {
|
||||
var deferred = jQuery.Deferred();
|
||||
currentOptions = options, currentDeferred = deferred, hasChanges = !1;
|
||||
currentOptions = options;
|
||||
currentDeferred = deferred;
|
||||
hasChanges = false;
|
||||
var xhr = new XMLHttpRequest;
|
||||
return xhr.open("GET", "components/medialibraryeditor/medialibraryeditor.template.html", !0), xhr.onload = function(e) {
|
||||
var template = this.response,
|
||||
dlg = dialogHelper.createDialog({
|
||||
size: "medium-tall",
|
||||
modal: !1,
|
||||
removeOnClose: !0,
|
||||
scrollY: !1
|
||||
});
|
||||
dlg.classList.add("dlg-libraryeditor"), dlg.classList.add("ui-body-a"), dlg.classList.add("background-theme-a"), dlg.classList.add("formDialog"), dlg.innerHTML = Globalize.translateDocument(template), dlg.querySelector(".formDialogHeaderTitle").innerHTML = options.library.Name, initEditor(dlg, options), dlg.addEventListener("closing", onDialogClosing), dlg.addEventListener("close", onDialogClosed), dialogHelper.open(dlg), dlg.querySelector(".btnCancel").addEventListener("click", function() {
|
||||
dialogHelper.close(dlg)
|
||||
}), refreshLibraryFromServer(dlg)
|
||||
}, xhr.send(), deferred.promise()
|
||||
xhr.open("GET", "components/medialibraryeditor/medialibraryeditor.template.html", true);
|
||||
xhr.onload = function(e) {
|
||||
var template = this.response;
|
||||
var dlg = dialogHelper.createDialog({
|
||||
size: "medium-tall",
|
||||
modal: false,
|
||||
removeOnClose: true,
|
||||
scrollY: false
|
||||
});
|
||||
dlg.classList.add("dlg-libraryeditor");
|
||||
dlg.classList.add("ui-body-a");
|
||||
dlg.classList.add("background-theme-a");
|
||||
dlg.classList.add("formDialog");
|
||||
dlg.innerHTML = Globalize.translateDocument(template);
|
||||
dlg.querySelector(".formDialogHeaderTitle").innerHTML = options.library.Name;
|
||||
initEditor(dlg, options);
|
||||
dlg.addEventListener("closing", onDialogClosing);
|
||||
dlg.addEventListener("close", onDialogClosed);
|
||||
dialogHelper.open(dlg);
|
||||
dlg.querySelector(".btnCancel").addEventListener("click", function() {
|
||||
dialogHelper.close(dlg);
|
||||
});
|
||||
refreshLibraryFromServer(dlg);
|
||||
};
|
||||
xhr.send();
|
||||
return deferred.promise();
|
||||
}
|
||||
}
|
||||
var currentDeferred, hasChanges, currentOptions;
|
||||
return editor
|
||||
|
||||
var currentDeferred;
|
||||
var hasChanges;
|
||||
var currentOptions;
|
||||
|
||||
return editor;
|
||||
});
|
|
@ -14,11 +14,11 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
require(["medialibrarycreator"], function(medialibrarycreator) {
|
||||
(new medialibrarycreator).show({
|
||||
collectionTypeOptions: getCollectionTypeOptions().filter(function(f) {
|
||||
return !f.hidden
|
||||
return !f.hidden;
|
||||
}),
|
||||
refresh: shouldRefreshLibraryAfterChanges(page)
|
||||
}).then(function(hasChanges) {
|
||||
hasChanges && reloadLibrary(page)
|
||||
hasChanges && reloadLibrary(page);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -29,18 +29,22 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
refresh: shouldRefreshLibraryAfterChanges(page),
|
||||
library: virtualFolder
|
||||
}).then(function(hasChanges) {
|
||||
hasChanges && reloadLibrary(page)
|
||||
hasChanges && reloadLibrary(page);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function deleteVirtualFolder(page, virtualFolder) {
|
||||
var msg = globalize.translate("MessageAreYouSureYouWishToRemoveMediaFolder");
|
||||
virtualFolder.Locations.length && (msg += "<br/><br/>" + globalize.translate("MessageTheFollowingLocationWillBeRemovedFromLibrary") + "<br/><br/>", msg += virtualFolder.Locations.join("<br/>")), require(["confirm"], function(confirm) {
|
||||
if (virtualFolder.Locations.length) {
|
||||
msg += "<br/><br/>" + globalize.translate("MessageTheFollowingLocationWillBeRemovedFromLibrary") + "<br/><br/>";
|
||||
msg += virtualFolder.Locations.join("<br/>");
|
||||
}
|
||||
require(["confirm"], function(confirm) {
|
||||
confirm(msg, globalize.translate("HeaderRemoveMediaFolder")).then(function() {
|
||||
var refreshAfterChange = shouldRefreshLibraryAfterChanges(page);
|
||||
ApiClient.removeVirtualFolder(virtualFolder.Name, refreshAfterChange).then(function() {
|
||||
reloadLibrary(page)
|
||||
reloadLibrary(page);
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -52,8 +56,8 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
itemIds: [virtualFolder.ItemId],
|
||||
serverId: ApiClient.serverId(),
|
||||
mode: "scan"
|
||||
}).show()
|
||||
})
|
||||
}).show();
|
||||
});
|
||||
}
|
||||
|
||||
function renameVirtualFolder(page, virtualFolder) {
|
||||
|
@ -65,43 +69,49 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
if (newName && newName != virtualFolder.Name) {
|
||||
var refreshAfterChange = shouldRefreshLibraryAfterChanges(page);
|
||||
ApiClient.renameVirtualFolder(virtualFolder.Name, newName, refreshAfterChange).then(function() {
|
||||
reloadLibrary(page)
|
||||
})
|
||||
reloadLibrary(page);
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function showCardMenu(page, elem, virtualFolders) {
|
||||
var card = dom.parentWithClass(elem, "card"),
|
||||
index = parseInt(card.getAttribute("data-index")),
|
||||
virtualFolder = virtualFolders[index],
|
||||
menuItems = [];
|
||||
var card = dom.parentWithClass(elem, "card");
|
||||
var index = parseInt(card.getAttribute("data-index"));
|
||||
var virtualFolder = virtualFolders[index];
|
||||
var menuItems = [];
|
||||
menuItems.push({
|
||||
name: globalize.translate("ButtonChangeContentType"),
|
||||
id: "changetype",
|
||||
ironIcon: "videocam"
|
||||
}), menuItems.push({
|
||||
});
|
||||
menuItems.push({
|
||||
name: globalize.translate("ButtonEditImages"),
|
||||
id: "editimages",
|
||||
ironIcon: "photo"
|
||||
}), menuItems.push({
|
||||
});
|
||||
menuItems.push({
|
||||
name: globalize.translate("ManageLibrary"),
|
||||
id: "edit",
|
||||
ironIcon: "folder_open"
|
||||
}), menuItems.push({
|
||||
});
|
||||
menuItems.push({
|
||||
name: globalize.translate("ButtonRemove"),
|
||||
id: "delete",
|
||||
ironIcon: "remove"
|
||||
}), menuItems.push({
|
||||
});
|
||||
menuItems.push({
|
||||
name: globalize.translate("ButtonRename"),
|
||||
id: "rename",
|
||||
ironIcon: "mode_edit"
|
||||
}), menuItems.push({
|
||||
});
|
||||
menuItems.push({
|
||||
name: globalize.translate("ScanLibrary"),
|
||||
id: "refresh",
|
||||
ironIcon: "refresh"
|
||||
}), require(["actionsheet"], function(actionsheet) {
|
||||
});
|
||||
require(["actionsheet"], function(actionsheet) {
|
||||
actionsheet.show({
|
||||
items: menuItems,
|
||||
positionTo: elem,
|
||||
|
@ -123,21 +133,22 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
deleteVirtualFolder(page, virtualFolder);
|
||||
break;
|
||||
case "refresh":
|
||||
refreshVirtualFolder(page, virtualFolder)
|
||||
refreshVirtualFolder(page, virtualFolder);
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function reloadLibrary(page) {
|
||||
loading.show(), ApiClient.getVirtualFolders().then(function(result) {
|
||||
reloadVirtualFolders(page, result)
|
||||
})
|
||||
loading.show();
|
||||
ApiClient.getVirtualFolders().then(function(result) {
|
||||
reloadVirtualFolders(page, result);
|
||||
});
|
||||
}
|
||||
|
||||
function shouldRefreshLibraryAfterChanges(page) {
|
||||
return "mediaLibraryPage" === page.id
|
||||
return "mediaLibraryPage" === page.id;
|
||||
}
|
||||
|
||||
function reloadVirtualFolders(page, virtualFolders) {
|
||||
|
@ -156,16 +167,22 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
html += getVirtualFolderHtml(page, virtualFolder, i)
|
||||
}
|
||||
var divVirtualFolders = page.querySelector("#divVirtualFolders");
|
||||
divVirtualFolders.innerHTML = html, divVirtualFolders.classList.add("itemsContainer"), divVirtualFolders.classList.add("vertical-wrap"), $(".btnCardMenu", divVirtualFolders).on("click", function() {
|
||||
showCardMenu(page, this, virtualFolders)
|
||||
}), divVirtualFolders.querySelector(".addLibrary").addEventListener("click", function() {
|
||||
addVirtualFolder(page)
|
||||
}), $(".editLibrary", divVirtualFolders).on("click", function() {
|
||||
var card = $(this).parents(".card")[0],
|
||||
index = parseInt(card.getAttribute("data-index")),
|
||||
virtualFolder = virtualFolders[index];
|
||||
virtualFolder.ItemId && editVirtualFolder(page, virtualFolder)
|
||||
}), loading.hide()
|
||||
divVirtualFolders.innerHTML = html;
|
||||
divVirtualFolders.classList.add("itemsContainer");
|
||||
divVirtualFolders.classList.add("vertical-wrap");
|
||||
$(".btnCardMenu", divVirtualFolders).on("click", function() {
|
||||
showCardMenu(page, this, virtualFolders);
|
||||
});
|
||||
divVirtualFolders.querySelector(".addLibrary").addEventListener("click", function() {
|
||||
addVirtualFolder(page);
|
||||
});
|
||||
$(".editLibrary", divVirtualFolders).on("click", function() {
|
||||
var card = $(this).parents(".card")[0];
|
||||
var index = parseInt(card.getAttribute("data-index"));
|
||||
var virtualFolder = virtualFolders[index];
|
||||
virtualFolder.ItemId && editVirtualFolder(page, virtualFolder);
|
||||
});
|
||||
loading.hide();
|
||||
}
|
||||
|
||||
function editImages(page, virtualFolder) {
|
||||
|
@ -174,13 +191,13 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
itemId: virtualFolder.ItemId,
|
||||
serverId: ApiClient.serverId()
|
||||
}).then(function() {
|
||||
reloadLibrary(page)
|
||||
})
|
||||
reloadLibrary(page);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function getLink(text, url) {
|
||||
return globalize.translate(text, '<a is="emby-linkbutton" class="button-link" href="' + url + '" target="_blank" data-autohide="true">', "</a>")
|
||||
return globalize.translate(text, '<a is="emby-linkbutton" class="button-link" href="' + url + '" target="_blank" data-autohide="true">', "</a>");
|
||||
}
|
||||
|
||||
function getCollectionTypeOptions() {
|
||||
|
@ -236,31 +253,81 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
case "channels":
|
||||
case "playlists":
|
||||
default:
|
||||
return "folder"
|
||||
return "folder";
|
||||
}
|
||||
}
|
||||
|
||||
function getVirtualFolderHtml(page, virtualFolder, index) {
|
||||
var html = "",
|
||||
style = "";
|
||||
page.classList.contains("wizardPage") && (style += "min-width:33.3%;"), html += '<div class="card backdropCard scalableCard backdropCard-scalable" style="' + style + '" data-index="' + index + '" data-id="' + virtualFolder.ItemId + '">', html += '<div class="cardBox visualCardBox">', html += '<div class="cardScalable visualCardBox-cardScalable">', html += '<div class="cardPadder cardPadder-backdrop"></div>', html += '<div class="cardContent">';
|
||||
var html = "";
|
||||
var style = "";
|
||||
page.classList.contains("wizardPage") && (style += "min-width:33.3%;");
|
||||
html += '<div class="card backdropCard scalableCard backdropCard-scalable" style="' + style + '" data-index="' + index + '" data-id="' + virtualFolder.ItemId + '">';
|
||||
html += '<div class="cardBox visualCardBox">';
|
||||
html += '<div class="cardScalable visualCardBox-cardScalable">';
|
||||
html += '<div class="cardPadder cardPadder-backdrop"></div>';
|
||||
html += '<div class="cardContent">';
|
||||
var imgUrl = "";
|
||||
virtualFolder.PrimaryImageItemId && (imgUrl = ApiClient.getScaledImageUrl(virtualFolder.PrimaryImageItemId, {
|
||||
type: "Primary"
|
||||
}));
|
||||
if (virtualFolder.PrimaryImageItemId) {
|
||||
imgUrl = ApiClient.getScaledImageUrl(virtualFolder.PrimaryImageItemId, {
|
||||
type: "Primary"
|
||||
});
|
||||
}
|
||||
var hasCardImageContainer;
|
||||
if (imgUrl ? (html += '<div class="cardImageContainer editLibrary" style="cursor:pointer;background-image:url(\'' + imgUrl + "');\">", hasCardImageContainer = !0) : virtualFolder.showNameWithIcon || (html += '<div class="cardImageContainer editLibrary" style="cursor:pointer;">', html += '<i class="cardImageIcon-small md-icon">' + (virtualFolder.icon || getIcon(virtualFolder.CollectionType)) + "</i>", hasCardImageContainer = !0), hasCardImageContainer) {
|
||||
if (imgUrl) {
|
||||
html += '<div class="cardImageContainer editLibrary" style="cursor:pointer;background-image:url(\'' + imgUrl + "');\">";
|
||||
hasCardImageContainer = true;
|
||||
} else if (!virtualFolder.showNameWithIcon) {
|
||||
html += '<div class="cardImageContainer editLibrary" style="cursor:pointer;">';
|
||||
html += '<i class="cardImageIcon-small md-icon">' + (virtualFolder.icon || getIcon(virtualFolder.CollectionType)) + "</i>";
|
||||
hasCardImageContainer = true;
|
||||
}
|
||||
if (hasCardImageContainer) {
|
||||
html += '<div class="cardIndicators backdropCardIndicators">';
|
||||
html += '<div is="emby-itemrefreshindicator"' + (virtualFolder.RefreshProgress || virtualFolder.RefreshStatus && "Idle" !== virtualFolder.RefreshStatus ? "" : ' class="hide"') + ' data-progress="' + (virtualFolder.RefreshProgress || 0) + '" data-status="' + virtualFolder.RefreshStatus + '"></div>', html += "</div>", html += "</div>"
|
||||
html += '<div is="emby-itemrefreshindicator"' + (virtualFolder.RefreshProgress || virtualFolder.RefreshStatus && "Idle" !== virtualFolder.RefreshStatus ? "" : ' class="hide"') + ' data-progress="' + (virtualFolder.RefreshProgress || 0) + '" data-status="' + virtualFolder.RefreshStatus + '"></div>';
|
||||
html += "</div>";
|
||||
html += "</div>";
|
||||
}
|
||||
if (!imgUrl && virtualFolder.showNameWithIcon && (html += '<h3 class="cardImageContainer addLibrary" style="position:absolute;top:0;left:0;right:0;bottom:0;cursor:pointer;flex-direction:column;">', html += '<i class="cardImageIcon-small md-icon">' + (virtualFolder.icon || getIcon(virtualFolder.CollectionType)) + "</i>", virtualFolder.showNameWithIcon && (html += '<div style="margin:1em 0;position:width:100%;">', html += virtualFolder.Name, html += "</div>"), html += "</h3>"), html += "</div>", html += "</div>", html += '<div class="cardFooter visualCardBox-cardFooter">', !1 !== virtualFolder.showMenu) {
|
||||
html += '<div style="text-align:right; float:right;padding-top:5px;">', html += '<button type="button" is="paper-icon-button-light" class="btnCardMenu autoSize"><i class="md-icon"></i></button>', html += "</div>"
|
||||
if (!imgUrl && virtualFolder.showNameWithIcon) {
|
||||
html += '<h3 class="cardImageContainer addLibrary" style="position:absolute;top:0;left:0;right:0;bottom:0;cursor:pointer;flex-direction:column;">';
|
||||
html += '<i class="cardImageIcon-small md-icon">' + (virtualFolder.icon || getIcon(virtualFolder.CollectionType)) + "</i>";
|
||||
virtualFolder.showNameWithIcon && (html += '<div style="margin:1em 0;position:width:100%;">', html += virtualFolder.Name, html += "</div>");
|
||||
html += "</h3>";
|
||||
}
|
||||
html += "<div class='cardText'>", virtualFolder.showNameWithIcon ? html += " " : html += virtualFolder.Name, html += "</div>";
|
||||
html += "</div>";
|
||||
html += "</div>";
|
||||
html += '<div class="cardFooter visualCardBox-cardFooter">';
|
||||
if (virtualFolder.showMenu === true) {
|
||||
html += '<div style="text-align:right; float:right;padding-top:5px;">';
|
||||
html += '<button type="button" is="paper-icon-button-light" class="btnCardMenu autoSize"><i class="md-icon"></i></button>';
|
||||
html += "</div>";
|
||||
}
|
||||
html += "<div class='cardText'>";
|
||||
virtualFolder.showNameWithIcon ? html += " " : html += virtualFolder.Name;
|
||||
html += "</div>";
|
||||
var typeName = getCollectionTypeOptions().filter(function(t) {
|
||||
return t.value == virtualFolder.CollectionType
|
||||
})[0];
|
||||
return typeName = typeName ? typeName.name : globalize.translate("FolderTypeUnset"), html += "<div class='cardText cardText-secondary'>", !1 === virtualFolder.showType ? html += " " : html += typeName, html += "</div>", !1 === virtualFolder.showLocations ? (html += "<div class='cardText cardText-secondary'>", html += " ", html += "</div>") : virtualFolder.Locations.length && 1 == virtualFolder.Locations.length ? (html += "<div class='cardText cardText-secondary'>", html += virtualFolder.Locations[0], html += "</div>") : (html += "<div class='cardText cardText-secondary'>", html += globalize.translate("NumLocationsValue", virtualFolder.Locations.length), html += "</div>"), html += "</div>", html += "</div>", html += "</div>"
|
||||
typeName = typeName ? typeName.name : globalize.translate("FolderTypeUnset");
|
||||
html += "<div class='cardText cardText-secondary'>";
|
||||
virtualFolder.showType === false ? html += " " : html += typeName;
|
||||
html += "</div>";
|
||||
if (virtualFolder.showLocations === false) {
|
||||
html += "<div class='cardText cardText-secondary'>";
|
||||
html += " ";
|
||||
html += "</div>";
|
||||
} else if (virtualFolder.Locations.length && virtualFolder.Locations.length === 1) {
|
||||
html += "<div class='cardText cardText-secondary'>";
|
||||
html += virtualFolder.Locations[0];
|
||||
html += "</div>";
|
||||
} else {
|
||||
html += "<div class='cardText cardText-secondary'>";
|
||||
html += globalize.translate("NumLocationsValue", virtualFolder.Locations.length);
|
||||
html += "</div>";
|
||||
}
|
||||
html += "</div>";
|
||||
html += "</div>";
|
||||
html += "</div>";
|
||||
return html;
|
||||
}
|
||||
|
||||
function getTabs() {
|
||||
|
@ -285,9 +352,11 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
next: function() {
|
||||
Dashboard.navigate("wizardsettings.html")
|
||||
}
|
||||
}, pageClassOn("pageshow", "mediaLibraryPage", function() {
|
||||
reloadLibrary(this)
|
||||
}), pageIdOn("pageshow", "mediaLibraryPage", function() {
|
||||
};
|
||||
pageClassOn("pageshow", "mediaLibraryPage", function() {
|
||||
reloadLibrary(this);
|
||||
});
|
||||
pageIdOn("pageshow", "mediaLibraryPage", function() {
|
||||
libraryMenu.setTabs("librarysetup", 0, getTabs);
|
||||
var page = this;
|
||||
taskButton({
|
||||
|
@ -295,14 +364,15 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||
progressElem: page.querySelector(".refreshProgress"),
|
||||
taskKey: "RefreshLibrary",
|
||||
button: page.querySelector(".btnRefresh")
|
||||
})
|
||||
}), pageIdOn("pagebeforehide", "mediaLibraryPage", function() {
|
||||
});
|
||||
});
|
||||
pageIdOn("pagebeforehide", "mediaLibraryPage", function() {
|
||||
var page = this;
|
||||
taskButton({
|
||||
mode: "off",
|
||||
progressElem: page.querySelector(".refreshProgress"),
|
||||
taskKey: "RefreshLibrary",
|
||||
button: page.querySelector(".btnRefresh")
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue