Improved look of all messages being sent back and forth

This commit is contained in:
Kasper Rynning-Tønnesen
2016-09-02 21:45:19 +02:00
parent f3778ae260
commit d5acdb2161
11 changed files with 74 additions and 74 deletions

View File

@@ -9,7 +9,7 @@ To get the website to run as intended, please enabled mod_rewrite for apache2, a
### About
Zöff is a shared (free) YouTube based radio service, built upon the YouTube API.
Zöff is a shared (free) YouTube based radio service, built upon the YouTube API.
Zöff is mainly a webbased service. The website uses <a href="https://nodejs.org/">NodeJS</a> with <a href="http://socket.io/">Socket.IO</a>, <a href="https://www.mongodb.org/">MongoDB</a> and PHP on the backend, with JavaScript, jQuery and <a href="http://materializecss.com/">Materialize</a> on the frontend.
@@ -34,7 +34,7 @@ The team can be reached on <a href="mailto:contact@zoff.no?Subject=Contact%20Zof
### Android exclusive screens:
<div style="text-align:center;">
<img src="http://i.imgur.com/2LMOnUe.png" alt="android1" height="600px">
<img src="http://i.imgur.com/2LMOnUe.png" alt="android1" height="600px">
<img src="http://i.imgur.com/mIOrtng.png" alt="android2" height="400px">
</div>
@@ -42,43 +42,43 @@ The team can be reached on <a href="mailto:contact@zoff.no?Subject=Contact%20Zof
Emitted events between the server and client
```
socket.emit("end", VIDEO_ID); Tells the server the song is clientside
socket.emit("pos"); Asks server where in the song it should be
socket.emit("end", {id: video_id, channel: channel_name}); Tells the server the song is clientside
socket.emit("pos", {channel: channel_name}); Asks server where in the song it should be
socket.emit('list', CHANNEL_NAME); Tells the server the client wants the list
socket.emit("add", [VIDEO_ID, VIDEO_TITLE, sha256(PASSWORD), VIDEO_DURATION]); Sends info about a song the client wants to add
socket.emit("add", {id: VIDEO_ID, title: VIDEO_TITLE, adminpass: sha256(PASSWORD), duration: VIDEO_DURATION, list: channel_name, playlist: true_if_importing_playlist, num: current_number_of_sending_songs, total: total_number_of_sending_songs}); Sends info about a song the client wants to add
socket.emit("change_channel"); Tells the server to disconnect the user from the current channel, is used for remote controlling on the host side
socket.emit("all,chat", TEXT); Sends chat text to all chat
socket.emit("chat", TEXT); Sends chat text to channelchat
socket.emit('vote', [CHANNEL_NAME, VIDEO_ID, VOTE_TYPE, PASSWORD]); Sends info about song the user wants to vote on. If VOTE_TYPE is del, its deleting the song, if its pos, its just voting
socket.emit('skip', [CHANNEL_NAME, PASSWORD]); Sends skip message to server
socket.emit("password", [PASSWORD, CHANNEL_NAME]); Sends password for instant log in to server
socket.emit('vote', {channel: CHANNEL_NAME, id: VIDEO_ID, type: VOTE_TYPE, adminpass: PASSWORD}); Sends info about song the user wants to vote on. If VOTE_TYPE is del, its deleting the song, if its pos, its just voting
socket.emit('skip', {channel: CHANNEL_NAME, adminpass: PASSWORD, id: video_id}); Sends skip message to server
socket.emit("password", {password: PASSWORD, channel: CHANNEL_NAME, oldpass: old_pass_if_changing_password}); Sends password for instant log in to server
socket.emit('frontpage_lists'); Tells the server the client wants frontpage lists
socket.emit("id", [CHANNEL_ID, "play", "mock"]); Sends message to the host channel for play
socket.emit("id", [CHANNEL_ID, "pause", "mock"]); Sends message to the host channel for pause
socket.emit("id", [CHANNEL_ID, "skip", "mock"]); Sends message to the host channel for skip
socket.emit("id", [CHANNEL_ID, "volume", VALUE]); Sends message to the host channel to change volume
socket.emit("id", [CHANNEL_ID, "channel", NEW_CHANNEL_NAME]); Sends message to the host channel to change channel
socket.emit("id", {id: CHANNEL_ID, type: "play", value: "mock"}); Sends message to the host channel for play
socket.emit("id", {id: CHANNEL_ID, type: "pause", value: "mock"}); Sends message to the host channel for pause
socket.emit("id", {id: CHANNEL_ID, type: "skip", value: "mock"}); Sends message to the host channel for skip
socket.emit("id", {id: CHANNEL_ID, type: "volume", value: VALUE}); Sends message to the host channel to change volume
socket.emit("id", {id: CHANNEL_ID, type: "channel", value: NEW_CHANNEL_NAME}); Sends message to the host channel to change channel
socket.on("toast", STRING) Recieves a string from server for what type of toast to be triggered
socket.on("pw", STRING) Recieves the password for the channel if the user sent the right in the first place
socket.on("conf", [ARRAY]) Recieves configuration array from server
socket.on("chat.all", [CLIENT_NAME, STRING, CLIENT_CHANNEL_NAME]) Recieves chat message from allchat
socket.on("chat", [CLIENT_NAME, STRING]) Recieves chat message from channelchat
socket.on("chat.all", {from: CLIENT_NAME, msg: STRING, channel: CLIENT_CHANNEL_NAME}) Recieves chat message from allchat
socket.on("chat", {from: CLIENT_NAME, msg: STRING}) Recieves chat message from channelchat
socket.on("id", STRING) Recieves the ID of the current client, used for remote listening
socket.on(id, [ARRAY]) Recieves the messages sent on CHANNEL_ID above
socket.on("channel", [TYPE, [TYPE_SPECIFIC_VALUE]]) Recieves updates from channel. [0] is one of the following: list, added, deleted, vote, song_change
socket.on(id, {type: STRING, value: VALUE}) Recieves the messages sent on CHANNEL_ID above
socket.on("channel", {type: TYPE, value: value, time: time_of_occurence}) Recieves updates from channel. type is one of the following: list, added, deleted, vote, song_change
socket.on("get_list") Recieves message from the server that its ready to send the playlist and info
socket.on('playlists', [ARRAY]) Recieves the playlists for the frontpage
socket.on("np", [NOW_PLAYING, CONFIGURATION, SERVER_TIME]) Recieves array of now playing song. Is triggered on song-change
socket.on('playlists', {channels: array, viewers: number}) Recieves the playlists for the frontpage
socket.on("np", {np: NOW_PLAYING, conf: CONFIGURATION, time: SERVER_TIME}) Recieves array of now playing song. Is triggered on song-change
socket.on("viewers", VALUE) Recieves number of viewers on the current channel
```
### Legal
Copyright © 2016
Nicolas Almagro Tonne and Kasper Rynning-Tønnesen
Copyright © 2016
Nicolas Almagro Tonne and Kasper Rynning-Tønnesen
Creative Commons License
Zöff is licensed under a
<a href="http://creativecommons.org/licenses/by-nc-nd/3.0/no/">Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Norway License.</a>.
Do not redistribute without permission from the developers.
Zöff is licensed under a
<a href="http://creativecommons.org/licenses/by-nc-nd/3.0/no/">Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Norway License.</a>.
Do not redistribute without permission from the developers.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
!function(){function e(e){var t,o=e.substring(1).split("&"),n={};for(var a in o)t=o[a].split("="),2==t.length&&(n[t[0]]=t[1]);return n}window.addEventListener("load",function(){var t="b934ecdd173648f5bcd38738af529d58",o=window.location.protocol+"//"+window.location.hostname+"/spotify_callback",n="token",a="playlist-read-private playlist-read-collaborative user-read-private";if(window.location.hash.length<=0)window.location.href="https://accounts.spotify.com/authorize?client_id="+t+"&scope="+a+"&show_dialog=false&response_type="+n+"&redirect_uri="+o;else{var i=e(window.location.hash);window.opener.callback(i)}})}();
!function(){function o(o){var i,t=o.substring(1).split("&"),a={};for(var n in t)i=t[n].split("="),2==i.length&&(a[i[0]]=i[1]);return a}window.addEventListener("load",function(){var i="b934ecdd173648f5bcd38738af529d58",t=window.location.protocol+"//"+window.location.hostname+"/spotify_callback",a="token",n="playlist-read-private playlist-read-collaborative user-read-private";if(window.location.hash.length<=0)window.location.href="https://accounts.spotify.com/authorize?client_id="+i+"&scope="+n+"&show_dialog=false&response_type="+a+"&redirect_uri="+t;else{var e=o(window.location.hash);window.opener.callback(e)}})}();

