Merge pull request #145 from zoff-music/one

One
This commit is contained in:
KasperRT
2016-01-25 14:15:20 +01:00
10 changed files with 156 additions and 103 deletions

View File

@@ -16,10 +16,10 @@
<div class="navbar-fixed"> <div class="navbar-fixed">
<nav id="nav"> <nav id="nav">
<div class="nav-wrapper"> <div class="nav-wrapper">
<a href="/" class="brand-logo hide-on-med-and-down noselect"> <a href="/" class="brand-logo brand-logo-navigate hide-on-med-and-down noselect">
<img id="zicon" src="static/images/squareicon_small.png" alt="zöff" title="Zöff" /> <img id="zicon" src="static/images/squareicon_small.png" alt="zöff" title="Zöff" />
</a> </a>
<div class="brand-logo truncate zbrand"> <div class="brand-logo brand-logo-navigate truncate zbrand">
<a href="/" class="hide-on-large-only">Zöff</a> <a href="/" class="hide-on-large-only">Zöff</a>
<span class="hide-on-large-only">/</span> <span class="hide-on-large-only">/</span>
<span id="chan" class="chan clickable" title="Show big URL"><?php echo(ucfirst($list));?></span> <span id="chan" class="chan clickable" title="Show big URL"><?php echo(ucfirst($list));?></span>

View File

