Updated how adding playlists works.

This commit is contained in:
Kasper Rynning-Tønnesen
2016-08-13 13:33:17 +02:00
parent 4359144925
commit a9a02b56ba
19 changed files with 229 additions and 139 deletions

0
manifest.json Normal file → Executable file
View File

0
php/bot.php Normal file → Executable file
View File

View File

@@ -146,6 +146,51 @@
<form action="#" id="listImport" onsubmit="return false;">
<i class="mdi-av-playlist-add import-icon"></i>
<input title="Input YouTube-playlist id here!" placeholder="Enter YouTube-list ID" id="import" type="text" class="validate" autocomplete="off" />
<li id="playlist_loader" class="valign-wrapper hide">
<div class="valign">
<div class="preloader-wrapper small active">
<div class="spinner-layer spinner-blue">
<div class="circle-clipper left">
<div class="circle"></div>
</div><div class="gap-patch">
<div class="circle"></div>
</div><div class="circle-clipper right">
<div class="circle"></div>
</div>
</div>
<div class="spinner-layer spinner-red">
<div class="circle-clipper left">
<div class="circle"></div>
</div><div class="gap-patch">
<div class="circle"></div>
</div><div class="circle-clipper right">
<div class="circle"></div>
</div>
</div>
<div class="spinner-layer spinner-yellow">
<div class="circle-clipper left">
<div class="circle"></div>
</div><div class="gap-patch">
<div class="circle"></div>
</div><div class="circle-clipper right">
<div class="circle"></div>
</div>
</div>
<div class="spinner-layer spinner-green">
<div class="circle-clipper left">
<div class="circle"></div>
</div><div class="gap-patch">
<div class="circle"></div>
</div><div class="circle-clipper right">
<div class="circle"></div>
</div>
</div>
</div>
</div>
</li>
</form>
</div>
</li>

0
service-worker.js Normal file → Executable file
View File

View File

@@ -869,6 +869,10 @@ ul #chat-log{
margin-top:15px;
}
#playlist_loader {
padding: 10px 0px 0px 70px;
}
#search_loader:hover {
background-color:rgba(0,0,0,0);
}

File diff suppressed because one or more lines are too long

0
static/dist/lib/aes.js vendored Normal file → Executable file
View File

0
static/dist/lib/cache-polyfill.js vendored Normal file → Executable file
View File

0
static/dist/lib/sha256.js vendored Normal file → Executable file
View File

0
static/dist/lib/socket.io-1.4.5.js vendored Normal file → Executable file
View File

File diff suppressed because one or more lines are too long

