Files
qBittorrent/src/webui/www/private/setlocation.html
tehcneko f748a682ca WebUI: Fix path autofill in set location and new category
Attach `PathAutofill` after `DOMContentLoaded`.
Also removed pathAutofill.js in newfolder.html since it's meant for new RSS folder name.

PR #22773.
2025-05-29 21:37:07 +03:00

84 lines
3.3 KiB
HTML

<!DOCTYPE html>
<html lang="${LANG}" class="dark">
<head>
<meta charset="UTF-8">
<title>QBT_TR(Set location)QBT_TR[CONTEXT=HttpServer]</title>
<link rel="stylesheet" href="css/style.css?v=${CACHEID}" type="text/css">
<script src="scripts/lib/MooTools-Core-1.6.0-compat-compressed.js"></script>
<script src="scripts/lib/MooTools-More-1.6.0-compat-compressed.js"></script>
<script src="scripts/localpreferences.js?v=${CACHEID}"></script>
<script src="scripts/color-scheme.js?v=${CACHEID}"></script>
<script src="scripts/misc.js?locale=${LANG}&v=${CACHEID}"></script>
<script src="scripts/pathAutofill.js?v=${CACHEID}"></script>
<script>
"use strict";
window.addEventListener("DOMContentLoaded", () => {
window.addEventListener("keydown", (event) => {
switch (event.key) {
case "Enter":
event.preventDefault();
$("setLocationButton").click();
break;
case "Escape":
event.preventDefault();
window.parent.qBittorrent.Client.closeFrameWindow(window);
break;
}
});
const searchParams = new URLSearchParams(window.location.search);
const path = searchParams.get("path");
// set text field to current value
if (path !== null)
$("setLocation").value = decodeURIComponent(path);
$("setLocation").focus();
$("setLocationButton").addEventListener("click", (e) => {
e.preventDefault();
e.stopPropagation();
// check field
const location = $("setLocation").value.trim();
if ((location === null) || (location === "")) {
$("error_div").textContent = "QBT_TR(Save path is empty)QBT_TR[CONTEXT=TorrentsController]";
return;
}
fetch("api/v2/torrents/setLocation", {
method: "POST",
body: new URLSearchParams({
hashes: searchParams.get("hashes"),
location: location
})
})
.then(async (response) => {
if (!response.ok) {
$("error_div").textContent = await response.text();
return;
}
window.parent.qBittorrent.Client.closeFrameWindow(window);
});
});
window.qBittorrent.pathAutofill.attachPathAutofill();
});
</script>
</head>
<body>
<div style="padding: 10px 10px 0px 10px;">
<label for="setLocation" style="font-weight: bold;">QBT_TR(Location:)QBT_TR[CONTEXT=TransferListWidget]</label>
<input type="text" id="setLocation" class="pathDirectory" autocorrect="off" autocapitalize="none" style="width: 99%;">
<div style="float: none; width: 99%;" id="error_div">&nbsp;</div>
<div style="text-align: center; padding-top: 10px;">
<input type="button" value="QBT_TR(Save)QBT_TR[CONTEXT=HttpServer]" id="setLocationButton">
</div>
</div>
</body>
</html>