@@ -8,11 +8,11 @@
<div class="navbar-fixed"> <div class="navbar-fixed">
<nav id="nav"> <nav id="nav">
<div class="nav-wrapper"> <div class="nav-wrapper">
<a href="/" class="brand-logo hide-on-med-and-down noselect"> <a href="/" class="brand-logo brand-logo-navigate hide-on-med-and-down noselect">
<img id="zicon" src="static/images/squareicon_small.png" alt="zöff" title="Zöff" /> <img id="zicon" src="static/images/squareicon_small.png" alt="zöff" title="Zöff" />
</a> </a>
<div class="brand-logo truncate zbrand"> <div class="brand-logo truncate zbrand">
<a href="/" class="hide-on-large-only">Zöff</a> <a href="/" class="hide-on-large-only brand-logo-navigate">Zöff</a>
<span class="hide-on-large-only">/</span> <span class="hide-on-large-only">/</span>
<span id="chan" class="chan clickable" title="Show big URL"><?php echo(ucfirst($list));?></span> <span id="chan" class="chan clickable" title="Show big URL"><?php echo(ucfirst($list));?></span>
</div> </div>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -9,6 +9,7 @@ var List = {
channel_function: function(msg) channel_function: function(msg)
{ {
switch(msg[0]) switch(msg[0])
{ {
case "list": case "list":
@@ -42,6 +43,7 @@ var List = {
populate_list: function(msg) populate_list: function(msg)
{ {
full_playlist = msg; full_playlist = msg;
List.sortList(); List.sortList();

View File

@@ -39,29 +39,36 @@ var list;
var seekTo; var seekTo;
var song_title; var song_title;
var previous_video_id; var previous_video_id;
var socket;
var connection_options = { var connection_options = {
'sync disconnect on unload':true, 'sync disconnect on unload':true,
'secure': true, 'secure': true,
'force new connection': true 'force new connection': true
}; };
if(window.location.hostname == "zoff.no") add = "https://zoff.no"; $().ready(function(){init();});
else add = "localhost";
var 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);
});
$(document).ready(function() function init(){
{
chan = $("#chan").html();
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(){ setTimeout(function(){
Youtube.stopInterval= false;
//window.vote = List.vote; //window.vote = List.vote;
//window.submit = Search.submit; //window.submit = Search.submit;
//window.submitAndClose = Search.submitAndClose; //window.submitAndClose = Search.submitAndClose;
@@ -181,7 +188,11 @@ $(document).ready(function()
} }
}, 1); }, 1);
}, 1000); }, 1000);
});
}
window.init = init;
$(document).keyup(function(e) { $(document).keyup(function(e) {
if(event.keyCode == 27){ if(event.keyCode == 27){
@@ -262,7 +273,7 @@ $("#skip").on("click", function(){
List.skip(); List.skip();
}); });
$("#chan").on("click", function(){ $(document).on("click", "#chan", function(){
List.show(); List.show();
}); });
@@ -355,7 +366,7 @@ $(document).on('click', '#toast-container', function(){
}); });
}); });
$(".brand-logo").click(function(e){ $(document).on("click", ".brand-logo-navigate", function(e){
e.preventDefault(); e.preventDefault();
window.history.pushState("to the frontpage!", "Title", "/"); window.history.pushState("to the frontpage!", "Title", "/");
@@ -369,16 +380,22 @@ window.onpopstate = function(e){
function onepage_load(){ function onepage_load(){
var url_split = window.location.href.split("/"); var url_split = window.location.href.split("/");
if(url_split[3] == "" || url_split[3].substring(0,1) == "#"){ if(url_split[3] == "" || url_split[3].substring(0,1) == "#"){
$("#channel-load").css("display", "block"); $("#channel-load").css("display", "block");
window.scrollTo(0, 0); window.scrollTo(0, 0);
Youtube.stopInterval = true; Youtube.stopInterval = true;
Admin.display_logged_out();
Admin.beginning = true;
chan = "";
socket.removeAllListeners();
$.ajax({ $.ajax({
url: "php/nochan_content.php", url: "php/nochan_content.php",
success: function(e){ success: function(e){
Youtube.ytplayer.destroy();
socket.disconnect(); socket.disconnect();
@@ -387,7 +404,7 @@ function onepage_load(){
document.getElementById("fullscreen").removeEventListener("click", Playercontrols.fullscreen); document.getElementById("fullscreen").removeEventListener("click", Playercontrols.fullscreen);
setTimeout(function(){ setTimeout(function(){
delete Admin /*delete Admin
delete Chat delete Chat
delete Crypt delete Crypt
delete Hostcontroller delete Hostcontroller
@@ -438,21 +455,26 @@ function onepage_load(){
delete previous_video_id; delete previous_video_id;
delete connection_options; delete connection_options;
delete socket; delete socket;
delete window.onYouTubeIframeAPIReady; delete window.onYouTubeIframeAPIReady;*/
Youtube.ytplayer.destroy();
$(".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());
if($("#alreadychannel").length == 0) $("head").append("<div id='alreadychannel'></div")
if($("#alreadyfp").length == 1) window.initfp();
else $("#scripts").append($($(e)[8]).html());
}, 1000); }, 1000);
document.title = "Zöff"; 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

@@ -1,6 +1,6 @@
//script for frontpage //script for frontpage
var list_html; var channel_list;
var git_info; var git_info;
/* /*
@@ -40,7 +40,7 @@ var Nochan = {
if(pinned !== undefined){ if(pinned !== undefined){
lists.unshift(pinned); lists.unshift(pinned);
} }
pre_card = $(list_html); pre_card = $(channel_list);
if(!window.mobilecheck()) if(!window.mobilecheck())
Nochan.add_backdrop(lists, 0); Nochan.add_backdrop(lists, 0);
@@ -56,7 +56,7 @@ var Nochan = {
var img = "background-image:url('https://img.youtube.com/vi/"+id+"/hqdefault.jpg');"; var img = "background-image:url('https://img.youtube.com/vi/"+id+"/hqdefault.jpg');";
var song_count = lists[x][4]; var song_count = lists[x][4];
//$("#channels").append(list_html); //$("#channels").append(channel_list);
var card = pre_card; var card = pre_card;
if(lists[x][5] == 1) if(lists[x][5] == 1)
@@ -204,6 +204,8 @@ var Nochan = {
$("#channel-load").css("display", "block"); $("#channel-load").css("display", "block");
window.scrollTo(0, 0); window.scrollTo(0, 0);
socket.removeAllListeners();
$.ajax({ $.ajax({
url: chan + "/php/channel.php", url: chan + "/php/channel.php",
success: function(e){ success: function(e){
@@ -212,16 +214,21 @@ var Nochan = {
socket.disconnect(); socket.disconnect();
if(!popstate) window.history.pushState("to the channel!", "Title", "/" + chan); if(!popstate) window.history.pushState("to the channel!", "Title", "/" + chan + "/");
$.holdReady(true);
$(".mega").remove(); $(".mega").remove();
$(".mobile-search").remove(); $(".mobile-search").remove();
$("main").attr("class", "container center-align main"); $("main").attr("class", "container center-align main");
$("body").attr("id", "channelpage"); $("body").attr("id", "channelpage");
$("header").html($($(e)[0]).html()); $("header").html($($(e)[0]).html());
$("main").html($($(e)[2]).html()); $("main").html($($(e)[2]).html());
$("#scripts").html($($(e)[4]).html()); if($("#alreadychannel").length == 1){
window.init();
}else{
$("#scripts").append($($(e)[4]).html());
}
if($("#alreadyfp").length == 0) $("head").append("<div id='alreadyfp'></div>");
} }
}); });
} }
@@ -242,14 +249,16 @@ String.prototype.capitalizeFirstLetter = function() {
return this.charAt(0).toUpperCase() + this.slice(1); return this.charAt(0).toUpperCase() + this.slice(1);
} }
$(document).ready(function (){ $().ready(initfp);
function initfp(){
//Materialize.toast("<a href='/remote' style='color:white;'>Try out our new feature, remote!</a>", 8000) //Materialize.toast("<a href='/remote' style='color:white;'>Try out our new feature, remote!</a>", 8000)
if(window.location.hash == "#donation") if(window.location.hash == "#donation")
$('#donation').openModal() $('#donation').openModal()
list_html = $("#channel-list-container").html(); channel_list = $("#channel-list-container").html();
window.list_html = list_html; //window.channel_list = channel_list;
$("#channels").empty(); $("#channels").empty();
var connection_options = { var connection_options = {
@@ -309,33 +318,37 @@ $(document).ready(function (){
+ git_info[0].sha.substring(0,10) + "</a>: " + git_info[0].sha.substring(0,10) + "</a>: "
+ git_info[0].commit.message+"<br"); + git_info[0].commit.message+"<br");
});
}
window.initfp = initfp;
$(document).on('click', '#cookieok', function() { $(document).on('click', '#cookieok', function() {
$(this).fadeOut(function(){ $(this).fadeOut(function(){
$(this).remove(); $(this).remove();
localStorage["ok_cookie"] = true; localStorage["ok_cookie"] = true;
}); });
}); });
$(document).on('click', '#toast-container', function(){ $(document).on('click', '#toast-container', function(){
$(this).fadeOut(function(){ $(this).fadeOut(function(){
$(this).remove(); $(this).remove();
}); });
}); });
$(document).on('click', ".chan-link", function(e){ $(document).on('click', ".chan-link", function(e){
e.preventDefault(); e.preventDefault();
Nochan.to_channel($(this).attr("href"), false); Nochan.to_channel($(this).attr("href"), false);
}); });
$(".listen-button").click(function(e){ $(".listen-button").click(function(e){
//console.log($(".room-namer").attr("placeholder")); //console.log($(".room-namer").attr("placeholder"));
if($(".room-namer").val() == ""){ if($(".room-namer").val() == ""){
e.preventDefault(); e.preventDefault();
//window.location = "?chan="+ //window.location = "?chan="+
Nochan.to_channel($(".room-namer").attr("placeholder"));
}
});
Nochan.to_channel($(".room-namer").attr("placeholder"));
}
});

View File

@@ -49,7 +49,7 @@ var Playercontrols = {
play_pause: function() play_pause: function()
{ {
console.log("play pause");
if(Youtube.ytplayer.getPlayerState() == 1) if(Youtube.ytplayer.getPlayerState() == 1)
{ {
Youtube.ytplayer.pauseVideo(); Youtube.ytplayer.pauseVideo();

View File

@@ -11,7 +11,9 @@ var Youtube = {
socket.on("np", function(obj) socket.on("np", function(obj)
{ {
Youtube.loaded = false; 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){ if(obj[0].length == 0){
document.getElementById('song-title').innerHTML = "Empty channel. Add some songs!"; document.getElementById('song-title').innerHTML = "Empty channel. Add some songs!";
@@ -44,22 +46,26 @@ var Youtube = {
//if(player_ready && !window.mobilecheck()) //if(player_ready && !window.mobilecheck())
if(player_ready && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) if(player_ready && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream)
{ {
if(Youtube.ytplayer.getVideoUrl().split('v=')[1] != video_id)
{ try{
Youtube.ytplayer.loadVideoById(video_id); if(Youtube.ytplayer.getVideoUrl().split('v=')[1] != video_id)
Youtube.notifyUser(video_id, song_title); {
Youtube.ytplayer.seekTo(seekTo); Youtube.ytplayer.loadVideoById(video_id);
if(paused) Youtube.notifyUser(video_id, song_title);
Youtube.ytplayer.pauseVideo(); Youtube.ytplayer.seekTo(seekTo);
} if(paused)
if(!paused){ Youtube.ytplayer.pauseVideo();
Youtube.ytplayer.playVideo(); }
Youtube.durationSetter();
} if(!paused){
if(Youtube.ytplayer.getDuration() > seekTo || Youtube.ytplayer.getDuration() == 0) Youtube.ytplayer.playVideo();
Youtube.ytplayer.seekTo(seekTo); Youtube.durationSetter();
Youtube.after_load = video_id; }
setTimeout(function(){Youtube.loaded = true;},500); 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){Youtube.durationSetter();}
} }
else else
Youtube.getTitle(song_title, viewers); Youtube.getTitle(song_title, viewers);
@@ -157,6 +163,7 @@ var Youtube = {
}, },
onPlayerReady: function(event) { onPlayerReady: function(event) {
try{
beginning = true; beginning = true;
player_ready = true; player_ready = true;
if(!/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) if(!/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream)
@@ -164,6 +171,7 @@ var Youtube = {
$("#player").css("opacity", "1"); $("#player").css("opacity", "1");
$("#controls").css("opacity", "1"); $("#controls").css("opacity", "1");
$(".playlist").css("opacity", "1"); $(".playlist").css("opacity", "1");
window.ytplayer = Youtube.ytplayer;
Youtube.ytplayer.loadVideoById(video_id); Youtube.ytplayer.loadVideoById(video_id);
Youtube.ytplayer.playVideo(); Youtube.ytplayer.playVideo();
Youtube.durationSetter(); Youtube.durationSetter();
@@ -173,6 +181,7 @@ var Youtube = {
Playercontrols.initYoutubeControls(Youtube.ytplayer); Playercontrols.initYoutubeControls(Youtube.ytplayer);
Playercontrols.initSlider(); Playercontrols.initSlider();
Youtube.ytplayer.setVolume(Crypt.get_volume()); Youtube.ytplayer.setVolume(Crypt.get_volume());
}catch(e){window.location.reload();};
}, },
readyLooks: function() readyLooks: function()
@@ -243,22 +252,28 @@ var Youtube = {
durationSetter: function() durationSetter: function()
{ {
//console.log(Youtube.stopInterval); //console.log(Youtube.stopInterval);
duration = Youtube.ytplayer.getDuration(); try{
duration = Youtube.ytplayer.getDuration();
}catch(e){duration = 0};
if(duration != undefined){ if(duration != undefined){
dMinutes = Math.floor(duration / 60); try{
dSeconds = duration - dMinutes * 60; dMinutes = Math.floor(duration / 60);
currDurr = Youtube.ytplayer.getCurrentTime(); dSeconds = duration - dMinutes * 60;
if(currDurr > duration) currDurr = Youtube.ytplayer.getCurrentTime();
currDurr = duration; if(currDurr > duration)
minutes = Math.floor(currDurr / 60); currDurr = duration;
seconds = currDurr - minutes * 60; minutes = Math.floor(currDurr / 60);
document.getElementById("duration").innerHTML = Helper.pad(minutes)+":"+Helper.pad(seconds)+" <span id='dash'>/</span> "+Helper.pad(dMinutes)+":"+Helper.pad(dSeconds); seconds = currDurr - minutes * 60;
per = (100 / duration) * currDurr; document.getElementById("duration").innerHTML = Helper.pad(minutes)+":"+Helper.pad(seconds)+" <span id='dash'>/</span> "+Helper.pad(dMinutes)+":"+Helper.pad(dSeconds);
if(per >= 100) per = (100 / duration) * currDurr;
per = 100; if(per >= 100)
else if(duration == 0) per = 100;
per = 0; else if(duration == 0)
$("#bar").width(per+"%"); per = 0;
$("#bar").width(per+"%");
}catch(e){
}
} }
if(!Youtube.stopInterval) setTimeout(Youtube.durationSetter, 1000); if(!Youtube.stopInterval) setTimeout(Youtube.durationSetter, 1000);
}, },