mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-03 14:12:30 -06:00
Conditionally hide settings in Advanced Options
This commit is contained in:
@@ -125,24 +125,8 @@ function getSyncMainDataInterval() {
|
||||
return customSyncMainDataInterval ? customSyncMainDataInterval : serverSyncMainDataInterval;
|
||||
}
|
||||
|
||||
const fetchQbtVersion = function() {
|
||||
new Request({
|
||||
url: 'api/v2/app/version',
|
||||
method: 'get',
|
||||
onSuccess: function(info) {
|
||||
if (!info)
|
||||
return;
|
||||
sessionStorage.setItem('qbtVersion', info);
|
||||
}
|
||||
}).send();
|
||||
};
|
||||
fetchQbtVersion();
|
||||
|
||||
const qbtVersion = function() {
|
||||
const version = sessionStorage.getItem('qbtVersion');
|
||||
if (!version)
|
||||
return '';
|
||||
return version;
|
||||
return LocalPreferences.get('qbtVersion', '');
|
||||
};
|
||||
|
||||
window.addEvent('load', function() {
|
||||
@@ -1474,6 +1458,38 @@ window.addEvent('load', function() {
|
||||
});
|
||||
};
|
||||
registerDragAndDrop();
|
||||
|
||||
// fetch qbt version and store it locally
|
||||
new Request({
|
||||
url: 'api/v2/app/version',
|
||||
method: 'get',
|
||||
noCache: true,
|
||||
onSuccess: (info) => {
|
||||
if (!info)
|
||||
return;
|
||||
|
||||
LocalPreferences.set('qbtVersion', info);
|
||||
}
|
||||
}).send();
|
||||
|
||||
// fetch build info and store it locally
|
||||
new Request.JSON({
|
||||
url: 'api/v2/app/buildInfo',
|
||||
method: 'get',
|
||||
noCache: true,
|
||||
onSuccess: (info) => {
|
||||
if (!info)
|
||||
return;
|
||||
|
||||
LocalPreferences.set('buildInfo.qtVersion', info.qt);
|
||||
LocalPreferences.set('buildInfo.libtorrentVersion', info.libtorrent);
|
||||
LocalPreferences.set('buildInfo.boostVersion', info.boost);
|
||||
LocalPreferences.set('buildInfo.opensslVersion', info.openssl);
|
||||
LocalPreferences.set('buildInfo.zlibVersion', info.zlib);
|
||||
LocalPreferences.set('buildInfo.bitness', info.bitness);
|
||||
LocalPreferences.set('buildInfo.platform', info.platform);
|
||||
}
|
||||
}).send();
|
||||
});
|
||||
|
||||
function registerMagnetHandler() {
|
||||
|
||||
@@ -40,6 +40,7 @@ window.qBittorrent.Misc = (function() {
|
||||
friendlyPercentage: friendlyPercentage,
|
||||
friendlyFloat: friendlyFloat,
|
||||
parseHtmlLinks: parseHtmlLinks,
|
||||
parseVersion: parseVersion,
|
||||
escapeHtml: escapeHtml,
|
||||
naturalSortCollator: naturalSortCollator,
|
||||
safeTrim: safeTrim,
|
||||
@@ -171,6 +172,29 @@ window.qBittorrent.Misc = (function() {
|
||||
return text.replace(exp, "<a target='_blank' rel='noopener noreferrer' href='$1'>$1</a>");
|
||||
};
|
||||
|
||||
const parseVersion = function(versionString) {
|
||||
const failure = {
|
||||
valid: false
|
||||
};
|
||||
|
||||
if (typeof versionString !== 'string')
|
||||
return failure;
|
||||
|
||||
const tryToNumber = (str) => {
|
||||
const num = Number(str);
|
||||
return (isNaN(num) ? str : num);
|
||||
};
|
||||
|
||||
const ver = versionString.split('.', 4).map(val => tryToNumber(val));
|
||||
return {
|
||||
valid: true,
|
||||
major: ver[0],
|
||||
minor: ver[1],
|
||||
fix: ver[2],
|
||||
patch: ver[3]
|
||||
};
|
||||
};
|
||||
|
||||
const escapeHtml = function(str) {
|
||||
const div = document.createElement('div');
|
||||
div.appendChild(document.createTextNode(str));
|
||||
|
||||
Reference in New Issue
Block a user