jellyfin-web/dashboard-ui/dashboard/wizardcomponents.js

145 lines
5.0 KiB
JavaScript
Raw Normal View History

2016-06-23 10:04:18 -07:00
define([], function () {
2016-10-22 22:11:46 -07:00
'use strict';
2016-06-23 10:04:18 -07:00
function goNext() {
2016-10-18 23:27:02 -07:00
Dashboard.navigate('wizardagreement.html');
2016-06-23 10:04:18 -07:00
}
function loadDownloadInfo(view) {
2016-06-28 19:45:37 -07:00
var instructions = '';
2016-06-23 10:04:18 -07:00
ApiClient.getSystemInfo().then(function (systemInfo) {
2016-11-11 01:13:11 -07:00
var operatingSystem = systemInfo.OperatingSystem.toLowerCase();
if (operatingSystem == 'windows') {
2016-06-29 09:31:01 -07:00
view.querySelector('.fldSelectEncoderPathType').classList.add('hide');
2016-12-22 14:52:18 -07:00
view.querySelector('.markExec').classList.add('hide');
2016-06-29 09:31:01 -07:00
} else {
view.querySelector('.fldSelectEncoderPathType').classList.remove('hide');
2016-12-22 14:52:18 -07:00
view.querySelector('.markExec').classList.remove('hide');
2016-06-29 09:31:01 -07:00
}
2016-11-11 01:13:11 -07:00
if (operatingSystem == 'windows' && systemInfo.SystemArchitecture != 'Arm') {
2016-07-02 19:47:39 -07:00
2016-06-23 10:04:18 -07:00
view.querySelector('.suggestedLocation').innerHTML = Globalize.translate('FFmpegSuggestedDownload', '<a target="_blank" href="https://ffmpeg.zeranoe.com/builds">https://ffmpeg.zeranoe.com</a>');
if (systemInfo.SystemArchitecture == 'X86') {
2016-06-28 22:49:31 -07:00
instructions = 'Download FFmpeg 32-Bit Static';
2016-06-23 10:04:18 -07:00
}
else if (systemInfo.SystemArchitecture == 'X64') {
2016-06-28 22:49:31 -07:00
instructions = 'Download FFmpeg 64-Bit Static';
2016-06-23 10:04:18 -07:00
}
2016-11-11 01:13:11 -07:00
} else if (operatingSystem == 'linux') {
2016-06-28 20:17:27 -07:00
view.querySelector('.suggestedLocation').innerHTML = Globalize.translate('FFmpegSuggestedDownload', '<a target="_blank" href="http://johnvansickle.com/ffmpeg">http://johnvansickle.com/ffmpeg</a>');
2016-07-02 19:47:39 -07:00
2016-06-28 20:17:27 -07:00
if (systemInfo.SystemArchitecture == 'X86') {
instructions = 'Download x86 build';
}
else if (systemInfo.SystemArchitecture == 'X64') {
instructions = 'Download x86_64 build';
}
2016-11-11 01:13:11 -07:00
} else if (operatingSystem == 'osx' && systemInfo.SystemArchitecture == 'X64') {
2016-06-28 19:45:37 -07:00
view.querySelector('.suggestedLocation').innerHTML = Globalize.translate('FFmpegSuggestedDownload', '<a target="_blank" href="http://evermeet.cx/ffmpeg">http://evermeet.cx/ffmpeg</a>');
instructions = 'Download both ffmpeg and ffprobe, and extract them to the same folder.';
2016-06-23 10:04:18 -07:00
} else {
2016-06-28 19:45:37 -07:00
view.querySelector('.suggestedLocation').innerHTML = Globalize.translate('FFmpegSuggestedDownload', '<a target="_blank" href="http://ffmpeg.org">https://ffmpeg.org/download.html</a>');
2016-06-23 10:04:18 -07:00
}
2016-06-29 09:31:01 -07:00
2016-07-02 19:47:39 -07:00
view.querySelector('.downloadInstructions').innerHTML = instructions;
2016-06-29 09:31:01 -07:00
var selectEncoderPath = view.querySelector('#selectEncoderPath');
selectEncoderPath.value = 'Custom';
onSelectEncoderPathChange.call(selectEncoderPath);
2016-06-23 10:04:18 -07:00
});
}
function onSaveEncodingPathFailure(response) {
var msg = '';
// This is a fallback that handles both 404 and 400 (no path entered)
msg = Globalize.translate('FFmpegSavePathNotFound');
require(['alert'], function (alert) {
alert(msg);
});
}
2016-06-29 09:31:01 -07:00
function parentWithClass(elem, className) {
while (!elem.classList || !elem.classList.contains(className)) {
elem = elem.parentNode;
if (!elem) {
return null;
}
}
return elem;
}
function onSelectEncoderPathChange(e) {
var page = parentWithClass(this, 'page');
if (this.value == 'Custom') {
page.querySelector('.fldEncoderPath').classList.remove('hide');
} else {
page.querySelector('.fldEncoderPath').classList.add('hide');
}
}
2016-06-23 10:04:18 -07:00
return function (view, params) {
view.querySelector('#btnSelectEncoderPath').addEventListener("click", function () {
require(['directorybrowser'], function (directoryBrowser) {
var picker = new directoryBrowser();
picker.show({
includeFiles: true,
callback: function (path) {
if (path) {
view.querySelector('.txtEncoderPath').value = path;
}
picker.close();
}
});
});
});
view.querySelector('form').addEventListener('submit', function (e) {
var form = this;
ApiClient.ajax({
url: ApiClient.getUrl('System/MediaEncoder/Path'),
type: 'POST',
data: {
2016-06-28 22:49:31 -07:00
Path: form.querySelector('.txtEncoderPath').value,
PathType: 'Custom'
2016-06-23 10:04:18 -07:00
}
}).then(goNext, onSaveEncodingPathFailure);
e.preventDefault();
return false;
});
2016-06-29 09:31:01 -07:00
view.querySelector('#selectEncoderPath').addEventListener('change', onSelectEncoderPathChange);
2016-06-23 10:04:18 -07:00
view.addEventListener('viewbeforeshow', function (e) {
loadDownloadInfo(view);
});
};
});