From 4b9f0a87cd5e33c8cda6a84dafa1d36029df52c0 Mon Sep 17 00:00:00 2001
From: jerrymakesjelly <ganzhaoyu037@sina.com>
Date: Sat, 11 May 2019 12:25:07 +0800
Subject: [PATCH] Change the speed unit from Bytes/s to KiB/s

Updated the adding torrent dialogs in WebUI. Closes #10017.
---
 src/webui/www/private/download.html | 13 +++++++++----
 src/webui/www/private/upload.html   | 13 +++++++++----
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/webui/www/private/download.html b/src/webui/www/private/download.html
index c420a3be9..b615f16b2 100644
--- a/src/webui/www/private/download.html
+++ b/src/webui/www/private/download.html
@@ -114,18 +114,20 @@
                     </tr>
                     <tr>
                         <td>
-                            <label for="dlLimit">QBT_TR(Limit download rate)QBT_TR[CONTEXT=HttpServer]</label>
+                            <label for="dlLimitText">QBT_TR(Limit download rate)QBT_TR[CONTEXT=HttpServer]</label>
                         </td>
                         <td>
-                            <input type="text" id="dlLimit" name="dlLimit" style="width: 16em;" placeholder="Bytes/s" />
+                            <input type="hidden" id="dlLimitHidden" name="dlLimit" />
+                            <input type="text" id="dlLimitText" style="width: 16em;" placeholder="KiB/s" />
                         </td>
                     </tr>
                     <tr>
                         <td>
-                            <label for="upLimit">QBT_TR(Limit upload rate)QBT_TR[CONTEXT=HttpServer]</label>
+                            <label for="upLimitText">QBT_TR(Limit upload rate)QBT_TR[CONTEXT=HttpServer]</label>
                         </td>
                         <td>
-                            <input type="text" id="upLimit" name="upLimit" style="width: 16em;" placeholder="Bytes/s" />
+                            <input type="hidden" id="upLimitHidden" name="upLimit" />
+                            <input type="text" id="upLimitText" style="width: 16em;" placeholder="KiB/s" />
                         </td>
                     </tr>
                 </table>
@@ -155,6 +157,9 @@
             $('startTorrentHidden').value = $('startTorrent').checked ? 'false' : 'true';
             $('rootFolderHidden').value = $('rootFolder').checked ? 'true' : 'false';
 
+            $('dlLimitHidden').value = $('dlLimitText').value.toInt() * 1024;
+            $('upLimitHidden').value = $('upLimitText').value.toInt() * 1024;
+
             $('download_spinner').style.display = "block";
             submitted = true;
         });
diff --git a/src/webui/www/private/upload.html b/src/webui/www/private/upload.html
index f00395444..4fa58c747 100644
--- a/src/webui/www/private/upload.html
+++ b/src/webui/www/private/upload.html
@@ -102,18 +102,20 @@
                 </tr>
                 <tr>
                     <td>
-                        <label for="dlLimit">QBT_TR(Limit download rate)QBT_TR[CONTEXT=HttpServer]</label>
+                        <label for="dlLimitText">QBT_TR(Limit download rate)QBT_TR[CONTEXT=HttpServer]</label>
                     </td>
                     <td>
-                        <input type="text" id="dlLimit" name="dlLimit" style="width: 16em;" placeholder="Bytes/s" />
+                        <input type="hidden" id="dlLimitHidden" name="dlLimit" />
+                        <input type="text" id="dlLimitText" style="width: 16em;" placeholder="KiB/s" />
                     </td>
                 </tr>
                 <tr>
                     <td>
-                        <label for="upLimit">QBT_TR(Limit upload rate)QBT_TR[CONTEXT=HttpServer]</label>
+                        <label for="upLimitText">QBT_TR(Limit upload rate)QBT_TR[CONTEXT=HttpServer]</label>
                     </td>
                     <td>
-                        <input type="text" id="upLimit" name="upLimit" style="width: 16em;" placeholder="Bytes/s" />
+                        <input type="hidden" id="upLimitHidden" name="upLimit" />
+                        <input type="text" id="upLimitText" style="width: 16em;" placeholder="KiB/s" />
                     </td>
                 </tr>
             </table>
@@ -131,6 +133,9 @@
             $('startTorrentHidden').value = $('startTorrent').checked ? 'false' : 'true';
             $('rootFolderHidden').value = $('rootFolder').checked ? 'true' : 'false';
 
+            $('dlLimitHidden').value = $('dlLimitText').value.toInt() * 1024;
+            $('upLimitHidden').value = $('upLimitText').value.toInt() * 1024;
+
             $('upload_spinner').style.display = "block";
             submitted = true;
         });