0
static/images/144x144.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@@ -6,43 +6,49 @@ var Admin = {
{
switch(msg) {
case "addedsong":
msg=Helper.rnd(["I added your song", "Your song has been added", "Yay, more songs!", "Thats a cool song!", "I added that song for you", "I see you like adding songs..."])
msg=Helper.rnd(["I added your song", "Your song has been added", "Yay, more songs!", "Thats a cool song!", "I added that song for you", "I see you like adding songs..."]);
break;
case "addedplaylist":
msg=Helper.rnd(["I added the playlist", "Your playlist has been added", "Yay, many more songes!", "Thats a cool playlist!", "I added all the songs for you", "I see you like adding songs.."]);
document.getElementById("import").disabled = false;
$("#playlist_loader").addClass("hide");
$("#import").removeClass("hide");
break;
case "savedsettings":
msg=Helper.rnd(["I've saved your settings", "I stored all your settings", "Your settings have been stored in a safe place"])
msg=Helper.rnd(["I've saved your settings", "I stored all your settings", "Your settings have been stored in a safe place"]);
break;
case "wrongpass":
msg=Helper.rnd(["That's not the right password!", "Wrong! Better luck next time...", "You seem to have mistyped the password", "Incorrect. Have you tried meditating?","Nope, wrong password!", "Wrong password. The authorities have been notified."])
msg=Helper.rnd(["That's not the right password!", "Wrong! Better luck next time...", "You seem to have mistyped the password", "Incorrect. Have you tried meditating?","Nope, wrong password!", "Wrong password. The authorities have been notified."]);
Crypt.remove_pass(chan.toLowerCase());
Admin.display_logged_out();
w_p = true;
break;
case "shuffled":
msg=Helper.rnd(["♫ You stir me right round, baby. ♫","♫ Stir, stir, stir my boat ♫","I vigorously stirred your playlist!", "I hope you like your list stirred, not shaken.", "I shuffled your playlist with the cosmic background radiation as a seed. Enjoy.", "100% randomized, for your listening pleasure!", "I hope you enjoy your fresh playlist!"])
msg=Helper.rnd(["♫ You stir me right round, baby. ♫","♫ Stir, stir, stir my boat ♫","I vigorously stirred your playlist!", "I hope you like your list stirred, not shaken.", "I shuffled your playlist with the cosmic background radiation as a seed. Enjoy.", "100% randomized, for your listening pleasure!", "I hope you enjoy your fresh playlist!"]);
break;
case "deletesong":
msg=Helper.rnd(["Your song is now in a better place...", "You won't be seeing any more of that video...", "EXTERMINATE! EXTERMINATE! EXTERMINATE!", "I killed it with fire", "Thanks for deleting that song. I didn't like it anyways...", "Removed song securely."])
msg=Helper.rnd(["Your song is now in a better place...", "You won't be seeing any more of that video...", "EXTERMINATE! EXTERMINATE! EXTERMINATE!", "I killed it with fire", "Thanks for deleting that song. I didn't like it anyways...", "Removed song securely."]);
break;
case "voted":
msg=Helper.rnd(["You voted!", "You vote like a boss", "Voting is the key to democracy", "May you get your song to the very top!", "I love that song! I vouch for you.", "Only you vote that good", "I like the way you vote...", "Up the video goes!", "Voted Zöff for president", "Only 999 more to go!"])
msg=Helper.rnd(["You voted!", "You vote like a boss", "Voting is the key to democracy", "May you get your song to the very top!", "I love that song! I vouch for you.", "Only you vote that good", "I like the way you vote...", "Up the video goes!", "Voted Zöff for president", "Only 999 more to go!"]);
break;
case "alreadyvoted":
msg=Helper.rnd(["You can't vote twice on that song!", "I see you have voted on that song before", "One vote per person!", "I know you want to hear your song, but have patience!", "I'm sorry, but I can't let you vote twice, Dave."])
msg=Helper.rnd(["You can't vote twice on that song!", "I see you have voted on that song before", "One vote per person!", "I know you want to hear your song, but have patience!", "I'm sorry, but I can't let you vote twice, Dave."]);
break;
case "skip":
msg=Helper.rnd(["The song was skipped", "I have skipped a song", "Skipped to the beat", "Skipmaster3000", "They see me skippin', they hatin'"])
msg=Helper.rnd(["The song was skipped", "I have skipped a song", "Skipped to the beat", "Skipmaster3000", "They see me skippin', they hatin'"]);
break;
case "listhaspass":
msg=Helper.rnd(["I'm sorry, but you have to be an admin to do that!", "Only admins can do that", "You're not allowed to do that, try logging in!", "I can't let you do that", "Please log in to do that"])
msg=Helper.rnd(["I'm sorry, but you have to be an admin to do that!", "Only admins can do that", "You're not allowed to do that, try logging in!", "I can't let you do that", "Please log in to do that"]);
Crypt.remove_pass(chan.toLowerCase());
Admin.display_logged_out();
w_p = true;
break;
case "noskip":
msg=Helper.rnd(["Only Admins can skip songs, peasant!", "You have to log in to skip songs on this channel", "Try clicking the settings icon and logging in before you skip"])
msg=Helper.rnd(["Only Admins can skip songs, peasant!", "You have to log in to skip songs on this channel", "Try clicking the settings icon and logging in before you skip"]);
break;
case "alreadyskip":
msg=Helper.rnd(["Skipping is democratic, only one vote per person!", "More people have to vote to skip, not just you!", "Get someone else to skip too! You can't do it on yourself."])
msg=Helper.rnd(["Skipping is democratic, only one vote per person!", "More people have to vote to skip, not just you!", "Get someone else to skip too! You can't do it on yourself."]);
break;
case "notyetskip":
msg="Skipping is disabled the first 10 seconds.";
@@ -70,7 +76,7 @@ var Admin = {
names = ["vote","addsongs","longsongs","frontpage", "allvideos",
"removeplay", "skip", "shuffle"];
Crypt.set_pass(chan.toLowerCase(), Crypt.decrypt_pass(msg))
Crypt.set_pass(chan.toLowerCase(), Crypt.decrypt_pass(msg));
for (var i = 0; i < names.length; i++) {
$("input[name="+names[i]+"]").attr("disabled", false);
@@ -79,7 +85,7 @@ var Admin = {
$(".card-action").removeClass("hide");
$("#admin-lock").removeClass("mdi-action-lock");
$("#password").val("");
$("#password").attr("placeholder", "Change channel password")
$("#password").attr("placeholder", "Change channel password");
//if(!Helper.mobilecheck()){
if(!Helper.contains($(".playlist-tabs").attr("class").split(" "), "hide")) {
$(".playlist-tabs-loggedIn").removeClass("hide");
@@ -98,7 +104,7 @@ var Admin = {
{
Crypt.init();
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()) !== ""){
socket.emit("password", [Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), chan.toLowerCase()]);
Admin.beginning = false;
}
@@ -148,7 +154,7 @@ var Admin = {
$(".playlist-tabs").removeClass("hide");
}
if($(".card-action").length != 0 &&
if($(".card-action").length !== 0 &&
!Helper.contains($(".card-action").attr("class").split(" "), "hide")){
$(".card-action").addClass("hide");
}
@@ -174,13 +180,13 @@ var Admin = {
set_conf: function(conf_array)
{
music = conf_array["allvideos"];
longsongs = conf_array["longsongs"];
music = conf_array.allvideos;
longsongs = conf_array.longsongs;
names = ["vote","addsongs","longsongs","frontpage", "allvideos",
"removeplay", "skip", "shuffle"];
if(conf_array['adminpass'] == "" || !w_p){
if(conf_array.adminpass === "" || !w_p){
hasadmin = false;
if(!Helper.mobilecheck()){
//$(".playlist-tabs").removeClass("hide");
@@ -196,7 +202,7 @@ var Admin = {
}
if((hasadmin)){
if($(".mdi-action-lock").length == 0) Admin.display_logged_out();
if($(".mdi-action-lock").length === 0) Admin.display_logged_out();
}else if(!hasadmin && Crypt.get_pass(chan.toLowerCase()) === undefined){
if(!Helper.contains($(".playlist-tabs").attr("class").split(" "), "hide")) {
$(".playlist-tabs-loggedIn").removeClass("hide");
@@ -241,4 +247,4 @@ var Admin = {
return [w_p, hasadmin];
}
}
};

View File

@@ -31,7 +31,6 @@ var List = {
insertAtIndex: function(song_info, transition) {
var i = List.getIndexOfSong(song_info.id);
if(!song_info.now_playing){
var add = List.generateSong(song_info, transition, false, true, false);
@@ -53,12 +52,19 @@ var List = {
populate_list: function(msg)
{
if(list_html == undefined) list_html = $("#list-song-html").html();
if(list_html === undefined) list_html = $("#list-song-html").html();
full_playlist = msg;
List.sortList();
$("#wrapper").empty();
if(localStorage.debug) {
console.log("---------------------------");
console.log("---------FULL PLAYLIST-----");
console.log(full_playlist);
console.log("---------------------------");
}
if(full_playlist.length > 1){
$.each(full_playlist, function(j, current_song){
if(!current_song.now_playing){ //check that the song isnt playing
@@ -147,12 +153,17 @@ var List = {
full_playlist[0].guids = [];
full_playlist[0].added = time;
full_playlist[length].now_playing = false;
if(localStorage.debug) {
console.log("---------------------------");
console.log("---SONG ON FIRST INDEX-----");
console.log(full_playlist[0]);
console.log("---------------------------");
}
try{
full_playlist.push(full_playlist.shift());
if(!List.empty)
$("#wrapper").children()[0].remove();
if($("#wrapper").children().length == 0) {
if($("#wrapper").children().length === 0) {
List.empty = true;
$("#wrapper").append("<span id='empty-channel-message'>The playlist is empty.</span>");
}

View File

@@ -1,4 +1,4 @@
var chan = window.chan == undefined ? $("#chan").html() : window.chan;
var chan = window.chan === undefined ? $("#chan").html() : window.chan;
var w_p = true;
var hasadmin = 0;
var showToggle = true;
@@ -6,8 +6,8 @@ var list_html = $("#list-song-html").html();
var blink_interval_exists = false;
var unseen = false;
var api_key = "***REMOVED***";
var searching = false
var time_regex = /P((([0-9]*\.?[0-9]*)Y)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)W)?(([0-9]*\.?[0-9]*)D)?)?(T(([0-9]*\.?[0-9]*)H)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)S)?)?/
var searching = false;
var time_regex = /P((([0-9]*\.?[0-9]*)Y)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)W)?(([0-9]*\.?[0-9]*)D)?)?(T(([0-9]*\.?[0-9]*)H)?(([0-9]*\.?[0-9]*)M)?(([0-9]*\.?[0-9]*)S)?)?/;
var conf = [];
var music = 0;
var frontpage = 1;
@@ -29,7 +29,7 @@ var chat_active = false;
var chat_unseen = false;
var blinking = false;
if(localStorage.debug == undefined){
if(localStorage.debug === undefined){
var debug = false;
localStorage.debug = debug;
}
@@ -67,7 +67,7 @@ if (navigator.serviceWorker) {
})
.catch(function (e) {
console.error(e);
})
});
} else {
console.log('Service Worker is not supported in this browser.');
}
@@ -78,18 +78,20 @@ $().ready(function(){
initfp();
}
setup_no_connection_listener();
git_info = $.ajax({ type: "GET",
url: "https://api.github.com/repos/zoff-music/zoff/commits",
async: false
}).responseText;
git_info = $.parseJSON(git_info);
$("#latest-commit").html("Latest Commit: <br>"
+ git_info[0].commit.author.date.substring(0,10)
+ ": " + git_info[0].committer.login
+ "<br><a href='"+git_info[0].html_url+"'>"
+ git_info[0].sha.substring(0,10) + "</a>: "
+ git_info[0].commit.message+"<br");
$("#latest-commit").html("Latest Commit: <br>" +
git_info[0].commit.author.date.substring(0,10) +
": " + git_info[0].committer.login +
"<br><a href='"+git_info[0].html_url+"'>" +
git_info[0].sha.substring(0,10) + "</a>: " +
git_info[0].commit.message+"<br");
});
@@ -103,14 +105,14 @@ function init(){
window.onpopstate = function(e){
onepage_load();
}
};
share_link_modifier_channel();
if(window.location.hostname == "zoff.no") add = "https://zoff.no";
else add = window.location.hostname;
if(Player != undefined) Player.stopInterval= false;
if(Player !== undefined) Player.stopInterval= false;
$('ul.playlist-tabs').tabs();
$('ul.playlist-tabs-loggedIn').tabs();
@@ -139,12 +141,12 @@ function init(){
minWidth: 350
});
if(socket == undefined || Helper.mobilecheck()){
if(socket === undefined || Helper.mobilecheck()){
no_socket = false;
socket = io.connect(''+add+':8880', connection_options);
}
if($("#alreadychannel").length == 0 || Helper.mobilecheck()){
if($("#alreadychannel").length === 0 || Helper.mobilecheck()){
setup_youtube_listener();
get_list_listener();
setup_suggested_listener();
@@ -162,7 +164,7 @@ function init(){
$(".video-container").removeClass("no-opacity");
var codeURL = "https://remote."+window.location.hostname+"/"+id;
$("#code-text").text(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);
@@ -176,7 +178,7 @@ function init(){
$("#channel-load").css("display", "none");
} else {
window.onYouTubeIframeAPIReady = Player.onYouTubeIframeAPIReady;
if(Player.ytplayer == "" || Player.ytplayer == undefined || Helper.mobilecheck()) Player.loadPlayer();
if(Player.ytplayer === "" || Player.ytplayer === undefined || Helper.mobilecheck()) Player.loadPlayer();
}
if(Helper.mobilecheck()) Mobile_remote.initiate_volume();
@@ -184,7 +186,7 @@ function init(){
setup_admin_listener();
setup_list_listener();
setup_chat_listener();
if(!Helper.mobilecheck() && $("#alreadychannel").length == 0) setup_host_initialization();
if(!Helper.mobilecheck() && $("#alreadychannel").length === 0) setup_host_initialization();
if(!Helper.msieversion()) Notification.requestPermission();
@@ -200,6 +202,16 @@ function init(){
}
function setup_no_connection_listener(){
socket.on('connect_failed', function(){
console.log('Connection Failed');
});
socket.on("connect_error", function(){
console.log("Connection failed.");
});
}
function setup_youtube_listener(){
socket.on("np", Player.youtube_listener);
}
@@ -213,7 +225,7 @@ function get_list_listener(){
function setup_suggested_listener(){
socket.on("suggested", function(params){
var single = true;
if(params.id == undefined)
if(params.id === undefined)
single = false;
Suggestions.catchUserSuggests(params, single);
});
@@ -287,7 +299,7 @@ $(document).keyup(function(e) {
$(document).on('click', '#cookieok', function() {
$(this).fadeOut(function(){
$(this).remove();
localStorage["ok_cookie"] = true;
localStorage.ok_cookie = true;
});
});
@@ -321,7 +333,7 @@ $(document).on('click', ".chan-link", function(e){
});
$(document).on("click", ".listen-button", function(e){
if($(".room-namer").val() == ""){
if($(".room-namer").val() === ""){
e.preventDefault();
Nochan.to_channel($(".room-namer").attr("placeholder"));
}
@@ -357,6 +369,10 @@ $("#clickme").click(function(){
$(document).on("submit", "#listImport", function(){
Search.importPlaylist(document.getElementById("import").value);
document.getElementById("import").value = "";
document.getElementById("import").disabled = true;
$("#import").addClass("hide");
$("#playlist_loader").removeClass("hide");
});
$(window).focus(function(){
@@ -618,7 +634,7 @@ $(document).on("click", "#bottom-button", function(){
function share_link_modifier_channel(){
$("#facebook-code-link").attr("href", "https://www.facebook.com/sharer/sharer.php?u=https://zoff.no/" + chan.toLowerCase());
$("#facebook-code-link").attr("onclick", "window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.no/" + chan.toLowerCase() + "', 'Share Playlist','width=600,height=300'); return false;");
$("#twitter-code-link").attr("href", "http://twitter.com/intent/tweet?url=https://zoff.no/" + chan.toLowerCase() + "&amp;text=Check%20out%20this%20playlist%20" + chan.toLowerCase() + "%20on%20Zöff!&amp;via=zoffmusic")
$("#twitter-code-link").attr("href", "http://twitter.com/intent/tweet?url=https://zoff.no/" + chan.toLowerCase() + "&amp;text=Check%20out%20this%20playlist%20" + chan.toLowerCase() + "%20on%20Zöff!&amp;via=zoffmusic");
$("#twitter-code-link").attr("onclick", "window.open('http://twitter.com/intent/tweet?url=https://zoff.no/" + chan.toLowerCase() + "/&amp;text=Check%20out%20this%20playlist%20" + chan.toLowerCase() + "%20on%20Zöff!&amp;via=zoffmusic','Share Playlist','width=600,height=300'); return false;");
$("#qr-code-link").attr("href", "//chart.googleapis.com/chart?chs=500x500&cht=qr&chl=https://zoff.no/" + chan.toLowerCase() + "&choe=UTF-8&chld=L%7C1");
$("#qr-code-image-link").attr("src", "//chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https://zoff.no/" + chan.toLowerCase() + "&choe=UTF-8&chld=L%7C1");
@@ -628,7 +644,7 @@ function onepage_load(){
var url_split = window.location.href.split("/");
if(url_split[3].substr(0,1) != "#!" && url_split[3] != "" && !(url_split.length == 5 && url_split[4].substr(0,1) == "#")){
if(url_split[3].substr(0,1) != "#!" && url_split[3] !== "" && !(url_split.length == 5 && url_split[4].substr(0,1) == "#")){
socket.emit("change_channel");
Admin.beginning = true;
@@ -637,7 +653,7 @@ function onepage_load(){
w_p = true;
socket.emit("list", chan.toLowerCase());
}else if(url_split[3] == ""){
}else if(url_split[3] === ""){
$("#channel-load").css("display", "block");
window.scrollTo(0, 0);
@@ -716,8 +732,8 @@ function onepage_load(){
initfp();
}
if($("#alreadychannel").length == 0){
$("head").append("<div id='alreadychannel'></div")
if($("#alreadychannel").length === 0){
$("head").append("<div id='alreadychannel'></div");
}
$("#channel-load").css("display", "none");

0
static/js/mobileremote.js Normal file → Executable file
View File

View File

@@ -53,7 +53,7 @@ var Nochan = {
if(!Helper.mobilecheck())
Nochan.add_backdrop(lists, 0);
for(x in lists)
for(var x in lists)
{
var chan = lists[x][3];
@@ -120,7 +120,7 @@ var Nochan = {
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
if (c.indexOf(name) === 0) return c.substring(name.length,c.length);
}
return "";
},
@@ -235,7 +235,7 @@ var Nochan = {
success: function(e){
if(Player.ytplayer != ""){
if(Player.ytplayer !== ""){
//Player.ytplayer.destroy();
socket.emit("change_channel", {channel: chan.toLowerCase()});
}
@@ -253,7 +253,7 @@ var Nochan = {
$("main").attr("class", "container center-align main");
$("body").attr("id", "channelpage");
$("header").html($($(e)[61]).html());
if($("#alreadychannel").length == 0 || Helper.mobilecheck() || Player.ytplayer == undefined){
if($("#alreadychannel").length === 0 || Helper.mobilecheck() || Player.ytplayer === undefined){
$("main").html($($(e)[65]).html());
} else {
var main = $($($($($(e)[65]).html())[0]).html());
@@ -274,21 +274,21 @@ var Nochan = {
fromFront = true;
init();
}
if($("#alreadyfp").length == 0) $("head").append("<div id='alreadyfp'></div>");
if($("#alreadyfp").length === 0) $("head").append("<div id='alreadyfp'></div>");
}
});
}
}
};
String.prototype.capitalizeFirstLetter = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
};
function share_link_modifier_frontpage(){
$("#facebook-code-link").attr("href", "https://www.facebook.com/sharer/sharer.php?u=https://zoff.no/");
$("#facebook-code-link").attr("onclick", "window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.no/', 'Share Zöff','width=600,height=300'); return false;");
$("#twitter-code-link").attr("href", "http://twitter.com/intent/tweet?url=https://zoff.no/&amp;text=Check%20out%20Zöff!&amp;via=zoffmusic")
$("#twitter-code-link").attr("href", "http://twitter.com/intent/tweet?url=https://zoff.no/&amp;text=Check%20out%20Zöff!&amp;via=zoffmusic");
$("#twitter-code-link").attr("onclick", "window.open('http://twitter.com/intent/tweet?url=https://zoff.no/&amp;text=Check%20out%20Zöff!&amp;via=zoffmusic','Share Playlist','width=600,height=300'); return false;");
$("#qr-code-link").attr("href", "//chart.googleapis.com/chart?chs=500x500&cht=qr&chl=https://zoff.no/&choe=UTF-8&chld=L%7C1");
$("#qr-code-image-link").attr("src", "//chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https://zoff.no/&choe=UTF-8&chld=L%7C1");
@@ -308,10 +308,10 @@ function initfp(){
window.onpopstate = function(e){
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) != "#"){
Nochan.to_channel(url_split[3], true);
}
}
};
channel_list = $("#channel-list-container").html();
@@ -324,11 +324,12 @@ function initfp(){
if(window.location.hostname == "zoff.no") add = "https://zoff.no";
else add = window.location.hostname;
if(socket == undefined || Helper.mobilecheck()) socket = io.connect(''+add+':8880', connection_options);
if($("#alreadyfp").length == 0 || Helper.mobilecheck()){
if(socket === undefined || Helper.mobilecheck()) socket = io.connect(''+add+':8880', connection_options);
if($("#alreadyfp").length === 0 || Helper.mobilecheck()){
setup_playlist_listener();
}
window.socket = socket;
socket.emit('frontpage_lists');
@@ -337,12 +338,12 @@ function initfp(){
if(window.location.hash == "#donation")
{
window.location.hash = "#";
$('#donation').openModal()
$('#donation').openModal();
}
//window.channel_list = channel_list;
if(!localStorage["ok_cookie"])
if(!localStorage.ok_cookie)
Materialize.toast("We're using cookies to enhance your experience! <a class='waves-effect waves-light btn light-green' href='#' id='cookieok' style='cursor:pointer;pointer-events:all;'> ok</a>", 10000);
var pad = 0;

View File

@@ -16,7 +16,7 @@ var Search = {
},
search: function(search_input){
if(result_html == undefined || empty_results_html == undefined) {
if(result_html === undefined || empty_results_html === undefined) {
result_html = $("#temp-results-container");
empty_results_html = $("#empty-results-container").html();
}
@@ -42,7 +42,7 @@ var Search = {
url: yt_url,
dataType:"jsonp",
success: function(response){
if(response.items.length == 0)
if(response.items.length === 0)
{
$("<div style='display:none;' id='mock-div'>"+empty_results_html+"</div>").appendTo($("#results")).show("blind", 83.33);
@@ -70,12 +70,12 @@ var Search = {
$.each(response.items, function(i,song)
{
var duration=song.contentDetails.duration;
secs=Search.durationToSeconds(duration)
secs=Search.durationToSeconds(duration);
if(!longsongs || secs<720){
title=song.snippet.title;
enc_title=title;//encodeURIComponent(title).replace(/'/g, "\\\'");
id=song.id;
duration = duration.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s")
duration = duration.replace("PT","").replace("H","h ").replace("M","m ").replace("S","s");
thumb=song.snippet.thumbnails.medium.url;
//$("#results").append(result_html);
@@ -100,7 +100,7 @@ var Search = {
$("<div style='display:none;' id='mock-div'>"+output+"</div>").appendTo($("#results")).show("blind", (response.items.length-1) * 83.33);
setTimeout(function(){$(".thumb").lazyload({container: $("#results")})}, 250);
setTimeout(function(){$(".thumb").lazyload({container: $("#results")});}, 250);
if(!Helper.contains($("#search_loader").attr("class").split(" "), "hide"))
$("#search_loader").addClass("hide");
@@ -124,7 +124,7 @@ var Search = {
},
submitAndClose: function(id,title,duration){
Search.submit(id,title, duration);
Search.submit(id,title, duration, false, 0, 1);
$("#results").html('');
Search.showSearch();
document.getElementById("search").value = "";
@@ -168,30 +168,37 @@ var Search = {
url: request_url,
dataType:"jsonp",
success: function(response){
var x = 0;
var to_add = [];
$.each(response.items, function(i,song)
{
var duration=Search.durationToSeconds(song.contentDetails.duration);
if(!longsongs || duration<720){
enc_title= song.snippet.title;//encodeURIComponent(song.snippet.title);
Search.submit(song.id, enc_title, duration, playlist);
//Search.submit(song.id, enc_title, duration, playlist, i);
x += 1;
to_add.push({id: song.id, enc_title: enc_title, duration: duration, playlist: playlist});
}
});
$.each(to_add, function(i, item){
Search.submit(item.id, item.enc_title, item.duration, item.playlist, i, x);
});
}
});
},
submit: function(id,title,duration, playlist){
socket.emit("add", {id: id, title: decodeURIComponent(title), adminpass: adminpass, list: chan.toLowerCase(), duration: duration, playlist: playlist});
submit: function(id,title,duration, playlist, num, full_num){
socket.emit("add", {id: id, title: decodeURIComponent(title), adminpass: adminpass, list: chan.toLowerCase(), duration: duration, playlist: playlist, num: num, total: full_num});
//[id, decodeURIComponent(title), adminpass, duration, playlist]);
},
durationToSeconds: function(duration) {
var matches = duration.match(time_regex);
hours= parseInt(matches[12])||0,
minutes= parseInt(matches[14])||0,
seconds= parseInt(matches[16])||0
hours= parseInt(matches[12])||0;
minutes= parseInt(matches[14])||0;
seconds= parseInt(matches[16])||0;
return hours*60*60+minutes*60+seconds;
}
}
};

0
static/offline/offline.html Normal file → Executable file
View File