From 08f3630f018351078f28bfbe3dd4b695c60c48d0 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 30 Mar 2022 14:26:17 +0800 Subject: [PATCH 1/3] WebUI: make various dialog resizable And enlarge dialog default width. --- src/webui/www/private/newcategory.html | 4 ++-- src/webui/www/private/newtag.html | 2 +- src/webui/www/private/rename.html | 2 +- src/webui/www/private/scripts/mocha-init.js | 22 ++++++++++----------- src/webui/www/private/setlocation.html | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/webui/www/private/newcategory.html b/src/webui/www/private/newcategory.html index 7839a29f9..6fc407d09 100644 --- a/src/webui/www/private/newcategory.html +++ b/src/webui/www/private/newcategory.html @@ -132,9 +132,9 @@

QBT_TR(Category)QBT_TR[CONTEXT=TransferListWidget]:

- +

QBT_TR(Save path)QBT_TR[CONTEXT=TransferListWidget]:

- +
diff --git a/src/webui/www/private/newtag.html b/src/webui/www/private/newtag.html index 6b95fdae8..16b779ce3 100644 --- a/src/webui/www/private/newtag.html +++ b/src/webui/www/private/newtag.html @@ -95,7 +95,7 @@

QBT_TR(Comma-separated tags:)QBT_TR[CONTEXT=TransferListWidget]

- +
diff --git a/src/webui/www/private/rename.html b/src/webui/www/private/rename.html index c530e313c..1284812db 100644 --- a/src/webui/www/private/rename.html +++ b/src/webui/www/private/rename.html @@ -65,7 +65,7 @@

QBT_TR(New name)QBT_TR[CONTEXT=TransferListWidget]:

