Skip to content

Commit

Permalink
Code refactoring after #1063
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Apr 27, 2024
1 parent 8516f82 commit 8d6aabc
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
<meta charset="utf-8">
<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">

<title>go2rtc</title>

<style>

body {
margin: 0;
padding: 0;
Expand Down Expand Up @@ -86,25 +83,24 @@

ev.preventDefault();

const url = new URL('api/streams', location.href);
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);
if (userInput !== src) {
alert("Stream name does not match. Deletion cancelled.");

const message = `Please type the name of the stream "${src}" to confirm its deletion from the configuration. This action is irreversible.`;
if (prompt(message) !== src) {
alert('Stream name does not match. Deletion cancelled.');
return;
}

try {
await fetch(url, { method: 'DELETE' });

const url = new URL('api/streams', location.href);
url.searchParams.set('src', src);

try {
await fetch(url, {method: 'DELETE'});
reload();
} catch (error) {
console.error('Failed to delete the stream:', error);
}
});


document.getElementById('selectall').addEventListener('change', ev => {
document.querySelectorAll('#streams input').forEach(el => {
Expand Down

0 comments on commit 8d6aabc

Please sign in to comment.