mirror of
https://git.waldn.net/git/knotteye/satyr.git
synced 2025-10-21 11:32:42 +00:00
Add viewer count to web UI
This commit is contained in:
@@ -80,9 +80,10 @@ async function render(path, s){
|
||||
else var usr = path.substring(7);
|
||||
var config = JSON.parse(await makeRequest("GET", '/api/'+usr+'/config'));
|
||||
if(!config.title){document.body.innerHTML = nunjucks.render('404.njk', context); break;}
|
||||
document.body.innerHTML = nunjucks.render('user.njk', Object.assign({about: config.about, title: config.title, username: config.username}, context));
|
||||
document.body.innerHTML = nunjucks.render('user.njk', Object.assign({about: config.about, title: config.title, username: config.username, viewers: config.viewers}, context));
|
||||
modifyLinks();
|
||||
initPlayer(usr);
|
||||
updateViewers();
|
||||
break;
|
||||
case (path.match(/^\/vods\/.+\/manage\/?$/) || {}).input: // /vods/:user/manage
|
||||
var usr = path.substring(6, (path.length - 7));
|
||||
@@ -177,6 +178,18 @@ function modifyLinks() {
|
||||
}
|
||||
}
|
||||
|
||||
async function updateViewers(){
|
||||
let vc = document.getElementById('viewercount');
|
||||
if(!vc) return false;
|
||||
let path = window.location.pathname;
|
||||
if(path.substring(path.length - 1).indexOf('/') !== -1)
|
||||
var usr = path.substring(7, path.length - 1);
|
||||
else var usr = path.substring(7);
|
||||
let viewers = JSON.parse(await makeRequest("GET", "/api/"+usr+"/config")).viewers;
|
||||
vc.innerHTML = "[Viewers: "+viewers+"]";
|
||||
setTimeout(updateViewers, 2000);
|
||||
}
|
||||
|
||||
function internalLink(path){
|
||||
this.render(path);
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user