Moves client side javascript to a new file
- creates new file, resources/script.js - removes javascript from index.html
This commit is contained in:
parent
823abb4395
commit
f9a78d9d10
32
index.html
32
index.html
|
@ -28,36 +28,6 @@
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script>
|
<script src="resources/script.js"></script>
|
||||||
async function getEndpoint(url = '') {
|
|
||||||
const response = await fetch(url, {method:'GET'});
|
|
||||||
const data = await response.json();
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function uiUpdate() {
|
|
||||||
window.setInterval(async () => {
|
|
||||||
data = await getEndpoint('http://127.0.0.1:5000/api/serverstatus');
|
|
||||||
document.getElementById("streamTitle").innerHTML = data.streamTitle
|
|
||||||
document.getElementById("currentViewers").innerHTML = data.viewerCount
|
|
||||||
document.getElementById("sessionMaxViewerCount").innerHTML = data.sessionMaxViewerCount
|
|
||||||
document.getElementById("overallMaxViewerCount").innerHTML = data.overallMaxViewerCount
|
|
||||||
document.getElementById("tags").innerHTML = data.tags
|
|
||||||
}, 1000)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function updateStreamTitle() {
|
|
||||||
response = await fetch('http://127.0.0.1:5000/api/update/streamtitle',
|
|
||||||
{
|
|
||||||
method:'POST',
|
|
||||||
data:JSON.stringify('a big test')
|
|
||||||
}
|
|
||||||
);
|
|
||||||
const data = await response.json()
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
// uiUpdate()
|
|
||||||
updateStreamTitle()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
async function getEndpoint(url = '') {
|
||||||
|
const response = await fetch(url, {method:'GET'});
|
||||||
|
const data = await response.json();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function uiUpdate() {
|
||||||
|
window.setInterval(async () => {
|
||||||
|
data = await getEndpoint('http://127.0.0.1:5000/api/serverstatus');
|
||||||
|
document.getElementById("streamTitle").innerHTML = data.streamTitle
|
||||||
|
document.getElementById("currentViewers").innerHTML = data.viewerCount
|
||||||
|
document.getElementById("sessionMaxViewerCount").innerHTML = data.sessionMaxViewerCount
|
||||||
|
document.getElementById("overallMaxViewerCount").innerHTML = data.overallMaxViewerCount
|
||||||
|
document.getElementById("tags").innerHTML = data.tags
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateStreamTitle() {
|
||||||
|
response = await fetch('http://127.0.0.1:5000/api/update/streamtitle',
|
||||||
|
{
|
||||||
|
method:'POST',
|
||||||
|
data:JSON.stringify('a big test')
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const data = await response.json()
|
||||||
|
return data
|
||||||
|
}
|
Loading…
Reference in New Issue