Added listeners on frontpage

This commit is contained in:
Kasper Rynning-Tønnesen
2016-02-02 13:13:51 +01:00
parent f96b9d11de
commit dfc9ec73aa
8 changed files with 38 additions and 14 deletions

View File

@@ -91,7 +91,6 @@ var Admin = {
socket.on("conf", function(msg)
{
Crypt.init();
Admin.set_conf(msg[0]);
if(Crypt.get_pass(chan.toLowerCase()) !== undefined && Admin.beginning && Crypt.get_pass(chan.toLowerCase()) != ""){

View File

@@ -30,6 +30,8 @@ var Nochan = {
winter: false,
times_rotated: 0,
populate_channels: function(lists)
{
var output = "";
@@ -169,7 +171,12 @@ var Nochan = {
}
setTimeout(function(){
if(frontpage) Nochan.add_backdrop(list, i+1);
if(Nochan.times_rotated == 2 && frontpage){
socket.emit("frontpage_lists");
}else if(frontpage){
Nochan.times_rotated += 1;
Nochan.add_backdrop(list, i+1);
}
},6000);
},
@@ -201,6 +208,13 @@ var Nochan = {
}
},
set_viewers: function(viewers){
if(viewers > 0){
var to_add = viewers > 1 ? "listeners" : "listener";
$("#frontpage-viewer-counter").html(viewers + " " + to_add);
}
},
to_channel: function(chan, popstate){
$("#channel-load").css("display", "block");
@@ -256,6 +270,17 @@ $().ready(initfp);
function initfp(){
if(window.location.hostname == "zoff.no") add = "https://zoff.no";
else add = "localhost";
socket = io.connect(''+add+':8880', connection_options);
socket.emit('frontpage_lists');
socket.on('playlists', function(msg){
Nochan.populate_channels(msg.channels);
Nochan.set_viewers(msg.viewers);
});
$("#channel-load").css("display", "none");
//Materialize.toast("<a href='/remote' style='color:white;'>Try out our new feature, remote!</a>", 8000)
if(window.location.hash == "#donation")
@@ -273,14 +298,6 @@ function initfp(){
'force new connection': true
};
if(window.location.hostname == "zoff.no") add = "https://zoff.no";
else add = "localhost";
socket = io.connect(''+add+':8880', connection_options);
socket.emit('frontpage_lists');
socket.on('playlists', function(msg){
Nochan.populate_channels(msg);
});
if(!localStorage["ok_cookie"])
Materialize.toast("We're using cookies to enhance your experience! <a class='waves-effect waves-light btn light-green' href='#ok' id='cookieok' style='cursor:pointer;pointer-events:all;'> ok</a>", 10000);