mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Started migration from jquery
This commit is contained in:
@@ -9,8 +9,8 @@ var Admin = {
|
|||||||
w_p = false;
|
w_p = false;
|
||||||
|
|
||||||
if(Admin.logged_in) {
|
if(Admin.logged_in) {
|
||||||
$("#thumbnail_form").css("display", "inline-block");
|
Helper.css("#thumbnail_form", "display", "inline-block");
|
||||||
$("#description_form").css("display", "inline-block");
|
Helper.css("#description_form", "display", "inline-block");
|
||||||
$("#user_suggests").removeClass("hide");
|
$("#user_suggests").removeClass("hide");
|
||||||
$("#user-suggest-html").removeClass("hide");
|
$("#user-suggest-html").removeClass("hide");
|
||||||
if($(".suggested-badge").text() != "0" && $(".suggested-badge").text() != "") {
|
if($(".suggested-badge").text() != "0" && $(".suggested-badge").text() != "") {
|
||||||
|
|||||||
@@ -571,8 +571,9 @@ var Channel = {
|
|||||||
socket.removeEventListener("suggested");
|
socket.removeEventListener("suggested");
|
||||||
socket.removeEventListener("color");
|
socket.removeEventListener("color");
|
||||||
socket.removeEventListener("chat_history");
|
socket.removeEventListener("chat_history");
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
url: "/",
|
url: "/",
|
||||||
|
method: "GET",
|
||||||
success: function(e){
|
success: function(e){
|
||||||
|
|
||||||
if(!client) {
|
if(!client) {
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ var Frontpage = {
|
|||||||
if(window.location.hostname == "fb.zoff.me") {
|
if(window.location.hostname == "fb.zoff.me") {
|
||||||
add = "https://zoff.me";
|
add = "https://zoff.me";
|
||||||
}
|
}
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {id:id},
|
data: {id:id},
|
||||||
url: add + "/api/imageblob",
|
url: add + "/api/imageblob",
|
||||||
@@ -259,10 +259,11 @@ var Frontpage = {
|
|||||||
if(window.location.hostname == "fb.zoff.me") {
|
if(window.location.hostname == "fb.zoff.me") {
|
||||||
add = "https://zoff.me";
|
add = "https://zoff.me";
|
||||||
}
|
}
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
url: add + "/api/frontpages",
|
url: add + "/api/frontpages",
|
||||||
method: "get",
|
method: "get",
|
||||||
success: function(response){
|
success: function(response){
|
||||||
|
response = JSON.parse(response);
|
||||||
Frontpage.frontpage_function(response.results);
|
Frontpage.frontpage_function(response.results);
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
@@ -327,7 +328,7 @@ var Frontpage = {
|
|||||||
}
|
}
|
||||||
currently_showing_channels = 1;
|
currently_showing_channels = 1;
|
||||||
clearTimeout(retry_frontpage);
|
clearTimeout(retry_frontpage);
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
url: "/" + new_channel,
|
url: "/" + new_channel,
|
||||||
method: "get",
|
method: "get",
|
||||||
data: {channel: new_channel},
|
data: {channel: new_channel},
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ function removeAllListeners() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getColor(id) {
|
function getColor(id) {
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/api/color",
|
url: "/api/color",
|
||||||
async: true,
|
async: true,
|
||||||
@@ -30,6 +30,7 @@ function getColor(id) {
|
|||||||
id: id
|
id: id
|
||||||
},
|
},
|
||||||
success: function(c) {
|
success: function(c) {
|
||||||
|
c = JSON.parse(c);
|
||||||
if(typeof(c) == "object") {
|
if(typeof(c) == "object") {
|
||||||
Player.setBGimage({color:c, only:true});
|
Player.setBGimage({color:c, only:true});
|
||||||
}
|
}
|
||||||
@@ -185,7 +186,7 @@ function emit_list() {
|
|||||||
|
|
||||||
function get_list_ajax() {
|
function get_list_ajax() {
|
||||||
//var c = Crypt.get_userpass(chan.toLowerCase());
|
//var c = Crypt.get_userpass(chan.toLowerCase());
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {
|
data: {
|
||||||
userpass: "",
|
userpass: "",
|
||||||
@@ -193,6 +194,7 @@ function get_list_ajax() {
|
|||||||
},
|
},
|
||||||
url: "/api/list/" + chan.toLowerCase(),
|
url: "/api/list/" + chan.toLowerCase(),
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
|
response = JSON.parse(response);
|
||||||
if(response.results.length > 0) {
|
if(response.results.length > 0) {
|
||||||
if(response.status == 403) {
|
if(response.status == 403) {
|
||||||
start_auth();
|
start_auth();
|
||||||
@@ -203,13 +205,14 @@ function get_list_ajax() {
|
|||||||
List.populate_list(response.results);
|
List.populate_list(response.results);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(response) {
|
error: function(response, xmlhttp) {
|
||||||
if(response.responseJSON.status == 403) {
|
response = JSON.parse(response);
|
||||||
|
if(response.status == 403) {
|
||||||
start_auth();
|
start_auth();
|
||||||
} else if(response.responseJSON.status == 429) {
|
} else if(response.status == 429) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
get_list_ajax();
|
get_list_ajax();
|
||||||
}, response.getResponseHeader("Retry-After") * 1000)
|
}, xmlhttp.getResponseHeader("Retry-After") * 1000)
|
||||||
}
|
}
|
||||||
if(client) {
|
if(client) {
|
||||||
$("#channel-load").remove();
|
$("#channel-load").remove();
|
||||||
@@ -260,7 +263,7 @@ function mouseContext(left, top) {
|
|||||||
function get_np_ajax() {
|
function get_np_ajax() {
|
||||||
/*var c = Crypt.get_userpass(chan.toLowerCase());
|
/*var c = Crypt.get_userpass(chan.toLowerCase());
|
||||||
if(c == undefined) c = "";*/
|
if(c == undefined) c = "";*/
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {
|
data: {
|
||||||
userpass: "",
|
userpass: "",
|
||||||
@@ -269,15 +272,17 @@ function get_np_ajax() {
|
|||||||
},
|
},
|
||||||
url: "/api/list/" + chan.toLowerCase() + "/__np__",
|
url: "/api/list/" + chan.toLowerCase() + "/__np__",
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
|
response = JSON.parse(response);
|
||||||
Player.getTitle(response.results[0].title, 1);
|
Player.getTitle(response.results[0].title, 1);
|
||||||
},
|
},
|
||||||
error: function(response) {
|
error: function(response, xmlhttp) {
|
||||||
if(response.responseJSON.status == 403) {
|
response = JSON.parse(response);
|
||||||
|
if(response.status == 403) {
|
||||||
start_auth();
|
start_auth();
|
||||||
} else if(response.responseJSON.status == 429) {
|
} else if(response.status == 429) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
get_np_ajax();
|
get_np_ajax();
|
||||||
}, response.getResponseHeader("Retry-After") * 1000)
|
}, xmlhttp.getResponseHeader("Retry-After") * 1000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -288,7 +293,7 @@ function del_ajax(id) {
|
|||||||
var u = Crypt.get_userpass(chan.toLowerCase());
|
var u = Crypt.get_userpass(chan.toLowerCase());
|
||||||
if(a == undefined) a = "";
|
if(a == undefined) a = "";
|
||||||
if(u == undefined) u = "";*/
|
if(u == undefined) u = "";*/
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "DELETE",
|
type: "DELETE",
|
||||||
data: {
|
data: {
|
||||||
adminpass: "",
|
adminpass: "",
|
||||||
@@ -300,13 +305,14 @@ function del_ajax(id) {
|
|||||||
toast("deletesong");
|
toast("deletesong");
|
||||||
get_list_ajax();
|
get_list_ajax();
|
||||||
},
|
},
|
||||||
error: function(response) {
|
error: function(response, xmlhttp) {
|
||||||
if(response.responseJSON.status == 403) {
|
response = JSON.parse(response);
|
||||||
|
if(response.status == 403) {
|
||||||
toast("listhaspass");
|
toast("listhaspass");
|
||||||
} else if(response.responseJSON.status == 429) {
|
} else if(response.status == 429) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
del_ajax(id);
|
del_ajax(id);
|
||||||
}, response.getResponseHeader("Retry-After") * 1000);
|
}, xmlhttp.getResponseHeader("Retry-After") * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -317,7 +323,7 @@ function add_ajax(id, title, duration, playlist, num, full_num, start, end) {
|
|||||||
var u = Crypt.get_userpass(chan.toLowerCase());
|
var u = Crypt.get_userpass(chan.toLowerCase());
|
||||||
if(a == undefined) a = "";
|
if(a == undefined) a = "";
|
||||||
if(u == undefined) u = "";*/
|
if(u == undefined) u = "";*/
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {
|
data: {
|
||||||
adminpass: "",
|
adminpass: "",
|
||||||
@@ -333,15 +339,16 @@ function add_ajax(id, title, duration, playlist, num, full_num, start, end) {
|
|||||||
toast("addedsong");
|
toast("addedsong");
|
||||||
get_list_ajax();
|
get_list_ajax();
|
||||||
},
|
},
|
||||||
error: function(response) {
|
error: function(response, xmlhttp) {
|
||||||
if(response.responseJSON.status == 403) {
|
response = JSON.parse(response);
|
||||||
|
if(response.status == 403) {
|
||||||
toast("listhaspass");
|
toast("listhaspass");
|
||||||
} else if(response.responseJSON.status == 409) {
|
} else if(response.status == 409) {
|
||||||
vote_ajax(id);
|
vote_ajax(id);
|
||||||
} else if(response.responseJSON.status == 429) {
|
} else if(response.status == 429) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
add_ajax(id, title, duration, playlist, num, full_num, start, end);
|
add_ajax(id, title, duration, playlist, num, full_num, start, end);
|
||||||
}, response.getResponseHeader("Retry-After") * 1000);
|
}, xmlhttp.getResponseHeader("Retry-After") * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -352,7 +359,7 @@ function vote_ajax(id) {
|
|||||||
var u = Crypt.get_userpass(chan.toLowerCase());
|
var u = Crypt.get_userpass(chan.toLowerCase());
|
||||||
if(a == undefined) a = "";
|
if(a == undefined) a = "";
|
||||||
if(u == undefined) u = "";*/
|
if(u == undefined) u = "";*/
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "PUT",
|
type: "PUT",
|
||||||
data: {
|
data: {
|
||||||
adminpass: "",
|
adminpass: "",
|
||||||
@@ -364,13 +371,14 @@ function vote_ajax(id) {
|
|||||||
toast("voted");
|
toast("voted");
|
||||||
get_list_ajax();
|
get_list_ajax();
|
||||||
},
|
},
|
||||||
error: function(response) {
|
error: function(response, xmlhttp) {
|
||||||
if(response.responseJSON.status == 403) {
|
response = JSON.parse(response);
|
||||||
|
if(response.status == 403) {
|
||||||
toast("listhaspass");
|
toast("listhaspass");
|
||||||
} else if(response.responseJSON.status == 429) {
|
} else if(response.status == 429) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
vote_ajax(id);
|
vote_ajax(id);
|
||||||
}, response.getResponseHeader("Retry-After") * 1000);
|
}, xmlhttp.getResponseHeader("Retry-After") * 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -18,6 +18,81 @@ var Helper = {
|
|||||||
return arr[Math.floor(Math.random() * arr.length)];
|
return arr[Math.floor(Math.random() * arr.length)];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
css: function(element, attribute, value) {
|
||||||
|
try {
|
||||||
|
if(element.substring(0,1) == "#") {
|
||||||
|
document.getElementById(element.substring(1)).style[attribute] = value;
|
||||||
|
} else {
|
||||||
|
var elements = documents.getElementsByClassName(element.substring(1));
|
||||||
|
for(var i = 0; i < elements.length; i++) {
|
||||||
|
elements[i].style[attribute] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
removeClass: function(element, className) {
|
||||||
|
try {
|
||||||
|
if(element.substring(0,1) == "#") {
|
||||||
|
document.getElementById(element.substring(1)).classList.remove(className);
|
||||||
|
} else {
|
||||||
|
var elements = documents.getElementsByClassName(element.substring(1));
|
||||||
|
for(var i = 0; i < elements.length; i++) {
|
||||||
|
elements[i].classList.remove(className);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
addClass: function(element, className) {
|
||||||
|
if(element.substring(0,1) == "#") {
|
||||||
|
var elem = document.getElementById(element.substring(1));
|
||||||
|
if(elem.className.indexOf(className) == -1) {
|
||||||
|
elem.className += " " + className;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var elements = documents.getElementsByClassName(element.substring(1));
|
||||||
|
for(var i = 0; i < elements.length; i++) {
|
||||||
|
if(elements[i].className.indexOf(className) == -1) {
|
||||||
|
elements[i].className += " " + className;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
ajax: function(obj) {
|
||||||
|
var _async = true;
|
||||||
|
if(obj.async) _async = obj.async;
|
||||||
|
if(obj.method == undefined) obj.method = "GET";
|
||||||
|
var xmlhttp = new XMLHttpRequest();
|
||||||
|
if(obj.headers) {
|
||||||
|
for(header in obj.headers) {
|
||||||
|
xmlhttp.setRequestHeader(header, obj.headers[header]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xmlhttp.onreadystatechange = function() {
|
||||||
|
if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4
|
||||||
|
if (xmlhttp.status == 200) {
|
||||||
|
obj.success(xmlhttp.responseText, xmlhttp);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
obj.error(xmlhttp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
xmlhttp.open(obj.method, obj.url, _async);
|
||||||
|
if(obj.data) {
|
||||||
|
if(typeof(obj.data) == "object") obj.data = JSON.stringify(obj.data);
|
||||||
|
xmlhttp.send(obj.data);
|
||||||
|
}
|
||||||
|
else xmlhttp.send();
|
||||||
|
},
|
||||||
|
|
||||||
randomString: function(length){
|
randomString: function(length){
|
||||||
var text = "";
|
var text = "";
|
||||||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_";
|
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_";
|
||||||
@@ -262,12 +337,6 @@ var Helper = {
|
|||||||
return string.substring(0,1).toUpperCase()+string.substring(1).toLowerCase();
|
return string.substring(0,1).toUpperCase()+string.substring(1).toLowerCase();
|
||||||
},
|
},
|
||||||
|
|
||||||
addClass: function(object, toAdd){
|
|
||||||
if(!Helper.contains($(object).attr("class").split(" "), toAdd)){
|
|
||||||
$(object).addClass(toAdd);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
send_mail: function(from, message){
|
send_mail: function(from, message){
|
||||||
if(from !== "" && message !== ""){
|
if(from !== "" && message !== ""){
|
||||||
|
|
||||||
@@ -276,7 +345,7 @@ var Helper = {
|
|||||||
$("#contact-form-from").attr("disabled", "true");
|
$("#contact-form-from").attr("disabled", "true");
|
||||||
$("#contact-form-message").attr("disabled", "true");
|
$("#contact-form-message").attr("disabled", "true");
|
||||||
var captcha_response = grecaptcha.getResponse();
|
var captcha_response = grecaptcha.getResponse();
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {
|
data: {
|
||||||
from: from,
|
from: from,
|
||||||
|
|||||||
@@ -187,14 +187,15 @@ var List = {
|
|||||||
full_playlist
|
full_playlist
|
||||||
]);
|
]);
|
||||||
if(full_playlist.length > 1){
|
if(full_playlist.length > 1){
|
||||||
$.each(full_playlist, function(j, _current_song){
|
for(var j = 0; j < full_playlist.length; j++) {
|
||||||
|
var _current_song = full_playlist[j];
|
||||||
if(!_current_song.hasOwnProperty("start")) full_playlist[j].start = 0;
|
if(!_current_song.hasOwnProperty("start")) full_playlist[j].start = 0;
|
||||||
if(!_current_song.hasOwnProperty("end")) full_playlist[j].end = full_playlist[j].duration;
|
if(!_current_song.hasOwnProperty("end")) full_playlist[j].end = full_playlist[j].duration;
|
||||||
if(!_current_song.now_playing && _current_song.type != "suggested"){ //check that the song isnt playing
|
if(!_current_song.now_playing && _current_song.type != "suggested"){ //check that the song isnt playing
|
||||||
var generated = List.generateSong(_current_song, false, lazy_load, true, false, "", true)
|
var generated = List.generateSong(_current_song, false, lazy_load, true, false, "", true)
|
||||||
$("#wrapper").append(generated);
|
$("#wrapper").append(generated);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
if($("#wrapper").children().length > List.can_fit && !$("#pageButtons").length){
|
if($("#wrapper").children().length > List.can_fit && !$("#pageButtons").length){
|
||||||
$(".prev_page").css("display", "none");
|
$(".prev_page").css("display", "none");
|
||||||
$(".first_page").css("display", "none");
|
$(".first_page").css("display", "none");
|
||||||
@@ -593,17 +594,18 @@ var List = {
|
|||||||
exportToSpotify: function() {
|
exportToSpotify: function() {
|
||||||
ga('send', 'event', "export", "spotify");
|
ga('send', 'event', "export", "spotify");
|
||||||
|
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: "https://api.spotify.com/v1/me",
|
url: "https://api.spotify.com/v1/me",
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ' + access_token_data.access_token
|
'Authorization': 'Bearer ' + access_token_data.access_token
|
||||||
},
|
},
|
||||||
success: function(response){
|
success: function(response){
|
||||||
|
response = JSON.parse(response);
|
||||||
var user_id = response.id;
|
var user_id = response.id;
|
||||||
$("#playlist_loader_export").removeClass("hide");
|
$("#playlist_loader_export").removeClass("hide");
|
||||||
$(".exported-list-container").removeClass("hide");
|
$(".exported-list-container").removeClass("hide");
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "https://api.spotify.com/v1/users/" + user_id + "/playlists",
|
url: "https://api.spotify.com/v1/users/" + user_id + "/playlists",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -616,13 +618,14 @@ var List = {
|
|||||||
public: true
|
public: true
|
||||||
}),
|
}),
|
||||||
success: function(response){
|
success: function(response){
|
||||||
|
response = JSON.parse(response);
|
||||||
var playlist_id = response.id;
|
var playlist_id = response.id;
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: window.location.protocol + "//" + window.location.hostname + "/assets/images/small-square.base64.txt",
|
url: window.location.protocol + "//" + window.location.hostname + "/assets/images/small-square.base64.txt",
|
||||||
success: function(base64image) {
|
success: function(base64image) {
|
||||||
var image = base64image.substring(0, base64image.length - 1);
|
var image = base64image.substring(0, base64image.length - 1);
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "PUT",
|
type: "PUT",
|
||||||
url: "https://api.spotify.com/v1/users/" + user_id + "/playlists/" + playlist_id + "/images",
|
url: "https://api.spotify.com/v1/users/" + user_id + "/playlists/" + playlist_id + "/images",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -656,7 +659,7 @@ var List = {
|
|||||||
|
|
||||||
$(".current_number").removeClass("hide");
|
$(".current_number").removeClass("hide");
|
||||||
$(".current_number").text((current_element + 1) + " of " + (full_playlist.length));
|
$(".current_number").text((current_element + 1) + " of " + (full_playlist.length));
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: "https://api.spotify.com/v1/search?q=" + track + "&type=track",
|
url: "https://api.spotify.com/v1/search?q=" + track + "&type=track",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -677,8 +680,10 @@ var List = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
success: function(response){
|
success: function(response){
|
||||||
|
response = JSON.parse(response);
|
||||||
var found = false;
|
var found = false;
|
||||||
$.each(response.tracks.items, function(i, data){
|
for(var i = 0; i < response.tracks.items.length; i++) {
|
||||||
|
var data = response.tracks.items[i];
|
||||||
data.name = Helper.replaceForFind(data.name);
|
data.name = Helper.replaceForFind(data.name);
|
||||||
data.artists[0].name = Helper.replaceForFind(data.artists[0].name);
|
data.artists[0].name = Helper.replaceForFind(data.artists[0].name);
|
||||||
if(data.name.substring(data.name.length-1) == " ") data.name = data.name.substring(0,data.name.length-1);
|
if(data.name.substring(data.name.length-1) == " ") data.name = data.name.substring(0,data.name.length-1);
|
||||||
@@ -693,7 +698,7 @@ var List = {
|
|||||||
track
|
track
|
||||||
]);
|
]);
|
||||||
//List.num_songs = List.num_songs + 1;
|
//List.num_songs = List.num_songs + 1;
|
||||||
return false;
|
break;
|
||||||
} 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);
|
||||||
@@ -702,16 +707,19 @@ var List = {
|
|||||||
track
|
track
|
||||||
]);
|
]);
|
||||||
//List.num_songs = List.num_songs + 1;
|
//List.num_songs = List.num_songs + 1;
|
||||||
return false;
|
break;
|
||||||
} else {
|
} else {
|
||||||
var splitted = data.name.split(" ");
|
var splitted = data.name.split(" ");
|
||||||
|
var toBreak = false;
|
||||||
for(var i = 0; i < splitted.length; i++) {
|
for(var i = 0; i < splitted.length; i++) {
|
||||||
if((splitted[i] == "and" && track.indexOf("&") >= 0) || (splitted[i] == "&" && track.indexOf("and") >= 0)){
|
if((splitted[i] == "and" && track.indexOf("&") >= 0) || (splitted[i] == "&" && track.indexOf("and") >= 0)){
|
||||||
continue;
|
continue;
|
||||||
} else if(track.indexOf(splitted[i]) < 0){
|
} else if(track.indexOf(splitted[i]) < 0){
|
||||||
return true;
|
toBreak = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(toBreak) break;
|
||||||
found = true;
|
found = true;
|
||||||
List.uris.push(data.uri);
|
List.uris.push(data.uri);
|
||||||
Helper.log([
|
Helper.log([
|
||||||
@@ -719,9 +727,9 @@ var List = {
|
|||||||
track
|
track
|
||||||
]);
|
]);
|
||||||
//List.num_songs = List.num_songs + 1;
|
//List.num_songs = List.num_songs + 1;
|
||||||
return false;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
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;
|
||||||
@@ -745,12 +753,14 @@ var List = {
|
|||||||
if($(".exported-spotify-list").length == 0) {
|
if($(".exported-spotify-list").length == 0) {
|
||||||
$(".exported-list").append("<a target='_blank' class='btn light exported-playlist exported-spotify-list' href='https://open.spotify.com/user/" + user_id + "/playlist/"+ playlist_id + "'>" + chan + "</a>");
|
$(".exported-list").append("<a target='_blank' class='btn light exported-playlist exported-spotify-list' href='https://open.spotify.com/user/" + user_id + "/playlist/"+ playlist_id + "'>" + chan + "</a>");
|
||||||
}
|
}
|
||||||
$.each(List.not_found, function(i, data){
|
for(var i = 0; i < List.not_found.length; i++) {
|
||||||
|
var data = List.not_found[i];
|
||||||
|
|
||||||
var not_added_song = $("<div>" + not_export_html + "</div>");
|
var not_added_song = $("<div>" + not_export_html + "</div>");
|
||||||
not_added_song.find(".extra-add-text").attr("value", data);
|
not_added_song.find(".extra-add-text").attr("value", data);
|
||||||
not_added_song.find(".extra-add-text").attr("title", data);
|
not_added_song.find(".extra-add-text").attr("title", data);
|
||||||
$(".not-exported-container").append(not_added_song.html());
|
$(".not-exported-container").append(not_added_song.html());
|
||||||
})
|
}
|
||||||
$(".current_number").addClass("hide");
|
$(".current_number").addClass("hide");
|
||||||
$(".not-exported").removeClass("hide");
|
$(".not-exported").removeClass("hide");
|
||||||
$(".spotify_export_button").css("display", "block");
|
$(".spotify_export_button").css("display", "block");
|
||||||
@@ -762,7 +772,7 @@ var List = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
addToSpotifyPlaylist: function(uris, playlist_id, user_id) {
|
addToSpotifyPlaylist: function(uris, playlist_id, user_id) {
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "https://api.spotify.com/v1/users/" + user_id + "/playlists/" + playlist_id + "/tracks",
|
url: "https://api.spotify.com/v1/users/" + user_id + "/playlists/" + playlist_id + "/tracks",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -792,7 +802,7 @@ var List = {
|
|||||||
var request_url = "https://www.googleapis.com/youtube/v3/playlists?part=snippet";
|
var request_url = "https://www.googleapis.com/youtube/v3/playlists?part=snippet";
|
||||||
$(".exported-list-container").removeClass("hide");
|
$(".exported-list-container").removeClass("hide");
|
||||||
$("#playlist_loader_export").removeClass("hide");
|
$("#playlist_loader_export").removeClass("hide");
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: request_url,
|
url: request_url,
|
||||||
headers: {
|
headers: {
|
||||||
@@ -806,12 +816,14 @@ var List = {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
success: function(response){
|
success: function(response){
|
||||||
|
response = JSON.parse(response);
|
||||||
var number_added = 0;
|
var number_added = 0;
|
||||||
var playlist_id = response.id;
|
var playlist_id = response.id;
|
||||||
var request_url = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet";
|
var request_url = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet";
|
||||||
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){
|
||||||
|
response = response.responseText;
|
||||||
Helper.log([
|
Helper.log([
|
||||||
"export to youtube response",
|
"export to youtube response",
|
||||||
response
|
response
|
||||||
@@ -830,7 +842,7 @@ var List = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: request_url,
|
url: request_url,
|
||||||
headers: {
|
headers: {
|
||||||
@@ -839,6 +851,7 @@ var List = {
|
|||||||
},
|
},
|
||||||
data: _data,
|
data: _data,
|
||||||
success: function(response){
|
success: function(response){
|
||||||
|
response = JSON.parse(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!"]);
|
||||||
|
|||||||
@@ -141,9 +141,10 @@ try{
|
|||||||
|
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
|
|
||||||
|
/*
|
||||||
$.ajaxPrefilter(function( options, original_Options, jqXHR ) {
|
$.ajaxPrefilter(function( options, original_Options, jqXHR ) {
|
||||||
options.async = true;
|
options.async = true;
|
||||||
});
|
});*/
|
||||||
|
|
||||||
window.zoff = {
|
window.zoff = {
|
||||||
enable_debug: enable_debug,
|
enable_debug: enable_debug,
|
||||||
@@ -1226,7 +1227,7 @@ $(document).on('submit', "#error-report-form", function(e) {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var captcha_response = grecaptcha.getResponse();
|
var captcha_response = grecaptcha.getResponse();
|
||||||
$("#send-loader").removeClass("hide");
|
$("#send-loader").removeClass("hide");
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {
|
data: {
|
||||||
from: "no-reply@zoff.me",
|
from: "no-reply@zoff.me",
|
||||||
@@ -1358,7 +1359,7 @@ $(document).on("click", "#player_bottom_overlay", function(e){
|
|||||||
|
|
||||||
$(document).on("click", ".generate-channel-name", function(e) {
|
$(document).on("click", ".generate-channel-name", function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: "/api/generate_name",
|
url: "/api/generate_name",
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
|
|||||||
@@ -295,6 +295,8 @@ var Player = {
|
|||||||
}*/
|
}*/
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
$("#playpause").css("visibility", "visible");
|
||||||
|
$("#playpause").css("pointer-events", "all");
|
||||||
playing = true;
|
playing = true;
|
||||||
if(beginning && Helper.mobilecheck() && !chromecastAvailable){
|
if(beginning && Helper.mobilecheck() && !chromecastAvailable){
|
||||||
//Player.pauseVideo();
|
//Player.pauseVideo();
|
||||||
|
|||||||
@@ -58,11 +58,12 @@ var Search = {
|
|||||||
if(Helper.contains($("#results").attr("class").split(" "), "hide"))
|
if(Helper.contains($("#results").attr("class").split(" "), "hide"))
|
||||||
$("#results").removeClass("hide");
|
$("#results").removeClass("hide");
|
||||||
|
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: yt_url,
|
url: yt_url,
|
||||||
dataType: "jsonp",
|
dataType: "jsonp",
|
||||||
success: function(response){
|
success: function(response){
|
||||||
|
response = JSON.parse(response);
|
||||||
var nextPageToken = response.nextPageToken;
|
var nextPageToken = response.nextPageToken;
|
||||||
var prevPageToken = response.prevPageToken;
|
var prevPageToken = response.prevPageToken;
|
||||||
if(response.items.length === 0) {
|
if(response.items.length === 0) {
|
||||||
@@ -73,23 +74,23 @@ var Search = {
|
|||||||
$(".search_loader_spinner").removeClass("active");
|
$(".search_loader_spinner").removeClass("active");
|
||||||
|
|
||||||
} else if(response.items){
|
} else if(response.items){
|
||||||
$.each(response.items, function(i,data) {
|
for(var i = 0; i < response.items.length; i++) {
|
||||||
vid_url += data.id.videoId+",";
|
vid_url += response.items[i].id.videoId+",";
|
||||||
});
|
}
|
||||||
|
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: vid_url,
|
url: vid_url,
|
||||||
dataType:"jsonp",
|
dataType:"jsonp",
|
||||||
success: function(response){
|
success: function(response){
|
||||||
|
response = JSON.parse(response);
|
||||||
var output = "";
|
var output = "";
|
||||||
var pre_result = $(result_html);
|
var pre_result = $(result_html);
|
||||||
|
|
||||||
//$("#results").append(result_html);
|
//$("#results").append(result_html);
|
||||||
|
|
||||||
$.each(response.items, function(i,song)
|
for(var i = 0; i < response.items.length; i++) {
|
||||||
{
|
var song = response.items[i];
|
||||||
var duration=song.contentDetails.duration;
|
var duration=song.contentDetails.duration;
|
||||||
secs=Search.durationToSeconds(duration);
|
secs=Search.durationToSeconds(duration);
|
||||||
var _temp_duration = Helper.secondsToOther(secs);
|
var _temp_duration = Helper.secondsToOther(secs);
|
||||||
@@ -121,7 +122,7 @@ var Search = {
|
|||||||
output += songs.html();
|
output += songs.html();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
var fresh = false;
|
var fresh = false;
|
||||||
if($("#inner-results").length == 0) {
|
if($("#inner-results").length == 0) {
|
||||||
fresh = true;
|
fresh = true;
|
||||||
@@ -189,11 +190,12 @@ var Search = {
|
|||||||
artist = artist.split(" ");
|
artist = artist.split(" ");
|
||||||
var temptitle = title.split("-");
|
var temptitle = title.split("-");
|
||||||
temptitle = temptitle.join(" ").split(" ");
|
temptitle = temptitle.join(" ").split(" ");
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: yt_url,
|
url: yt_url,
|
||||||
dataType:"jsonp",
|
dataType:"jsonp",
|
||||||
success: function(response){
|
success: function(response){
|
||||||
|
response = JSON.parse(response);
|
||||||
//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});
|
||||||
@@ -209,19 +211,21 @@ var Search = {
|
|||||||
$(".not-imported-container").append(not_added_song.html());
|
$(".not-imported-container").append(not_added_song.html());
|
||||||
$(".not-imported").removeClass("hide");
|
$(".not-imported").removeClass("hide");
|
||||||
} else if(response.items.length > 0) {
|
} else if(response.items.length > 0) {
|
||||||
$.each(response.items, function(i,data)
|
for(var i = 0; i < response.items; i++) {
|
||||||
{
|
var data = response.items[i];
|
||||||
vid_url += data.id.videoId+",";
|
vid_url += data.id.videoId+",";
|
||||||
});
|
}
|
||||||
|
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: vid_url,
|
url: vid_url,
|
||||||
dataType:"jsonp",
|
dataType:"jsonp",
|
||||||
success: function(response){
|
success: function(response){
|
||||||
|
response = JSON.parse(response);
|
||||||
if(response.items.length > 0) {
|
if(response.items.length > 0) {
|
||||||
var matched = false;
|
var matched = false;
|
||||||
$.each(response.items, function(i, data){
|
for(var i = 0; i < response.items.length; i++) {
|
||||||
|
var data = response.items[i];
|
||||||
//Helper.log(data);
|
//Helper.log(data);
|
||||||
//var title = data.snippet.title;
|
//var title = data.snippet.title;
|
||||||
var duration = Search.durationToSeconds(data.contentDetails.duration);
|
var duration = Search.durationToSeconds(data.contentDetails.duration);
|
||||||
@@ -229,7 +233,9 @@ var Search = {
|
|||||||
if(similarity(data.snippet.title, artist + " - " + title) > 0.75) {
|
if(similarity(data.snippet.title, artist + " - " + title) > 0.75) {
|
||||||
not_matched = false;
|
not_matched = false;
|
||||||
} else {
|
} else {
|
||||||
$.each(temptitle, function(i, data_title){
|
for(var i = 0; i < temptitle.length; i++) {
|
||||||
|
var data_title = temptitle[i];
|
||||||
|
|
||||||
if(data.snippet.title.toLowerCase().indexOf(data_title.toLowerCase()) == -1 || !(
|
if(data.snippet.title.toLowerCase().indexOf(data_title.toLowerCase()) == -1 || !(
|
||||||
data.snippet.title.toLowerCase().indexOf("cover") == -1 &&
|
data.snippet.title.toLowerCase().indexOf("cover") == -1 &&
|
||||||
title.toLowerCase().indexOf("cover") == -1 &&
|
title.toLowerCase().indexOf("cover") == -1 &&
|
||||||
@@ -243,16 +249,16 @@ var Search = {
|
|||||||
not_matched = true;
|
not_matched = true;
|
||||||
else if(duration > 1800) not_matched = true;
|
else if(duration > 1800) not_matched = true;
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((!not_matched)){
|
if((!not_matched)){
|
||||||
matched = true;
|
matched = true;
|
||||||
Search.readySubmit(true, { id: data.id, title: data.snippet.title, duration: duration, totalLength: totalNumber - 1});
|
Search.readySubmit(true, { id: data.id, title: data.snippet.title, duration: duration, totalLength: totalNumber - 1});
|
||||||
return false;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
if(!matched){
|
if(!matched){
|
||||||
Search.readySubmit(false, {totalLength: totalNumber - 1});
|
Search.readySubmit(false, {totalLength: totalNumber - 1});
|
||||||
Helper.log([
|
Helper.log([
|
||||||
@@ -327,13 +333,14 @@ var Search = {
|
|||||||
headers = {};//'Content-Type': 'application/json'};
|
headers = {};//'Content-Type': 'application/json'};
|
||||||
datatype = "jsonp";
|
datatype = "jsonp";
|
||||||
}
|
}
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: playlist_url,
|
url: playlist_url,
|
||||||
dataType: datatype,
|
dataType: datatype,
|
||||||
//dataType:"jsonp",
|
//dataType:"jsonp",
|
||||||
headers: headers,
|
headers: headers,
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
|
response = JSON.parse(response);
|
||||||
if(response.error){
|
if(response.error){
|
||||||
if(response.error.errors[0].reason == "playlistItemsNotAccessible"){
|
if(response.error.errors[0].reason == "playlistItemsNotAccessible"){
|
||||||
var nonce = Helper.randomString(29);
|
var nonce = Helper.randomString(29);
|
||||||
@@ -372,12 +379,13 @@ var Search = {
|
|||||||
if(typeof(response) == "string") response = $.parseJSON(response);
|
if(typeof(response) == "string") response = $.parseJSON(response);
|
||||||
//Search.addVideos(response.items[0].contentDetails.videoId);
|
//Search.addVideos(response.items[0].contentDetails.videoId);
|
||||||
//response.items.shift();
|
//response.items.shift();
|
||||||
$.each(response.items, function(i,data) {
|
for(var i = 0; i < response.items.length; i++) {
|
||||||
|
var data = response.items[i];
|
||||||
ids+=data.contentDetails.videoId+",";
|
ids+=data.contentDetails.videoId+",";
|
||||||
Search.submitYouTubeArrayIds.push(data.contentDetails.videoId);
|
Search.submitYouTubeArrayIds.push(data.contentDetails.videoId);
|
||||||
this_length += 1;
|
this_length += 1;
|
||||||
Search.submitYouTubeExpected += 1;
|
Search.submitYouTubeExpected += 1;
|
||||||
});
|
}
|
||||||
|
|
||||||
if(response.nextPageToken) {
|
if(response.nextPageToken) {
|
||||||
//Search.addVideos(ids, true, 0, false, this_length);
|
//Search.addVideos(ids, true, 0, false, this_length);
|
||||||
@@ -394,18 +402,19 @@ var Search = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
importSpotifyPlaylist: function(url){
|
importSpotifyPlaylist: function(url){
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ' + access_token_data.access_token
|
'Authorization': 'Bearer ' + access_token_data.access_token
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
$.each(response.items, function(i,data)
|
response = JSON.parse(response);
|
||||||
{
|
for(var i = 0; i < response.items.length; i++) {
|
||||||
|
var data = response.items[i];
|
||||||
//ids+=data.contentDetails.videoId+",";
|
//ids+=data.contentDetails.videoId+",";
|
||||||
Search.backgroundSearch(data.track.name, data.track.artists.map(function(elem){return elem.name;}).join(" "), Math.floor(data.track.duration_ms/1000), response.total, i + response.offset);
|
Search.backgroundSearch(data.track.name, data.track.artists.map(function(elem){return elem.name;}).join(" "), Math.floor(data.track.duration_ms/1000), response.total, i + response.offset);
|
||||||
|
|
||||||
});
|
}
|
||||||
if(response.next){
|
if(response.next){
|
||||||
Search.importSpotifyPlaylist(response.next);
|
Search.importSpotifyPlaylist(response.next);
|
||||||
}
|
}
|
||||||
@@ -433,16 +442,18 @@ var Search = {
|
|||||||
request_url += ids[i] + ",";
|
request_url += ids[i] + ",";
|
||||||
}
|
}
|
||||||
|
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: request_url,
|
url: request_url,
|
||||||
dataType:"jsonp",
|
dataType:"jsonp",
|
||||||
success: function(response){
|
success: function(response){
|
||||||
|
response = JSON.parse(response);
|
||||||
var x = 0;
|
var x = 0;
|
||||||
if(response.error) {
|
if(response.error) {
|
||||||
Search.submitYouTubeError = true;
|
Search.submitYouTubeError = true;
|
||||||
}
|
}
|
||||||
$.each(response.items, function(i,song) {
|
for(var i = 0; i < response.items.length; i++) {
|
||||||
|
var song = response.items[i];
|
||||||
var duration=Search.durationToSeconds(song.contentDetails.duration);
|
var duration=Search.durationToSeconds(song.contentDetails.duration);
|
||||||
if(!longsongs || duration<720){
|
if(!longsongs || duration<720){
|
||||||
enc_title= song.snippet.title;//encodeURIComponent(song.snippet.title);
|
enc_title= song.snippet.title;//encodeURIComponent(song.snippet.title);
|
||||||
@@ -450,7 +461,7 @@ var Search = {
|
|||||||
x += 1;
|
x += 1;
|
||||||
Search.submitYouTubeArray.push({id: song.id, title: enc_title, duration: duration});
|
Search.submitYouTubeArray.push({id: song.id, title: enc_title, duration: duration});
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
if(more) Search.addVideos(next_ids);
|
if(more) Search.addVideos(next_ids);
|
||||||
else {
|
else {
|
||||||
socket.emit("addPlaylist", {channel: chan.toLowerCase(), songs: Search.submitYouTubeArray});
|
socket.emit("addPlaylist", {channel: chan.toLowerCase(), songs: Search.submitYouTubeArray});
|
||||||
|
|||||||
@@ -40,26 +40,29 @@ var Suggestions = {
|
|||||||
var get_url = "https://www.googleapis.com/youtube/v3/search?part=snippet&relatedToVideoId="+id+"&type=video&key="+api_key;
|
var get_url = "https://www.googleapis.com/youtube/v3/search?part=snippet&relatedToVideoId="+id+"&type=video&key="+api_key;
|
||||||
var video_urls = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
var video_urls = "https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key="+api_key+"&id=";
|
||||||
|
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: get_url,
|
url: get_url,
|
||||||
dataType:"jsonp",
|
dataType:"jsonp",
|
||||||
success: function(response)
|
success: function(response)
|
||||||
{
|
{
|
||||||
$.each(response.items.slice(0,5), function(i,data){
|
response = JSON.parse(response);
|
||||||
|
var this_resp = response.items.slice(0,5);
|
||||||
|
for(var i = 0; i < this_resp.length; i++) {
|
||||||
|
var data = this_resp[i];
|
||||||
video_urls += data.id.videoId+",";
|
video_urls += data.id.videoId+",";
|
||||||
});
|
}
|
||||||
|
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: video_urls,
|
url: video_urls,
|
||||||
dataType: "jsonp",
|
dataType: "jsonp",
|
||||||
success: function(response)
|
success: function(response)
|
||||||
{
|
{
|
||||||
|
response = JSON.parse(response);
|
||||||
$("#suggest-song-html").empty();
|
$("#suggest-song-html").empty();
|
||||||
|
for(var i = 0; i < response.items.length; i++) {
|
||||||
$.each(response.items, function(i,song)
|
var song = response.items[i];
|
||||||
{
|
|
||||||
var duration = song.contentDetails.duration;
|
var duration = song.contentDetails.duration;
|
||||||
var length = Search.durationToSeconds(duration);
|
var length = Search.durationToSeconds(duration);
|
||||||
duration = Helper.secondsToOther(Search.durationToSeconds(duration));
|
duration = Helper.secondsToOther(Search.durationToSeconds(duration));
|
||||||
@@ -67,7 +70,7 @@ var Suggestions = {
|
|||||||
var video_title = song.snippet.title;
|
var video_title = song.snippet.title;
|
||||||
|
|
||||||
$("#suggest-song-html").append(List.generateSong({id: video_id, title: video_title, length: length, duration: duration}, false, false, false));
|
$("#suggest-song-html").append(List.generateSong({id: video_id, title: video_title, length: length, duration: duration}, false, false, false));
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ $(document).ready(function() {
|
|||||||
$(".submit").toggleClass("disabled");
|
$(".submit").toggleClass("disabled");
|
||||||
$(".full-form-token").removeClass("hide");
|
$(".full-form-token").removeClass("hide");
|
||||||
var captcha_response = grecaptcha.getResponse();
|
var captcha_response = grecaptcha.getResponse();
|
||||||
$.ajax({
|
Helper.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/api/apply",
|
url: "/api/apply",
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
Reference in New Issue
Block a user