- +
diff --git a/src/webui/www/private/scripts/mocha-init.js b/src/webui/www/private/scripts/mocha-init.js index 2576673ab..643585b08 100644 --- a/src/webui/www/private/scripts/mocha-init.js +++ b/src/webui/www/private/scripts/mocha-init.js @@ -489,7 +489,7 @@ const initializeWindows = function() { loadMethod: 'iframe', contentURL: new URI("setlocation.html").setData("hashes", hashes.join('|')).setData("path", row.full_data.save_path).toString(), scrollbars: false, - resizable: false, + resizable: true, maximizable: false, paddingVertical: 0, paddingHorizontal: 0, @@ -511,11 +511,11 @@ const initializeWindows = function() { loadMethod: 'iframe', contentURL: new URI("rename.html").setData("hash", hash).setData("name", row.full_data.name).toString(), scrollbars: false, - resizable: false, + resizable: true, maximizable: false, paddingVertical: 0, paddingHorizontal: 0, - width: 250, + width: 400, height: 100 }); } @@ -532,11 +532,11 @@ const initializeWindows = function() { loadMethod: 'iframe', contentURL: new URI("newcategory.html").setData("action", action).setData("hashes", hashes.join('|')).toString(), scrollbars: false, - resizable: false, + resizable: true, maximizable: false, paddingVertical: 0, paddingHorizontal: 0, - width: 250, + width: 400, height: 150 }); } @@ -567,11 +567,11 @@ const initializeWindows = function() { loadMethod: 'iframe', contentURL: new URI("newcategory.html").setData("action", action).toString(), scrollbars: false, - resizable: false, + resizable: true, maximizable: false, paddingVertical: 0, paddingHorizontal: 0, - width: 250, + width: 400, height: 150 }); updateMainData(); @@ -587,11 +587,11 @@ const initializeWindows = function() { loadMethod: 'iframe', contentURL: new URI('newcategory.html').setData("action", action).setData("categoryName", categoryName).setData("savePath", savePath).toString(), scrollbars: false, - resizable: false, + resizable: true, maximizable: false, paddingVertical: 0, paddingHorizontal: 0, - width: 250, + width: 400, height: 150 }); updateMainData(); @@ -682,7 +682,7 @@ const initializeWindows = function() { loadMethod: 'iframe', contentURL: new URI("newtag.html").setData("action", action).setData("hashes", hashes.join("|")).toString(), scrollbars: false, - resizable: false, + resizable: true, maximizable: false, paddingVertical: 0, paddingHorizontal: 0, @@ -728,7 +728,7 @@ const initializeWindows = function() { loadMethod: 'iframe', contentURL: new URI("newtag.html").setData("action", action).toString(), scrollbars: false, - resizable: false, + resizable: true, maximizable: false, paddingVertical: 0, paddingHorizontal: 0, diff --git a/src/webui/www/private/setlocation.html b/src/webui/www/private/setlocation.html index 6c7df6270..68122fa43 100644 --- a/src/webui/www/private/setlocation.html +++ b/src/webui/www/private/setlocation.html @@ -68,8 +68,8 @@

QBT_TR(Location)QBT_TR[CONTEXT=TransferListWidget]:

- -
 
+ +
 
From 0d334369f08a69d015d375fa5d11dbc7d81092e8 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 30 Mar 2022 14:56:49 +0800 Subject: [PATCH 2/3] WebUI: show correct location path The `path` might contains '&' (delimit character) so it must be encoded. Closes #15976. --- src/webui/www/private/scripts/mocha-init.js | 2 +- src/webui/www/private/setlocation.html | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/webui/www/private/scripts/mocha-init.js b/src/webui/www/private/scripts/mocha-init.js index 643585b08..e16b78efa 100644 --- a/src/webui/www/private/scripts/mocha-init.js +++ b/src/webui/www/private/scripts/mocha-init.js @@ -487,7 +487,7 @@ const initializeWindows = function() { id: 'setLocationPage', title: "QBT_TR(Set location)QBT_TR[CONTEXT=TransferListWidget]", loadMethod: 'iframe', - contentURL: new URI("setlocation.html").setData("hashes", hashes.join('|')).setData("path", row.full_data.save_path).toString(), + contentURL: new URI("setlocation.html").setData("hashes", hashes.join('|')).setData("path", encodeURIComponent(row.full_data.save_path)).toString(), scrollbars: false, resizable: true, maximizable: false, diff --git a/src/webui/www/private/setlocation.html b/src/webui/www/private/setlocation.html index 68122fa43..36a2ee815 100644 --- a/src/webui/www/private/setlocation.html +++ b/src/webui/www/private/setlocation.html @@ -31,16 +31,17 @@ window.addEvent('domready', function() { const path = new URI().getData('path'); + // set text field to current value if (path) - $('setLocation').value = window.qBittorrent.Misc.escapeHtml(path); + $('setLocation').value = decodeURIComponent(path); $('setLocation').focus(); $('setLocationButton').addEvent('click', function(e) { new Event(e).stop(); // check field const location = $('setLocation').value.trim(); - if (location === null || location === "") { + if ((location === null) || (location === "")) { $('error_div').set('text', 'QBT_TR(Save path is empty)QBT_TR[CONTEXT=TorrentsController]'); return false; } From af7c32d3aaa8324dcb18ee713b28f1a21c8cdcdf Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 30 Mar 2022 16:00:54 +0800 Subject: [PATCH 3/3] WebUI: remove temporary element --- src/webui/www/private/scripts/misc.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/webui/www/private/scripts/misc.js b/src/webui/www/private/scripts/misc.js index 8783fba69..d456648b4 100644 --- a/src/webui/www/private/scripts/misc.js +++ b/src/webui/www/private/scripts/misc.js @@ -169,7 +169,9 @@ window.qBittorrent.Misc = (function() { const escapeHtml = function(str) { const div = document.createElement('div'); div.appendChild(document.createTextNode(str)); - return div.innerHTML; + const escapedString = div.innerHTML; + div.remove(); + return escapedString; } const safeTrim = function(value) {