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

@@ -124,7 +124,7 @@
</a> </a>
<a> <a>
You can control this Zöff instance from another device by going to <b>https://remote.zoff.no/</b> You can control this Zöff instance from another device by going to <b>https://remote.zoff.no/</b>
</a> </a>
</li> </li>
</ul> </ul>
@@ -146,9 +146,54 @@
<form action="#" id="listImport" onsubmit="return false;"> <form action="#" id="listImport" onsubmit="return false;">
<i class="mdi-av-playlist-add import-icon"></i> <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" /> <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> </form>
</div> </div>
</li> </li>
</ul> </ul>
</div> </div>
</li> </li>
@@ -190,7 +235,7 @@
</button> </button>
<i class="mdi-av-volume-up slider-vol"></i> <i class="mdi-av-volume-up slider-vol"></i>
<div class="" id="volume-control-remote" title="Volume"></div> <div class="" id="volume-control-remote" title="Volume"></div>
</li> </li>
</ul> </ul>
</div> </div>
</li> </li>

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

View File

@@ -143,7 +143,7 @@
#channel-load-move{ #channel-load-move{
background-color: #FFFFFF !important; background-color: #FFFFFF !important;
} }
.rounded{ .rounded{
border-radius: 4px; border-radius: 4px;
} }
@@ -153,11 +153,11 @@ body {
min-height: 100vh; min-height: 100vh;
flex-direction: column; flex-direction: column;
overflow-x: hidden; overflow-x: hidden;
-webkit-transition: background-color 1s; -webkit-transition: background-color 1s;
-moz-transition:background-color 1s; -moz-transition:background-color 1s;
-ms-transition:background-color 1s; -ms-transition:background-color 1s;
-o-transition:background-color 1s; -o-transition:background-color 1s;
transition:background-color 1s; transition:background-color 1s;
} }
.main, #main-row, .video-container, #playlist{ .main, #main-row, .video-container, #playlist{
@@ -479,12 +479,12 @@ hide mdi-action-visibility mdi-action-visibility-off
.mega h5{ .mega h5{
/*box-sizing: border-box; */ /*box-sizing: border-box; */
color: rgb(255, 255, 255); cursor: default; display: inline; color: rgb(255, 255, 255); cursor: default; display: inline;
/*font-family: futura-pt, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; */ /*font-family: futura-pt, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; */
font-size: 50px; font-size: 50px;
font-weight: 100; font-weight: 100;
height: auto; height: auto;
line-height: 90.069229px; text-align: center; line-height: 90.069229px; text-align: center;
text-shadow: rgba(18, 18, 18, 0.76) 0px 1px 4px; width: auto; text-shadow: rgba(18, 18, 18, 0.76) 0px 1px 4px; width: auto;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
@@ -505,16 +505,16 @@ hide mdi-action-visibility mdi-action-visibility-off
} }
.mega .prething{ .mega .prething{
box-sizing: border-box; box-sizing: border-box;
/*color: rgb(155, 155, 155);*/ /*color: rgb(155, 155, 155);*/
cursor: text; display: block; cursor: text; display: block;
text-shadow: rgba(18, 18, 18, 0.76) 0px 1px 4px; text-shadow: rgba(18, 18, 18, 0.76) 0px 1px 4px;
color: rgb(255, 255, 255); color: rgb(255, 255, 255);
/*font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; */ /*font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; */
font-size: 17px; font-size: 17px;
/*font-weight: 200; */ /*font-weight: 200; */
height: 24px; line-height: 26px; margin-bottom: 8px; margin-left: 0px; margin-right: 8.5px; margin-top: 8px; height: 24px; line-height: 26px; margin-bottom: 8px; margin-left: 0px; margin-right: 8.5px; margin-top: 8px;
min-width: 56px; text-align: center; min-width: 56px; text-align: center;
width: 40px; width: 40px;
margin-right: -85px; margin-right: -85px;
} }
@@ -688,7 +688,7 @@ hide mdi-action-visibility mdi-action-visibility-off
.suggest_buttons button{ .suggest_buttons button{
padding-left:10px !important; padding-left:10px !important;
padding-right:10px !important; padding-right:10px !important;
margin-right: 20px; margin-right: 20px;
width:90px; width:90px;
} }
@@ -772,7 +772,7 @@ hide mdi-action-visibility mdi-action-visibility-off
} }
} }
@media screen and (-webkit-min-device-pixel-ratio:0) { @media screen and (-webkit-min-device-pixel-ratio:0) {
#wrapper { #wrapper {
padding-right:0vh !important; padding-right:0vh !important;
width:100% !important; width:100% !important;
@@ -869,6 +869,10 @@ ul #chat-log{
margin-top:15px; margin-top:15px;
} }
#playlist_loader {
padding: 10px 0px 0px 70px;
}
#search_loader:hover { #search_loader:hover {
background-color:rgba(0,0,0,0); background-color:rgba(0,0,0,0);
} }
@@ -1601,7 +1605,7 @@ nav ul li:hover, nav ul li.active {
} }
@media only screen and (min-width: 769px){ @media only screen and (min-width: 769px){
.navbar-fixed { .navbar-fixed {
height: 64px; height: 64px;

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) { switch(msg) {
case "addedsong": 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; break;
case "savedsettings": 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; break;
case "wrongpass": 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()); Crypt.remove_pass(chan.toLowerCase());
Admin.display_logged_out(); Admin.display_logged_out();
w_p = true; w_p = true;
break; break;
case "shuffled": 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; break;
case "deletesong": 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; break;
case "voted": 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; break;
case "alreadyvoted": 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; break;
case "skip": 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; break;
case "listhaspass": 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()); Crypt.remove_pass(chan.toLowerCase());
Admin.display_logged_out(); Admin.display_logged_out();
w_p = true; w_p = true;
break; break;
case "noskip": 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; break;
case "alreadyskip": 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; break;
case "notyetskip": case "notyetskip":
msg="Skipping is disabled the first 10 seconds."; msg="Skipping is disabled the first 10 seconds.";
@@ -67,10 +73,10 @@ var Admin = {
{ {
w_p = false; w_p = false;
adminpass = msg; adminpass = msg;
names = ["vote","addsongs","longsongs","frontpage", "allvideos", names = ["vote","addsongs","longsongs","frontpage", "allvideos",
"removeplay", "skip", "shuffle"]; "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++) { for (var i = 0; i < names.length; i++) {
$("input[name="+names[i]+"]").attr("disabled", false); $("input[name="+names[i]+"]").attr("disabled", false);
@@ -79,7 +85,7 @@ var Admin = {
$(".card-action").removeClass("hide"); $(".card-action").removeClass("hide");
$("#admin-lock").removeClass("mdi-action-lock"); $("#admin-lock").removeClass("mdi-action-lock");
$("#password").val(""); $("#password").val("");
$("#password").attr("placeholder", "Change channel password") $("#password").attr("placeholder", "Change channel password");
//if(!Helper.mobilecheck()){ //if(!Helper.mobilecheck()){
if(!Helper.contains($(".playlist-tabs").attr("class").split(" "), "hide")) { if(!Helper.contains($(".playlist-tabs").attr("class").split(" "), "hide")) {
$(".playlist-tabs-loggedIn").removeClass("hide"); $(".playlist-tabs-loggedIn").removeClass("hide");
@@ -98,7 +104,7 @@ var Admin = {
{ {
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()) !== ""){
socket.emit("password", [Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), chan.toLowerCase()]); socket.emit("password", [Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), chan.toLowerCase()]);
Admin.beginning = false; Admin.beginning = false;
} }
@@ -130,7 +136,7 @@ var Admin = {
{ {
w_p = true; w_p = true;
adminpass = ""; adminpass = "";
names = ["vote","addsongs","longsongs","frontpage", "allvideos", names = ["vote","addsongs","longsongs","frontpage", "allvideos",
"removeplay", "skip", "shuffle"]; "removeplay", "skip", "shuffle"];
document.getElementById("password").value = ""; document.getElementById("password").value = "";
@@ -148,7 +154,7 @@ var Admin = {
$(".playlist-tabs").removeClass("hide"); $(".playlist-tabs").removeClass("hide");
} }
if($(".card-action").length != 0 && if($(".card-action").length !== 0 &&
!Helper.contains($(".card-action").attr("class").split(" "), "hide")){ !Helper.contains($(".card-action").attr("class").split(" "), "hide")){
$(".card-action").addClass("hide"); $(".card-action").addClass("hide");
} }
@@ -174,13 +180,13 @@ var Admin = {
set_conf: function(conf_array) set_conf: function(conf_array)
{ {
music = conf_array["allvideos"]; music = conf_array.allvideos;
longsongs = conf_array["longsongs"]; longsongs = conf_array.longsongs;
names = ["vote","addsongs","longsongs","frontpage", "allvideos", names = ["vote","addsongs","longsongs","frontpage", "allvideos",
"removeplay", "skip", "shuffle"]; "removeplay", "skip", "shuffle"];
if(conf_array['adminpass'] == "" || !w_p){ if(conf_array.adminpass === "" || !w_p){
hasadmin = false; hasadmin = false;
if(!Helper.mobilecheck()){ if(!Helper.mobilecheck()){
//$(".playlist-tabs").removeClass("hide"); //$(".playlist-tabs").removeClass("hide");
@@ -188,15 +194,15 @@ var Admin = {
} }
} }
else hasadmin = true; else hasadmin = true;
for (var i = 0; i < names.length; i++) for (var i = 0; i < names.length; i++)
{ {
document.getElementsByName(names[i])[0].checked = (conf_array[names[i]] === true); document.getElementsByName(names[i])[0].checked = (conf_array[names[i]] === true);
$("input[name="+names[i]+"]").attr("disabled", hasadmin); $("input[name="+names[i]+"]").attr("disabled", hasadmin);
} }
if((hasadmin)){ 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){ }else if(!hasadmin && Crypt.get_pass(chan.toLowerCase()) === undefined){
if(!Helper.contains($(".playlist-tabs").attr("class").split(" "), "hide")) { if(!Helper.contains($(".playlist-tabs").attr("class").split(" "), "hide")) {
$(".playlist-tabs-loggedIn").removeClass("hide"); $(".playlist-tabs-loggedIn").removeClass("hide");
@@ -221,7 +227,7 @@ var Admin = {
removeplay = form.removeplay.checked; removeplay = form.removeplay.checked;
skipping = form.skip.checked; skipping = form.skip.checked;
shuffling = form.shuffle.checked; shuffling = form.shuffle.checked;
configs = [voting, addsongs, longsongs, frontpage, allvideos, configs = [voting, addsongs, longsongs, frontpage, allvideos,
removeplay, adminpass, skipping, shuffling]; removeplay, adminpass, skipping, shuffling];
socket.emit("conf", configs); socket.emit("conf", configs);
@@ -241,4 +247,4 @@ var Admin = {
return [w_p, hasadmin]; return [w_p, hasadmin];
} }
} };

View File

@@ -31,7 +31,6 @@ var List = {
insertAtIndex: function(song_info, transition) { insertAtIndex: function(song_info, transition) {
var i = List.getIndexOfSong(song_info.id); var i = List.getIndexOfSong(song_info.id);
if(!song_info.now_playing){ if(!song_info.now_playing){
var add = List.generateSong(song_info, transition, false, true, false); var add = List.generateSong(song_info, transition, false, true, false);
@@ -53,12 +52,19 @@ var List = {
populate_list: function(msg) 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; full_playlist = msg;
List.sortList(); List.sortList();
$("#wrapper").empty(); $("#wrapper").empty();
if(localStorage.debug) {
console.log("---------------------------");
console.log("---------FULL PLAYLIST-----");
console.log(full_playlist);
console.log("---------------------------");
}
if(full_playlist.length > 1){ if(full_playlist.length > 1){
$.each(full_playlist, function(j, current_song){ $.each(full_playlist, function(j, current_song){
if(!current_song.now_playing){ //check that the song isnt playing if(!current_song.now_playing){ //check that the song isnt playing
@@ -69,7 +75,7 @@ var List = {
if(lazy_load){ if(lazy_load){
if(Helper.mobilecheck()) $(".list-image").lazyload({}); if(Helper.mobilecheck()) $(".list-image").lazyload({});
else{ else{
$(".list-image").lazyload({container: $("#wrapper")}).removeClass("lazy"); $(".list-image").lazyload({container: $("#wrapper")}).removeClass("lazy");
document.getElementById('wrapper').scrollTop += 1; document.getElementById('wrapper').scrollTop += 1;
@@ -93,10 +99,10 @@ var List = {
$("#suggested-"+added.id).remove(); $("#suggested-"+added.id).remove();
if(List.empty){ if(List.empty){
List.empty = false; List.empty = false;
} }
$("#empty-channel-message").remove(); $("#empty-channel-message").remove();
List.insertAtIndex(added, true); List.insertAtIndex(added, true);
}, },
deleted_song: function(deleted){ deleted_song: function(deleted){
@@ -147,12 +153,17 @@ var List = {
full_playlist[0].guids = []; full_playlist[0].guids = [];
full_playlist[0].added = time; full_playlist[0].added = time;
full_playlist[length].now_playing = false; 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{ try{
full_playlist.push(full_playlist.shift()); full_playlist.push(full_playlist.shift());
if(!List.empty) if(!List.empty)
$("#wrapper").children()[0].remove(); $("#wrapper").children()[0].remove();
if($("#wrapper").children().length == 0) { if($("#wrapper").children().length === 0) {
List.empty = true; List.empty = true;
$("#wrapper").append("<span id='empty-channel-message'>The playlist is empty.</span>"); $("#wrapper").append("<span id='empty-channel-message'>The playlist is empty.</span>");
} }
@@ -245,7 +256,7 @@ var List = {
if(lazy){ if(lazy){
video_thumb = "//img.youtube.com/vi/"+video_id+"/mqdefault.jpg"; video_thumb = "//img.youtube.com/vi/"+video_id+"/mqdefault.jpg";
image_attr = "data-original"; image_attr = "data-original";
} }
if(list){ if(list){
song.find(".list-votes").text(video_votes); song.find(".list-votes").text(video_votes);
@@ -303,4 +314,4 @@ var List = {
scrollBottom: function(){ scrollBottom: function(){
$("#wrapper").scrollTop($("#wrapper")[0].scrollHeight); $("#wrapper").scrollTop($("#wrapper")[0].scrollHeight);
} }
} }

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 w_p = true;
var hasadmin = 0; var hasadmin = 0;
var showToggle = true; var showToggle = true;
@@ -6,8 +6,8 @@ var list_html = $("#list-song-html").html();
var blink_interval_exists = false; var blink_interval_exists = false;
var unseen = false; var unseen = false;
var api_key = "***REMOVED***"; var api_key = "***REMOVED***";
var searching = false 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 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 conf = [];
var music = 0; var music = 0;
var frontpage = 1; var frontpage = 1;
@@ -29,7 +29,7 @@ var chat_active = false;
var chat_unseen = false; var chat_unseen = false;
var blinking = false; var blinking = false;
if(localStorage.debug == undefined){ if(localStorage.debug === undefined){
var debug = false; var debug = false;
localStorage.debug = debug; localStorage.debug = debug;
} }
@@ -55,7 +55,7 @@ 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
}; };
var fromFront = false; var fromFront = false;
var fromChannel = false; var fromChannel = false;
@@ -67,7 +67,7 @@ if (navigator.serviceWorker) {
}) })
.catch(function (e) { .catch(function (e) {
console.error(e); console.error(e);
}) });
} else { } else {
console.log('Service Worker is not supported in this browser.'); console.log('Service Worker is not supported in this browser.');
} }
@@ -78,18 +78,20 @@ $().ready(function(){
initfp(); initfp();
} }
setup_no_connection_listener();
git_info = $.ajax({ type: "GET", git_info = $.ajax({ type: "GET",
url: "https://api.github.com/repos/zoff-music/zoff/commits", url: "https://api.github.com/repos/zoff-music/zoff/commits",
async: false async: false
}).responseText; }).responseText;
git_info = $.parseJSON(git_info); git_info = $.parseJSON(git_info);
$("#latest-commit").html("Latest Commit: <br>" $("#latest-commit").html("Latest Commit: <br>" +
+ git_info[0].commit.author.date.substring(0,10) git_info[0].commit.author.date.substring(0,10) +
+ ": " + git_info[0].committer.login ": " + git_info[0].committer.login +
+ "<br><a href='"+git_info[0].html_url+"'>" "<br><a href='"+git_info[0].html_url+"'>" +
+ 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");
}); });
@@ -103,14 +105,14 @@ function init(){
window.onpopstate = function(e){ window.onpopstate = function(e){
onepage_load(); onepage_load();
} };
share_link_modifier_channel(); share_link_modifier_channel();
if(window.location.hostname == "zoff.no") add = "https://zoff.no"; if(window.location.hostname == "zoff.no") add = "https://zoff.no";
else add = window.location.hostname; else add = window.location.hostname;
if(Player != undefined) Player.stopInterval= false; if(Player !== undefined) Player.stopInterval= false;
$('ul.playlist-tabs').tabs(); $('ul.playlist-tabs').tabs();
$('ul.playlist-tabs-loggedIn').tabs(); $('ul.playlist-tabs-loggedIn').tabs();
@@ -139,17 +141,17 @@ function init(){
minWidth: 350 minWidth: 350
}); });
if(socket == undefined || Helper.mobilecheck()){ if(socket === undefined || Helper.mobilecheck()){
no_socket = false; no_socket = false;
socket = io.connect(''+add+':8880', connection_options); socket = io.connect(''+add+':8880', connection_options);
} }
if($("#alreadychannel").length == 0 || Helper.mobilecheck()){ if($("#alreadychannel").length === 0 || Helper.mobilecheck()){
setup_youtube_listener(); setup_youtube_listener();
get_list_listener(); get_list_listener();
setup_suggested_listener(); setup_suggested_listener();
setup_viewers_listener(); setup_viewers_listener();
} else { } else {
$("#channel-load").css("display", "none"); $("#channel-load").css("display", "none");
$("#player").css("opacity", "1"); $("#player").css("opacity", "1");
@@ -162,7 +164,7 @@ function init(){
$(".video-container").removeClass("no-opacity"); $(".video-container").removeClass("no-opacity");
var codeURL = "https://remote."+window.location.hostname+"/"+id; 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-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); $("#code-link").attr("href", codeURL);
@@ -176,7 +178,7 @@ function init(){
$("#channel-load").css("display", "none"); $("#channel-load").css("display", "none");
} else { } else {
window.onYouTubeIframeAPIReady = Player.onYouTubeIframeAPIReady; 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(); if(Helper.mobilecheck()) Mobile_remote.initiate_volume();
@@ -184,20 +186,30 @@ function init(){
setup_admin_listener(); setup_admin_listener();
setup_list_listener(); setup_list_listener();
setup_chat_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(); if(!Helper.msieversion()) Notification.requestPermission();
$(".search_input").focus(); $(".search_input").focus();
Helper.sample(); Helper.sample();
$( "#results" ).hover( function() { $("div.result").removeClass("hoverResults"); i = 0; }, function(){ }); $( "#results" ).hover( function() { $("div.result").removeClass("hoverResults"); i = 0; }, function(){ });
$("#search").focus(); $("#search").focus();
$("#embed-button").css("display", "inline-block"); $("#embed-button").css("display", "inline-block");
$("#embed-area").val('<embed src="https://zoff.no/embed.html#' + chan.toLowerCase() + '&autplay" width="600px" height="300px">'); $("#embed-area").val('<embed src="https://zoff.no/embed.html#' + chan.toLowerCase() + '&autplay" width="600px" height="300px">');
$("#search").attr("placeholder", "Find song on YouTube..."); $("#search").attr("placeholder", "Find song on YouTube...");
}
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(){ function setup_youtube_listener(){
@@ -213,7 +225,7 @@ function get_list_listener(){
function setup_suggested_listener(){ function setup_suggested_listener(){
socket.on("suggested", function(params){ socket.on("suggested", function(params){
var single = true; var single = true;
if(params.id == undefined) if(params.id === undefined)
single = false; single = false;
Suggestions.catchUserSuggests(params, single); Suggestions.catchUserSuggests(params, single);
}); });
@@ -287,7 +299,7 @@ $(document).keyup(function(e) {
$(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;
}); });
}); });
@@ -321,7 +333,7 @@ $(document).on('click', ".chan-link", function(e){
}); });
$(document).on("click", ".listen-button", function(e){ $(document).on("click", ".listen-button", function(e){
if($(".room-namer").val() == ""){ if($(".room-namer").val() === ""){
e.preventDefault(); e.preventDefault();
Nochan.to_channel($(".room-namer").attr("placeholder")); Nochan.to_channel($(".room-namer").attr("placeholder"));
} }
@@ -357,6 +369,10 @@ $("#clickme").click(function(){
$(document).on("submit", "#listImport", function(){ $(document).on("submit", "#listImport", function(){
Search.importPlaylist(document.getElementById("import").value); 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(){ $(window).focus(function(){
@@ -521,7 +537,7 @@ $(document).on( "click", ".result-object", function(e){
var id = $(this).attr("data-video-id"); var id = $(this).attr("data-video-id");
var title = $(this).attr("data-video-title"); var title = $(this).attr("data-video-title");
var length = $(this).attr("data-video-length"); var length = $(this).attr("data-video-length");
Search.submitAndClose(id, title, length); Search.submitAndClose(id, title, length);
} }
}); });
@@ -573,7 +589,7 @@ $(document).on('click', '#toast-container', function(){
}); });
$(document).on("click", "#embed-area", function(){ $(document).on("click", "#embed-area", function(){
this.select(); this.select();
}); });
$(document).on("click", ".brand-logo-navigate", function(e){ $(document).on("click", ".brand-logo-navigate", function(e){
@@ -600,7 +616,7 @@ $(document).on("mousemove", "#playlist", function(e)
Helper.addClass("#bottom-button", "hide"); Helper.addClass("#bottom-button", "hide");
Helper.addClass("#top-button", "hide"); Helper.addClass("#top-button", "hide");
} }
}); });
$(document).on("mouseleave", "#playlist", function(){ $(document).on("mouseleave", "#playlist", function(){
Helper.addClass("#bottom-button", "hide"); Helper.addClass("#bottom-button", "hide");
@@ -618,7 +634,7 @@ $(document).on("click", "#bottom-button", function(){
function share_link_modifier_channel(){ 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("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;"); $("#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;"); $("#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-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"); $("#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("/"); 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"); socket.emit("change_channel");
Admin.beginning = true; Admin.beginning = true;
@@ -637,7 +653,7 @@ function onepage_load(){
w_p = true; w_p = true;
socket.emit("list", chan.toLowerCase()); socket.emit("list", chan.toLowerCase());
}else if(url_split[3] == ""){ }else if(url_split[3] === ""){
$("#channel-load").css("display", "block"); $("#channel-load").css("display", "block");
window.scrollTo(0, 0); window.scrollTo(0, 0);
@@ -668,13 +684,13 @@ function onepage_load(){
document.getElementById("volume-button").removeEventListener("click", Playercontrols.mute_video); document.getElementById("volume-button").removeEventListener("click", Playercontrols.mute_video);
document.getElementById("playpause").removeEventListener("click", Playercontrols.play_pause); document.getElementById("playpause").removeEventListener("click", Playercontrols.play_pause);
document.getElementById("fullscreen").removeEventListener("click", Playercontrols.fullscreen); document.getElementById("fullscreen").removeEventListener("click", Playercontrols.fullscreen);
if(Helper.mobilecheck()) { if(Helper.mobilecheck()) {
video_id = ""; video_id = "";
song_title = ""; song_title = "";
} }
$("meta[name=theme-color]").attr("content", "#2D2D2D"); $("meta[name=theme-color]").attr("content", "#2D2D2D");
if(!Helper.mobilecheck()){ if(!Helper.mobilecheck()){
$("main").append("<a id='closePlayer' title='Close Player'>X</a>"); $("main").append("<a id='closePlayer' title='Close Player'>X</a>");
@@ -716,12 +732,12 @@ function onepage_load(){
initfp(); initfp();
} }
if($("#alreadychannel").length == 0){ if($("#alreadychannel").length === 0){
$("head").append("<div id='alreadychannel'></div") $("head").append("<div id='alreadychannel'></div");
} }
$("#channel-load").css("display", "none"); $("#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()) if(!Helper.mobilecheck())
Nochan.add_backdrop(lists, 0); Nochan.add_backdrop(lists, 0);
for(x in lists) for(var x in lists)
{ {
var chan = lists[x][3]; var chan = lists[x][3];
@@ -67,12 +67,12 @@ var Nochan = {
//$("#channels").append(channel_list); //$("#channels").append(channel_list);
var card = pre_card; var card = pre_card;
if(lists[x][5] == 1) if(lists[x][5] == 1)
{ {
card.find(".pin").attr("style", "display:block;"); card.find(".pin").attr("style", "display:block;");
card.find(".card").attr("title", "Pinned!"); card.find(".card").attr("title", "Pinned!");
} }
else else
{ {
card.find(".pin").attr("style", "display:none;"); card.find(".pin").attr("style", "display:none;");
card.find(".card").attr("title", ""); card.find(".card").attr("title", "");
@@ -120,7 +120,7 @@ var Nochan = {
for(var i=0; i<ca.length; i++) { for(var i=0; i<ca.length; i++) {
var c = ca[i]; var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1); 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 ""; return "";
}, },
@@ -132,7 +132,7 @@ var Nochan = {
if(Nochan.blob_list[i] !== undefined){ if(Nochan.blob_list[i] !== undefined){
//$(".room-namer").css("opacity", 0); //$(".room-namer").css("opacity", 0);
setTimeout(function(){ setTimeout(function(){
if(frontpage){ if(frontpage){
$("#mega-background").css("background", "url(data:image/png;base64,"+Nochan.blob_list[i]+")"); $("#mega-background").css("background", "url(data:image/png;base64,"+Nochan.blob_list[i]+")");
$("#mega-background").css("background-size" , "200%"); $("#mega-background").css("background-size" , "200%");
@@ -140,7 +140,7 @@ var Nochan = {
$("#searchFrontpage").attr("placeholder", list[i][3]); $("#searchFrontpage").attr("placeholder", list[i][3]);
//$(".room-namer").css("opacity", 1); //$(".room-namer").css("opacity", 1);
} }
},500); },500);
} else { } else {
var img = new Image(); var img = new Image();
img.src = "/static/images/thumbnails/"+id+".jpg"; img.src = "/static/images/thumbnails/"+id+".jpg";
@@ -154,13 +154,13 @@ var Nochan = {
Nochan.blob_list.push(data); Nochan.blob_list.push(data);
//data will contain the vote count echoed by the controller i.e. //data will contain the vote count echoed by the controller i.e.
//$(".room-namer").css("opacity", 0); //$(".room-namer").css("opacity", 0);
setTimeout(function(){ setTimeout(function(){
$("#mega-background").css("background", "url(data:image/png;base64,"+data+")"); $("#mega-background").css("background", "url(data:image/png;base64,"+data+")");
$("#mega-background").css("background-size" , "200%"); $("#mega-background").css("background-size" , "200%");
$("#mega-background").css("opacity", 1); $("#mega-background").css("opacity", 1);
$("#searchFrontpage").attr("placeholder", list[i][3]); $("#searchFrontpage").attr("placeholder", list[i][3]);
//$(".room-namer").css("opacity", 1); //$(".room-namer").css("opacity", 1);
},500); },500);
//then append the result where ever you want like //then append the result where ever you want like
//$("span#votes_number").html(data); //data will be containing the vote count which you have echoed from the controller //$("span#votes_number").html(data); //data will be containing the vote count which you have echoed from the controller
@@ -173,7 +173,7 @@ var Nochan = {
$("#mega-background").css("opacity", 1); $("#mega-background").css("opacity", 1);
$("#searchFrontpage").attr("placeholder", list[i][3]); $("#searchFrontpage").attr("placeholder", list[i][3]);
}; };
} }
rotation_timeout = setTimeout(function(){ rotation_timeout = setTimeout(function(){
if(Nochan.times_rotated == 50 && frontpage){ if(Nochan.times_rotated == 50 && frontpage){
@@ -185,7 +185,7 @@ var Nochan = {
Nochan.add_backdrop(list, i+1); Nochan.add_backdrop(list, i+1);
} }
},6000); },6000);
}, },
start_snowfall: function(){ start_snowfall: function(){
@@ -229,13 +229,13 @@ var Nochan = {
frontpage = false; frontpage = false;
clearTimeout(rotation_timeout); clearTimeout(rotation_timeout);
if(Helper.mobilecheck()) socket.removeAllListeners(); if(Helper.mobilecheck()) socket.removeAllListeners();
$("body").css("background-color", "#2d2d2d"); $("body").css("background-color", "#2d2d2d");
$.ajax({ $.ajax({
url: new_channel + "/php/index.php", url: new_channel + "/php/index.php",
success: function(e){ success: function(e){
if(Player.ytplayer != ""){ if(Player.ytplayer !== ""){
//Player.ytplayer.destroy(); //Player.ytplayer.destroy();
socket.emit("change_channel", {channel: chan.toLowerCase()}); socket.emit("change_channel", {channel: chan.toLowerCase()});
} }
@@ -247,13 +247,13 @@ var Nochan = {
window.chan = new_channel; window.chan = new_channel;
} }
$(".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)[61]).html()); $("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()); $("main").html($($(e)[65]).html());
} else { } else {
var main = $($($($($(e)[65]).html())[0]).html()); var main = $($($($($(e)[65]).html())[0]).html());
@@ -274,21 +274,21 @@ var Nochan = {
fromFront = true; fromFront = true;
init(); 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() { String.prototype.capitalizeFirstLetter = function() {
return this.charAt(0).toUpperCase() + this.slice(1); return this.charAt(0).toUpperCase() + this.slice(1);
} };
function share_link_modifier_frontpage(){ 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("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;"); $("#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;"); $("#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-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"); $("#qr-code-image-link").attr("src", "//chart.googleapis.com/chart?chs=150x150&cht=qr&chl=https://zoff.no/&choe=UTF-8&chld=L%7C1");
@@ -303,15 +303,15 @@ function initfp(){
$(".mega").css("-moz-transform", "rotate(180deg)"); $(".mega").css("-moz-transform", "rotate(180deg)");
//Materialize.toast('<p id="aprilfools">We suck at pranks..<a class="waves-effect waves-light btn light-green" style="pointer-events:none;">Agreed</a></p>', 100000); //Materialize.toast('<p id="aprilfools">We suck at pranks..<a class="waves-effect waves-light btn light-green" style="pointer-events:none;">Agreed</a></p>', 100000);
} }
window.onpopstate = function(e){ window.onpopstate = function(e){
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) != "#"){
Nochan.to_channel(url_split[3], true); Nochan.to_channel(url_split[3], true);
} }
} };
channel_list = $("#channel-list-container").html(); channel_list = $("#channel-list-container").html();
@@ -319,16 +319,17 @@ function initfp(){
var connection_options = { var connection_options = {
'secure': true, 'secure': true,
'force new connection': true 'force new connection': true
}; };
if(window.location.hostname == "zoff.no") add = "https://zoff.no"; if(window.location.hostname == "zoff.no") add = "https://zoff.no";
else add = window.location.hostname; else add = window.location.hostname;
if(socket == undefined || Helper.mobilecheck()) socket = io.connect(''+add+':8880', connection_options); if(socket === undefined || Helper.mobilecheck()) socket = io.connect(''+add+':8880', connection_options);
if($("#alreadyfp").length == 0 || Helper.mobilecheck()){ if($("#alreadyfp").length === 0 || Helper.mobilecheck()){
setup_playlist_listener(); setup_playlist_listener();
} }
window.socket = socket;
socket.emit('frontpage_lists'); socket.emit('frontpage_lists');
@@ -337,12 +338,12 @@ function initfp(){
if(window.location.hash == "#donation") if(window.location.hash == "#donation")
{ {
window.location.hash = "#"; window.location.hash = "#";
$('#donation').openModal() $('#donation').openModal();
} }
//window.channel_list = channel_list; //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); 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; var pad = 0;

View File

@@ -16,7 +16,7 @@ var Search = {
}, },
search: function(search_input){ 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"); result_html = $("#temp-results-container");
empty_results_html = $("#empty-results-container").html(); empty_results_html = $("#empty-results-container").html();
} }
@@ -42,13 +42,13 @@ var Search = {
url: yt_url, url: yt_url,
dataType:"jsonp", dataType:"jsonp",
success: function(response){ 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); $("<div style='display:none;' id='mock-div'>"+empty_results_html+"</div>").appendTo($("#results")).show("blind", 83.33);
if(!Helper.contains($("#search_loader").attr("class").split(" "), "hide")) if(!Helper.contains($("#search_loader").attr("class").split(" "), "hide"))
$("#search_loader").addClass("hide"); $("#search_loader").addClass("hide");
}else if(response.items){ }else if(response.items){
//get list of IDs and make new request for video info //get list of IDs and make new request for video info
$.each(response.items, function(i,data) $.each(response.items, function(i,data)
@@ -70,12 +70,12 @@ var Search = {
$.each(response.items, function(i,song) $.each(response.items, function(i,song)
{ {
var duration=song.contentDetails.duration; var duration=song.contentDetails.duration;
secs=Search.durationToSeconds(duration) secs=Search.durationToSeconds(duration);
if(!longsongs || secs<720){ if(!longsongs || secs<720){
title=song.snippet.title; title=song.snippet.title;
enc_title=title;//encodeURIComponent(title).replace(/'/g, "\\\'"); enc_title=title;//encodeURIComponent(title).replace(/'/g, "\\\'");
id=song.id; 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; thumb=song.snippet.thumbnails.medium.url;
//$("#results").append(result_html); //$("#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); $("<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")) if(!Helper.contains($("#search_loader").attr("class").split(" "), "hide"))
$("#search_loader").addClass("hide"); $("#search_loader").addClass("hide");
@@ -124,7 +124,7 @@ var Search = {
}, },
submitAndClose: function(id,title,duration){ submitAndClose: function(id,title,duration){
Search.submit(id,title, duration); Search.submit(id,title, duration, false, 0, 1);
$("#results").html(''); $("#results").html('');
Search.showSearch(); Search.showSearch();
document.getElementById("search").value = ""; document.getElementById("search").value = "";
@@ -161,37 +161,44 @@ var Search = {
addVideos: function(ids, playlist){ addVideos: function(ids, playlist){
var request_url="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key=***REMOVED***&id="; var request_url="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key=***REMOVED***&id=";
request_url += ids; request_url += ids;
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: request_url, url: request_url,
dataType:"jsonp", dataType:"jsonp",
success: function(response){ success: function(response){
var x = 0;
var to_add = [];
$.each(response.items, function(i,song) $.each(response.items, function(i,song)
{ {
var duration=Search.durationToSeconds(song.contentDetails.duration); var duration=Search.durationToSeconds(song.contentDetails.duration);
if(!longsongs || duration<720){ if(!longsongs || duration<720){
enc_title= song.snippet.title;//encodeURIComponent(song.snippet.title); 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){ 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}); 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]); //[id, decodeURIComponent(title), adminpass, duration, playlist]);
}, },
durationToSeconds: function(duration) { durationToSeconds: function(duration) {
var matches = duration.match(time_regex); var matches = duration.match(time_regex);
hours= parseInt(matches[12])||0, hours= parseInt(matches[12])||0;
minutes= parseInt(matches[14])||0, minutes= parseInt(matches[14])||0;
seconds= parseInt(matches[16])||0 seconds= parseInt(matches[16])||0;
return hours*60*60+minutes*60+seconds; return hours*60*60+minutes*60+seconds;
} }
} };

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