mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Merge pull request #318 from zoff-music/refactor/helper-log
Refactor/helper log
This commit is contained in:
@@ -15,7 +15,9 @@ var mail_config = {
|
|||||||
authMethod: 'PLAIN',
|
authMethod: 'PLAIN',
|
||||||
tls: {
|
tls: {
|
||||||
ciphers:'SSLv3'
|
ciphers:'SSLv3'
|
||||||
}
|
},
|
||||||
|
from: 'no-reply@zoff.me',
|
||||||
|
to: 'contact@zoff.me'
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = mail_config;
|
module.exports = mail_config;
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ body {
|
|||||||
background: white;
|
background: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.error-code-container {
|
||||||
|
background: lightgrey;
|
||||||
|
border: 1px solid darkgrey;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.admin_panel{
|
.admin_panel{
|
||||||
margin-top:100px;
|
margin-top:100px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -247,8 +247,7 @@ var Channel = {
|
|||||||
$(".castButton").css("display", "none");
|
$(".castButton").css("display", "none");
|
||||||
}
|
}
|
||||||
|
|
||||||
Helper.log("chromecastAvailable" + chromecastAvailable);
|
Helper.log(["chromecastAvailable " + chromecastAvailable, "chromecastAvailable" + chromecastReady]);
|
||||||
Helper.log("chromecastAvailable" + chromecastReady);
|
|
||||||
|
|
||||||
if(chromecastAvailable){
|
if(chromecastAvailable){
|
||||||
hide_native(1);
|
hide_native(1);
|
||||||
@@ -281,7 +280,6 @@ var Channel = {
|
|||||||
var total = full_playlist[full_playlist.length - 1].duration / $("#controls").width();
|
var total = full_playlist[full_playlist.length - 1].duration / $("#controls").width();
|
||||||
total = total * e.clientX;
|
total = total * e.clientX;
|
||||||
|
|
||||||
Helper.log(total);
|
|
||||||
if(!chromecastAvailable){
|
if(!chromecastAvailable){
|
||||||
Player.player.seekTo(total + Player.np.start);
|
Player.player.seekTo(total + Player.np.start);
|
||||||
|
|
||||||
@@ -345,18 +343,17 @@ var Channel = {
|
|||||||
|
|
||||||
spotify_is_authenticated: function(bool){
|
spotify_is_authenticated: function(bool){
|
||||||
if(bool){
|
if(bool){
|
||||||
Helper.log("------------------------");
|
Helper.log([
|
||||||
Helper.log("Spotify is authenticated");
|
"Spotify is authenticated",
|
||||||
Helper.log("access_token: " + access_token_data.access_token);
|
"access_token: " + access_token_data.access_token,
|
||||||
Helper.log("token_type:" + access_token_data.token_type);
|
"token_type:" + access_token_data.token_type,
|
||||||
Helper.log("expires_in: " + access_token_data.expires_in);
|
"expires_in: " + access_token_data.expires_in
|
||||||
Helper.log("------------------------");
|
]);
|
||||||
|
|
||||||
$(".spotify_authenticated").css("display", "block");
|
$(".spotify_authenticated").css("display", "block");
|
||||||
$(".spotify_unauthenticated").css("display", "none");
|
$(".spotify_unauthenticated").css("display", "none");
|
||||||
} else {
|
} else {
|
||||||
Helper.log("----------------------------");
|
Helper.log(["Spotify is not authenticated"]);
|
||||||
Helper.log("Spotify is not authenticated");
|
|
||||||
Helper.log("----------------------------");
|
|
||||||
$(".spotify_authenticated").css("display", "none");
|
$(".spotify_authenticated").css("display", "none");
|
||||||
$(".spotify_unauthenticated").css("display", "block");
|
$(".spotify_unauthenticated").css("display", "block");
|
||||||
}
|
}
|
||||||
@@ -522,7 +519,7 @@ var Channel = {
|
|||||||
clearTimeout(tap_target_timeout);
|
clearTimeout(tap_target_timeout);
|
||||||
before_toast();
|
before_toast();
|
||||||
if(Helper.mobilecheck() || user_auth_avoid) {
|
if(Helper.mobilecheck() || user_auth_avoid) {
|
||||||
Helper.log("Removing all listeners");
|
Helper.log(["Removing all listeners"]);
|
||||||
//socket.emit("change_channel");
|
//socket.emit("change_channel");
|
||||||
//removeAllListeners();
|
//removeAllListeners();
|
||||||
//socket.removeEventListener(id);
|
//socket.removeEventListener(id);
|
||||||
@@ -595,7 +592,7 @@ var Channel = {
|
|||||||
$("#favicon").attr("href", "/assets/images/favicon-32x32.png");
|
$("#favicon").attr("href", "/assets/images/favicon-32x32.png");
|
||||||
|
|
||||||
$(".context-menu-list").remove();
|
$(".context-menu-list").remove();
|
||||||
Helper.log(socket);
|
Helper.log(["Socket", socket]);
|
||||||
if($("#alreadyfp").length == 1){
|
if($("#alreadyfp").length == 1){
|
||||||
Frontpage.init();
|
Frontpage.init();
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ var Frontpage = {
|
|||||||
frontpage_function: function(msg) {
|
frontpage_function: function(msg) {
|
||||||
frontpage = true;
|
frontpage = true;
|
||||||
|
|
||||||
Helper.log("-----------");
|
Helper.log([
|
||||||
Helper.log("Frontpage fetch");
|
"Frontpage fetch",
|
||||||
Helper.log(msg);
|
msg
|
||||||
Helper.log("------------");
|
]);
|
||||||
Frontpage.all_channels = msg.channels;
|
Frontpage.all_channels = msg.channels;
|
||||||
Frontpage.populate_channels(msg.channels, true);
|
Frontpage.populate_channels(msg.channels, true);
|
||||||
Frontpage.set_viewers(msg.viewers);
|
Frontpage.set_viewers(msg.viewers);
|
||||||
@@ -63,9 +63,10 @@ var Frontpage = {
|
|||||||
|
|
||||||
pre_card = $(channel_list);
|
pre_card = $(channel_list);
|
||||||
|
|
||||||
Helper.log("------------");
|
Helper.log([
|
||||||
Helper.log(pre_card);
|
"Pre_card: ",
|
||||||
Helper.log("-------------");
|
pre_card
|
||||||
|
]);
|
||||||
|
|
||||||
for(var x in lists) {
|
for(var x in lists) {
|
||||||
var chan = lists[x]._id;
|
var chan = lists[x]._id;
|
||||||
@@ -297,7 +298,7 @@ var Frontpage = {
|
|||||||
new_channel = new_channel.toLowerCase();
|
new_channel = new_channel.toLowerCase();
|
||||||
clearTimeout(rotation_timeout);
|
clearTimeout(rotation_timeout);
|
||||||
if(Helper.mobilecheck()){
|
if(Helper.mobilecheck()){
|
||||||
Helper.log("removing all listeners");
|
Helper.log(["removing all listeners"]);
|
||||||
removeAllListeners();
|
removeAllListeners();
|
||||||
}
|
}
|
||||||
$("#main-container").css("background-color", "#2d2d2d");
|
$("#main-container").css("background-color", "#2d2d2d");
|
||||||
@@ -415,10 +416,11 @@ var Frontpage = {
|
|||||||
$("#contact").modal();
|
$("#contact").modal();
|
||||||
$('select').material_select();
|
$('select').material_select();
|
||||||
|
|
||||||
Helper.log("----");
|
Helper.log([
|
||||||
Helper.log("Sending frontpage_lists");
|
"Sending frontpage_lists",
|
||||||
Helper.log("Socket", socket);
|
"Socket",
|
||||||
Helper.log("-----");
|
socket
|
||||||
|
]);
|
||||||
|
|
||||||
Crypt.init();
|
Crypt.init();
|
||||||
if(Crypt.get_offline()){
|
if(Crypt.get_offline()){
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
function removeAllListeners() {
|
function removeAllListeners() {
|
||||||
Helper.log("Removing all listeners");
|
Helper.log(["Removing all listeners"]);
|
||||||
socket.removeEventListener("chat.all");
|
socket.removeEventListener("chat.all");
|
||||||
socket.removeEventListener("chat");
|
socket.removeEventListener("chat");
|
||||||
socket.removeEventListener("conf");
|
socket.removeEventListener("conf");
|
||||||
@@ -147,7 +147,7 @@ function setup_auth_listener() {
|
|||||||
|
|
||||||
function setup_no_connection_listener(){
|
function setup_no_connection_listener(){
|
||||||
socket.on('connect_failed', function(){
|
socket.on('connect_failed', function(){
|
||||||
Helper.log('Connection Failed');
|
Helper.log(['Connection Failed']);
|
||||||
if(!connect_error){
|
if(!connect_error){
|
||||||
connect_error = true;
|
connect_error = true;
|
||||||
Materialize.toast("Error connecting to server, please wait..", 100000000, "red lighten connect_error");
|
Materialize.toast("Error connecting to server, please wait..", 100000000, "red lighten connect_error");
|
||||||
@@ -155,7 +155,7 @@ function setup_no_connection_listener(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on("connect_error", function(){
|
socket.on("connect_error", function(){
|
||||||
Helper.log("Connection Failed.");
|
Helper.log(["Connection Failed."]);
|
||||||
if(!connect_error){
|
if(!connect_error){
|
||||||
connect_error = true;
|
connect_error = true;
|
||||||
Materialize.toast("Error connecting to server, please wait..", 100000000, "red lighten connect_error");
|
Materialize.toast("Error connecting to server, please wait..", 100000000, "red lighten connect_error");
|
||||||
@@ -225,17 +225,17 @@ function setup_list_listener(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setup_playlist_listener(){
|
function setup_playlist_listener(){
|
||||||
Helper.log("Setting up playlist_listener");
|
Helper.log(["Setting up playlist_listener"]);
|
||||||
socket.on('playlists', Frontpage.frontpage_function);
|
socket.on('playlists', Frontpage.frontpage_function);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_host_initialization(){
|
function setup_host_initialization(){
|
||||||
Helper.log("Setting up host initialization listener");
|
Helper.log(["Setting up host initialization listener"]);
|
||||||
socket.on("id", Hostcontroller.host_listener);
|
socket.on("id", Hostcontroller.host_listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_host_listener(id){
|
function setup_host_listener(id){
|
||||||
Helper.log("Setting up host action listener");
|
Helper.log(["Setting up host action listener"]);
|
||||||
socket.on(id, Hostcontroller.host_on_action);
|
socket.on(id, Hostcontroller.host_on_action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
var Helper = {
|
var Helper = {
|
||||||
|
logs: [],
|
||||||
log: function(to_log) {
|
log: function(to_log) {
|
||||||
if(localStorage.debug === "true") {
|
if(localStorage.debug === "true") {
|
||||||
console.log(to_log);
|
console.log("------------ " + new Date());
|
||||||
|
for(var i = 0; i < to_log.length; i++) {
|
||||||
|
console.log(to_log[i]);
|
||||||
|
}
|
||||||
|
console.log("------------ " + new Date());
|
||||||
|
}
|
||||||
|
Helper.logs.unshift({log: to_log, date: new Date()});
|
||||||
|
if(Helper.logs.length > 10) {
|
||||||
|
Helper.logs.splice(-1, Helper.logs.length - 10);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ var Hostcontroller = {
|
|||||||
old_id: null,
|
old_id: null,
|
||||||
|
|
||||||
host_listener: function(id) {
|
host_listener: function(id) {
|
||||||
Helper.log("Host-listener triggered");
|
Helper.log([
|
||||||
Helper.log("Host-listener id:" + id);
|
"Host-listener triggered",
|
||||||
|
"Host-listener id:" + id
|
||||||
|
]);
|
||||||
if(Hostcontroller.old_id === null) Hostcontroller.old_id = id;
|
if(Hostcontroller.old_id === null) Hostcontroller.old_id = id;
|
||||||
else {
|
else {
|
||||||
socket.removeAllListeners(id);
|
socket.removeAllListeners(id);
|
||||||
|
|||||||
@@ -163,10 +163,10 @@ var List = {
|
|||||||
|
|
||||||
$("#wrapper").empty();
|
$("#wrapper").empty();
|
||||||
|
|
||||||
Helper.log("---------------------------");
|
Helper.log([
|
||||||
Helper.log("---------FULL PLAYLIST-----");
|
"FULL PLAYLIST",
|
||||||
Helper.log(full_playlist);
|
full_playlist
|
||||||
Helper.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.hasOwnProperty("start")) full_playlist[j].start = 0;
|
if(!_current_song.hasOwnProperty("start")) full_playlist[j].start = 0;
|
||||||
@@ -213,7 +213,7 @@ var List = {
|
|||||||
$("#pageButtons").removeClass("hide");
|
$("#pageButtons").removeClass("hide");
|
||||||
|
|
||||||
if(!embed) {
|
if(!embed) {
|
||||||
Helper.log("Starting empty-checker");
|
Helper.log(["Starting empty-checker"]);
|
||||||
clearTimeout(timed_remove_check);
|
clearTimeout(timed_remove_check);
|
||||||
timed_remove_check = setTimeout(function() {
|
timed_remove_check = setTimeout(function() {
|
||||||
if(full_playlist.length > 0) {
|
if(full_playlist.length > 0) {
|
||||||
@@ -230,7 +230,7 @@ var List = {
|
|||||||
function (data, status, xhr) {
|
function (data, status, xhr) {
|
||||||
//Helper.log("Empty-checker items " + data.items.length);
|
//Helper.log("Empty-checker items " + data.items.length);
|
||||||
if (data.items.length == 0) {
|
if (data.items.length == 0) {
|
||||||
Helper.log("Emtpy-checker error at " + full_playlist[i].id + " " + full_playlist[i].title);
|
Helper.log(["Emtpy-checker error at " + full_playlist[i].id + " " + full_playlist[i].title]);
|
||||||
socket.emit("error_video", {channel: chan.toLowerCase(), id: full_playlist[i].id, title: full_playlist[i].title});
|
socket.emit("error_video", {channel: chan.toLowerCase(), id: full_playlist[i].id, title: full_playlist[i].title});
|
||||||
}
|
}
|
||||||
if(full_playlist.length > i + 1 && window.location.pathname != "/") {
|
if(full_playlist.length > i + 1 && window.location.pathname != "/") {
|
||||||
@@ -238,7 +238,7 @@ var List = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}).error(function (xhr, errorType, exception) {
|
}).error(function (xhr, errorType, exception) {
|
||||||
Helper.log("Emtpy-checker error at " + full_playlist[i].id + " " + full_playlist[i].title);
|
Helper.log(["Emtpy-checker error at " + full_playlist[i].id + " " + full_playlist[i].title]);
|
||||||
socket.emit("error_video", {channel: chan.toLowerCase(), id: full_playlist[i].id, title: full_playlist[i].title});
|
socket.emit("error_video", {channel: chan.toLowerCase(), id: full_playlist[i].id, title: full_playlist[i].title});
|
||||||
if(full_playlist.length > i + 1 && window.location.pathname != "/") {
|
if(full_playlist.length > i + 1 && window.location.pathname != "/") {
|
||||||
List.check_error_videos(i + 1);
|
List.check_error_videos(i + 1);
|
||||||
@@ -521,10 +521,10 @@ var List = {
|
|||||||
} else {
|
} else {
|
||||||
delete full_playlist[length];
|
delete full_playlist[length];
|
||||||
}
|
}
|
||||||
Helper.log("---------------------------");
|
Helper.log([
|
||||||
Helper.log("---SONG ON FIRST INDEX-----");
|
"SONG ON FIRST INDEX",
|
||||||
Helper.log(full_playlist[0]);
|
full_playlist[0]
|
||||||
Helper.log("---------------------------");
|
]);
|
||||||
full_playlist.push(full_playlist.shift());
|
full_playlist.push(full_playlist.shift());
|
||||||
if(!remove){
|
if(!remove){
|
||||||
List.insertAtIndex(full_playlist[$("#wrapper").children().length], false, true);
|
List.insertAtIndex(full_playlist[$("#wrapper").children().length], false, true);
|
||||||
@@ -634,12 +634,12 @@ var List = {
|
|||||||
async: true,
|
async: true,
|
||||||
error: function(err){
|
error: function(err){
|
||||||
if(err.status == 429 || err.status == 502){
|
if(err.status == 429 || err.status == 502){
|
||||||
Helper.log(err.getAllResponseHeaders());
|
Helper.log([err.getAllResponseHeaders()]);
|
||||||
var retryAfter = err.getResponseHeader("Retry-After");
|
var retryAfter = err.getResponseHeader("Retry-After");
|
||||||
Helper.log(retryAfter);
|
Helper.log([retryAfter]);
|
||||||
if (!retryAfter) retryAfter = 5;
|
if (!retryAfter) retryAfter = 5;
|
||||||
retryAfter = parseInt(retryAfter, 10);
|
retryAfter = parseInt(retryAfter, 10);
|
||||||
Helper.log("Retry-After", retryAfter);
|
Helper.log(["Retry-After", retryAfter]);
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
List.searchSpotify(curr_song, playlist_id, user_id, full_playlist, current_element);
|
List.searchSpotify(curr_song, playlist_id, user_id, full_playlist, current_element);
|
||||||
}, retryAfter * 1000);
|
}, retryAfter * 1000);
|
||||||
@@ -657,13 +657,19 @@ var List = {
|
|||||||
if(similarity(data.artists[0].name + " - " + data.name, decodeURIComponent(track)) > 0.60 || (data.artists.length > 1 && similarity(data.artists[0].name + " " + data.artists[1].name + " - " + data.name, decodeURIComponent(track)))) {
|
if(similarity(data.artists[0].name + " - " + data.name, decodeURIComponent(track)) > 0.60 || (data.artists.length > 1 && similarity(data.artists[0].name + " " + data.artists[1].name + " - " + data.name, decodeURIComponent(track)))) {
|
||||||
found = true;
|
found = true;
|
||||||
List.uris.push(data.uri);
|
List.uris.push(data.uri);
|
||||||
Helper.log("Found", track);
|
Helper.log([
|
||||||
|
"Found",
|
||||||
|
track
|
||||||
|
]);
|
||||||
//List.num_songs = List.num_songs + 1;
|
//List.num_songs = List.num_songs + 1;
|
||||||
return false;
|
return false;
|
||||||
} else if(decodeURIComponent(track).indexOf(data.artists[0].name.toLowerCase()) >= 0 && decodeURIComponent(track).indexOf(data.name.toLowerCase()) >= 0){
|
} else if(decodeURIComponent(track).indexOf(data.artists[0].name.toLowerCase()) >= 0 && decodeURIComponent(track).indexOf(data.name.toLowerCase()) >= 0){
|
||||||
found = true;
|
found = true;
|
||||||
List.uris.push(data.uri);
|
List.uris.push(data.uri);
|
||||||
Helper.log("Found", track);
|
Helper.log([
|
||||||
|
"Found",
|
||||||
|
track
|
||||||
|
]);
|
||||||
//List.num_songs = List.num_songs + 1;
|
//List.num_songs = List.num_songs + 1;
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -677,7 +683,10 @@ var List = {
|
|||||||
}
|
}
|
||||||
found = true;
|
found = true;
|
||||||
List.uris.push(data.uri);
|
List.uris.push(data.uri);
|
||||||
Helper.log("Found", track);
|
Helper.log([
|
||||||
|
"Found",
|
||||||
|
track
|
||||||
|
]);
|
||||||
//List.num_songs = List.num_songs + 1;
|
//List.num_songs = List.num_songs + 1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -685,7 +694,10 @@ var List = {
|
|||||||
if(!found){
|
if(!found){
|
||||||
List.not_found.push(original_track);
|
List.not_found.push(original_track);
|
||||||
List.num_songs = List.num_songs + 1;
|
List.num_songs = List.num_songs + 1;
|
||||||
Helper.log("Didn't find", original_track);
|
Helper.log([
|
||||||
|
"Didn't find",
|
||||||
|
original_track
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
if(List.num_songs + List.uris.length == full_playlist.length){
|
if(List.num_songs + List.uris.length == full_playlist.length){
|
||||||
if(List.uris.length > 100){
|
if(List.uris.length > 100){
|
||||||
@@ -738,7 +750,7 @@ var List = {
|
|||||||
}, 3000);
|
}, 3000);
|
||||||
},
|
},
|
||||||
success: function(response){
|
success: function(response){
|
||||||
Helper.log("Added songs");
|
Helper.log(["Added songs"]);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -769,7 +781,10 @@ var List = {
|
|||||||
List.addToYoutubePlaylist(playlist_id, full_playlist, number_added, request_url)
|
List.addToYoutubePlaylist(playlist_id, full_playlist, number_added, request_url)
|
||||||
},
|
},
|
||||||
error: function(response){
|
error: function(response){
|
||||||
Helper.log(response);
|
Helper.log([
|
||||||
|
"export to youtube response",
|
||||||
|
response
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -793,10 +808,10 @@ var List = {
|
|||||||
},
|
},
|
||||||
data: _data,
|
data: _data,
|
||||||
success: function(response){
|
success: function(response){
|
||||||
Helper.log("Added video: " + full_playlist[num].id + " to playlist id " + playlist_id);
|
Helper.log(["Added video: " + full_playlist[num].id + " to playlist id " + playlist_id]);
|
||||||
if(num == full_playlist.length - 1){
|
if(num == full_playlist.length - 1){
|
||||||
Helper.log("All videoes added!");
|
Helper.log(["All videoes added!"]);
|
||||||
Helper.log("url: https://www.youtube.com/playlist?list=" + playlist_id);
|
Helper.log(["url: https://www.youtube.com/playlist?list=" + playlist_id]);
|
||||||
$(".exported-list").append("<a target='_blank' class='btn light exported-playlist' href='https://www.youtube.com/playlist?list=" + playlist_id + "'>" + chan + "</a>");
|
$(".exported-list").append("<a target='_blank' class='btn light exported-playlist' href='https://www.youtube.com/playlist?list=" + playlist_id + "'>" + chan + "</a>");
|
||||||
$("#playlist_loader_export").addClass("hide");
|
$("#playlist_loader_export").addClass("hide");
|
||||||
$(".current_number").addClass("hide");
|
$(".current_number").addClass("hide");
|
||||||
|
|||||||
@@ -138,10 +138,34 @@ window.zoff = {
|
|||||||
disable_debug: disable_debug
|
disable_debug: disable_debug
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!Helper.mobilecheck()) {
|
||||||
|
$(window).error(function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
Helper.logs.unshift({log: e.originalEvent.error.stack.toString().replace(/(\r\n|\n|\r)/gm,""), date: new Date()});
|
||||||
|
$(".contact-form-content").remove();
|
||||||
|
$("#submit-contact-form").remove();
|
||||||
|
$(".contact-modal-header").text("An error occurred");
|
||||||
|
$(".contact-container-info").remove();
|
||||||
|
$(".contact-modal-footer").prepend('<a href="#!" class="waves-effect waves-green btn-flat send-error-modal">Send</a>');
|
||||||
|
$("#contact-form").attr("id", "error-report-form");
|
||||||
|
$("#contact-container").prepend('<p>Do you want to send an error-report?</p> \
|
||||||
|
<p class="error-report-success"></p> \
|
||||||
|
<div class="error-code-container"> \
|
||||||
|
<code id="error-report-code"></code> \
|
||||||
|
</div>');
|
||||||
|
$("#contact").modal();
|
||||||
|
$("#contact").modal("open");
|
||||||
|
/*$("#error-report-modal").modal();*/
|
||||||
|
$("#error-report-code").text(JSON.stringify(Helper.logs, undefined, 4));
|
||||||
|
console.error(e.originalEvent.error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$().ready(function(){
|
$().ready(function(){
|
||||||
if(!localStorage.getItem("VERSION") || parseInt(localStorage.getItem("VERSION")) != VERSION) {
|
if(!localStorage.getItem("VERSION") || parseInt(localStorage.getItem("VERSION")) != VERSION) {
|
||||||
localStorage.setItem("VERSION", VERSION);
|
localStorage.setItem("VERSION", VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!fromFront && window.location.pathname != "/") Channel.init();
|
if(!fromFront && window.location.pathname != "/") Channel.init();
|
||||||
else if(!fromChannel && window.location.pathname == "/"){
|
else if(!fromChannel && window.location.pathname == "/"){
|
||||||
Frontpage.init();
|
Frontpage.init();
|
||||||
@@ -205,8 +229,10 @@ initializeCastApi = function() {
|
|||||||
var context = cast.framework.CastContext.getInstance();
|
var context = cast.framework.CastContext.getInstance();
|
||||||
chromecastReady = true;
|
chromecastReady = true;
|
||||||
context.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED, function(event) {
|
context.addEventListener(cast.framework.CastContextEventType.SESSION_STATE_CHANGED, function(event) {
|
||||||
Helper.log("session state");
|
Helper.log([
|
||||||
Helper.log(event.sessionState);
|
"session state",
|
||||||
|
event.sessionState
|
||||||
|
]);
|
||||||
switch (event.sessionState) {
|
switch (event.sessionState) {
|
||||||
case cast.framework.SessionState.SESSION_STARTED:
|
case cast.framework.SessionState.SESSION_STARTED:
|
||||||
castSession = cast.framework.CastContext.getInstance().getCurrentSession();
|
castSession = cast.framework.CastContext.getInstance().getCurrentSession();
|
||||||
@@ -268,8 +294,10 @@ initializeCastApi = function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
context.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED, function(event){
|
context.addEventListener(cast.framework.CastContextEventType.CAST_STATE_CHANGED, function(event){
|
||||||
Helper.log("cast state");
|
Helper.log([
|
||||||
Helper.log(event.castState);
|
"cast state",
|
||||||
|
event.castState
|
||||||
|
]);
|
||||||
if(event.castState == "NOT_CONNECTED"){
|
if(event.castState == "NOT_CONNECTED"){
|
||||||
$(".castButton").css("display", "block");
|
$(".castButton").css("display", "block");
|
||||||
if(!$(".volume-container").hasClass("volume-container-cast")) {
|
if(!$(".volume-container").hasClass("volume-container-cast")) {
|
||||||
@@ -692,7 +720,6 @@ $("#clickme").click(function(){
|
|||||||
|
|
||||||
$(document).on("click", "#listExport", function(e){
|
$(document).on("click", "#listExport", function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
Helper.log(full_playlist);
|
|
||||||
if(!youtube_authenticated){
|
if(!youtube_authenticated){
|
||||||
var nonce = Helper.randomString(29);
|
var nonce = Helper.randomString(29);
|
||||||
window.callback = function(data) {
|
window.callback = function(data) {
|
||||||
@@ -1070,6 +1097,37 @@ $(document).on('submit', '#contact-form', function(e){
|
|||||||
Helper.send_mail(from, message);
|
Helper.send_mail(from, message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).on('click', ".send-error-modal", function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$("#error-report-form").submit();
|
||||||
|
})
|
||||||
|
|
||||||
|
$(document).on('submit', "#error-report-form", function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var captcha_response = grecaptcha.getResponse();
|
||||||
|
$("#send-loader").removeClass("hide");
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
data: {
|
||||||
|
from: "no-reply@zoff.me",
|
||||||
|
message: $("#error-report-code").text(),
|
||||||
|
"g-recaptcha-response": captcha_response,
|
||||||
|
},
|
||||||
|
url: "/api/mail",
|
||||||
|
success: function(data){
|
||||||
|
if(data == "success"){
|
||||||
|
$(".send-error-modal").remove();
|
||||||
|
$("#error-report-form").remove();
|
||||||
|
$(".error-code-container").remove();
|
||||||
|
$(".error-report-success").text("Error report sent!");
|
||||||
|
$("#contact-container").html("Mail has been sent, we'll be back with you shortly.")
|
||||||
|
}else{
|
||||||
|
$(".error-report-success").text("Mail was not sent, try again");
|
||||||
|
}
|
||||||
|
$("#send-loader").addClass("hide");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
$(document).on( "click", "#add-many", function(e){
|
$(document).on( "click", "#add-many", function(e){
|
||||||
var id = $(this).attr("data-video-id");
|
var id = $(this).attr("data-video-id");
|
||||||
@@ -1288,6 +1346,6 @@ $(document).on("submit", "#find_form", function(e){
|
|||||||
List.dynamicContentPageJumpTo(jump_to_page);
|
List.dynamicContentPageJumpTo(jump_to_page);
|
||||||
} else {
|
} else {
|
||||||
$(".highlight").removeClass("highlight");
|
$(".highlight").removeClass("highlight");
|
||||||
Helper.log("none found");
|
Helper.log(["none found"]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ var Mobile_remote = {
|
|||||||
animate: true,
|
animate: true,
|
||||||
stop:function(event, ui) {
|
stop:function(event, ui) {
|
||||||
socket.emit("id", {id: Mobile_remote.id, type: "volume", value: ui.value});
|
socket.emit("id", {id: Mobile_remote.id, type: "volume", value: ui.value});
|
||||||
Helper.log("volume");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,21 +30,21 @@ var Player = {
|
|||||||
prev_chan_player = chan;
|
prev_chan_player = chan;
|
||||||
from_frontpage = false;
|
from_frontpage = false;
|
||||||
Player.loaded = false;
|
Player.loaded = false;
|
||||||
Helper.log("--------youtube_listener--------");
|
Helper.log([
|
||||||
Helper.log("Received: ");
|
"youtube_listener",
|
||||||
Helper.log(obj);
|
"Received: ",
|
||||||
Helper.log("paused variable: " + paused);
|
obj,
|
||||||
Helper.log("mobile_beginning variable: " + mobile_beginning);
|
"paused variable: " + paused,
|
||||||
|
"mobile_beginning variable: " + mobile_beginning]);
|
||||||
try{
|
try{
|
||||||
Helper.log("getVideoUrl(): " + Player.player.getVideoUrl().split('v=')[1]);
|
Helper.log(["getVideoUrl(): " + Player.player.getVideoUrl().split('v=')[1]]);
|
||||||
} catch(e){
|
} catch(e){
|
||||||
|
|
||||||
}
|
}
|
||||||
Helper.log("video_id variable: " + video_id);
|
Helper.log(["video_id variable: " + video_id]);
|
||||||
Helper.log("---------------------------------");
|
|
||||||
|
|
||||||
if(!obj.np){
|
if(!obj.np){
|
||||||
document.getElementById('song-title').innerHTML = "Empty channel. Add some songs!";
|
$('#song-title').html("Empty channel. Add some songs!");
|
||||||
document.title = "Zoff - the shared YouTube based radio";
|
document.title = "Zoff - the shared YouTube based radio";
|
||||||
$("#channel-load").css("display", "none");
|
$("#channel-load").css("display", "none");
|
||||||
//$("#player_overlay").height($("#player").height());
|
//$("#player_overlay").height($("#player").height());
|
||||||
@@ -205,15 +205,16 @@ var Player = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onPlayerStateChange: function(newState) {
|
onPlayerStateChange: function(newState) {
|
||||||
Helper.log("-------onPlayerStateChange------");
|
Helper.log([
|
||||||
Helper.log("New state\nState: ");
|
"onPlayerStateChange",
|
||||||
Helper.log(newState);
|
"New state\nState: ",
|
||||||
|
newState
|
||||||
|
]);
|
||||||
try{
|
try{
|
||||||
Helper.log("Duration: " + Player.player.getDuration(), "Current time: " + Player.player.getCurrentTime());
|
Helper.log(["Duration: " + Player.player.getDuration(), "Current time: " + Player.player.getCurrentTime()]);
|
||||||
Helper.log("getVideoUrl(): " + Player.player.getVideoUrl().split('v=')[1]);
|
Helper.log(["getVideoUrl(): " + Player.player.getVideoUrl().split('v=')[1]]);
|
||||||
}catch(e){}
|
}catch(e){}
|
||||||
Helper.log("video_id variable: " + video_id);
|
Helper.log(["video_id variable: " + video_id]);
|
||||||
Helper.log("---------------------------------");
|
|
||||||
switch(newState.data) {
|
switch(newState.data) {
|
||||||
case YT.PlayerState.UNSTARTED:
|
case YT.PlayerState.UNSTARTED:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -193,11 +193,11 @@ var Search = {
|
|||||||
//Helper.log(response);
|
//Helper.log(response);
|
||||||
if(response.items.length === 0){
|
if(response.items.length === 0){
|
||||||
Search.readySubmit(false, {totalLength: totalNumber - 1});
|
Search.readySubmit(false, {totalLength: totalNumber - 1});
|
||||||
Helper.log("------------------------------");
|
Helper.log([
|
||||||
Helper.log("NO MATCH FOR:");
|
"NO MATCH FOR:",
|
||||||
Helper.log("Spotify title: " + title + " " + artist.join(" "));
|
"Spotify title: " + title + " " + artist.join(" "),
|
||||||
Helper.log("Spotify length: " + length);
|
"Spotify length: " + length
|
||||||
Helper.log("------------------------------");
|
]);
|
||||||
var not_added_song = $("<div>" + not_import_html + "</div>");
|
var not_added_song = $("<div>" + not_import_html + "</div>");
|
||||||
not_added_song.find(".extra-add-text").text(title + " - " + artist.join(" "));
|
not_added_song.find(".extra-add-text").text(title + " - " + artist.join(" "));
|
||||||
not_added_song.find(".extra-add-text").attr("title", title + " - " + artist.join(" "));
|
not_added_song.find(".extra-add-text").attr("title", title + " - " + artist.join(" "));
|
||||||
@@ -251,11 +251,11 @@ var Search = {
|
|||||||
});
|
});
|
||||||
if(!matched){
|
if(!matched){
|
||||||
Search.readySubmit(false, {totalLength: totalNumber - 1});
|
Search.readySubmit(false, {totalLength: totalNumber - 1});
|
||||||
Helper.log("------------------------------");
|
Helper.log([
|
||||||
Helper.log("NO MATCH FOR:");
|
"NO MATCH FOR:",
|
||||||
Helper.log("Spotify title: " + title + " " + artist.join(" "));
|
"Spotify title: " + title + " " + artist.join(" "),
|
||||||
Helper.log("Spotify length: " + length);
|
"Spotify length: " + length
|
||||||
Helper.log("------------------------------");
|
]);
|
||||||
var not_added_song = $("<div>" + not_import_html + "</div>");
|
var not_added_song = $("<div>" + not_import_html + "</div>");
|
||||||
not_added_song.find(".extra-add-text").text(title + " - " + artist.join(" "));
|
not_added_song.find(".extra-add-text").text(title + " - " + artist.join(" "));
|
||||||
not_added_song.find(".extra-add-text").attr("title", title + " - " + artist.join(" "));
|
not_added_song.find(".extra-add-text").attr("title", title + " - " + artist.join(" "));
|
||||||
@@ -351,7 +351,10 @@ var Search = {
|
|||||||
};
|
};
|
||||||
youtube_window = window.open("/o_callback#youtube=true&nonce=" + nonce, "", "width=600, height=600");
|
youtube_window = window.open("/o_callback#youtube=true&nonce=" + nonce, "", "width=600, height=600");
|
||||||
} else {
|
} else {
|
||||||
Helper.log(response.error);
|
Helper.log([
|
||||||
|
"import list error: ",
|
||||||
|
response.error
|
||||||
|
]);
|
||||||
document.getElementById("import").disabled = false;
|
document.getElementById("import").disabled = false;
|
||||||
$("#playlist_loader").addClass("hide");
|
$("#playlist_loader").addClass("hide");
|
||||||
$("#import").removeClass("hide");
|
$("#import").removeClass("hide");
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
<div id="contact" class="modal">
|
<div id="contact" class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content contact-modal-content">
|
||||||
<h4>Contact</h4>
|
<h4 class="contact-modal-header">Contact</h4>
|
||||||
<div id="contact-container">
|
<div id="contact-container">
|
||||||
<p>Found a bug, or just want to contact the team?</p>
|
<p class="contact-container-info">Found a bug, or just want to contact the team?</p>
|
||||||
<form id="contact-form" method="post">
|
<form id="contact-form" method="post">
|
||||||
<div class="input-field">
|
<div class="contact-form-content">
|
||||||
<input id="contact-form-from" name="from" type="email" autocomplete="off" class="validate" />
|
<div class="input-field">
|
||||||
<label for="contact-form-from" class="noselect">Email</label>
|
<input id="contact-form-from" name="from" type="email" autocomplete="off" class="validate" />
|
||||||
</div>
|
<label for="contact-form-from" class="noselect">Email</label>
|
||||||
<div class="input-field">
|
</div>
|
||||||
<input id="contact-form-message" name="message" type="text" autocomplete="off">
|
<div class="input-field">
|
||||||
<label for="contact-form-message" class="noselect">Message</label>
|
<input id="contact-form-message" name="message" type="text" autocomplete="off">
|
||||||
|
<label for="contact-form-message" class="noselect">Message</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{{captcha}}}
|
{{{captcha}}}
|
||||||
<div class="valign hide" id="send-loader">
|
<div class="valign hide" id="send-loader">
|
||||||
@@ -21,7 +23,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer contact-modal-footer">
|
||||||
<button class="waves-effect waves-green btn-flat" id="submit-contact-form">Send</button>
|
<button class="waves-effect waves-green btn-flat" id="submit-contact-form">Send</button>
|
||||||
<a href="#!" class=" modal-action modal-close waves-effect waves-red btn-flat">Close</a>
|
<a href="#!" class=" modal-action modal-close waves-effect waves-red btn-flat">Close</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -114,12 +114,16 @@ try {
|
|||||||
res.sendStatus(500);
|
res.sendStatus(500);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
var subject = 'ZOFF: Contact form webpage';
|
||||||
|
if(req.body.error_report) {
|
||||||
|
subject = 'ZOFF: Error report';
|
||||||
|
}
|
||||||
var from = req.body.from;
|
var from = req.body.from;
|
||||||
var message = req.body.message;
|
var message = req.body.message;
|
||||||
var msg = {
|
var msg = {
|
||||||
from: 'no-reply@zoff.me',
|
from: mailconfig.from,
|
||||||
to: 'contact@zoff.me',
|
to: mailconfig.to,
|
||||||
subject: 'ZOFF: Contact form webpage',
|
subject: subject,
|
||||||
text: message,
|
text: message,
|
||||||
html: message,
|
html: message,
|
||||||
replyTo: from
|
replyTo: from
|
||||||
|
|||||||
Reference in New Issue
Block a user