Add ESLinter and fix JS lint problems
This commit is contained in:
+47
-47
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>go2rtc - links</title>
|
||||
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1, maximum-scale=1">
|
||||
@@ -42,21 +42,21 @@
|
||||
<script src="main.js"></script>
|
||||
<div id="links"></div>
|
||||
<script>
|
||||
const src = new URLSearchParams(location.search).get('src')
|
||||
const src = new URLSearchParams(location.search).get('src');
|
||||
|
||||
document.getElementById('links').innerHTML = `
|
||||
<h2>Any codec in source</h2>
|
||||
<li><a href="stream.html?src=${src}">stream.html</a> with auto-select mode / browsers: all / codecs: H264, H265*, MJPEG, JPEG, AAC, PCMU, PCMA, OPUS</li>
|
||||
<li><a href="api/streams?src=${src}">info.json</a> page with active connections</li>
|
||||
`
|
||||
`;
|
||||
|
||||
const url = new URL('api', location.href)
|
||||
const url = new URL('api', location.href);
|
||||
fetch(url, {cache: 'no-cache'}).then(r => r.json()).then(data => {
|
||||
let rtsp = location.host + ':8554'
|
||||
let rtsp = location.host + ':8554';
|
||||
try {
|
||||
const host = data.host.match(/^[^:]+/)[0]
|
||||
const port = data.rtsp.listen.match(/[0-9]+$/)[0]
|
||||
rtsp = `${host}:${port}`
|
||||
const host = data.host.match(/^[^:]+/)[0];
|
||||
const port = data.rtsp.listen.match(/[0-9]+$/)[0];
|
||||
rtsp = `${host}:${port}`;
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@
|
||||
<li><a href="stream.html?src=${src}&mode=mjpeg">stream.html</a> with MJPEG mode / browsers: all / codecs: MJPEG, JPEG</li>
|
||||
<li><a href="api/stream.mjpeg?src=${src}">stream.mjpeg</a> MJPEG stream / browsers: all / codecs: MJPEG, JPEG</li>
|
||||
<li><a href="api/frame.jpeg?src=${src}">frame.jpeg</a> snapshot in JPEG-format / browsers: all / codecs: MJPEG, JPEG</li>
|
||||
`
|
||||
})
|
||||
`;
|
||||
});
|
||||
</script>
|
||||
|
||||
<div>
|
||||
@@ -92,12 +92,12 @@
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById('send').addEventListener('click', ev => {
|
||||
ev.preventDefault()
|
||||
const url = new URL('api/streams', location.href)
|
||||
url.searchParams.set('dst', src)
|
||||
url.searchParams.set('src', document.getElementById('source').value)
|
||||
fetch(url, {method: 'POST'})
|
||||
})
|
||||
ev.preventDefault();
|
||||
const url = new URL('api/streams', location.href);
|
||||
url.searchParams.set('dst', src);
|
||||
url.searchParams.set('src', document.getElementById('source').value);
|
||||
fetch(url, {method: 'POST'});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div id="webrtc">
|
||||
@@ -119,62 +119,62 @@
|
||||
</div>
|
||||
<script>
|
||||
function webrtcLinksUpdate() {
|
||||
const media = document.querySelector('input[name="webrtc"]:checked').value
|
||||
const media = document.querySelector('input[name="webrtc"]:checked').value;
|
||||
|
||||
const direction = media.indexOf('video') >= 0 || media === 'audio' ? 'src' : 'dst'
|
||||
document.getElementById('local').href = `webrtc.html?${direction}=${src}&media=${media}`
|
||||
const direction = media.indexOf('video') >= 0 || media === 'audio' ? 'src' : 'dst';
|
||||
document.getElementById('local').href = `webrtc.html?${direction}=${src}&media=${media}`;
|
||||
|
||||
const share = document.getElementById('shareget')
|
||||
share.href = `https://alexxit.github.io/go2rtc/#${share.dataset.auth}&media=${media}`
|
||||
const share = document.getElementById('shareget');
|
||||
share.href = `https://alexxit.github.io/go2rtc/#${share.dataset.auth}&media=${media}`;
|
||||
}
|
||||
|
||||
function share(method) {
|
||||
const url = new URL('api/webtorrent', location.href)
|
||||
url.searchParams.set('src', src)
|
||||
return fetch(url, {method: method, cache: 'no-cache'})
|
||||
const url = new URL('api/webtorrent', location.href);
|
||||
url.searchParams.set('src', src);
|
||||
return fetch(url, {method: method, cache: 'no-cache'});
|
||||
}
|
||||
|
||||
function onshareadd(r) {
|
||||
document.getElementById('shareget').dataset['auth'] = `share=${r.share}&pwd=${r.pwd}`
|
||||
document.getElementById('shareget').dataset['auth'] = `share=${r.share}&pwd=${r.pwd}`;
|
||||
|
||||
document.getElementById('shareadd').style.display = 'none'
|
||||
document.getElementById('shareget').style.display = ''
|
||||
document.getElementById('sharedel').style.display = ''
|
||||
document.getElementById('shareadd').style.display = 'none';
|
||||
document.getElementById('shareget').style.display = '';
|
||||
document.getElementById('sharedel').style.display = '';
|
||||
|
||||
webrtcLinksUpdate()
|
||||
webrtcLinksUpdate();
|
||||
}
|
||||
|
||||
function onsharedel() {
|
||||
document.getElementById('shareadd').style.display = ''
|
||||
document.getElementById('shareget').style.display = 'none'
|
||||
document.getElementById('sharedel').style.display = 'none'
|
||||
document.getElementById('shareadd').style.display = '';
|
||||
document.getElementById('shareget').style.display = 'none';
|
||||
document.getElementById('sharedel').style.display = 'none';
|
||||
}
|
||||
|
||||
document.getElementById('shareadd').addEventListener('click', ev => {
|
||||
ev.preventDefault()
|
||||
share('POST').then(r => r.json()).then(r => onshareadd(r))
|
||||
})
|
||||
ev.preventDefault();
|
||||
share('POST').then(r => r.json()).then(r => onshareadd(r));
|
||||
});
|
||||
|
||||
document.getElementById('shareget').addEventListener('click', ev => {
|
||||
ev.preventDefault()
|
||||
navigator.clipboard.writeText(ev.target.href)
|
||||
})
|
||||
ev.preventDefault();
|
||||
navigator.clipboard.writeText(ev.target.href);
|
||||
});
|
||||
|
||||
document.getElementById('sharedel').addEventListener('click', ev => {
|
||||
ev.preventDefault()
|
||||
share('DELETE').then(r => onsharedel())
|
||||
})
|
||||
ev.preventDefault();
|
||||
share('DELETE').then(() => onsharedel());
|
||||
});
|
||||
|
||||
document.getElementById('webrtc').addEventListener('click', ev => {
|
||||
if (ev.target.tagName === 'INPUT') webrtcLinksUpdate()
|
||||
})
|
||||
if (ev.target.tagName === 'INPUT') webrtcLinksUpdate();
|
||||
});
|
||||
|
||||
share('GET').then(r => {
|
||||
if (r.ok) r.json().then(r => onshareadd(r))
|
||||
else onsharedel()
|
||||
})
|
||||
if (r.ok) r.json().then(r => onshareadd(r));
|
||||
else onsharedel();
|
||||
});
|
||||
|
||||
webrtcLinksUpdate()
|
||||
webrtcLinksUpdate();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user