mirror of
https://github.com/KevinMidboe/zoff.git
synced 2026-05-09 07:06:05 +00:00
2
server/public/assets/dist/embed.min.js
vendored
2
server/public/assets/dist/embed.min.js
vendored
File diff suppressed because one or more lines are too long
2
server/public/assets/dist/main.min.js
vendored
2
server/public/assets/dist/main.min.js
vendored
File diff suppressed because one or more lines are too long
2
server/public/assets/dist/remote.min.js
vendored
2
server/public/assets/dist/remote.min.js
vendored
@@ -1 +1 @@
|
||||
!function(){var e=!0;mobilecheck=function(){var e=!1;return function(t){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=!0)}(navigator.userAgent||navigator.vendor||window.opera),e},$(document).ready(function(){document.title="Zoff Remote",setTimeout(function(){$("#search").focus()},500);var e={"sync disconnect on unload":!0,secure:!0};$("#about").modal(),$("#contact").modal(),"remote.zoff.me"==window.location.hostname?add="https://zoff.me":add="localhost",socket=io.connect(add+":8080",e),socket.on("update_required",function(){window.location.reload(!0)}),id=window.location.pathname.split("/")[1],id&&(id=id.toLowerCase(),t.control());try{$.ajax({type:"GET",url:"https://api.github.com/users/zoff-music/received_events",success:function(e){$("#latest-commit").html("Latest Commit: <br>"+e[0].created_at.substring(0,10)+": "+e[0].actor.display_login+"<br><a href='https://github.com/"+e[0].repo.name+"/commit/"+e[0].payload.commits[0].sha+"' target='_blank'>"+e[0].payload.commits[0].sha.substring(0,10)+"</a>: "+e[0].payload.commits[0].message+"<br")}})}catch(e){}}),$(document).on("click","#playbutton",function(){socket.emit("id",{id:id,type:"play",value:"mock"})}),$(document).on("click","#pausebutton",function(){socket.emit("id",{id:id,type:"pause",value:"mock"})}),$(document).on("click","#skipbutton",function(){socket.emit("id",{id:id,type:"skip",value:"mock"})}),$(document).on("submit","#remoteform",function(e){e.preventDefault(),t.control()});var t={control:function(){e?(id||(id=document.getElementById("remoteform").chan.value,window.history.pushState("object or string","Title","/"+id)),document.getElementById("remoteform").chan.value="",e=!1,$(".rc").css("display","block"),$("#remote-text").text("Controlling "+id.toUpperCase()),document.getElementById("search").setAttribute("length","18"),document.getElementById("search").setAttribute("maxlength","18"),$("#forsearch").html("Type new channel name to change to"),$("#volume-control").slider({min:0,max:100,value:100,range:"min",animate:!0,stop:function(e,t){socket.emit("id",{id:id,type:"volume",value:t.value})}})):(socket.emit("id",{id:id,type:"channel",value:$("#search").val().toLowerCase()}),$("#search").val(""))}}}();
|
||||
!function(){var e=!0;mobilecheck=function(){var e=!1;return function(t){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=!0)}(navigator.userAgent||navigator.vendor||window.opera),e},$(document).ready(function(){document.title="Zoff Remote",setTimeout(function(){$("#search").focus()},500);var e={"sync disconnect on unload":!0,secure:!0};$("#about").modal(),$("#contact").modal(),"remote.zoff.me"==window.location.hostname?add="https://zoff.me":add="localhost",socket=io.connect(add+":8080",e),socket.on("update_required",function(){window.location.reload(!0)}),id=window.location.pathname.split("/")[1],id&&(id=id.toLowerCase(),t.control());try{$.ajax({type:"GET",url:"https://api.github.com/users/zoff-music/received_events",success:function(e){for(var t=0;t<e.length;t++)if("PushEvent"==e[t].type)return void $("#latest-commit").html("Latest Commit: <br>"+e[0].created_at.substring(0,10)+": "+e[0].actor.display_login+"<br><a href='https://github.com/"+e[0].repo.name+"/commit/"+e[0].payload.commits[0].sha+"' target='_blank'>"+e[0].payload.commits[0].sha.substring(0,10)+"</a>: "+e[0].payload.commits[0].message+"<br")}})}catch(e){Helper.log("Error with fetching GitHub commit info")}}),$(document).on("click","#playbutton",function(){socket.emit("id",{id:id,type:"play",value:"mock"})}),$(document).on("click","#pausebutton",function(){socket.emit("id",{id:id,type:"pause",value:"mock"})}),$(document).on("click","#skipbutton",function(){socket.emit("id",{id:id,type:"skip",value:"mock"})}),$(document).on("submit","#remoteform",function(e){e.preventDefault(),t.control()});var t={control:function(){e?(id||(id=document.getElementById("remoteform").chan.value,window.history.pushState("object or string","Title","/"+id)),document.getElementById("remoteform").chan.value="",e=!1,$(".rc").css("display","block"),$("#remote-text").text("Controlling "+id.toUpperCase()),document.getElementById("search").setAttribute("length","18"),document.getElementById("search").setAttribute("maxlength","18"),$("#forsearch").html("Type new channel name to change to"),$("#volume-control").slider({min:0,max:100,value:100,range:"min",animate:!0,stop:function(e,t){socket.emit("id",{id:id,type:"volume",value:t.value})}})):(socket.emit("id",{id:id,type:"channel",value:$("#search").val().toLowerCase()}),$("#search").val(""))}}}();
|
||||
@@ -18,6 +18,11 @@
|
||||
<script>
|
||||
function receiveMessage(event)
|
||||
{
|
||||
if(event.data == "parent") {
|
||||
//console.log(event);
|
||||
window.parentWindow = event.source;
|
||||
window.parentOrigin = event.origin;
|
||||
}
|
||||
if(event.data == "lower") {
|
||||
window.setVolume(10);
|
||||
}else if(event.data == "reset") {
|
||||
|
||||
@@ -16,6 +16,7 @@ var filesadded = "";
|
||||
var player_ready = false;
|
||||
var viewers = 1;
|
||||
var temp_user_pass = "";
|
||||
var chromecast_specs_sent = false;
|
||||
var dragging = false;
|
||||
var user_auth_started = false;
|
||||
var user_auth_avoid = false;
|
||||
@@ -59,6 +60,7 @@ var prev_chan_player = "";
|
||||
var chromecastReady = false;
|
||||
var found_array = [];
|
||||
var found_array_index = 0;
|
||||
var guid = "";
|
||||
var castSession;
|
||||
var width_timeout;
|
||||
var tap_target_timeout;
|
||||
@@ -125,6 +127,12 @@ $().ready(function(){
|
||||
initfp();
|
||||
}
|
||||
|
||||
if(Helper.mobilecheck()) {
|
||||
socket.on("guid", function(msg) {
|
||||
guid = msg;
|
||||
});
|
||||
}
|
||||
|
||||
socket.on("connect", function(){
|
||||
if(connect_error){
|
||||
connect_error = false;
|
||||
@@ -148,12 +156,17 @@ $().ready(function(){
|
||||
type: "GET",
|
||||
url: "https://api.github.com/users/zoff-music/received_events",
|
||||
success: function(git_info){
|
||||
$("#latest-commit").html("Latest Commit: <br>" +
|
||||
git_info[0].created_at.substring(0,10) +
|
||||
": " + git_info[0].actor.display_login +
|
||||
"<br><a href='https://github.com/"+git_info[0].repo.name+"/commit/" + git_info[0].payload.commits[0].sha + "' target='_blank'>" +
|
||||
git_info[0].payload.commits[0].sha.substring(0,10) + "</a>: " +
|
||||
git_info[0].payload.commits[0].message+"<br");
|
||||
for(var i = 0; i < git_info.length; i++) {
|
||||
if(git_info[i].type == "PushEvent") {
|
||||
$("#latest-commit").html("Latest Commit: <br>" +
|
||||
git_info[0].created_at.substring(0,10) +
|
||||
": " + git_info[0].actor.display_login +
|
||||
"<br><a href='https://github.com/"+git_info[0].repo.name+"/commit/" + git_info[0].payload.commits[0].sha + "' target='_blank'>" +
|
||||
git_info[0].payload.commits[0].sha.substring(0,10) + "</a>: " +
|
||||
git_info[0].payload.commits[0].message+"<br");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch(error){
|
||||
@@ -399,44 +412,50 @@ initializeCastApi = function() {
|
||||
Helper.log(event.sessionState);
|
||||
switch (event.sessionState) {
|
||||
case cast.framework.SessionState.SESSION_STARTED:
|
||||
castSession = cast.framework.CastContext.getInstance().getCurrentSession();
|
||||
castSession.addMessageListener("urn:x-cast:zoff.me", chromecastListener)
|
||||
chrome.cast.media.GenericMediaMetadata({title:song_title, image: 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg'});
|
||||
chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
||||
chromecastAvailable = true;
|
||||
paused = false;
|
||||
mobile_beginning = false;
|
||||
var _seekTo;
|
||||
try{
|
||||
_seekTo = Player.player.getCurrentTime();
|
||||
} catch(e){
|
||||
_seekTo = seekTo;
|
||||
}
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", videoId: video_id, seekTo: _seekTo})
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title})
|
||||
hide_native(1);
|
||||
break;
|
||||
castSession = cast.framework.CastContext.getInstance().getCurrentSession();
|
||||
castSession.addMessageListener("urn:x-cast:zoff.me", chromecastListener)
|
||||
chrome.cast.media.GenericMediaMetadata({title:song_title, image: 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg'});
|
||||
chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
||||
chromecastAvailable = true;
|
||||
paused = false;
|
||||
mobile_beginning = false;
|
||||
var _seekTo;
|
||||
try{
|
||||
_seekTo = Player.player.getCurrentTime();
|
||||
} catch(e){
|
||||
_seekTo = seekTo;
|
||||
}
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", videoId: video_id, seekTo: _seekTo})
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title})
|
||||
|
||||
if(Helper.mobilecheck() && !chromecast_specs_sent) {
|
||||
chromecast_specs_sent = true;
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "mobilespecs", guid: guid, socketid: socket.id, adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), channel: chan.toLowerCase(), userpass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))})
|
||||
}
|
||||
|
||||
hide_native(1);
|
||||
break;
|
||||
case cast.framework.SessionState.SESSION_RESUMED:
|
||||
castSession = cast.framework.CastContext.getInstance().getCurrentSession();
|
||||
castSession.addMessageListener("urn:x-cast:zoff.me", chromecastListener);
|
||||
chrome.cast.media.GenericMediaMetadata({title:song_title, image: 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg'});
|
||||
chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
||||
chromecastAvailable = true;
|
||||
paused = false;
|
||||
mobile_beginning = false;
|
||||
var _seekTo;
|
||||
try{
|
||||
_seekTo = Player.player.getCurrentTime();
|
||||
} catch(e){
|
||||
_seekTo = seekTo;
|
||||
}
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", videoId: video_id, seekTo: _seekTo})
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title})
|
||||
hide_native(1);
|
||||
break;
|
||||
castSession = cast.framework.CastContext.getInstance().getCurrentSession();
|
||||
castSession.addMessageListener("urn:x-cast:zoff.me", chromecastListener);
|
||||
chrome.cast.media.GenericMediaMetadata({title:song_title, image: 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg'});
|
||||
chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
||||
chromecastAvailable = true;
|
||||
paused = false;
|
||||
mobile_beginning = false;
|
||||
var _seekTo;
|
||||
try{
|
||||
_seekTo = Player.player.getCurrentTime();
|
||||
} catch(e){
|
||||
_seekTo = seekTo;
|
||||
}
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", videoId: video_id, seekTo: _seekTo})
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title})
|
||||
hide_native(1);
|
||||
break;
|
||||
case cast.framework.SessionState.SESSION_ENDED:
|
||||
chromecastAvailable = false;
|
||||
hide_native(0);
|
||||
chromecastAvailable = false;
|
||||
hide_native(0);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -77,6 +77,12 @@ var Player = {
|
||||
song_title = obj.np[0].title;
|
||||
duration = obj.np[0].duration;
|
||||
|
||||
if(embed) {
|
||||
if(window.parentWindow && window.parentOrigin) {
|
||||
window.parentWindow.postMessage({type: "np", title: obj.np[0].title}, window.parentOrigin);
|
||||
}
|
||||
}
|
||||
|
||||
if(mobile_beginning && Helper.mobilecheck() && seekTo === 0 && !chromecastAvailable) {
|
||||
seekTo = 1;
|
||||
}
|
||||
@@ -411,7 +417,7 @@ var Player = {
|
||||
|
||||
notifyUser: function(id, title) {
|
||||
title = title.replace(/\\\'/g, "'").replace(/"/g,"'").replace(/&/g,"&");
|
||||
if (Notification.permission === "granted" && document.hidden) {
|
||||
if (Notification.permission === "granted" && document.hidden && !embed) {
|
||||
var notification = new Notification("Now Playing", {body: title, icon: "https://i.ytimg.com/vi/"+id+"/mqdefault.jpg", iconUrl: "http://i.ytimg.com/vi/"+id+"/mqdefault.jpg"});
|
||||
notification.onclick = function(x) { window.focus(); this.cancel(); };
|
||||
setTimeout(function(){
|
||||
|
||||
@@ -35,15 +35,22 @@ $(document).ready(function (){
|
||||
type: "GET",
|
||||
url: "https://api.github.com/users/zoff-music/received_events",
|
||||
success: function(git_info){
|
||||
$("#latest-commit").html("Latest Commit: <br>" +
|
||||
git_info[0].created_at.substring(0,10) +
|
||||
": " + git_info[0].actor.display_login +
|
||||
"<br><a href='https://github.com/"+git_info[0].repo.name+"/commit/" + git_info[0].payload.commits[0].sha + "' target='_blank'>" +
|
||||
git_info[0].payload.commits[0].sha.substring(0,10) + "</a>: " +
|
||||
git_info[0].payload.commits[0].message+"<br");
|
||||
for(var i = 0; i < git_info.length; i++) {
|
||||
if(git_info[i].type == "PushEvent") {
|
||||
$("#latest-commit").html("Latest Commit: <br>" +
|
||||
git_info[0].created_at.substring(0,10) +
|
||||
": " + git_info[0].actor.display_login +
|
||||
"<br><a href='https://github.com/"+git_info[0].repo.name+"/commit/" + git_info[0].payload.commits[0].sha + "' target='_blank'>" +
|
||||
git_info[0].payload.commits[0].sha.substring(0,10) + "</a>: " +
|
||||
git_info[0].payload.commits[0].message+"<br");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch(e) {}
|
||||
} catch(error){
|
||||
Helper.log("Error with fetching GitHub commit info");
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("click", "#playbutton", function()
|
||||
|
||||
@@ -155,6 +155,24 @@ io.on('connection', function(socket){
|
||||
else
|
||||
name = names[guid];
|
||||
|
||||
socket.emit("guid", guid);
|
||||
|
||||
socket.on('chromecast', function(msg) {
|
||||
try {
|
||||
if(typeof(msg) == "object" && msg.hasOwnProperty("guid") && msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel")) {
|
||||
if(lists[msg.channel].indexOf(msg.guid) > -1) {
|
||||
guid = msg.guid;
|
||||
socketid = msg.socket_id;
|
||||
coll = msg.channel;
|
||||
in_list = true;
|
||||
socket.join(coll);
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("get_userlists", function(id) {
|
||||
db.collection("frontpage_lists_" + id).find(function(err, docs) {
|
||||
socket.emit("userlists", [docs]);
|
||||
@@ -605,6 +623,7 @@ io.on('connection', function(socket){
|
||||
io.to(coll).emit("channel", {type: "added", value: {"_id": "asd", "added":added,"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration}});
|
||||
}
|
||||
db.collection("frontpage_lists").update({_id:coll}, {$inc:{count:1}, $set:{accessed: get_time()}}, {upsert:true}, function(err, docs){});
|
||||
getNextSong(coll);
|
||||
});
|
||||
if(!full_list) {
|
||||
socket.emit("toast", "addedsong");
|
||||
@@ -1031,6 +1050,7 @@ io.on('connection', function(socket){
|
||||
if(!docs){
|
||||
send_list(coll, undefined, false, true, false, true);
|
||||
socket.emit("toast", "shuffled");
|
||||
|
||||
return;
|
||||
}else{
|
||||
num = Math.floor(Math.random()*1000000);
|
||||
@@ -1048,6 +1068,7 @@ io.on('connection', function(socket){
|
||||
if(tot == curr)
|
||||
{
|
||||
send_list(coll, undefined, false, true, false);
|
||||
getNextSong(coll);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1310,6 +1331,8 @@ function vote(coll, id, guid, socket, full_list, last) {
|
||||
if((full_list && last) || (!full_list))
|
||||
socket.emit("toast", "voted");
|
||||
io.to(coll).emit("channel", {type: "vote", value: id, time: get_time()});
|
||||
|
||||
getNextSong(coll);
|
||||
});
|
||||
}else
|
||||
{
|
||||
@@ -1318,6 +1341,32 @@ function vote(coll, id, guid, socket, full_list, last) {
|
||||
});
|
||||
}
|
||||
|
||||
function getNextSong(coll) {
|
||||
db.collection(coll).aggregate([{
|
||||
$match:{
|
||||
views:{
|
||||
$exists: false
|
||||
},
|
||||
type:{
|
||||
$ne: "suggested"
|
||||
}
|
||||
}
|
||||
}, {
|
||||
$sort:{
|
||||
now_playing: 1,
|
||||
votes:-1,
|
||||
added:1,
|
||||
title: 1
|
||||
}
|
||||
}, {
|
||||
$limit:1
|
||||
}], function(err, doc) {
|
||||
if(doc.length == 1) {
|
||||
io.to(coll).emit("next_song", {videoId: doc[0].id, title: doc[0].title});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function change_song(coll, error, id) {
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||
@@ -1565,9 +1614,10 @@ function send_play(coll, socket)
|
||||
if(conf[0].hasOwnProperty("userpass") && conf[0].userpass != "") conf[0].userpass = true;
|
||||
else conf[0].userpass = false;
|
||||
toSend = {np: np, conf: conf, time: get_time()};
|
||||
if(socket === undefined)
|
||||
io.to(coll).emit("np", toSend);
|
||||
else{
|
||||
if(socket === undefined) {
|
||||
io.to(coll).emit("np", toSend);
|
||||
getNextSong(coll)
|
||||
} else {
|
||||
socket.emit("np", toSend);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user