speedLimiter #10
@@ -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]
 | 
			
		||||
 
 | 
			
		||||
@@ -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 @@
 | 
			
		||||
        <h2>Settings</h2>
 | 
			
		||||
        <div class="speed-limit-container">
 | 
			
		||||
            <div class="form-group">
 | 
			
		||||
                <label for="speedLimitValue">Global Speed Limit:</label>
 | 
			
		||||
                <label for="speedLimitValue">Speed Limit:</label>
 | 
			
		||||
                <input type="number" id="speedLimitValue" name="speedLimitValue" min="0" step="0.01" required>
 | 
			
		||||
                <select id="speedLimitUnit" name="speedLimitUnit">
 | 
			
		||||
                    <option value="GBps">GBps</option>
 | 
			
		||||
                    <option value="MBps" selected>MBps</option>
 | 
			
		||||
                    <option value="KBps">KBps</option>
 | 
			
		||||
                </select>
 | 
			
		||||
                <button type="button" onclick="updateSpeedLimit(event)">Set Speed Limit</button>
 | 
			
		||||
                <button type="button" onclick="updateSpeedLimit(event)">Set Limit</button>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
@@ -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');
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user