mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Only missing del, shuffle and remove after play
This commit is contained in:
39
js/admin.js
39
js/admin.js
@@ -1,6 +1,23 @@
|
||||
var adminTogg = false;
|
||||
var pass_corr = "";
|
||||
|
||||
socket.on("success_settings", function()
|
||||
{
|
||||
pass_corr = "correct";
|
||||
document.getElementById("sBar").innerHTML = "Successfully applied settings.";
|
||||
$("#sBar").addClass("opacityFull");
|
||||
document.getElementById("passbox").value = "";
|
||||
remove_bar();
|
||||
});
|
||||
|
||||
socket.on("error_settings", function(msg){
|
||||
pass_corr = "wrong";
|
||||
document.getElementById("eBar").innerHTML = "Error: " + msg;
|
||||
$("#eBar").addClass("opacityFull");
|
||||
document.getElementById("passbox").value = "";
|
||||
remove_bar();
|
||||
});
|
||||
|
||||
function admin()
|
||||
{
|
||||
adminTogg = !adminTogg;
|
||||
@@ -39,8 +56,8 @@ function submitAdmin(form)
|
||||
|
||||
configs = [voting, addsongs, longsongs, frontpage, allvideos, removeplay, adminpass, skipping, shuffling];
|
||||
|
||||
socket.emit("config", configs);
|
||||
|
||||
socket.emit("conf", configs);
|
||||
/*
|
||||
confRes = $.ajax({
|
||||
type: "POST",
|
||||
url: "php/change.php",
|
||||
@@ -52,7 +69,7 @@ function submitAdmin(form)
|
||||
console.log("configurations response: "+response);
|
||||
}
|
||||
}).responseText;
|
||||
|
||||
|
||||
pass_corr = confRes;
|
||||
|
||||
if(pass_corr=="correct"){
|
||||
@@ -60,14 +77,24 @@ function submitAdmin(form)
|
||||
document.getElementById("sBar").innerHTML = "Successfully applied settings.";
|
||||
$("#sBar").addClass("opacityFull");
|
||||
document.getElementById("passbox").value = "";
|
||||
}else{
|
||||
}else{
|
||||
document.getElementById("eBar").innerHTML = "Error: Wrong Admin Password!";
|
||||
$("#eBar").addClass("opacityFull");
|
||||
document.getElementById("passbox").value = "";/*$("#adminPanel").addClass("fadeerror");*/
|
||||
document.getElementById("passbox").value = "";/*$("#adminPanel").addClass("fadeerror");
|
||||
}
|
||||
|
||||
console.log(pass_corr);
|
||||
updateList();
|
||||
setTimeout(function(){
|
||||
$("#adminPanel").removeClass("success");
|
||||
$("#adminPanel").removeClass("fadeerror");
|
||||
$("#eBar").removeClass("opacityFull");
|
||||
$("#sBar").removeClass("opacityFull");
|
||||
},1500);*/
|
||||
}
|
||||
|
||||
function remove_bar()
|
||||
{
|
||||
setTimeout(function(){
|
||||
$("#adminPanel").removeClass("success");
|
||||
$("#adminPanel").removeClass("fadeerror");
|
||||
@@ -79,6 +106,7 @@ function submitAdmin(form)
|
||||
function shuffle(form)
|
||||
{
|
||||
console.log(adminpass);
|
||||
/*
|
||||
confRes = $.ajax({
|
||||
type: "GET",
|
||||
url: "php/change.php",
|
||||
@@ -107,4 +135,5 @@ function shuffle(form)
|
||||
$("#eBar").removeClass("opacityFull");
|
||||
$("#sBar").removeClass("opacityFull");
|
||||
},1500);
|
||||
*/
|
||||
}
|
||||
|
||||
139
js/list.js
139
js/list.js
@@ -19,6 +19,15 @@ socket.on(chan.toLowerCase(), function(msg){
|
||||
populate_list(msg);
|
||||
});
|
||||
|
||||
socket.on("skipping", function(obj)
|
||||
{
|
||||
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);
|
||||
});
|
||||
|
||||
function populate_list(msg)
|
||||
{
|
||||
console.log(msg);
|
||||
@@ -35,16 +44,20 @@ function populate_list(msg)
|
||||
if(listeID.hasOwnProperty('startTime'))
|
||||
{
|
||||
console.log("startTime");
|
||||
if(listeID.hasOwnProperty("addsongs") && listeID.addsongs) adminadd = 1;
|
||||
else adminadd = 0;
|
||||
if(listeID.hasOwnProperty("allvideos") && listeID.allvideos) music = 1;
|
||||
else music = 0;
|
||||
if(listeID.hasOwnProperty("longsongs") && listeID.longsongs) longS = 1;
|
||||
else longS = 0;
|
||||
if(listeID.hasOwnProperty("vote") && listeID.vote) adminvote = 1;
|
||||
else adminvote = 0;
|
||||
if(listeID.hasOwnProperty("adminpass") && listeID.adminpass !== '') hasadmin = 1;
|
||||
else hasadmin = 0;
|
||||
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){
|
||||
var video_title=listeID.title.replace(/\\\'/g, "'").replace(/"/g,"'").replace(/&/g,"&");
|
||||
var video_id = listeID.id;
|
||||
@@ -99,100 +112,17 @@ function populate_list(msg)
|
||||
}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");
|
||||
}
|
||||
$("#settings").css("visibility", "visible");
|
||||
$("#settings").css("opacity", "0.7");
|
||||
$("#wrapper").css("opacity", "1");
|
||||
}
|
||||
|
||||
function updateList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function vote(id, vote){
|
||||
socket.emit('vote', [chan, id, vote, guid]);
|
||||
|
||||
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(){
|
||||
socket.emit('skip', [chan, guid]);
|
||||
/*
|
||||
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);
|
||||
*/
|
||||
}
|
||||
|
||||
function show(){
|
||||
@@ -213,24 +143,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;
|
||||
}
|
||||
24
js/search.js
24
js/search.js
@@ -5,18 +5,18 @@ var timer = 0;
|
||||
$(document).ready(function()
|
||||
{
|
||||
$( "#results" ).hover( function() { $("div.result").removeClass("hoverResults"); i = 0; }, function() { });
|
||||
|
||||
|
||||
|
||||
$("#search").focus();
|
||||
|
||||
$('#base').bind("keyup keypress", function(e) {
|
||||
var code = e.keyCode || e.which;
|
||||
if (code == 13) {
|
||||
var code = e.keyCode || e.which;
|
||||
if (code == 13) {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$(".search_input").focus();
|
||||
$(".search_input").keyup(function(event) {
|
||||
var search_input = $(this).val();
|
||||
@@ -27,7 +27,7 @@ $(document).ready(function()
|
||||
{
|
||||
peis = true;
|
||||
loadjsfile("js/jazzscript.js");
|
||||
|
||||
|
||||
}else
|
||||
{
|
||||
peis = false;
|
||||
@@ -74,7 +74,7 @@ $(document).ready(function()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
setInterval(function(){
|
||||
@@ -85,7 +85,7 @@ $(document).ready(function()
|
||||
}, 1);
|
||||
});
|
||||
|
||||
$(document).keyup(function(e) {
|
||||
$(document).keyup(function(e) {
|
||||
if ($("div.result").length > 2){
|
||||
if (e.keyCode == 40) {
|
||||
if(i < $("div.result").length -2)
|
||||
@@ -115,13 +115,13 @@ $(document).keyup(function(e) {
|
||||
|
||||
|
||||
function search(search_input){
|
||||
|
||||
|
||||
|
||||
$("#results").html('');
|
||||
if(search_input !== ""){
|
||||
var keyword= encodeURIComponent(search_input);
|
||||
|
||||
var yt_url='http://gdata.youtube.com/feeds/api/videos?q='+keyword+'&format=5&orderby=relevance&max-results=6&v=2&alt=jsonc';
|
||||
var yt_url='http://gdata.youtube.com/feeds/api/videos?q='+keyword+'&format=5&orderby=relevance&max-results=6&v=2&alt=jsonc';
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
@@ -163,7 +163,7 @@ function search(search_input){
|
||||
}
|
||||
|
||||
$("<div id='r' style='display:none;'>"+wrapper+"</div>").appendTo('#results').slideDown('slow');
|
||||
|
||||
|
||||
}
|
||||
else{ $("#video").html("<div id='no'>No Video</div>");}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ function submitAndClose(id,title){
|
||||
|
||||
function submit(id,title,type){
|
||||
|
||||
socket.emit("add", [id, title]);
|
||||
socket.emit("add", [id, title, adminpass]);
|
||||
/*
|
||||
serverAns = $.ajax({
|
||||
type: "GET",
|
||||
@@ -229,7 +229,7 @@ function submit(id,title,type){
|
||||
document.getElementById("sBar").innerHTML = "Successfully added song!";
|
||||
$("#sBar").addClass("opacityFull");
|
||||
}
|
||||
|
||||
|
||||
$("#search").focus();
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
@@ -11,7 +11,7 @@ var beginning;
|
||||
var diffVideo;
|
||||
var serverTime;
|
||||
var url;
|
||||
var response;
|
||||
var response;
|
||||
var url;
|
||||
var tag;
|
||||
var firstScriptTag;
|
||||
@@ -37,6 +37,10 @@ var chan = $("#chan").html();
|
||||
var player_ready = false;
|
||||
var seekTo;
|
||||
var arr = []
|
||||
var song_title;
|
||||
var viewers = 1;
|
||||
var paused = false;
|
||||
var playing = false;
|
||||
|
||||
socket.on(chan.toLowerCase()+",np", function(obj)
|
||||
{
|
||||
@@ -46,15 +50,26 @@ socket.on(chan.toLowerCase()+",np", function(obj)
|
||||
conf = obj[1][0];
|
||||
time = obj[2];
|
||||
seekTo = time - conf["startTime"];
|
||||
getTitle(obj[0][0]["title"], 1);
|
||||
song_title = obj[0][0]["title"];
|
||||
getTitle(song_title, viewers);
|
||||
console.log(seekTo);
|
||||
if(player_ready)
|
||||
{
|
||||
ytplayer.loadVideoById(video_id);
|
||||
ytplayer.playVideo();
|
||||
if(!playing){
|
||||
ytplayer.loadVideoById(video_id);
|
||||
ytplayer.playVideo();
|
||||
}
|
||||
ytplayer.seekTo(seekTo);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on(chan.toLowerCase()+",viewers", function(view)
|
||||
{
|
||||
viewers = view;
|
||||
if(song_title !== undefined)
|
||||
getTitle(song_title, viewers);
|
||||
});
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
window.mobilecheck = function() {
|
||||
@@ -129,17 +144,31 @@ function onPlayerStateChange(newState) {
|
||||
break;
|
||||
case 0:
|
||||
socket.emit("end", video_id);
|
||||
playing = false;
|
||||
console.log("ended");
|
||||
break;
|
||||
case 1:
|
||||
console.log("playing");
|
||||
$("#playpause").toggleClass("play");
|
||||
$("#playpause").toggleClass("pause");
|
||||
playing = true;
|
||||
if(document.getElementById("playpause").className == "play")
|
||||
{
|
||||
$("#playpause").toggleClass("play");
|
||||
$("#playpause").toggleClass("pause");
|
||||
}
|
||||
if(paused)
|
||||
{
|
||||
socket.emit('pos');
|
||||
paused = false;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
console.log("paused");
|
||||
$("#playpause").toggleClass("play");
|
||||
$("#playpause").toggleClass("pause");
|
||||
paused = true;
|
||||
if(document.getElementById("playpause").className == "pause")
|
||||
{
|
||||
$("#playpause").toggleClass("play");
|
||||
$("#playpause").toggleClass("pause");
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
console.log("buffering");
|
||||
@@ -147,46 +176,30 @@ function onPlayerStateChange(newState) {
|
||||
}
|
||||
}
|
||||
|
||||
function checkEnd()
|
||||
function getTitle(titt, v)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function startNextSong()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function getTime()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function getTitle(titt, viewers)
|
||||
{
|
||||
/*var outPutWord = viewers[5].length > 1 ? "viewers" : "viewer";*/
|
||||
var outPutWord = v > 1 ? "viewers" : "viewer";
|
||||
console.log(titt);
|
||||
var title= titt.replace(/\\\'/g, "'").replace(/"/g,"'").replace(/&/g,"&");
|
||||
document.title = title + " • Zöff";
|
||||
|
||||
if(!window.mobilecheck()){
|
||||
console.log("ikke mobil");
|
||||
document.getElementsByName('v')[0].placeholder = title + " • 1 ";
|
||||
document.getElementsByName('v')[0].placeholder = title + " • " + v + " " + outPutWord;
|
||||
}else
|
||||
{
|
||||
document.getElementById("mobileTitle").innerHTML = title;
|
||||
document.getElementsByName('v')[0].placeholder = "Search • 1 " + outPutWord;
|
||||
document.getElementsByName('v')[0].placeholder = "Search • 1 " + v + " " + outPutWord;
|
||||
//document.getElementById("viewers").innerHTML = viewers[5].length + " " + outPutWord;
|
||||
}
|
||||
}
|
||||
|
||||
function errorHandler(newState)
|
||||
function errorHandler(newState)
|
||||
{
|
||||
socket.emit("end", video_id);
|
||||
}
|
||||
function onPlayerReady(event) {
|
||||
function onPlayerReady(event) {
|
||||
player_ready = true;
|
||||
getTime();
|
||||
if(!window.mobilecheck())
|
||||
{
|
||||
$("#player").css("opacity", "1");
|
||||
@@ -236,4 +249,4 @@ function notifyUser(id, title) {
|
||||
notification.close();
|
||||
},5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user