WebUI: move scripts into <head> section

For consistency reasons.
This commit is contained in:
Chocobo1 2025-06-16 03:10:37 +08:00
parent 753c6629a3
commit 5605e08347
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
3 changed files with 73 additions and 76 deletions

View file

@ -10,6 +10,37 @@
<script defer src="scripts/color-scheme.js?v=${CACHEID}"></script> <script defer src="scripts/color-scheme.js?v=${CACHEID}"></script>
<script defer src="scripts/download.js?v=${CACHEID}"></script> <script defer src="scripts/download.js?v=${CACHEID}"></script>
<script defer src="scripts/pathAutofill.js?v=${CACHEID}"></script> <script defer src="scripts/pathAutofill.js?v=${CACHEID}"></script>
<script>
"use strict";
window.addEventListener("DOMContentLoaded", (event) => {
const encodedUrls = new URLSearchParams(window.location.search).get("urls");
if (encodedUrls !== null) {
const urls = encodedUrls.split("|").map(decodeURIComponent);
if (urls.length > 0)
document.getElementById("urls").value = urls.join("\n");
}
let submitted = false;
document.getElementById("downloadForm").addEventListener("submit", (event) => {
document.getElementById("startTorrentHidden").value = document.getElementById("startTorrent").checked ? "false" : "true";
document.getElementById("dlLimitHidden").value = Number(document.getElementById("dlLimitText").value) * 1024;
document.getElementById("upLimitHidden").value = Number(document.getElementById("upLimitText").value) * 1024;
document.getElementById("download_spinner").style.display = "block";
submitted = true;
});
document.getElementById("download_frame").addEventListener("load", (event) => {
if (submitted)
window.parent.qBittorrent.Client.closeFrameWindow(window);
});
window.qBittorrent.pathAutofill.attachPathAutofill();
});
</script>
</head> </head>
<body> <body>
@ -156,38 +187,6 @@
</div> </div>
</form> </form>
<div id="download_spinner" class="mochaSpinner"></div> <div id="download_spinner" class="mochaSpinner"></div>
<script>
"use strict";
window.addEventListener("DOMContentLoaded", (event) => {
const encodedUrls = new URLSearchParams(window.location.search).get("urls");
if (encodedUrls !== null) {
const urls = encodedUrls.split("|").map(decodeURIComponent);
if (urls.length > 0)
document.getElementById("urls").value = urls.join("\n");
}
let submitted = false;
document.getElementById("downloadForm").addEventListener("submit", (event) => {
document.getElementById("startTorrentHidden").value = document.getElementById("startTorrent").checked ? "false" : "true";
document.getElementById("dlLimitHidden").value = Number(document.getElementById("dlLimitText").value) * 1024;
document.getElementById("upLimitHidden").value = Number(document.getElementById("upLimitText").value) * 1024;
document.getElementById("download_spinner").style.display = "block";
submitted = true;
});
document.getElementById("download_frame").addEventListener("load", (event) => {
if (submitted)
window.parent.qBittorrent.Client.closeFrameWindow(window);
});
window.qBittorrent.pathAutofill.attachPathAutofill();
});
</script>
</body> </body>
</html> </html>

View file

