Browse Source

Remove conditionals

adaptive-webui-19844
Thomas Piccirello 7 years ago
parent
commit
e0c74c2d39
  1. 325
      src/webui/www/private/preferences_content.html

325
src/webui/www/private/preferences_content.html

@ -483,12 +483,9 @@
var WatchedFoldersTable = new HtmlTable($("watched_folders_tab")); var WatchedFoldersTable = new HtmlTable($("watched_folders_tab"));
updateTempDirEnabled = function() { updateTempDirEnabled = function() {
if($('temppath_checkbox').getProperty('checked')) { var isTempDirEnabled = $('temppath_checkbox').getProperty('checked');
$('temppath_text').setProperty('disabled', false); $('temppath_text').setProperty('disabled', !isTempDirEnabled);
} else { };
$('temppath_text').setProperty('disabled', true);
}
}
addWatchFolder = function() { addWatchFolder = function() {
var new_folder = $('new_watch_folder_txt').getProperty('value').trim(); var new_folder = $('new_watch_folder_txt').getProperty('value').trim();
@ -508,7 +505,7 @@ addWatchFolder = function() {
elt.setProperty('value', 'watch_folder'); elt.setProperty('value', 'watch_folder');
var text = elt.options[elt.selectedIndex].innerHTML; var text = elt.options[elt.selectedIndex].innerHTML;
$('new_watch_folder_other_txt').setProperty('value', text); $('new_watch_folder_other_txt').setProperty('value', text);
} };
changeWatchFolderSelect = function(item) { changeWatchFolderSelect = function(item) {
if (item.value == "other") { if (item.value == "other") {
@ -518,11 +515,11 @@ changeWatchFolderSelect = function(item) {
var text = item.options[item.selectedIndex].innerHTML; var text = item.options[item.selectedIndex].innerHTML;
item.nextElementSibling.value = text; item.nextElementSibling.value = text;
} }
} };
changeWatchFolderText = function(item) { changeWatchFolderText = function(item) {
item.previousElementSibling.value = 'other'; item.previousElementSibling.value = 'other';
} };
pushWatchFolder = function(pos, folder, sel, other) { pushWatchFolder = function(pos, folder, sel, other) {
var myinput = "<input id='text_watch_"+ pos +"' type='text' value='" + folder + "'>"; var myinput = "<input id='text_watch_"+ pos +"' type='text' value='" + folder + "'>";
@ -542,7 +539,7 @@ pushWatchFolder = function(pos, folder, sel, other) {
other = elt.options[elt.selectedIndex].innerHTML; other = elt.options[elt.selectedIndex].innerHTML;
} }
$('cb_watch_txt_'+ pos).setProperty('value', other); $('cb_watch_txt_'+ pos).setProperty('value', other);
} };
getWatchedFolders = function() { getWatchedFolders = function() {
var nb_folders = $("watched_folders_tab").getChildren("tbody")[0].getChildren("tr").length; var nb_folders = $("watched_folders_tab").getChildren("tbody")[0].getChildren("tr").length;
@ -561,113 +558,82 @@ getWatchedFolders = function() {
} }
} }
return folders; return folders;
} };
updateExportDirEnabled = function() { updateExportDirEnabled = function() {
if($('exportdir_checkbox').getProperty('checked')) { var isExportDirEnabled = $('exportdir_checkbox').getProperty('checked');
$('exportdir_text').setProperty('disabled', false); $('exportdir_text').setProperty('disabled', !isExportDirEnabled);
} else { };
$('exportdir_text').setProperty('disabled', true);
}
}
updateExportDirFinEnabled = function() { updateExportDirFinEnabled = function() {
if($('exportdirfin_checkbox').getProperty('checked')) { var isExportDirFinEnabled = $('exportdirfin_checkbox').getProperty('checked');
$('exportdirfin_text').setProperty('disabled', false); $('exportdirfin_text').setProperty('disabled', !isExportDirFinEnabled);
} else { };
$('exportdirfin_text').setProperty('disabled', true);
}
}
updateMailNotification = function() { updateMailNotification = function() {
if($('mail_notification_checkbox').getProperty('checked')) { var isMailNotificationEnabled = $('mail_notification_checkbox').getProperty('checked');
$('dest_email_txt').setProperty('disabled', false); $('dest_email_txt').setProperty('disabled', !isMailNotificationEnabled);
$('smtp_server_txt').setProperty('disabled', false); $('smtp_server_txt').setProperty('disabled', !isMailNotificationEnabled);
$('mail_auth_checkbox').setProperty('disabled', false); $('mail_ssl_checkbox').setProperty('disabled', !isMailNotificationEnabled);
$('mail_ssl_checkbox').setProperty('disabled', false); $('mail_auth_checkbox').setProperty('disabled', !isMailNotificationEnabled);
} else {
$('dest_email_txt').setProperty('disabled', true); if(!isMailNotificationEnabled) {
$('smtp_server_txt').setProperty('disabled', true); $('mail_auth_checkbox').setProperty('checked', !isMailNotificationEnabled);
$('mail_ssl_checkbox').setProperty('disabled', true);
$('mail_auth_checkbox').setProperty('disabled', true);
$('mail_auth_checkbox').setProperty('checked', false);
updateMailAuthSettings(); updateMailAuthSettings();
} }
} };
updateMailAuthSettings = function() { updateMailAuthSettings = function() {
if($('mail_auth_checkbox').getProperty('checked')) { var isMailAuthEnabled = $('mail_auth_checkbox').getProperty('checked');
$('mail_username_text').setProperty('disabled', false); $('mail_username_text').setProperty('disabled', !isMailAuthEnabled);
$('mail_password_text').setProperty('disabled', false); $('mail_password_text').setProperty('disabled', !isMailAuthEnabled);
} else { };
$('mail_username_text').setProperty('disabled', true);
$('mail_password_text').setProperty('disabled', true);
}
}
updateAutoRun = function() { updateAutoRun = function() {
if($('autorun_checkbox').getProperty('checked')) { var isAutoRunEnabled = $('autorun_checkbox').getProperty('checked');
$('autorunProg_txt').setProperty('disabled', false); $('autorunProg_txt').setProperty('disabled', !isAutoRunEnabled);
} else { };
$('autorunProg_txt').setProperty('disabled', true);
}
}
// Connection tab // Connection tab
updateMaxConnecEnabled = function() { updateMaxConnecEnabled = function() {
if($('max_connec_checkbox').getProperty('checked')) { var isMaxConnecEnabled = $('max_connec_checkbox').getProperty('checked');
$('max_connec_value').setProperty('disabled', false); $('max_connec_value').setProperty('disabled', !isMaxConnecEnabled);
} else { };
$('max_connec_value').setProperty('disabled', true);
}
}
updateMaxConnecPerTorrentEnabled = function() { updateMaxConnecPerTorrentEnabled = function() {
if($('max_connec_per_torrent_checkbox').getProperty('checked')) { var isMaxConnecPerTorrentEnabled = $('max_connec_per_torrent_checkbox').getProperty('checked');
$('max_connec_per_torrent_value').setProperty('disabled', false); $('max_connec_per_torrent_value').setProperty('disabled', !isMaxConnecPerTorrentEnabled);
} else { };
$('max_connec_per_torrent_value').setProperty('disabled', true);
}
}
updateMaxUploadsEnabled = function() { updateMaxUploadsEnabled = function() {
if($('max_uploads_checkbox').getProperty('checked')) { var isMaxUploadsEnabled = $('max_uploads_checkbox').getProperty('checked');
$('max_uploads_value').setProperty('disabled', false); $('max_uploads_value').setProperty('disabled', !isMaxUploadsEnabled);
} else { };
$('max_uploads_value').setProperty('disabled', true);
}
}
updateMaxUploadsPerTorrentEnabled = function() { updateMaxUploadsPerTorrentEnabled = function() {
if($('max_uploads_per_torrent_checkbox').getProperty('checked')) { var isMaxUploadsPerTorrentEnabled = $('max_uploads_per_torrent_checkbox').getProperty('checked');
$('max_uploads_per_torrent_value').setProperty('disabled', false); $('max_uploads_per_torrent_value').setProperty('disabled', !isMaxUploadsPerTorrentEnabled);
} else { };
$('max_uploads_per_torrent_value').setProperty('disabled', true);
}
}
updatePeerProxySettings = function() { updatePeerProxySettings = function() {
if($('peer_proxy_type_select').getProperty('value') != "none") { var isPeerProxyTypeSelected = $('peer_proxy_type_select').getProperty('value') != "none";
$('peer_proxy_host_text').setProperty('disabled', false); $('peer_proxy_host_text').setProperty('disabled', !isPeerProxyTypeSelected);
$('peer_proxy_port_value').setProperty('disabled', false); $('peer_proxy_port_value').setProperty('disabled', !isPeerProxyTypeSelected);
$('use_peer_proxy_checkbox').setProperty('disabled', false); $('use_peer_proxy_checkbox').setProperty('disabled', !isPeerProxyTypeSelected);
$('force_proxy_checkbox').setProperty('disabled', false); $('force_proxy_checkbox').setProperty('disabled', !isPeerProxyTypeSelected);
$('proxy_only_for_torrents_checkbox').setProperty('disabled', false); $('proxy_only_for_torrents_checkbox').setProperty('disabled', !isPeerProxyTypeSelected);
if($('peer_proxy_type_select').getProperty('value') != "socks5") {
$('peer_proxy_auth_checkbox').setProperty('checked', false); if(isPeerProxyTypeSelected) {
$('peer_proxy_auth_checkbox').setProperty('disabled', true); var isPeerProxyTypeSocks5 = $('peer_proxy_type_select').getProperty('value') == "socks5";
$('peer_proxy_auth_checkbox').setProperty('disabled', !isPeerProxyTypeSocks5);
if(!isPeerProxyTypeSocks5) {
$('peer_proxy_auth_checkbox').setProperty('checked', isPeerProxyTypeSocks5);
updatePeerProxyAuthSettings(); updatePeerProxyAuthSettings();
} else {
$('peer_proxy_auth_checkbox').setProperty('disabled', false);
} }
} else { } else {
$('peer_proxy_host_text').setProperty('disabled', true); $('peer_proxy_auth_checkbox').setProperty('disabled', !isPeerProxyTypeSelected);
$('peer_proxy_port_value').setProperty('disabled', true); $('peer_proxy_auth_checkbox').setProperty('checked', isPeerProxyTypeSelected);
$('use_peer_proxy_checkbox').setProperty('disabled', true);
$('force_proxy_checkbox').setProperty('disabled', true);
$('proxy_only_for_torrents_checkbox').setProperty('disabled', true);
$('peer_proxy_auth_checkbox').setProperty('disabled', true);
$('peer_proxy_auth_checkbox').setProperty('checked', false);
updatePeerProxyAuthSettings(); updatePeerProxyAuthSettings();
} }
@ -682,148 +648,91 @@ updateForceProxySettings = function() {
}; };
updatePeerProxyAuthSettings = function() { updatePeerProxyAuthSettings = function() {
if($('peer_proxy_auth_checkbox').getProperty('checked')) { var isPeerProxyAuthEnabled = $('peer_proxy_auth_checkbox').getProperty('checked');
$('peer_proxy_username_text').setProperty('disabled', false); $('peer_proxy_username_text').setProperty('disabled', !isPeerProxyAuthEnabled);
$('peer_proxy_password_text').setProperty('disabled', false); $('peer_proxy_password_text').setProperty('disabled', !isPeerProxyAuthEnabled);
} else { };
$('peer_proxy_username_text').setProperty('disabled', true);
$('peer_proxy_password_text').setProperty('disabled', true);
}
}
updateFilterSettings = function() { updateFilterSettings = function() {
if($('ipfilter_enabled_checkbox').getProperty('checked')) { var isIPFilterEnabled = $('ipfilter_enabled_checkbox').getProperty('checked');
$('ipfilter_text').setProperty('disabled', false); $('ipfilter_text').setProperty('disabled', !isIPFilterEnabled);
$('ipfilter_trackers_checkbox').setProperty('disabled', false); $('ipfilter_trackers_checkbox').setProperty('disabled', !isIPFilterEnabled);
$('banned_IPs_textarea').setProperty('disabled', false); $('banned_IPs_textarea').setProperty('disabled', !isIPFilterEnabled);
} else { };
$('ipfilter_text').setProperty('disabled', true);
$('ipfilter_trackers_checkbox').setProperty('disabled', true);
$('banned_IPs_textarea').setProperty('disabled', true);
}
}
// Speed tab // Speed tab
updateUpLimitEnabled = function() { updateUpLimitEnabled = function() {
if($('up_limit_checkbox').getProperty('checked')) { var isUpLimitEnabled = $('up_limit_checkbox').getProperty('checked');
$('up_limit_value').setProperty('disabled', false); $('up_limit_value').setProperty('disabled', !isUpLimitEnabled);
} else { };
$('up_limit_value').setProperty('disabled', true);
}
}
updateDlLimitEnabled = function() { updateDlLimitEnabled = function() {
if($('dl_limit_checkbox').getProperty('checked')) { var isDlLimitEnabled = $('dl_limit_checkbox').getProperty('checked');
$('dl_limit_value').setProperty('disabled', false); $('dl_limit_value').setProperty('disabled', !isDlLimitEnabled);
} else { };
$('dl_limit_value').setProperty('disabled', true);
}
}
updateAltUpLimitEnabled = function() { updateAltUpLimitEnabled = function() {
if($('alt_up_limit_checkbox').getProperty('checked')) { var isAltUpLimitEnabled = $('alt_up_limit_checkbox').getProperty('checked');
$('alt_up_limit_value').setProperty('disabled', false); $('alt_up_limit_value').setProperty('disabled', !isAltUpLimitEnabled);
} else { };
$('alt_up_limit_value').setProperty('disabled', true);
}
}
updateAltDlLimitEnabled = function() { updateAltDlLimitEnabled = function() {
if($('alt_dl_limit_checkbox').getProperty('checked')) { var isAltDlLimitEnabled = $('alt_dl_limit_checkbox').getProperty('checked');
$('alt_dl_limit_value').setProperty('disabled', false); $('alt_dl_limit_value').setProperty('disabled', !isAltDlLimitEnabled);
} else { };
$('alt_dl_limit_value').setProperty('disabled', true);
}
}
updateSchedulingEnabled = function() { updateSchedulingEnabled = function() {
if($('limit_sheduling_checkbox').getProperty('checked')) { var isLimitSchedulingEnabled = $('limit_sheduling_checkbox').getProperty('checked');
$('schedule_from_hour').setProperty('disabled', false); $('schedule_from_hour').setProperty('disabled', !isLimitSchedulingEnabled);
$('schedule_from_min').setProperty('disabled', false); $('schedule_from_min').setProperty('disabled', !isLimitSchedulingEnabled);
$('schedule_to_hour').setProperty('disabled', false); $('schedule_to_hour').setProperty('disabled', !isLimitSchedulingEnabled);
$('schedule_to_min').setProperty('disabled', false); $('schedule_to_min').setProperty('disabled', !isLimitSchedulingEnabled);
$('schedule_freq_select').setProperty('disabled', false); $('schedule_freq_select').setProperty('disabled', !isLimitSchedulingEnabled);
} else { };
$('schedule_from_hour').setProperty('disabled', true);
$('schedule_from_min').setProperty('disabled', true);
$('schedule_to_hour').setProperty('disabled', true);
$('schedule_to_min').setProperty('disabled', true);
$('schedule_freq_select').setProperty('disabled', true);
}
}
// Bittorrent tab // Bittorrent tab
updateQueueingSystem = function() { updateQueueingSystem = function() {
if($('queueing_checkbox').getProperty('checked')) { var isQueueingEnabled = $('queueing_checkbox').getProperty('checked');
$('max_active_dl_value').setProperty('disabled', false); $('max_active_dl_value').setProperty('disabled', !isQueueingEnabled);
$('max_active_up_value').setProperty('disabled', false); $('max_active_up_value').setProperty('disabled', !isQueueingEnabled);
$('max_active_to_value').setProperty('disabled', false); $('max_active_to_value').setProperty('disabled', !isQueueingEnabled);
$('dont_count_slow_torrents_checkbox').setProperty('disabled', false); $('dont_count_slow_torrents_checkbox').setProperty('disabled', !isQueueingEnabled);
} else { };
$('max_active_dl_value').setProperty('disabled', true);
$('max_active_up_value').setProperty('disabled', true);
$('max_active_to_value').setProperty('disabled', true);
$('dont_count_slow_torrents_checkbox').setProperty('disabled', true);
}
}
updateMaxRatioTimeEnabled = function() { updateMaxRatioTimeEnabled = function() {
if($('max_ratio_checkbox').getProperty('checked')) { var isMaxRatioEnabled = $('max_ratio_checkbox').getProperty('checked');
$('max_ratio_value').setProperty('disabled', false); $('max_ratio_value').setProperty('disabled', !isMaxRatioEnabled);
} else {
$('max_ratio_value').setProperty('disabled', true); var isMaxSeedingTimeEnabled = $('max_seeding_time_checkbox').getProperty('checked');
} $('max_seeding_time_value').setProperty('disabled', !isMaxSeedingTimeEnabled);
if($('max_seeding_time_checkbox').getProperty('checked')) {
$('max_seeding_time_value').setProperty('disabled', false); $('max_ratio_act').setProperty('disabled', !(isMaxRatioEnabled || isMaxSeedingTimeEnabled));
} else { };
$('max_seeding_time_value').setProperty('disabled', true);
}
if($('max_ratio_checkbox').getProperty('checked') || $('max_seeding_time_checkbox').getProperty('checked')) {
$('max_ratio_act').setProperty('disabled', false);
} else {
$('max_ratio_act').setProperty('disabled', true);
}
}
updateAddTrackersEnabled = function() { updateAddTrackersEnabled = function() {
if($('add_trackers_checkbox').getProperty('checked')) { var isAddTrackersEnabled = $('add_trackers_checkbox').getProperty('checked');
$('add_trackers_textarea').setProperty('disabled', false); $('add_trackers_textarea').setProperty('disabled', !isAddTrackersEnabled);
} else { };
$('add_trackers_textarea').setProperty('disabled', true);
}
}
// Web UI tab // Web UI tab
updateHttpsSettings = function() { updateHttpsSettings = function() {
if($('use_https_checkbox').getProperty('checked')) { var isAddTrackersEnabled = $('use_https_checkbox').getProperty('checked');
$('ssl_key_textarea').setProperty('disabled', false); $('ssl_key_textarea').setProperty('disabled', !isAddTrackersEnabled);
$('ssl_cert_textarea').setProperty('disabled', false); $('ssl_cert_textarea').setProperty('disabled', !isAddTrackersEnabled);
} else { };
$('ssl_key_textarea').setProperty('disabled', true);
$('ssl_cert_textarea').setProperty('disabled', true);
}
}
updateBypasssAuthSettings = function() { updateBypasssAuthSettings = function() {
if ($('bypass_auth_subnet_whitelist_checkbox').getProperty('checked')) var isBypassAuthSubnetWhitelistEnabled = $('bypass_auth_subnet_whitelist_checkbox').getProperty('checked');
$('bypass_auth_subnet_whitelist_textarea').setProperty('disabled', false); $('bypass_auth_subnet_whitelist_textarea').setProperty('disabled', !isBypassAuthSubnetWhitelistEnabled);
else
$('bypass_auth_subnet_whitelist_textarea').setProperty('disabled', true);
}; };
updateDynDnsSettings = function() { updateDynDnsSettings = function() {
if($('use_dyndns_checkbox').getProperty('checked')) { var isDynDnsEnabled = $('use_dyndns_checkbox').getProperty('checked');
$('dyndns_select').setProperty('disabled', false); $('dyndns_select').setProperty('disabled', !isDynDnsEnabled);
$('dyndns_domain_text').setProperty('disabled', false); $('dyndns_domain_text').setProperty('disabled', !isDynDnsEnabled);
$('dyndns_username_text').setProperty('disabled', false); $('dyndns_username_text').setProperty('disabled', !isDynDnsEnabled);
$('dyndns_password_text').setProperty('disabled', false); $('dyndns_password_text').setProperty('disabled', !isDynDnsEnabled);
} else { };
$('dyndns_select').setProperty('disabled', true);
$('dyndns_domain_text').setProperty('disabled', true);
$('dyndns_username_text').setProperty('disabled', true);
$('dyndns_password_text').setProperty('disabled', true);
}
}
registerDynDns = function() { registerDynDns = function() {
if($('dyndns_select').getProperty('value').toInt() == 1) { if($('dyndns_select').getProperty('value').toInt() == 1) {
@ -831,14 +740,14 @@ registerDynDns = function() {
} else { } else {
window.open("https://www.dyndns.com/account/services/hosts/add.html", "DynDNS Registration"); window.open("https://www.dyndns.com/account/services/hosts/add.html", "DynDNS Registration");
} }
} };
time_padding = function(val) { time_padding = function(val) {
ret = val.toString(); ret = val.toString();
if(ret.length == 1) if(ret.length == 1)
ret = '0' + ret ret = '0' + ret;
return ret; return ret;
} };
loadPreferences = function() { loadPreferences = function() {
var url = 'api/v2/app/preferences'; var url = 'api/v2/app/preferences';

Loading…
Cancel
Save