mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 15:37:26 -06:00
Conditionally hide settings in Advanced Options
This commit is contained in:
@@ -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