View File

@@ -105,7 +105,7 @@ var Admin = {
Crypt.init();
Admin.set_conf(msg[0]);
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", {password: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), channel: chan.toLowerCase()});
Admin.beginning = false;
}
},
@@ -114,11 +114,11 @@ var Admin = {
{
if(!w_p)
{
socket.emit('password', [Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), chan.toLowerCase(), Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase()))]);
socket.emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase(), oldpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase()))});
}
else
{
socket.emit('password', [Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), chan.toLowerCase()]);
socket.emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase()});
}
},

View File

@@ -33,7 +33,7 @@ var Chat = {
{
//$("#chat-btn").css("color", "grey");
if(!blink_interval_exists && inp[1].substring(0,1) == ":" && !chat_active)
if(!blink_interval_exists && inp.msg.substring(0,1) == ":" && !chat_active)
{
$("#favicon").attr("href", "static/images/highlogo.png");
blink_interval_exists = true;
@@ -47,7 +47,7 @@ var Chat = {
{
$("#favicon").attr("href", "static/images/highlogo.png");
}
var color = Helper.intToARGB(Helper.hashCode(inp[0]));
var color = Helper.intToARGB(Helper.hashCode(inp.from));
if(color.length < 6) {
for(x = color.length; x < 6; x++){
color = "0" + color;
@@ -55,15 +55,15 @@ var Chat = {
}
color = Helper.hexToRgb(color.substring(0,6));
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
$("#chatall").append("<li title='"+inp[2]+"''><span style='color:"+color_temp+";'>"+inp[0]+"</span></li>");
var in_text = document.createTextNode(inp[1]);
$("#chatall").append("<li title='"+inp.channel+"''><span style='color:"+color_temp+";'>"+inp.from+"</span></li>");
var in_text = document.createTextNode(inp.msg);
$("#chatall li:last")[0].appendChild(in_text);
document.getElementById("chatall").scrollTop = document.getElementById("chatall").scrollHeight;
},
channelchat: function(data)
{
if(!blink_interval_exists && data[1].substring(0,1) == ":" && !chat_active)
if(!blink_interval_exists && data.msg.substring(0,1) == ":" && !chat_active)
{
$("#favicon").attr("href", "static/images/highlogo.png");
unseen = true;
@@ -72,7 +72,7 @@ var Chat = {
//blink_interval = setTimeout(Chat.chat_blink, 1000);
}
var color = Helper.intToARGB(Helper.hashCode(data[0]));
var color = Helper.intToARGB(Helper.hashCode(data.from));
if(color.length < 6) {
for(x = color.length; x < 6; x++){
color = "0" + color;
@@ -80,8 +80,8 @@ var Chat = {
}
color = Helper.hexToRgb(color.substring(0,6));
var color_temp = Helper.rgbToHsl([color.r, color.g, color.b], false);
$("#chatchannel").append("<li><span style='color:"+color_temp+";'>"+data[0]+"</span></li>");
var in_text = document.createTextNode(data[1]);
$("#chatchannel").append("<li><span style='color:"+color_temp+";'>"+data.from+"</span></li>");
var in_text = document.createTextNode(data.msg);
$("#chatchannel li:last")[0].appendChild(in_text);
document.getElementById("chatchannel").scrollTop = document.getElementById("chatchannel").scrollHeight;
},

View File

@@ -27,31 +27,31 @@ var Hostcontroller = {
host_on_action: function(arr)
{
if(enabled){
if(arr[0] == "volume"){
$("#volume").slider("value", arr[1]);
Player.player.setVolume(arr[1]);
localStorage.setItem("volume", arr[1]);
Playercontrols.choose_button(arr[1], false);
}else if(arr[0] == "channel"){
if(arr.type == "volume"){
$("#volume").slider("value", arr.value);
Player.player.setVolume(arr.value);
localStorage.setItem("volume", arr.value);
Playercontrols.choose_button(arr.value, false);
}else if(arr.type == "channel"){
socket.emit("change_channel");
Admin.beginning = true;
chan = arr[1].toLowerCase();
chan = arr.value.toLowerCase();
$("#chan").html(Helper.upperFirst(chan));
w_p = true;
socket.emit("list", chan.toLowerCase());
/*if(Crypt.get_pass(chan.toLowerCase()) !== undefined && Crypt.get_pass(chan.toLowerCase()) != ""){
socket.emit("password", [Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), chan.toLowerCase()]);
socket.emit("password", {password: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), channel: chan.toLowerCase()});
}*/
window.history.pushState("object or string", "Title", "/"+chan.toLowerCase());
}else if(arr[0] == "pause")
}else if(arr.type == "pause")
Player.player.pauseVideo();
else if(arr[0] == "play")
else if(arr.type == "play")
Player.player.playVideo();
else if(arr[0] == "skip")
else if(arr.type == "skip")
List.skip();
}
},

View File

@@ -4,22 +4,22 @@ var List = {
channel_function: function(msg)
{
switch(msg[0])
switch(msg.type)
{
case "list":
List.populate_list(msg[1]);
List.populate_list(msg.playlist);
break;
case "added":
List.added_song(msg[1]);
List.added_song(msg.value);
break;
case "deleted":
List.deleted_song(msg[1]);
List.deleted_song(msg.value);
break;
case "vote":
List.voted_song(msg[1], msg[2]);
List.voted_song(msg.value, msg.time);
break;
case "song_change":
if(window.location.pathname != "/") List.song_change(msg[1]);
if(window.location.pathname != "/") List.song_change(msg.time);
break;
}
},
@@ -170,12 +170,12 @@ var List = {
},
vote: function(id, vote){
socket.emit('vote', [chan, id, vote, adminpass]);
socket.emit('vote', {channel: chan, id: id, type: vote, adminpass: adminpass});
return true;
},
skip: function(){
socket.emit('skip', {pass: adminpass, id:video_id});
socket.emit('skip', {pass: adminpass, id:video_id, channel: chan.toLowerCase()});
return true;
},

View File

@@ -22,19 +22,19 @@ var Mobile_remote = {
},
set_channel: function(channel_name) {
socket.emit("id", [Mobile_remote.id, "channel", channel_name]);
socket.emit("id", {id: Mobile_remote.id, type: "channel", value: channel_name});
},
play_remote: function() {
socket.emit("id", [Mobile_remote.id, "play", "mock"]);
socket.emit("id", {id: Mobile_remote.id, type: "play", value: "mock"});
},
pause_remote: function() {
socket.emit("id", [Mobile_remote.id, "pause", "mock"]);
socket.emit("id", {id: Mobile_remote.id, type: "pause", value: "mock"});
},
skip_remote: function() {
socket.emit("id", [Mobile_remote.id, "skip", "mock"]);
socket.emit("id", {id: Mobile_remote.id, type: "skip", value: "mock"});
},
initiate_volume: function() {
@@ -49,7 +49,7 @@ var Mobile_remote = {
//localStorage.setItem("volume", ui.value);
},*/
stop:function(event, ui) {
socket.emit("id", [Mobile_remote.id, "volume", ui.value]);
socket.emit("id", {id: Mobile_remote.id, type: "volume", value: ui.value});
Helper.log("volume");
//console.log(ui.value);
}

View File

@@ -34,16 +34,16 @@ var Player = {
else{
//Helper.log("gotten new song");
if(previous_video_id === undefined)
previous_video_id = obj[0][0].id;
previous_video_id = obj.np[0].id;
else if(previous_video_id != video_id)
previous_video_id = video_id;
video_id = obj[0][0].id;
conf = obj[1][0];
time = obj[2];
video_id = obj.np[0].id;
conf = obj.conf[0];
time = obj.time;
seekTo = time - conf.startTime;
song_title = obj[0][0].title;
duration = obj[0][0].duration;
song_title = obj.np[0].title;
duration = obj.np[0].duration;
if(mobile_beginning && Helper.mobilecheck() && seekTo === 0)
seekTo = 1;

View File

@@ -63,17 +63,17 @@ function success()
$("#playbutton").on("click", function()
{
socket.emit("id", [id, "play", "mock"]);
socket.emit("id", {id: id, type: "play", value: "mock"});
});
$("#pausebutton").on("click", function()
{
socket.emit("id", [id, "pause", "mock"]);
socket.emit("id", {id: id, type: "pause", value: "mock"});
});
$("#skipbutton").on("click", function()
{
socket.emit("id", [id, "skip", "mock"]);
socket.emit("id", {id: id, type: "skip", value: "mock"});
});
$("#remoteform").on("submit", function()
@@ -120,14 +120,14 @@ var Remotecontroller = {
//localStorage.setItem("volume", ui.value);
},*/
stop:function(event, ui) {
socket.emit("id", [id, "volume", ui.value]);
socket.emit("id", {id: id, type: "volume", value: ui.value});
console.log("volume");
//console.log(ui.value);
}
});
}else
{
socket.emit("id", [id, "channel", $("#search").val().toLowerCase()]);
socket.emit("id", {id: id, type: "channel", value: $("#search").val().toLowerCase()});
$("#search").val("");
}