From f1efb1d67c89e278be22c15d8ebc76abcbe29466 Mon Sep 17 00:00:00 2001 From: Joren Date: Mon, 30 Dec 2024 16:32:12 +0100 Subject: [PATCH] impl speed limit --- config.toml | 4 ++-- src/templates/index | 29 ++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/config.toml b/config.toml index 4b89b64..04a2c04 100644 --- a/config.toml +++ b/config.toml @@ -5,9 +5,9 @@ TempBaseDir = "/tmp/nre" EnableConsole = true [WatchFolder] -Path = "/mnt/watched" +Path = "/home/joren/dev/DRMDTool/folder" PollingInterval = 10 -UsePolling = false +UsePolling = true UseInotify = false [N_m3u8DLRE] diff --git a/src/templates/index b/src/templates/index index 7470463..1e6d92a 100644 --- a/src/templates/index +++ b/src/templates/index @@ -28,7 +28,6 @@ input[type="file"], input[type="submit"] { background-color: #2d2d2d; color: #d4d4d4; - border: 1px solid #444; padding: 8px 12px; border-radius: 4px; margin-bottom: 10px; @@ -152,7 +151,6 @@ background-color: #2d2d2d; padding: 8px 12px; border-radius: 4px; - border: 1px solid #444; } .speed-limit-container .form-group { display: flex; @@ -160,7 +158,16 @@ gap: 10px; width: 100%; } - .speed-limit-container input[type="number"], + .speed-limit-container input[type="number"] { + background-color: #2d2d2d; + color: #d4d4d4; + border: 1px solid #444; + padding: 8px 12px; + border-radius: 4px; + height: 40px; + box-sizing: border-box; + flex-grow: 1; + } .speed-limit-container select, .speed-limit-container button { background-color: #2d2d2d; @@ -225,14 +232,14 @@

Settings

- + - +
@@ -249,6 +256,7 @@ } }); } + function updateSpeedLimit(event) { event.preventDefault(); @@ -256,6 +264,11 @@ const speedLimitUnit = document.getElementById('speedLimitUnit').value; const speedLimit = speedLimitValue === "0" ? "unlimited" : speedLimitValue + speedLimitUnit; + if (!validateSpeedLimit(speedLimitValue)) { + alert('Please enter a valid speed limit.'); + return; + } + fetch('/set-speed-limit', { method: 'POST', headers: { @@ -271,6 +284,12 @@ } }); } + + function validateSpeedLimit(value) { + const number = parseFloat(value); + return !isNaN(number) && number >= 0; + } + document.addEventListener('DOMContentLoaded', function() { const currentSpeedLimit = "{{if .GlobalSpeedLimit}}{{.GlobalSpeedLimit}}{{else}}0{{end}}"; const speedLimitValueInput = document.getElementById('speedLimitValue');