Files
zoff/static/js/hostcontroller.js
Kasper Rynning-Tønnesen e4320205ac removed extension notification
2015-11-29 14:17:02 +01:00

74 lines
2.2 KiB
JavaScript
Executable File
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 Hostcontroller = {
enabled: true,
host_listener: function() {
var old_id;
socket.on("id", function(id)
{
if(old_id === undefined) old_id = id;
else
{
socket.removeAllListeners(id);
began = false;
old_id = id;
}
var codeURL = "https://remote."+window.location.hostname+"/"+id;
$("#code-text").text(id)
$("#code-qr").attr("src", "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+codeURL);
$("#code-link").attr("href", codeURL);
if(!began)
{
began = true;
socket.on(id, function(arr)
{
if(enabled){
if(arr[0] == "volume"){
$("#volume").slider("value", arr[1]);
ytplayer.setVolume(arr[1]);
localStorage.setItem("volume", arr[1]);
Playercontrols.choose_button(arr[1], false);
}else if(arr[0] == "channel"){
socket.emit("change_channel");
chan = arr[1].toLowerCase();
$("#chan").html(chan.substring(0,1).toUpperCase()+chan.substring(1).toLowerCase());
w_p = true;
socket.emit("list", chan.toLowerCase());
if(localStorage[chan.toLowerCase()]){
//localStorage.removeItem(chan.toLowerCase());
if(localStorage[chan.toLowerCase()].length != 64)
localStorage.removeItem(chan.toLowerCase());
else
socket.emit("password", [localStorage[chan.toLowerCase()], chan.toLowerCase()]);
}
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")
List.skip();
}
});
}
});
$('input[class=remote_switch_class]').change(function()
{
enabled = document.getElementsByName("remote_switch")[0].checked;
Crypt.set_remote(enabled);
});
},
change_enabled:function(val){
enabled = val;
document.getElementsByName("remote_switch")[0].checked = enabled;
}
}