mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
one page webapp try
This commit is contained in:
2
static/dist/frontpage.min.js
vendored
2
static/dist/frontpage.min.js
vendored
File diff suppressed because one or more lines are too long
4
static/dist/main.min.js
vendored
4
static/dist/main.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -5,9 +5,13 @@ var Crypt = {
|
||||
init: function(){
|
||||
try{
|
||||
conf_arr = Crypt.decrypt(Crypt.getCookie("_opt"), "_opt");
|
||||
conf_pass = Crypt.decrypt(Crypt.getCookie(chan.toLowerCase()), chan.toLowerCase());
|
||||
console.log("channel: " + chan.toLowerCase());
|
||||
}catch(err){
|
||||
conf_arr = Crypt.decrypt(Crypt.create_cookie("_opt"), "_opt");
|
||||
}
|
||||
try{
|
||||
conf_pass = Crypt.decrypt(Crypt.getCookie(chan.toLowerCase()), chan.toLowerCase());
|
||||
}catch(err){
|
||||
conf_pass = Crypt.decrypt(Crypt.create_cookie(chan.toLowerCase()), chan.toLowerCase());
|
||||
}
|
||||
Hostcontroller.change_enabled(conf_arr.remote);
|
||||
@@ -17,6 +21,7 @@ var Crypt = {
|
||||
decrypt: function(cookie, name){
|
||||
if(Crypt.getCookie(name) === undefined) {
|
||||
cookie = Crypt.create_cookie(name);
|
||||
console.log(cookie);
|
||||
}
|
||||
|
||||
var decrypted = CryptoJS.AES.decrypt(
|
||||
@@ -87,6 +92,7 @@ var Crypt = {
|
||||
if(name == "_opt") cookie_object = {volume: 100, width: 100, remote: true};
|
||||
else cookie_object = {passwords: {}};
|
||||
|
||||
console.log(cookie_object);
|
||||
|
||||
var string_it = JSON.stringify(cookie_object);
|
||||
|
||||
@@ -102,9 +108,13 @@ var Crypt = {
|
||||
var CookieDate = new Date;
|
||||
CookieDate.setFullYear(CookieDate.getFullYear( ) +1);
|
||||
|
||||
if(name != "_opt") add = chan.toLowerCase();
|
||||
else add = ";"
|
||||
document.cookie = name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/"+add
|
||||
//if(name != "_opt") add = chan.toLowerCase();
|
||||
//else
|
||||
add = ";"
|
||||
|
||||
console.log(name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/"+add);
|
||||
|
||||
document.cookie = name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/"+add;
|
||||
//document.cookie = name+"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;"
|
||||
//document.cookie = na"="+encrypted.toString()+";expires="+CookieDate.toGMTString()+";path=/;"
|
||||
return Crypt.getCookie(name);
|
||||
|
||||
@@ -41,25 +41,28 @@ var song_title;
|
||||
var previous_video_id;
|
||||
var connection_options = {
|
||||
'sync disconnect on unload':true,
|
||||
'secure': 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(){
|
||||
socket.emit('list', chan.toLowerCase());
|
||||
setTimeout(function(){socket.emit('list', chan.toLowerCase())},1000);
|
||||
});
|
||||
|
||||
socket.on("suggested", function(params){
|
||||
console.log(params);
|
||||
var single = true;
|
||||
if(params.id == undefined)
|
||||
single = false;
|
||||
Suggestions.catchUserSuggests(params, single);
|
||||
setTimeout(function(){Suggestions.catchUserSuggests(params, single)}, 1000);
|
||||
});
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
setTimeout(function(){
|
||||
//window.vote = List.vote;
|
||||
//window.submit = Search.submit;
|
||||
//window.submitAndClose = Search.submitAndClose;
|
||||
@@ -69,6 +72,7 @@ $(document).ready(function()
|
||||
localStorage.setItem("list_update", "13.06.15");
|
||||
window.location.reload(true);
|
||||
}
|
||||
console.log(Youtube);
|
||||
Youtube.setup_youtube_listener(chan);
|
||||
Admin.admin_listener();
|
||||
List.channel_listener();
|
||||
@@ -108,8 +112,8 @@ $(document).ready(function()
|
||||
Chat.setup_chat_listener(chan);
|
||||
Chat.allchat_listener();
|
||||
Hostcontroller.host_listener();
|
||||
Youtube.loadPlayer();
|
||||
window.onYouTubeIframeAPIReady = Youtube.onYouTubeIframeAPIReady;
|
||||
Youtube.loadPlayer();
|
||||
|
||||
$("#chat-btn").sideNav({
|
||||
menuWidth: 272, // Default is 240
|
||||
@@ -173,6 +177,7 @@ $(document).ready(function()
|
||||
Search.search($(".search_input").val());
|
||||
}
|
||||
}, 1);
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
$(document).keyup(function(e) {
|
||||
@@ -345,4 +350,87 @@ $(document).on('click', '#toast-container', function(){
|
||||
$(this).fadeOut(function(){
|
||||
$(this).remove();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
window.onpopstate = function(e){
|
||||
var url_split = window.location.href.split("/");
|
||||
|
||||
if(url_split[3] == "" || url_split[3].substring(0,1) == "#"){
|
||||
$.ajax({
|
||||
url: "php/nochan_content.php",
|
||||
success: function(e){
|
||||
ytplayer.destroy();
|
||||
Playercontrols.clearDurationInterval();
|
||||
|
||||
socket.disconnect();
|
||||
|
||||
document.getElementById("volume-button").removeEventListener("click", Playercontrols.mute_video);
|
||||
document.getElementById("playpause").removeEventListener("click", Playercontrols.play_pause);
|
||||
document.getElementById("fullscreen").removeEventListener("click", Playercontrols.fullscreen);
|
||||
|
||||
delete ytplayer
|
||||
delete Admin
|
||||
delete Chat
|
||||
delete Crypt
|
||||
delete Hostcontroller
|
||||
delete Playercontrols
|
||||
delete List
|
||||
delete Search
|
||||
delete Suggestions
|
||||
delete Youtube
|
||||
delete chan;
|
||||
delete w_p;
|
||||
delete hasadmin;
|
||||
delete showToggle;
|
||||
delete list_html;
|
||||
delete blink_interval_exists;
|
||||
delete unseen;
|
||||
delete timer;
|
||||
delete api_key;
|
||||
delete result_html;
|
||||
delete empty_results_html;
|
||||
delete searching;
|
||||
delete time_regex;
|
||||
delete conf;
|
||||
delete music;
|
||||
delete frontpage;
|
||||
delete adminpass;
|
||||
delete filesadded;
|
||||
delete player_ready;
|
||||
delete viewers;
|
||||
delete paused;
|
||||
delete playing;
|
||||
delete SAMPLE_RATE;
|
||||
delete lastSample;
|
||||
delete began;
|
||||
delete i;
|
||||
delete id;
|
||||
delete full_playlist;
|
||||
delete conf;
|
||||
delete blink_interval;
|
||||
delete tag;
|
||||
delete firstScriptTag;
|
||||
delete ytplayer;
|
||||
delete title;
|
||||
delete viewers;
|
||||
delete video_id;
|
||||
delete list;
|
||||
delete seekTo;
|
||||
delete song_title;
|
||||
delete previous_video_id;
|
||||
delete connection_options;
|
||||
delete socket;
|
||||
delete window.onYouTubeIframeAPIReady;
|
||||
|
||||
$("main").attr("class", "center-align container");
|
||||
$("body").attr("id", "");
|
||||
$("header").html($($(e)[0]).html());
|
||||
$($(e)[2]).insertAfter("header");
|
||||
$($(e)[4]).insertAfter(".mega");
|
||||
$("main").html($($(e)[6]).html());
|
||||
$("#scripts").html($($(e)[8]).html());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,6 @@ var Nochan = {
|
||||
//$("#channels").append(list_html);
|
||||
|
||||
var card = pre_card;
|
||||
|
||||
if(lists[x][5] == 1)
|
||||
{
|
||||
card.find(".pin").attr("style", "display:block;");
|
||||
@@ -198,6 +197,28 @@ var Nochan = {
|
||||
}else{
|
||||
corn.remove();
|
||||
}
|
||||
},
|
||||
|
||||
to_channel: function(chan){
|
||||
|
||||
$.ajax({
|
||||
url: chan + "/php/channel.php",
|
||||
success: function(e){
|
||||
|
||||
delete Nochan
|
||||
|
||||
socket.disconnect();
|
||||
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());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -219,7 +240,8 @@ $(document).ready(function (){
|
||||
$("#channels").empty();
|
||||
|
||||
var connection_options = {
|
||||
'secure': true
|
||||
'secure': true,
|
||||
'force new connection': true
|
||||
};
|
||||
|
||||
if(window.location.hostname == "zoff.no") add = "https://zoff.no";
|
||||
@@ -289,6 +311,11 @@ $(document).on('click', '#toast-container', function(){
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', ".chan-link", function(e){
|
||||
e.preventDefault();
|
||||
Nochan.to_channel($(this).attr("href"));
|
||||
});
|
||||
|
||||
$(".listen-button").click(function(e){
|
||||
//console.log($(".room-namer").attr("placeholder"));
|
||||
if($(".room-namer").val() == ""){
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
var Playercontrols = {
|
||||
|
||||
interval: null,
|
||||
|
||||
initYoutubeControls: function(player)
|
||||
{
|
||||
if(window.mobilecheck() && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream){
|
||||
$("#controls").appendTo("#playbar");
|
||||
}
|
||||
setInterval(Playercontrols.durationSetter, 1000);
|
||||
Playercontrols.interval = setInterval(Playercontrols.durationSetter, 1000);
|
||||
Playercontrols.initControls();
|
||||
},
|
||||
|
||||
@@ -17,6 +19,11 @@ var Playercontrols = {
|
||||
|
||||
},
|
||||
|
||||
clearDurationInterval: function()
|
||||
{
|
||||
clearInterval(Playercontrols.interval);
|
||||
},
|
||||
|
||||
initSlider: function()
|
||||
{
|
||||
vol = (Crypt.get_volume());
|
||||
|
||||
@@ -6,10 +6,11 @@ var Youtube = {
|
||||
|
||||
setup_youtube_listener: function(channel)
|
||||
{
|
||||
console.log("Setup shit");
|
||||
socket.on("np", function(obj)
|
||||
{
|
||||
Youtube.loaded = false;
|
||||
if(video_id != undefined) Youtube.before_load = ytplayer.getVideoUrl();
|
||||
if(video_id != undefined && ytplayer !== undefined) Youtube.before_load = ytplayer.getVideoUrl();
|
||||
if(obj[0].length == 0){
|
||||
|
||||
document.getElementById('song-title').innerHTML = "Empty channel. Add some songs!";
|
||||
@@ -223,6 +224,7 @@ var Youtube = {
|
||||
},
|
||||
|
||||
onYouTubeIframeAPIReady: function() {
|
||||
console.log("helloo?");
|
||||
ytplayer = new YT.Player('player', {
|
||||
videoId: "asd",
|
||||
playerVars: { rel:"0", wmode:"transparent", controls: "0" , iv_load_policy: "3", theme:"light", color:"white"},
|
||||
@@ -235,10 +237,12 @@ var Youtube = {
|
||||
},
|
||||
|
||||
loadPlayer: function() {
|
||||
tag = document.createElement('script');
|
||||
tag.src = "https://www.youtube.com/iframe_api";
|
||||
firstScriptTag = document.getElementsByTagName('script')[0];
|
||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
||||
console.log(ytplayer);
|
||||
console.log("load the player");
|
||||
tag = document.createElement('script');
|
||||
tag.src = "https://www.youtube.com/iframe_api";
|
||||
firstScriptTag = document.getElementsByTagName('script')[0];
|
||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user