onepage working

This commit is contained in:
Kasper Rynning-Tønnesen
2016-01-25 14:12:11 +01:00
parent 26dea79c7a
commit 522ccb2af0
10 changed files with 88 additions and 49 deletions

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)
{
Crypt.init();
Admin.set_conf(msg[0]);
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)
{
switch(msg[0])
{
case "list":
@@ -42,6 +43,7 @@ var List = {
populate_list: function(msg)
{
full_playlist = msg;
List.sortList();

View File

@@ -46,13 +46,16 @@ var connection_options = {
'force new connection': true
};
$().ready(init);
$().ready(function(){init();});
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);
});
@@ -63,7 +66,9 @@ function init(){
single = false;
setTimeout(function(){Suggestions.catchUserSuggests(params, single)}, 1000);
});
setTimeout(function(){
Youtube.stopInterval= false;
//window.vote = List.vote;
//window.submit = Search.submit;
//window.submitAndClose = Search.submitAndClose;
@@ -183,6 +188,8 @@ function init(){
}
}, 1);
}, 1000);
}
window.init = init;
@@ -266,7 +273,7 @@ $("#skip").on("click", function(){
List.skip();
});
$("#chan").on("click", function(){
$(document).on("click", "#chan", function(){
List.show();
});
@@ -359,7 +366,7 @@ $(document).on('click', '#toast-container', function(){
});
});
$(".brand-logo").click(function(e){
$(document).on("click", ".brand-logo-navigate", function(e){
e.preventDefault();
window.history.pushState("to the frontpage!", "Title", "/");
@@ -373,16 +380,22 @@ window.onpopstate = function(e){
function onepage_load(){
var url_split = window.location.href.split("/");
if(url_split[3] == "" || url_split[3].substring(0,1) == "#"){
$("#channel-load").css("display", "block");
window.scrollTo(0, 0);
Youtube.stopInterval = true;
Admin.display_logged_out();
Admin.beginning = true;
chan = "";
socket.removeAllListeners();
$.ajax({
url: "php/nochan_content.php",
success: function(e){
Youtube.ytplayer.destroy();
socket.disconnect();
@@ -443,6 +456,8 @@ function onepage_load(){
delete connection_options;
delete socket;
delete window.onYouTubeIframeAPIReady;*/
Youtube.ytplayer.destroy();
$(".drag-target").remove();
$(".sidenav-overlay").remove();
$("main").attr("class", "center-align container");
@@ -452,7 +467,10 @@ function onepage_load(){
$($(e)[2]).insertAfter("header");
$($(e)[4]).insertAfter(".mega");
$("main").html($($(e)[6]).html());
$("#scripts").append($($(e)[8]).html());
if($("#alreadychannel").length == 0) $("head").append("<div id='alreadychannel'></div")
if($("#alreadyfp").length == 1) window.initfp();
else $("#scripts").append($($(e)[8]).html());
}, 1000);
document.title = "Zöff";

View File

@@ -1,6 +1,6 @@
//script for frontpage
var list_html;
var channel_list;
var git_info;
/*
@@ -40,7 +40,7 @@ var Nochan = {
if(pinned !== undefined){
lists.unshift(pinned);
}
pre_card = $(list_html);
pre_card = $(channel_list);
if(!window.mobilecheck())
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 song_count = lists[x][4];
//$("#channels").append(list_html);
//$("#channels").append(channel_list);
var card = pre_card;
if(lists[x][5] == 1)
@@ -204,6 +204,8 @@ var Nochan = {
$("#channel-load").css("display", "block");
window.scrollTo(0, 0);
socket.removeAllListeners();
$.ajax({
url: chan + "/php/channel.php",
success: function(e){
@@ -212,7 +214,7 @@ var Nochan = {
socket.disconnect();
if(!popstate) window.history.pushState("to the channel!", "Title", "/" + chan);
if(!popstate) window.history.pushState("to the channel!", "Title", "/" + chan + "/");
$(".mega").remove();
@@ -221,8 +223,12 @@ var Nochan = {
$("body").attr("id", "channelpage");
$("header").html($($(e)[0]).html());
$("main").html($($(e)[2]).html());
window.init();
//$("#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>");
}
});
}
@@ -243,14 +249,16 @@ String.prototype.capitalizeFirstLetter = function() {
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)
if(window.location.hash == "#donation")
$('#donation').openModal()
list_html = $("#channel-list-container").html();
window.list_html = list_html;
channel_list = $("#channel-list-container").html();
//window.channel_list = channel_list;
$("#channels").empty();
var connection_options = {
@@ -310,33 +318,37 @@ $(document).ready(function (){
+ git_info[0].sha.substring(0,10) + "</a>: "
+ git_info[0].commit.message+"<br");
});
}
window.initfp = initfp;
$(document).on('click', '#cookieok', function() {
$(this).fadeOut(function(){
$(this).remove();
localStorage["ok_cookie"] = true;
});
});
$(this).fadeOut(function(){
$(this).remove();
localStorage["ok_cookie"] = true;
});
});
$(document).on('click', '#toast-container', function(){
$(this).fadeOut(function(){
$(this).remove();
});
});
$(document).on('click', '#toast-container', function(){
$(this).fadeOut(function(){
$(this).remove();
});
});
$(document).on('click', ".chan-link", function(e){
e.preventDefault();
$(document).on('click', ".chan-link", function(e){
e.preventDefault();
Nochan.to_channel($(this).attr("href"), false);
});
Nochan.to_channel($(this).attr("href"), false);
});
$(".listen-button").click(function(e){
//console.log($(".room-namer").attr("placeholder"));
if($(".room-namer").val() == ""){
e.preventDefault();
//window.location = "?chan="+
Nochan.to_channel($(".room-namer").attr("placeholder"));
}
});
$(".listen-button").click(function(e){
//console.log($(".room-namer").attr("placeholder"));
if($(".room-namer").val() == ""){
e.preventDefault();
//window.location = "?chan="+
Nochan.to_channel($(".room-namer").attr("placeholder"));
}
});

View File

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

View File

@@ -46,6 +46,7 @@ var Youtube = {
//if(player_ready && !window.mobilecheck())
if(player_ready && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream)
{
try{
if(Youtube.ytplayer.getVideoUrl().split('v=')[1] != video_id)
{
@@ -64,7 +65,7 @@ var Youtube = {
Youtube.ytplayer.seekTo(seekTo);
Youtube.after_load = video_id;
setTimeout(function(){Youtube.loaded = true;},500);
}catch(e){}
}catch(e){Youtube.durationSetter();}
}
else
Youtube.getTitle(song_title, viewers);
@@ -162,6 +163,7 @@ var Youtube = {
},
onPlayerReady: function(event) {
try{
beginning = true;
player_ready = true;
if(!/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream)
@@ -169,6 +171,7 @@ var Youtube = {
$("#player").css("opacity", "1");
$("#controls").css("opacity", "1");
$(".playlist").css("opacity", "1");
window.ytplayer = Youtube.ytplayer;
Youtube.ytplayer.loadVideoById(video_id);
Youtube.ytplayer.playVideo();
Youtube.durationSetter();
@@ -178,6 +181,7 @@ var Youtube = {
Playercontrols.initYoutubeControls(Youtube.ytplayer);
Playercontrols.initSlider();
Youtube.ytplayer.setVolume(Crypt.get_volume());
}catch(e){window.location.reload();};
},
readyLooks: function()
@@ -248,7 +252,9 @@ var Youtube = {
durationSetter: function()
{
//console.log(Youtube.stopInterval);
duration = Youtube.ytplayer.getDuration();
try{
duration = Youtube.ytplayer.getDuration();
}catch(e){duration = 0};
if(duration != undefined){
try{
dMinutes = Math.floor(duration / 60);
@@ -266,7 +272,7 @@ var Youtube = {
per = 0;
$("#bar").width(per+"%");
}catch(e){
Youtube.stopInterval = true;
}
}
if(!Youtube.stopInterval) setTimeout(Youtube.durationSetter, 1000);