jellyfin-web/dashboard-ui/components/libraryoptionseditor/libraryoptionseditor.js

79 lines
3.3 KiB
JavaScript
Raw Normal View History

2016-08-12 23:33:31 -07:00
define(['globalize', 'emby-checkbox'], function (globalize) {
2016-08-13 13:54:29 -07:00
function embed(parent, contentType, libraryOptions) {
2016-08-12 23:33:31 -07:00
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'components/libraryoptionseditor/libraryoptionseditor.template.html', true);
xhr.onload = function (e) {
var template = this.response;
parent.innerHTML = globalize.translateDocument(template);
setContentType(parent, contentType);
2016-08-13 13:54:29 -07:00
if (libraryOptions) {
setLibraryOptions(parent, libraryOptions);
}
2016-08-12 23:33:31 -07:00
resolve();
}
xhr.send();
});
}
function setContentType(parent, contentType) {
if (contentType == 'music' || contentType == 'tvshows' || contentType == 'movies' || contentType == 'homevideos' || contentType == 'musicvideos' || contentType == 'mixed') {
parent.querySelector('.chkArhiveAsMediaContainer').classList.remove('hide');
} else {
parent.querySelector('.chkArhiveAsMediaContainer').classList.add('hide');
}
2016-08-14 21:36:17 -07:00
if (contentType == 'homevideos') {
parent.querySelector('.chkEnablePhotosContainer').classList.remove('hide');
} else {
parent.querySelector('.chkEnablePhotosContainer').classList.add('hide');
}
if (contentType == 'tvshows' || contentType == 'movies' || contentType == 'homevideos' || contentType == 'musicvideos' || contentType == 'mixed' || !contentType) {
parent.querySelector('.fldExtractChaptersDuringLibraryScan').classList.remove('hide');
parent.querySelector('.fldExtractChapterImages').classList.remove('hide');
} else {
parent.querySelector('.fldExtractChaptersDuringLibraryScan').classList.add('hide');
parent.querySelector('.fldExtractChapterImages').classList.add('hide');
}
2016-08-12 23:33:31 -07:00
}
function getLibraryOptions(parent) {
var options = {
2016-08-14 21:36:17 -07:00
EnableArchiveMediaFiles: parent.querySelector('.chkArhiveAsMedia').checked,
2016-08-24 13:46:26 -07:00
EnablePhotos: parent.querySelector('.chkEnablePhotos').checked,
EnableRealtimeMonitor: parent.querySelector('.chkEnableRealtimeMonitor').checked,
ExtractChapterImagesDuringLibraryScan: parent.querySelector('.chkExtractChaptersDuringLibraryScan').checked,
EnableChapterImageExtraction: parent.querySelector('.chkExtractChapterImages').checked
2016-08-12 23:33:31 -07:00
};
return options;
}
2016-08-13 13:54:29 -07:00
function setLibraryOptions(parent, options) {
2016-08-14 21:36:17 -07:00
parent.querySelector('.chkArhiveAsMedia').checked = options.EnableArchiveMediaFiles;
parent.querySelector('.chkEnablePhotos').checked = options.EnablePhotos;
2016-08-24 13:46:26 -07:00
parent.querySelector('.chkEnableRealtimeMonitor').checked = options.EnableRealtimeMonitor;
parent.querySelector('.chkExtractChaptersDuringLibraryScan').checked = options.ExtractChapterImagesDuringLibraryScan;
parent.querySelector('.chkExtractChapterImages').checked = options.EnableChapterImageExtraction;
2016-08-13 13:54:29 -07:00
}
2016-08-12 23:33:31 -07:00
return {
embed: embed,
setContentType: setContentType,
2016-08-13 13:54:29 -07:00
getLibraryOptions: getLibraryOptions,
setLibraryOptions: setLibraryOptions
2016-08-12 23:33:31 -07:00
};
});