This commit is contained in:
Kasper Rynning-Tønnesen
2016-01-25 11:36:36 +01:00
parent 0968aeccc7
commit 26dea79c7a
5 changed files with 77 additions and 63 deletions

View File

@@ -39,28 +39,30 @@ var list;
var seekTo;
var song_title;
var previous_video_id;
var socket;
var connection_options = {
'sync disconnect on unload':true,
'secure': true,
'force new connection': true
};
if(window.location.hostname == "zoff.no") add = "https://zoff.no";
else add = "localhost";
var socket = io.connect(''+add+':8880', connection_options);
socket.on("get_list", function(){
setTimeout(function(){socket.emit('list', chan.toLowerCase())},1000);
});
$().ready(init);
socket.on("suggested", function(params){
var single = true;
if(params.id == undefined)
single = false;
setTimeout(function(){Suggestions.catchUserSuggests(params, single)}, 1000);
});
$(document).ready(function()
{
function init(){
if(window.location.hostname == "zoff.no") add = "https://zoff.no";
else add = "localhost";
socket = io.connect(''+add+':8880', connection_options);
socket.on("get_list", function(){
setTimeout(function(){socket.emit('list', chan.toLowerCase())},1000);
});
socket.on("suggested", function(params){
var single = true;
if(params.id == undefined)
single = false;
setTimeout(function(){Suggestions.catchUserSuggests(params, single)}, 1000);
});
setTimeout(function(){
//window.vote = List.vote;
//window.submit = Search.submit;
@@ -181,7 +183,9 @@ $(document).ready(function()
}
}, 1);
}, 1000);
});
}
window.init = init;
$(document).keyup(function(e) {
if(event.keyCode == 27){
@@ -387,7 +391,7 @@ function onepage_load(){
document.getElementById("fullscreen").removeEventListener("click", Playercontrols.fullscreen);
setTimeout(function(){
delete Admin
/*delete Admin
delete Chat
delete Crypt
delete Hostcontroller
@@ -438,21 +442,21 @@ function onepage_load(){
delete previous_video_id;
delete connection_options;
delete socket;
delete window.onYouTubeIframeAPIReady;
delete window.onYouTubeIframeAPIReady;*/
$(".drag-target").remove();
$(".sidenav-overlay").remove();
$("main").attr("class", "center-align container");
$("body").attr("id", "");
$("body").attr("style", "");
$("header").html($($(e)[0]).html());
$($(e)[2]).insertAfter("header");
$($(e)[4]).insertAfter(".mega");
$("main").html($($(e)[6]).html());
$("#scripts").append($($(e)[8]).html());
}, 1000);
document.title = "Zöff";
$(".drag-target").remove();
$(".sidenav-overlay").remove();
$("main").attr("class", "center-align container");
$("body").attr("id", "");
$("body").attr("style", "");
$("header").html($($(e)[0]).html());
$($(e)[2]).insertAfter("header");
$($(e)[4]).insertAfter(".mega");
$("main").html($($(e)[6]).html());
$("#scripts").html($($(e)[8]).html());
}
});

View File

@@ -214,14 +214,15 @@ var Nochan = {
if(!popstate) window.history.pushState("to the channel!", "Title", "/" + chan);
$.holdReady(true);
$(".mega").remove();
$(".mobile-search").remove();
$("main").attr("class", "container center-align main");
$("body").attr("id", "channelpage");
$("header").html($($(e)[0]).html());
$("main").html($($(e)[2]).html());
$("#scripts").html($($(e)[4]).html());
window.init();
//$("#scripts").html($($(e)[4]).html());
}
});
}

View File

@@ -11,7 +11,9 @@ var Youtube = {
socket.on("np", function(obj)
{
Youtube.loaded = false;
if(video_id != undefined && Youtube.ytplayer !== undefined) Youtube.before_load = Youtube.ytplayer.getVideoUrl();
try{
if(video_id != undefined && Youtube.ytplayer !== undefined) Youtube.before_load = Youtube.ytplayer.getVideoUrl();
}catch(e){}
if(obj[0].length == 0){
document.getElementById('song-title').innerHTML = "Empty channel. Add some songs!";
@@ -44,22 +46,25 @@ var Youtube = {
//if(player_ready && !window.mobilecheck())
if(player_ready && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream)
{
if(Youtube.ytplayer.getVideoUrl().split('v=')[1] != video_id)
{
Youtube.ytplayer.loadVideoById(video_id);
Youtube.notifyUser(video_id, song_title);
Youtube.ytplayer.seekTo(seekTo);
if(paused)
Youtube.ytplayer.pauseVideo();
}
if(!paused){
Youtube.ytplayer.playVideo();
Youtube.durationSetter();
}
if(Youtube.ytplayer.getDuration() > seekTo || Youtube.ytplayer.getDuration() == 0)
Youtube.ytplayer.seekTo(seekTo);
Youtube.after_load = video_id;
setTimeout(function(){Youtube.loaded = true;},500);
try{
if(Youtube.ytplayer.getVideoUrl().split('v=')[1] != video_id)
{
Youtube.ytplayer.loadVideoById(video_id);
Youtube.notifyUser(video_id, song_title);
Youtube.ytplayer.seekTo(seekTo);
if(paused)
Youtube.ytplayer.pauseVideo();
}
if(!paused){
Youtube.ytplayer.playVideo();
Youtube.durationSetter();
}
if(Youtube.ytplayer.getDuration() > seekTo || Youtube.ytplayer.getDuration() == 0)
Youtube.ytplayer.seekTo(seekTo);
Youtube.after_load = video_id;
setTimeout(function(){Youtube.loaded = true;},500);
}catch(e){}
}
else
Youtube.getTitle(song_title, viewers);
@@ -245,20 +250,24 @@ var Youtube = {
//console.log(Youtube.stopInterval);
duration = Youtube.ytplayer.getDuration();
if(duration != undefined){
dMinutes = Math.floor(duration / 60);
dSeconds = duration - dMinutes * 60;
currDurr = Youtube.ytplayer.getCurrentTime();
if(currDurr > duration)
currDurr = duration;
minutes = Math.floor(currDurr / 60);
seconds = currDurr - minutes * 60;
document.getElementById("duration").innerHTML = Helper.pad(minutes)+":"+Helper.pad(seconds)+" <span id='dash'>/</span> "+Helper.pad(dMinutes)+":"+Helper.pad(dSeconds);
per = (100 / duration) * currDurr;
if(per >= 100)
per = 100;
else if(duration == 0)
per = 0;
$("#bar").width(per+"%");
try{
dMinutes = Math.floor(duration / 60);
dSeconds = duration - dMinutes * 60;
currDurr = Youtube.ytplayer.getCurrentTime();
if(currDurr > duration)
currDurr = duration;
minutes = Math.floor(currDurr / 60);
seconds = currDurr - minutes * 60;
document.getElementById("duration").innerHTML = Helper.pad(minutes)+":"+Helper.pad(seconds)+" <span id='dash'>/</span> "+Helper.pad(dMinutes)+":"+Helper.pad(dSeconds);
per = (100 / duration) * currDurr;
if(per >= 100)
per = 100;
else if(duration == 0)
per = 0;
$("#bar").width(per+"%");
}catch(e){
Youtube.stopInterval = true;
}
}
if(!Youtube.stopInterval) setTimeout(Youtube.durationSetter, 1000);
},