mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
merge backed and material
This commit is contained in:
@@ -8,47 +8,70 @@ var chan = $("#chan").html();
|
||||
var list_html = $("#list-song-html").html();
|
||||
var hasadmin=0;
|
||||
|
||||
function updateList()
|
||||
socket.on(guid, function(msg){
|
||||
populate_list(msg);
|
||||
});
|
||||
|
||||
socket.on("abc", function(){
|
||||
alert("alert");
|
||||
});
|
||||
|
||||
socket.on(chan.toLowerCase(), function(msg){
|
||||
populate_list(msg);
|
||||
});
|
||||
|
||||
socket.on("skipping", function(obj)
|
||||
{
|
||||
console.log("updating list");
|
||||
list = $.ajax({ type: "GET",
|
||||
url: "php/change.php",
|
||||
async: false
|
||||
}).responseText;
|
||||
list = $.parseJSON(list);
|
||||
conf = list.conf;
|
||||
if(conf.hasOwnProperty("addsongs") && conf.addsongs == "true") adminadd = 1;
|
||||
else adminadd = 0;
|
||||
if(conf.hasOwnProperty("allvideos") && conf.allvideos == "true") music = 1;
|
||||
else music = 0;
|
||||
if(conf.hasOwnProperty("longsongs") && conf.longsongs == "true") longS = 1;
|
||||
else longS = 0;
|
||||
if(conf.hasOwnProperty("vote") && conf.vote == "true") adminvote = 1;
|
||||
else adminvote = 0;
|
||||
if(conf.hasOwnProperty("adminpass") && conf.adminpass !== '') hasadmin = 1;
|
||||
else hasadmin = 0;
|
||||
/*list[0].shift();
|
||||
list[3].shift();
|
||||
list[2].shift();*/
|
||||
document.getElementById("pBar").innerHTML = "Vote registrated! "+obj[0]+" of "+obj[1]+" has skipped. "+(Math.ceil(obj[1]/2))+" or more is needed!";
|
||||
$("#pBar").addClass("opacityFull");
|
||||
setTimeout(function(){
|
||||
$("#pBar").removeClass("opacityFull");
|
||||
},1500);
|
||||
});
|
||||
|
||||
setTimeout(function()
|
||||
function populate_list(msg)
|
||||
{
|
||||
console.log(msg);
|
||||
for(obj in msg)
|
||||
{
|
||||
console.log(msg[obj]);
|
||||
}
|
||||
|
||||
$("#wrapper").empty();
|
||||
$("#wrapper").empty();
|
||||
|
||||
$.each(list.songs, function(j, listeID){
|
||||
var video_title=listeID.title.replace(/\\\'/g, "'").replace(/"/g,"'").replace(/&/g,"&");
|
||||
var video_id = listeID.id;
|
||||
var video_thumb = "background-image:url('http://img.youtube.com/vi/"+video_id+"/mqdefault.jpg');";
|
||||
//var delsong = ""; if(pass_corr=="correct");
|
||||
var video_votes = listeID.votes;
|
||||
$("#wrapper").append(list_html);
|
||||
var song = $("#list-song");
|
||||
song.find(".list-title").text(video_title);
|
||||
song.find(".list-votes").text(video_votes);
|
||||
song.find(".votebg").attr("onclick", "vote('"+video_id+"','pos')");
|
||||
song.find(".list-image").attr("style",video_thumb);
|
||||
song.attr("id",video_id);
|
||||
$.each(msg, function(j, listeID){
|
||||
if(listeID.hasOwnProperty('startTime')) //check if its config part of list
|
||||
{
|
||||
console.log("startTime");
|
||||
console.log(listeID.addsongs);
|
||||
if(!adminTogg)
|
||||
{
|
||||
names=["vote","addsongs","longsongs","frontpage", "allvideos", "removeplay", "skip", "shuffle"];
|
||||
for (var i = 0; i < names.length; i++) {
|
||||
document.getElementsByName(names[i])[0].checked = (listeID[names[i]] === 'true');
|
||||
document.getElementsByName(names[i])[1].checked = (listeID[names[i]] === 'false');
|
||||
}
|
||||
|
||||
if(hasadmin)
|
||||
$("#setpass").text("Channel has admin");
|
||||
else
|
||||
$("#setpass").text("Channel has no admin");
|
||||
}
|
||||
}else if(!listeID.now_playing){ //check that the song isnt playing
|
||||
|
||||
var video_title=listeID.title.replace(/\\\'/g, "'").replace(/"/g,"'").replace(/&/g,"&");
|
||||
var video_id = listeID.id;
|
||||
var video_thumb = "background-image:url('http://img.youtube.com/vi/"+video_id+"/mqdefault.jpg');";
|
||||
//var delsong = ""; if(pass_corr=="correct");
|
||||
var video_votes = listeID.votes;
|
||||
$("#wrapper").append(list_html);
|
||||
var song = $("#list-song");
|
||||
song.find(".list-title").text(video_title);
|
||||
song.find(".list-votes").text(video_votes);
|
||||
song.find(".votebg").attr("onclick", "vote('"+video_id+"','pos')");
|
||||
song.find(".list-image").attr("style",video_thumb);
|
||||
song.attr("id",video_id);
|
||||
}
|
||||
});
|
||||
|
||||
if($("#playlist").height() != $("#player").height() || (peis && $("#playlist").height() != $("#jplayer").height()))
|
||||
@@ -84,89 +107,19 @@ function updateList()
|
||||
}else{
|
||||
myScroll.refresh();
|
||||
}
|
||||
if(!adminTogg)
|
||||
{
|
||||
names=["vote","addsongs","longsongs","frontpage", "allvideos", "removeplay", "skip", "shuffle"];
|
||||
for (var i = 0; i < names.length; i++) {
|
||||
document.getElementsByName(names[i])[0].checked = (conf[names[i]] === "true");
|
||||
document.getElementsByName(names[i])[1].checked = (conf[names[i]] === "false");
|
||||
}
|
||||
|
||||
if(hasadmin)
|
||||
$("#setpass").text("Channel has admin");
|
||||
else
|
||||
$("#setpass").text("Channel has no admin");
|
||||
}
|
||||
}, 2500);
|
||||
$("#settings").css("visibility", "visible");
|
||||
$("#settings").css("opacity", "0.7");
|
||||
$("#wrapper").css("opacity", "1");
|
||||
|
||||
}
|
||||
|
||||
function vote(id, vote){
|
||||
serverAns = ($.ajax({
|
||||
type: "GET",
|
||||
url: "php/change.php",
|
||||
async: false,
|
||||
data: "vote="+vote+"&id="+id+"&pass="+adminpass,
|
||||
success: function() {
|
||||
console.log("voted "+vote+" on "+id);
|
||||
/*if(vote=="pos"){ $("#playlist").addClass("success");}
|
||||
else{ $("#playlist").addClass("fadeerror");}
|
||||
updateList();*/
|
||||
},
|
||||
}).responseText);
|
||||
|
||||
if(serverAns == "wrong")
|
||||
{
|
||||
//alert("Wrong adminpassword!");
|
||||
$("#eBar").addClass("opacityFull");
|
||||
}else{
|
||||
if(vote=="pos" && serverAns != "many"){ $("."+id).addClass("success");}
|
||||
else{ $("."+id).addClass("fadeerror");}
|
||||
updateList();
|
||||
}
|
||||
|
||||
setTimeout(function(){
|
||||
$("."+id).removeClass("success");
|
||||
$("."+id).removeClass("fadeerror");
|
||||
$("#eBar").removeClass("opacityFull");
|
||||
},1500);
|
||||
socket.emit('vote', [chan, id, vote, guid, adminpass]);
|
||||
}
|
||||
|
||||
function skip(){
|
||||
voteRes = ($.ajax({
|
||||
type: "GET",
|
||||
url: "php/change.php",
|
||||
async: false,
|
||||
data: "skip",
|
||||
success: function() {
|
||||
console.log("voted to skip song");
|
||||
//$("#search").addClass("success");
|
||||
updateList();
|
||||
},
|
||||
}).responseText);
|
||||
|
||||
if(voteRes == "wrong!")
|
||||
{
|
||||
document.getElementById("eBar").innerHTML = "Error: Skipping disabled.";
|
||||
$("#eBar").addClass("opacityFull");
|
||||
}else{
|
||||
skipVotes = voteRes.split("/");
|
||||
if(skipVotes[0]>= skipVotes[1]/2)
|
||||
{
|
||||
document.getElementById("sBar").innerHTML = "Successfully skipped!";
|
||||
$("#sBar").addClass("opacityFull");
|
||||
}else
|
||||
{
|
||||
document.getElementById("pBar").innerHTML = "Vote registrated! "+skipVotes[0]+" of "+skipVotes[1]+" has skipped. "+(Math.ceil(skipVotes[1]/2))+" or more is needed!";
|
||||
$("#pBar").addClass("opacityFull");
|
||||
}
|
||||
}
|
||||
setTimeout(function(){
|
||||
$("#search").removeClass("success");
|
||||
$("#sBar").removeClass("opacityFull");
|
||||
$("#pBar").removeClass("opacityFull");
|
||||
$("#eBar").removeClass("opacityFull");
|
||||
},1500);
|
||||
|
||||
socket.emit('skip', [chan, guid]);
|
||||
}
|
||||
|
||||
function show(){
|
||||
@@ -187,24 +140,3 @@ function show(){
|
||||
fitToScreen();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function ks()
|
||||
{
|
||||
list = $.ajax({ type: "GET",
|
||||
url: "php/change.php",
|
||||
async: false
|
||||
}).responseText;
|
||||
list = $.parseJSON(list);
|
||||
myScroll.destroy();
|
||||
myScroll = null;
|
||||
$("#playlist").css({height: $("#player").height()});
|
||||
$("#playlist").css({overflow: "hidden"});
|
||||
myScroll = new IScroll('#playlist', {
|
||||
mouseWheel: true,
|
||||
scrollbars: false,
|
||||
scrollY: true,
|
||||
interactiveScrollbars: false
|
||||
});
|
||||
scroller = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user