define([], function () {
var systemInfo;
function getSystemInfo() {
var deferred = DeferredBuilder.Deferred();
if (systemInfo) {
deferred.resolveWith(null, [systemInfo]);
} else {
ApiClient.getPublicSystemInfo().done(function (info) {
systemInfo = info;
deferred.resolveWith(null, [systemInfo]);
});
}
return deferred.promise();
}
function onDialogClosed() {
$(this).remove();
Dashboard.hideLoadingMsg();
}
function refreshDirectoryBrowser(page, path, fileOptions) {
Dashboard.showLoadingMsg();
if (path) {
$('.networkHeadline').hide();
} else {
$('.networkHeadline').show();
}
var promise;
var parentPathPromise = null;
if (path === "Network") {
promise = ApiClient.getNetworkDevices();
}
else if (path) {
promise = ApiClient.getDirectoryContents(path, fileOptions);
parentPathPromise = ApiClient.getParentPath(path);
} else {
promise = ApiClient.getDrives();
}
if (!parentPathPromise) {
parentPathPromise = $.Deferred();
parentPathPromise.resolveWith(null, []);
parentPathPromise = parentPathPromise.promise();
}
$.when(promise, parentPathPromise).done(function (response1, response2) {
var folders = response1[0];
var parentPath = response2 && response2.length ? response2[0] || '' : '';
$('#txtDirectoryPickerPath', page).val(path || "");
var html = '';
if (path) {
html += '
' : '';
html += '
';
html += instruction;
html += Globalize.translate('MessageDirectoryPickerInstruction')
.replace('{0}', '\\\\server')
.replace('{1}', '\\\\192.168.1.101');
if (systemInfo.OperatingSystem.toLowerCase() == 'bsd') {
html += '
';
html += '
';
html += Globalize.translate('MessageDirectoryPickerBSDInstruction');
html += '
';
html += '' + Globalize.translate('ButtonMoreInformation') + '';
}
else if (systemInfo.OperatingSystem.toLowerCase() == 'linux') {
html += '
';
html += '
';
html += Globalize.translate('MessageDirectoryPickerLinuxInstruction');
html += '
';
html += '' + Globalize.translate('ButtonMoreInformation') + '';
}
html += '