Files
zoff/static/js/controller.js
Kasper Rynning-Tønnesen 011e906c47 Added more controllers
2015-06-04 14:32:00 +02:00

46 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var began = false;
var id
socket.on("id", function(id)
{
console.log(id);
if(!began)
{
socket.on(id, function(arr)
{
if(arr[0] == "volume")
{
$("#volume").slider("value", arr[1]);
ytplayer.setVolume(arr[1]);
localStorage.setItem("volume", arr[1]);
}else if(arr[0] == "channel")
{
socket.emit("change_channel");
socket.removeAllListeners(chan.toLowerCase());
socket.removeAllListeners("chat,"+chan.toLowerCase());
socket.removeAllListeners(chan.toLowerCase()+",np");
chan = arr[1].toLowerCase();
$("#chan").html(chan.substring(0,1).toUpperCase()+chan.substring(1).toLowerCase());
socket.on(chan.toLowerCase(), function(msg){
populate_list(msg, false);
});
setup_youtube_listener(chan);
setup_chat_listener(chan);
display_logged_out();
socket.emit("list", chan.toLowerCase()+",unused");
window.history.pushState("object or string", "Title", "/"+chan.toLowerCase());
}else if(arr[0] == "pause")
ytplayer.pauseVideo()
else if(arr[0] == "play")
ytplayer.playVideo();
else if(arr[0] == "skip")
skip();
});
}
began = true;
});