Code refactoring after #1063

This commit is contained in:
Alex X
2024-04-27 11:40:59 +03:00
parent 8516f825e1
commit 8d6aabce7a
+6 -10
View File
@@ -4,11 +4,8 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1, maximum-scale=1">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>go2rtc</title> <title>go2rtc</title>
<style> <style>
body { body {
margin: 0; margin: 0;
padding: 0; padding: 0;
@@ -86,17 +83,17 @@
ev.preventDefault(); ev.preventDefault();
const url = new URL('api/streams', location.href);
const src = decodeURIComponent(ev.target.dataset.name); const src = decodeURIComponent(ev.target.dataset.name);
url.searchParams.set('src', src);
const message = `Please type the name of the stream "${src}" to confirm its stop and deletion from the configuration. This action is irreversible.`;
const userInput = prompt(message); const message = `Please type the name of the stream "${src}" to confirm its deletion from the configuration. This action is irreversible.`;
if (userInput !== src) { if (prompt(message) !== src) {
alert("Stream name does not match. Deletion cancelled."); alert('Stream name does not match. Deletion cancelled.');
return; return;
} }
const url = new URL('api/streams', location.href);
url.searchParams.set('src', src);
try { try {
await fetch(url, {method: 'DELETE'}); await fetch(url, {method: 'DELETE'});
reload(); reload();
@@ -105,7 +102,6 @@
} }
}); });
document.getElementById('selectall').addEventListener('change', ev => { document.getElementById('selectall').addEventListener('change', ev => {
document.querySelectorAll('#streams input').forEach(el => { document.querySelectorAll('#streams input').forEach(el => {
el.checked = ev.target.checked; el.checked = ev.target.checked;