@ -7,21 +7,6 @@
<link rel="stylesheet" href="css/style.css?v=${CACHEID}" type="text/css"> <link rel="stylesheet" href="css/style.css?v=${CACHEID}" type="text/css">
<script defer src="scripts/localpreferences.js?v=${CACHEID}"></script> <script defer src="scripts/localpreferences.js?v=${CACHEID}"></script>
<script defer src="scripts/color-scheme.js?v=${CACHEID}"></script> <script defer src="scripts/color-scheme.js?v=${CACHEID}"></script>
</head>
<body>
<div style="padding-top: 10px; width: 100%; text-align: center; margin: 0 auto; overflow: hidden">
<div class="slider">
<div class="update">
<label id="limitUpdateLabel" for="limitUpdateValue">QBT_TR(Limit:)QBT_TR[CONTEXT=SpeedLimit]</label>
<input type="text" id="limitUpdateValue" size="6" placeholder="∞" style="text-align: center;">
<span id="limitUnit">QBT_TR(KiB/s)QBT_TR[CONTEXT=SpeedLimit]</span>
</div>
<input type="range" id="limitSliderInput" min="0" value="0" style="width: 100%;" aria-label="QBT_TR(Speed limit)QBT_TR[CONTEXT=SpeedLimit]">
</div>
<input type="button" id="applyButton" value="QBT_TR(Apply)QBT_TR[CONTEXT=HttpServer]">
</div>
<script> <script>
"use strict"; "use strict";
@ -158,6 +143,20 @@
limitUpdateValue.focus(); limitUpdateValue.focus();
}); });
</script> </script>
</head>
<body>
<div style="padding-top: 10px; width: 100%; text-align: center; margin: 0 auto; overflow: hidden">
<div class="slider">
<div class="update">
<label id="limitUpdateLabel" for="limitUpdateValue">QBT_TR(Limit:)QBT_TR[CONTEXT=SpeedLimit]</label>
<input type="text" id="limitUpdateValue" size="6" placeholder="∞" style="text-align: center;">
<span id="limitUnit">QBT_TR(KiB/s)QBT_TR[CONTEXT=SpeedLimit]</span>
</div>
<input type="range" id="limitSliderInput" min="0" value="0" style="width: 100%;" aria-label="QBT_TR(Speed limit)QBT_TR[CONTEXT=SpeedLimit]">
</div>
<input type="button" id="applyButton" value="QBT_TR(Apply)QBT_TR[CONTEXT=HttpServer]">
</div>
</body> </body>
</html> </html>

View file

@ -10,6 +10,34 @@
<script defer src="scripts/color-scheme.js?v=${CACHEID}"></script> <script defer src="scripts/color-scheme.js?v=${CACHEID}"></script>
<script defer src="scripts/download.js?v=${CACHEID}"></script> <script defer src="scripts/download.js?v=${CACHEID}"></script>
<script defer src="scripts/pathAutofill.js?v=${CACHEID}"></script> <script defer src="scripts/pathAutofill.js?v=${CACHEID}"></script>
<script>
"use strict";
window.addEventListener("DOMContentLoaded", (event) => {
let submitted = false;
document.getElementById("uploadForm").addEventListener("submit", (event) => {
document.getElementById("startTorrentHidden").value = document.getElementById("startTorrent").checked ? "false" : "true";
document.getElementById("dlLimitHidden").value = Number(document.getElementById("dlLimitText").value) * 1024;
document.getElementById("upLimitHidden").value = Number(document.getElementById("upLimitText").value) * 1024;
document.getElementById("upload_spinner").style.display = "block";
submitted = true;
});
document.getElementById("upload_frame").addEventListener("load", (event) => {
if (submitted)
window.parent.qBittorrent.Client.closeFrameWindow(window);
});
const userAgent = (navigator.userAgentData?.platform ?? navigator.platform).toLowerCase();
if (userAgent.includes("ipad") || userAgent.includes("iphone") || (userAgent.includes("mac") && (navigator.maxTouchPoints > 1)))
document.getElementById("fileselect").accept = ".torrent";
window.qBittorrent.pathAutofill.attachPathAutofill();
});
</script>
</head> </head>
<body> <body>
@ -153,35 +181,6 @@
</fieldset> </fieldset>
</form> </form>
<div id="upload_spinner" class="mochaSpinner"></div> <div id="upload_spinner" class="mochaSpinner"></div>
<script>
"use strict";
window.addEventListener("DOMContentLoaded", (event) => {
let submitted = false;
document.getElementById("uploadForm").addEventListener("submit", (event) => {
document.getElementById("startTorrentHidden").value = document.getElementById("startTorrent").checked ? "false" : "true";
document.getElementById("dlLimitHidden").value = Number(document.getElementById("dlLimitText").value) * 1024;
document.getElementById("upLimitHidden").value = Number(document.getElementById("upLimitText").value) * 1024;
document.getElementById("upload_spinner").style.display = "block";
submitted = true;
});
document.getElementById("upload_frame").addEventListener("load", (event) => {
if (submitted)
window.parent.qBittorrent.Client.closeFrameWindow(window);
});
const userAgent = (navigator.userAgentData?.platform ?? navigator.platform).toLowerCase();
if (userAgent.includes("ipad") || userAgent.includes("iphone") || (userAgent.includes("mac") && (navigator.maxTouchPoints > 1)))
document.getElementById("fileselect").accept = ".torrent";
window.qBittorrent.pathAutofill.attachPathAutofill();
});
</script>
</body> </body>
</html> </html>