mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Working without jQuery
This commit is contained in:
@@ -1476,14 +1476,18 @@ margin:-1px;
|
|||||||
}
|
}
|
||||||
|
|
||||||
#inner-results {
|
#inner-results {
|
||||||
height: calc(100vh - 64px);
|
height: calc(100vh - 64px - 76px);
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.empty-inner-results {
|
||||||
|
height: calc(100vh - 64px) !important;
|
||||||
|
}
|
||||||
|
|
||||||
#empty-results {
|
#empty-results {
|
||||||
text-align:center;
|
text-align:center;
|
||||||
height:100px;
|
height:calc(100vh - 64px);
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,9 @@ var Channel = {
|
|||||||
setup_youtube_listener();
|
setup_youtube_listener();
|
||||||
get_list_listener();
|
get_list_listener();
|
||||||
setup_suggested_listener();
|
setup_suggested_listener();
|
||||||
setup_viewers_listener();
|
if(!client) {
|
||||||
|
setup_viewers_listener();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Helper.css("#channel-load", "display", "none");
|
Helper.css("#channel-load", "display", "none");
|
||||||
Helper.css("#player", "opacity", "1");
|
Helper.css("#player", "opacity", "1");
|
||||||
@@ -273,11 +275,11 @@ var Channel = {
|
|||||||
//$("#results" ).hover( function() { Helper.removeClass(".result", "hoverResults"); i = 0; }, function(){ });
|
//$("#results" ).hover( function() { Helper.removeClass(".result", "hoverResults"); i = 0; }, function(){ });
|
||||||
document.getElementById("search").focus();
|
document.getElementById("search").focus();
|
||||||
Helper.css("#embed-button", "display", "inline-block");
|
Helper.css("#embed-button", "display", "inline-block");
|
||||||
document.getElementById("embed-area").value = embed_code(embed_autoplay, embed_width, embed_height, color);
|
|
||||||
document.getElementById("search").setAttribute("placeholder", "Find song on YouTube...");
|
document.getElementById("search").setAttribute("placeholder", "Find song on YouTube...");
|
||||||
|
|
||||||
if(!client) {
|
if(!client) {
|
||||||
Helper.addClass("footer", "padding-bottom-novideo");
|
Helper.addClass("footer", "padding-bottom-novideo");
|
||||||
|
document.getElementById("embed-area").value = embed_code(embed_autoplay, embed_width, embed_height, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!/chrom(e|ium)/.test(navigator.userAgent.toLowerCase()) && !Helper.mobilecheck() && !client){
|
if(!/chrom(e|ium)/.test(navigator.userAgent.toLowerCase()) && !Helper.mobilecheck() && !client){
|
||||||
@@ -451,12 +453,14 @@ var Channel = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(on) {
|
if(!client) {
|
||||||
document.getElementById("chatchannel").addEventListener("scroll", scrollListener);
|
if(on) {
|
||||||
document.getElementById("chatall").addEventListener("scroll", scrollListener);
|
document.getElementById("chatchannel").addEventListener("scroll", scrollListener);
|
||||||
} else {
|
document.getElementById("chatall").addEventListener("scroll", scrollListener);
|
||||||
document.getElementById("chatchannel").removeEventListener("scroll", scrollListener);
|
} else {
|
||||||
document.getElementById("chatall").removeEventListener("scroll", scrollAllListener);
|
document.getElementById("chatchannel").removeEventListener("scroll", scrollListener);
|
||||||
|
document.getElementById("chatall").removeEventListener("scroll", scrollAllListener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ function receiveMessage(event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener("message", receiveMessage, false);
|
window.addEventListener("message", receiveMessage, false);
|
||||||
|
console.log("qq");
|
||||||
window.addEventListener("load", function() {
|
window.addEventListener("DOMContentLoaded", function() {
|
||||||
|
console.log("ads");
|
||||||
if(hash.length >= 3 && hash[2] == "autoplay"){
|
if(hash.length >= 3 && hash[2] == "autoplay"){
|
||||||
autoplay = true;
|
autoplay = true;
|
||||||
Helper.css("#player", "visibility", "hidden");
|
Helper.css("#player", "visibility", "hidden");
|
||||||
@@ -374,21 +374,21 @@ addListener("click", ".vote-container", function(e) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
addListener("click", ".prev_page", function(e) {
|
addListener("click", ".prev_page", function(e) {
|
||||||
e.preventDefault();
|
event.preventDefault();
|
||||||
List.dynamicContentPage(-1);
|
List.dynamicContentPage(-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
addListener("click", ".next_page", function(e) {
|
addListener("click", ".next_page", function(e) {
|
||||||
e.preventDefault();
|
event.preventDefault();
|
||||||
List.dynamicContentPage(1);
|
List.dynamicContentPage(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
addListener("click", ".last_page", function(e){
|
addListener("click", ".last_page", function(e){
|
||||||
e.preventDefault();
|
event.preventDefault();
|
||||||
List.dynamicContentPage(10);
|
List.dynamicContentPage(10);
|
||||||
});
|
});
|
||||||
|
|
||||||
addListener("click", ".first_page", function(e){
|
addListener("click", ".first_page", function(e){
|
||||||
e.preventDefault();
|
event.preventDefault();
|
||||||
List.dynamicContentPage(-10);
|
List.dynamicContentPage(-10);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -112,7 +112,6 @@ var Frontpage = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("channels").insertAdjacentHTML("beforeend", card.children[0].innerHTML);
|
document.getElementById("channels").insertAdjacentHTML("beforeend", card.children[0].innerHTML);
|
||||||
//console.log(card.children[0].children[0]);
|
|
||||||
} else {
|
} else {
|
||||||
num--;
|
num--;
|
||||||
}
|
}
|
||||||
@@ -312,7 +311,6 @@ var Frontpage = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
to_channel: function(new_channel, popstate) {
|
to_channel: function(new_channel, popstate) {
|
||||||
console.log(new_channel);
|
|
||||||
Helper.css("#channel-load", "display", "block");
|
Helper.css("#channel-load", "display", "block");
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
frontpage = false;
|
frontpage = false;
|
||||||
@@ -375,7 +373,7 @@ var Frontpage = {
|
|||||||
document.getElementsByTagName("main")[0].innerHTML = response.querySelectorAll("main")[0].innerHTML;
|
document.getElementsByTagName("main")[0].innerHTML = response.querySelectorAll("main")[0].innerHTML;
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("main-row").insertAdjacentHTML("beforeend", response.querySelectorAll("#playlist")[0].outerHTML);
|
document.getElementById("main-row").insertAdjacentHTML("beforeend", response.querySelectorAll("#playlist")[0].outerHTML);
|
||||||
document.getElementById("video-container").insertAdjacentHTML("beforeend", response.querySelectorAll("#main_components")[0].outerHTML);
|
if(!client) document.getElementById("video-container").insertAdjacentHTML("beforeend", response.querySelectorAll("#main_components")[0].outerHTML);
|
||||||
document.getElementById("main-row").insertAdjacentHTML("beforeend", "<div id='playbar'></div>");
|
document.getElementById("main-row").insertAdjacentHTML("beforeend", "<div id='playbar'></div>");
|
||||||
Helper.removeClass("#player", "player_bottom");
|
Helper.removeClass("#player", "player_bottom");
|
||||||
Helper.removeClass("#main-row", "frontpage_modified_heights");
|
Helper.removeClass("#main-row", "frontpage_modified_heights");
|
||||||
|
|||||||
@@ -216,7 +216,6 @@ function get_list_ajax() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function contextListener(that, e) {
|
function contextListener(that, e) {
|
||||||
console.log("here");
|
|
||||||
var parent = that.parentElement;
|
var parent = that.parentElement;
|
||||||
var suggested = false;
|
var suggested = false;
|
||||||
if(parent.id.indexOf("suggested-") > -1) suggested = true;
|
if(parent.id.indexOf("suggested-") > -1) suggested = true;
|
||||||
@@ -235,7 +234,6 @@ function contextListener(that, e) {
|
|||||||
} else if(top < 0) {
|
} else if(top < 0) {
|
||||||
top = 15;
|
top = 15;
|
||||||
}
|
}
|
||||||
console.log(event.pageX);
|
|
||||||
Helper.css(".context-menu-root", "left", left + "px");
|
Helper.css(".context-menu-root", "left", left + "px");
|
||||||
Helper.css(".context-menu-root", "top", top + "px");
|
Helper.css(".context-menu-root", "top", top + "px");
|
||||||
Helper.removeClass(".context-menu-root","hide");
|
Helper.removeClass(".context-menu-root","hide");
|
||||||
@@ -642,21 +640,27 @@ function change_offline(enabled, already_offline){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pagination_results(e) {
|
||||||
|
event.preventDefault();
|
||||||
|
var that = this;
|
||||||
|
var pageToken = that.getAttribute("data-pagination");
|
||||||
|
var searchInput = that.getAttribute("data-original-search");
|
||||||
|
|
||||||
|
Helper.addClass(".next-results-button", "disabled");
|
||||||
|
Helper.addClass(".prev-results-button", "disabled");
|
||||||
|
Search.search(searchInput, false, false, pageToken);
|
||||||
|
}
|
||||||
|
|
||||||
function handleEvent(e, target, tried, type) {
|
function handleEvent(e, target, tried, type) {
|
||||||
//console.log(target, dynamicListeners);
|
|
||||||
//console.log(e.path, target);
|
|
||||||
console.log(target);
|
|
||||||
for(var y = 0; y < e.path.length; y++) {
|
for(var y = 0; y < e.path.length; y++) {
|
||||||
var target = e.path[y];
|
var target = e.path[y];
|
||||||
if(dynamicListeners[type] && dynamicListeners[type]["#" + target.id]) {
|
if(dynamicListeners[type] && dynamicListeners[type]["#" + target.id]) {
|
||||||
//console.log(target.id);
|
|
||||||
dynamicListeners[type]["#" + target.id].call(target);
|
dynamicListeners[type]["#" + target.id].call(target);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if(target.classList == undefined) return;
|
if(target.classList == undefined) return;
|
||||||
for(var i = 0; i < target.classList.length; i++) {
|
for(var i = 0; i < target.classList.length; i++) {
|
||||||
if(dynamicListeners[type] && dynamicListeners[type]["." + target.classList[i]]) {
|
if(dynamicListeners[type] && dynamicListeners[type]["." + target.classList[i]]) {
|
||||||
//console.log(target.id);
|
|
||||||
dynamicListeners[type]["." + target.classList[i]].call(target);
|
dynamicListeners[type]["." + target.classList[i]].call(target);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ var Helper = {
|
|||||||
logs: [],
|
logs: [],
|
||||||
log: function(to_log) {
|
log: function(to_log) {
|
||||||
if(localStorage.debug === "true") {
|
if(localStorage.debug === "true") {
|
||||||
console.log("------------ " + new Date() + " ------------");
|
console.log("------------ " + new Date() + " ------------");/*RemoveLogging:skip*/
|
||||||
for(var i = 0; i < to_log.length; i++) {
|
for(var i = 0; i < to_log.length; i++) {
|
||||||
console.log(to_log[i]);
|
console.log(to_log[i]);/*RemoveLogging:skip*/
|
||||||
}
|
}
|
||||||
console.log("------------ " + new Date() + " ------------");
|
console.log("------------ " + new Date() + " ------------");/*RemoveLogging:skip*/
|
||||||
}
|
}
|
||||||
Helper.logs.unshift({log: to_log, date: new Date()});
|
Helper.logs.unshift({log: to_log, date: new Date()});
|
||||||
if(Helper.logs.length > 10) {
|
if(Helper.logs.length > 10) {
|
||||||
@@ -19,46 +19,48 @@ var Helper = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
toggleClass: function(element, className) {
|
toggleClass: function(element, className) {
|
||||||
if(typeof(element) == "object") {
|
try {
|
||||||
if(element.className.indexOf(className) == -1) {
|
if(typeof(element) == "object") {
|
||||||
Helper.addClass(element, className);
|
if(element.className.indexOf(className) == -1) {
|
||||||
} else {
|
Helper.addClass(element, className);
|
||||||
Helper.removeClass(element, className);
|
|
||||||
}
|
|
||||||
} else if(element.substring(0,1) == "#") {
|
|
||||||
var elem = document.getElementById(element.substring(1));
|
|
||||||
if(elem.className.indexOf(className) == -1) {
|
|
||||||
Helper.addClass(elem, className);
|
|
||||||
} else {
|
|
||||||
Helper.removeClass(elem, className);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var elements;
|
|
||||||
if(element.substring(0,1) == ".") {
|
|
||||||
var testSplit = element.substring(1).split(" ");
|
|
||||||
if(testSplit.length > 1) {
|
|
||||||
var insideElement = document.getElementsByClassName(testSplit[0]);
|
|
||||||
elements = [];
|
|
||||||
for(var i = 0; i < insideElement.length; i++) {
|
|
||||||
var innards = insideElement[i].querySelectorAll(testSplit[1]);
|
|
||||||
for(var y = 0; y < innards.length; y++) {
|
|
||||||
elements.push(innards[y]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
elements = document.getElementsByClassName(element.substring(1));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
elements = document.getElementsByTagName(element);
|
|
||||||
}
|
|
||||||
for(var i = 0; i < elements.length; i++) {
|
|
||||||
if(elements[i].className.indexOf(className) == -1) {
|
|
||||||
Helper.addClass(elements[i], className);
|
|
||||||
} else {
|
|
||||||
Helper.removeClass(element, className);
|
Helper.removeClass(element, className);
|
||||||
}
|
}
|
||||||
|
} else if(element.substring(0,1) == "#") {
|
||||||
|
var elem = document.getElementById(element.substring(1));
|
||||||
|
if(elem.className.indexOf(className) == -1) {
|
||||||
|
Helper.addClass(elem, className);
|
||||||
|
} else {
|
||||||
|
Helper.removeClass(elem, className);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var elements;
|
||||||
|
if(element.substring(0,1) == ".") {
|
||||||
|
var testSplit = element.substring(1).split(" ");
|
||||||
|
if(testSplit.length > 1) {
|
||||||
|
var insideElement = document.getElementsByClassName(testSplit[0]);
|
||||||
|
elements = [];
|
||||||
|
for(var i = 0; i < insideElement.length; i++) {
|
||||||
|
var innards = insideElement[i].querySelectorAll(testSplit[1]);
|
||||||
|
for(var y = 0; y < innards.length; y++) {
|
||||||
|
elements.push(innards[y]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
elements = document.getElementsByClassName(element.substring(1));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
elements = document.getElementsByTagName(element);
|
||||||
|
}
|
||||||
|
for(var i = 0; i < elements.length; i++) {
|
||||||
|
if(elements[i].className.indexOf(className) == -1) {
|
||||||
|
Helper.addClass(elements[i], className);
|
||||||
|
} else {
|
||||||
|
Helper.removeClass(element, className);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}catch(e) {}
|
||||||
},
|
},
|
||||||
|
|
||||||
css: function(element, attribute, value) {
|
css: function(element, attribute, value) {
|
||||||
@@ -260,7 +262,6 @@ var Helper = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log(element);
|
|
||||||
if(element.className.indexOf(className) == -1) {
|
if(element.className.indexOf(className) == -1) {
|
||||||
element.className += " " + className;
|
element.className += " " + className;
|
||||||
}
|
}
|
||||||
@@ -294,7 +295,7 @@ var Helper = {
|
|||||||
var xmlhttp = new XMLHttpRequest();
|
var xmlhttp = new XMLHttpRequest();
|
||||||
xmlhttp.onreadystatechange = function() {
|
xmlhttp.onreadystatechange = function() {
|
||||||
if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4
|
if (xmlhttp.readyState == XMLHttpRequest.DONE) { // XMLHttpRequest.DONE == 4
|
||||||
if (xmlhttp.status == 200) {
|
if (xmlhttp.status == 200 || xmlhttp.status == 201 || xmlhttp.status == 202) {
|
||||||
obj.success(xmlhttp.responseText, xmlhttp);
|
obj.success(xmlhttp.responseText, xmlhttp);
|
||||||
}
|
}
|
||||||
else if(obj.hasOwnProperty("error")){
|
else if(obj.hasOwnProperty("error")){
|
||||||
@@ -310,12 +311,6 @@ var Helper = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(obj.data) {
|
if(obj.data) {
|
||||||
var sendRequest = "";
|
|
||||||
if(typeof(obj.data) == "string") JSON.parse(obj.data);
|
|
||||||
for(key in obj.data) {
|
|
||||||
sendRequest += key + "=" + obj.data[key] + "&";
|
|
||||||
}
|
|
||||||
sendRequest = sendRequest.substring(0, sendRequest.length - 1);
|
|
||||||
if(typeof(obj.data) == "object") obj.data = JSON.stringify(obj.data);
|
if(typeof(obj.data) == "object") obj.data = JSON.stringify(obj.data);
|
||||||
//xmlhttp.send(sendRequest);
|
//xmlhttp.send(sendRequest);
|
||||||
xmlhttp.send(obj.data);
|
xmlhttp.send(obj.data);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ var Hostcontroller = {
|
|||||||
old_id: null,
|
old_id: null,
|
||||||
|
|
||||||
host_listener: function(id) {
|
host_listener: function(id) {
|
||||||
|
if(client) return;
|
||||||
Helper.log([
|
Helper.log([
|
||||||
"Host-listener triggered",
|
"Host-listener triggered",
|
||||||
"Host-listener id:" + id
|
"Host-listener id:" + id
|
||||||
@@ -15,15 +16,16 @@ var Hostcontroller = {
|
|||||||
began = false;
|
began = false;
|
||||||
Hostcontroller.old_id = id;
|
Hostcontroller.old_id = id;
|
||||||
}
|
}
|
||||||
|
var codeURL = window.location.protocol + "//remote."+window.location.hostname+"/"+id;
|
||||||
if(embed) {
|
if(embed) {
|
||||||
if(window.parentWindow && window.parentOrigin) {
|
if(window.parentWindow && window.parentOrigin) {
|
||||||
window.parentWindow.postMessage({type: "controller", id: id}, window.parentOrigin);
|
window.parentWindow.postMessage({type: "controller", id: id}, window.parentOrigin);
|
||||||
}
|
}
|
||||||
|
} else if(!embed) {
|
||||||
|
document.querySelector("#code-text").innerText = id;
|
||||||
|
document.querySelector("#code-qr").setAttribute("src", "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+codeURL);
|
||||||
|
document.querySelector("#code-link").setAttribute("href", codeURL);
|
||||||
}
|
}
|
||||||
var codeURL = window.location.protocol + "//remote."+window.location.hostname+"/"+id;
|
|
||||||
document.querySelector("#code-text").innerText = id;
|
|
||||||
document.querySelector("#code-qr").setAttribute("src", "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+codeURL);
|
|
||||||
document.querySelector("#code-link").setAttribute("href", codeURL);
|
|
||||||
if(!began) {
|
if(!began) {
|
||||||
began = true;
|
began = true;
|
||||||
setup_host_listener(id);
|
setup_host_listener(id);
|
||||||
@@ -31,6 +33,7 @@ var Hostcontroller = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
host_on_action: function(arr) {
|
host_on_action: function(arr) {
|
||||||
|
if(client) return;
|
||||||
if(enabled){
|
if(enabled){
|
||||||
if(arr.type == "volume") {
|
if(arr.type == "volume") {
|
||||||
Playercontrols.visualVolume(arr.value);
|
Playercontrols.visualVolume(arr.value);
|
||||||
@@ -61,7 +64,10 @@ var Hostcontroller = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
change_enabled:function(val){
|
change_enabled:function(val){
|
||||||
|
if(client) return;
|
||||||
enabled = val;
|
enabled = val;
|
||||||
document.querySelector(".remote_switch_class").checked = enabled;
|
try {
|
||||||
|
document.querySelector(".remote_switch_class").checked = enabled;
|
||||||
|
}catch(e) {}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ var List = {
|
|||||||
|
|
||||||
empty: false,
|
empty: false,
|
||||||
page: 0,
|
page: 0,
|
||||||
can_fit: document.querySelectorAll("#wrapper").length > 0 ? Math.round((window.getComputedStyle(document.querySelector("#wrapper"), null).getPropertyValue("height")) / 71) : 0,
|
can_fit: document.querySelectorAll("#wrapper").length > 0 ? Math.round(parseInt(window.getComputedStyle(document.querySelector("#wrapper"), null).getPropertyValue("height").replace("px", "")) / 71) : 0,
|
||||||
element_height: document.querySelectorAll("#wrapper").length > 0 ? ((window.getComputedStyle(document.querySelector("#wrapper"), null).getPropertyValue("height")) / Math.round((window.getComputedStyle(document.querySelector("#wrapper"), null).getPropertyValue("height")) / 71)) - 25 : 0,
|
element_height: document.querySelectorAll("#wrapper").length > 0 ? (parseInt(window.getComputedStyle(document.querySelector("#wrapper"), null).getPropertyValue("height").replace("px", "")) / Math.round(parseInt(window.getComputedStyle(document.querySelector("#wrapper"), null).getPropertyValue("height").replace("px", "")) / 71)) - 25 : 0,
|
||||||
uris: [],
|
uris: [],
|
||||||
not_found: [],
|
not_found: [],
|
||||||
num_songs: 0,
|
num_songs: 0,
|
||||||
@@ -159,17 +159,17 @@ var List = {
|
|||||||
List.can_fit = Math.round((document.querySelector("#wrapper").offsetHeight) / 91) + 1;
|
List.can_fit = Math.round((document.querySelector("#wrapper").offsetHeight) / 91) + 1;
|
||||||
List.element_height = ((document.querySelector("#wrapper").offsetHeight) / List.can_fit)-4;
|
List.element_height = ((document.querySelector("#wrapper").offsetHeight) / List.can_fit)-4;
|
||||||
} else if(!client){
|
} else if(!client){
|
||||||
List.can_fit = Math.round((window.innerHeight - window.getComputedStyle(document.querySelector(".tabs"), null).getPropertyValue("height") - window.getComputedStyle(document.querySelector("header"), null).getPropertyValue("height") - 64 - 40) / 71)+1;
|
List.can_fit = Math.round((window.innerHeight - parseInt(window.getComputedStyle(document.querySelector(".tabs"), null).getPropertyValue("height").replace("px", "")) - parseInt(window.getComputedStyle(document.querySelector("header"), null).getPropertyValue("height").replace("px", "")) - 64 - 40) / 71)+1;
|
||||||
List.element_height = ((window.innerHeight - window.getComputedStyle(document.querySelector(".tabs"), null).getPropertyValue("height") - window.getComputedStyle(document.querySelector("header"), null).getPropertyValue("height") - 64 - 40) / List.can_fit)-5;
|
List.element_height = ((window.innerHeight - parseInt(window.getComputedStyle(document.querySelector(".tabs"), null).getPropertyValue("height").replace("px", "")) - parseInt(window.getComputedStyle(document.querySelector("header"), null).getPropertyValue("height").replace("px", "")) - 64 - 40) / List.can_fit)-5;
|
||||||
} else {
|
} else {
|
||||||
List.can_fit = Math.round((window.innerHeight - window.getComputedStyle(document.querySelector("header"), null).getPropertyValue("height") - window.getComputedStyle(document.querySelector(".pageButtons"), null).getPropertyValue("height")) / 80)+1;
|
List.can_fit = Math.round((window.innerHeight - parseInt(window.getComputedStyle(document.querySelector("header"), null).getPropertyValue("height").replace("px", ""))) / 80)+1;
|
||||||
List.element_height = ((window.innerHeight - window.getComputedStyle(document.querySelector("header"), null).getPropertyValue("height") - window.getComputedStyle(document.querySelector(".pageButtons"), null).getPropertyValue("height")) / List.can_fit) - 8;
|
List.element_height = ((window.innerHeight - parseInt(window.getComputedStyle(document.querySelector("header"), null).getPropertyValue("height").replace("px", ""))) / List.can_fit) - 8;
|
||||||
}
|
}
|
||||||
if(List.element_height < 55.2 && !client){
|
if(List.element_height < 55.2 && !client){
|
||||||
List.can_fit = List.can_fit - 1;
|
List.can_fit = List.can_fit - 1;
|
||||||
List.element_height = 55.2;
|
List.element_height = 55.2;
|
||||||
List.can_fit = Math.round((window.innerHeight - window.getComputedStyle(document.querySelector(".tabs"), null).getPropertyValue("height") - window.getComputedStyle(document.querySelector("header"), null).getPropertyValue("height") - 64 - 40) / 71);
|
List.can_fit = Math.round((window.innerHeight - parseInt(window.getComputedStyle(document.querySelector(".tabs"), null).getPropertyValue("height").replace("px", "")) - parseInt(window.getComputedStyle(document.querySelector("header"), null).getPropertyValue("height").replace("px", "")) - 64 - 40) / 71);
|
||||||
List.element_height = ((window.innerHeight - window.getComputedStyle(document.querySelector(".tabs"), null).getPropertyValue("height") - window.getComputedStyle(document.querySelector("header"), null).getPropertyValue("height") - 64 - 40) / List.can_fit)-5;
|
List.element_height = ((window.innerHeight - parseInt(window.getComputedStyle(document.querySelector(".tabs"), null).getPropertyValue("height").replace("px", "")) - parseInt(window.getComputedStyle(document.querySelector("header"), null).getPropertyValue("height").replace("px", "")) - 64 - 40) / List.can_fit)-5;
|
||||||
}
|
}
|
||||||
if(list_html === undefined) list_html = Helper.html("#list-song-html");
|
if(list_html === undefined) list_html = Helper.html("#list-song-html");
|
||||||
full_playlist = msg;
|
full_playlist = msg;
|
||||||
@@ -316,7 +316,6 @@ var List = {
|
|||||||
if(way==-10) {
|
if(way==-10) {
|
||||||
Helper.css(wrapperChildren.slice(List.page, List.page + List.can_fit), "display", "none");
|
Helper.css(wrapperChildren.slice(List.page, List.page + List.can_fit), "display", "none");
|
||||||
List.page = 0;
|
List.page = 0;
|
||||||
//console.log(List.page, List.can_fit, wrapperChildren.slice(List.page, List.page + List.can_fit));
|
|
||||||
Helper.css(wrapperChildren.slice(List.page, List.page + List.can_fit), "display", "inline-flex");
|
Helper.css(wrapperChildren.slice(List.page, List.page + List.can_fit), "display", "inline-flex");
|
||||||
} else {
|
} else {
|
||||||
Helper.css(wrapperChildren.slice(List.page - List.can_fit, List.page), "display", "inline-flex");
|
Helper.css(wrapperChildren.slice(List.page - List.can_fit, List.page), "display", "inline-flex");
|
||||||
@@ -407,7 +406,6 @@ var List = {
|
|||||||
//Helper.css(document.querySelector("#wrapper").children[List.page + (List.can_fit)], "display", "inline-flex");
|
//Helper.css(document.querySelector("#wrapper").children[List.page + (List.can_fit)], "display", "inline-flex");
|
||||||
//Helper.css(document.querySelector("#wrapper").children[List.page + (List.can_fit)], "height", List.element_height + "px");
|
//Helper.css(document.querySelector("#wrapper").children[List.page + (List.can_fit)], "height", List.element_height + "px");
|
||||||
}
|
}
|
||||||
console.log(List.element_height);
|
|
||||||
if(List.page >= document.querySelector("#wrapper").children.length - 1){
|
if(List.page >= document.querySelector("#wrapper").children.length - 1){
|
||||||
List.dynamicContentPage(-1);
|
List.dynamicContentPage(-1);
|
||||||
Helper.css(".next_page_hide", "display", "inline-flex");
|
Helper.css(".next_page_hide", "display", "inline-flex");
|
||||||
@@ -641,10 +639,13 @@ var List = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
var i = 0;
|
var i = 0;
|
||||||
List.searchSpotify(full_playlist[i], playlist_id, user_id, full_playlist, i);
|
List.searchSpotify(full_playlist[i], playlist_id, user_id, full_playlist, i);
|
||||||
//});
|
//});
|
||||||
|
}, error: function(e) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}, error: function(e) {
|
||||||
|
console.log(e);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -748,7 +749,7 @@ var List = {
|
|||||||
List.addToSpotifyPlaylist(List.uris, playlist_id, user_id);
|
List.addToSpotifyPlaylist(List.uris, playlist_id, user_id);
|
||||||
Helper.addClass("#playlist_loader_export", "hide");
|
Helper.addClass("#playlist_loader_export", "hide");
|
||||||
}
|
}
|
||||||
if(document.querySelector(".exported-spotify-list").length == 0) {
|
if(document.querySelectorAll(".exported-spotify-list").length == 0) {
|
||||||
document.querySelector(".exported-list").insertAdjacentHTML("beforeend", "<a target='_blank' class='btn light exported-playlist exported-spotify-list' href='https://open.spotify.com/user/" + user_id + "/playlist/"+ playlist_id + "'>" + chan + "</a>");
|
document.querySelector(".exported-list").insertAdjacentHTML("beforeend", "<a target='_blank' class='btn light exported-playlist exported-spotify-list' href='https://open.spotify.com/user/" + user_id + "/playlist/"+ playlist_id + "'>" + chan + "</a>");
|
||||||
}
|
}
|
||||||
for(var i = 0; i < List.not_found.length; i++) {
|
for(var i = 0; i < List.not_found.length; i++) {
|
||||||
@@ -854,7 +855,7 @@ var List = {
|
|||||||
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]);
|
||||||
document.querySelector(".exported-list").insertAtBeginning("beforeend", "<a target='_blank' class='btn light exported-playlist' href='https://www.youtube.com/playlist?list=" + playlist_id + "'>" + chan + "</a>");
|
document.querySelector(".exported-list").insertAdjacentHTML("beforeend", "<a target='_blank' class='btn light exported-playlist' href='https://www.youtube.com/playlist?list=" + playlist_id + "'>" + chan + "</a>");
|
||||||
Helper.addClass("#playlist_loader_export", "hide");
|
Helper.addClass("#playlist_loader_export", "hide");
|
||||||
Helper.addClass(".current_number", "hide");
|
Helper.addClass(".current_number", "hide");
|
||||||
//$(".youtube_export_button").removeClass("hide");
|
//$(".youtube_export_button").removeClass("hide");
|
||||||
@@ -967,8 +968,9 @@ var List = {
|
|||||||
list_image.className += " list-suggested-image";
|
list_image.className += " list-suggested-image";
|
||||||
//song.querySelector(".list-image").setAttribute("class", song.querySelector(".list-image").getAttribute("class").replace("list-image", "list-suggested-image"));
|
//song.querySelector(".list-image").setAttribute("class", song.querySelector(".list-image").getAttribute("class").replace("list-image", "list-suggested-image"));
|
||||||
}
|
}
|
||||||
|
if(!embed) {
|
||||||
song.querySelector(".mobile-delete").remove();
|
song.querySelector(".mobile-delete").remove();
|
||||||
|
}
|
||||||
song.querySelector(".list-title").innerText = video_title;
|
song.querySelector(".list-title").innerText = video_title;
|
||||||
song.querySelector(".list-title").setAttribute("title", video_title);
|
song.querySelector(".list-title").setAttribute("title", video_title);
|
||||||
song.querySelector(attr).setAttribute("data-video-id", video_id);
|
song.querySelector(attr).setAttribute("data-video-id", video_id);
|
||||||
@@ -976,7 +978,6 @@ var List = {
|
|||||||
if(song.querySelectorAll(".list-suggested-image").length > 0) {
|
if(song.querySelectorAll(".list-suggested-image").length > 0) {
|
||||||
song.querySelector(".list-suggested-image").setAttribute(image_attr,video_thumb);
|
song.querySelector(".list-suggested-image").setAttribute(image_attr,video_thumb);
|
||||||
}
|
}
|
||||||
//console.log(del_attr, song.querySelector("."+del_attr));
|
|
||||||
//song.querySelector("."+del_attr).setAttribute("data-video-id", video_id);
|
//song.querySelector("."+del_attr).setAttribute("data-video-id", video_id);
|
||||||
return song.innerHTML;
|
return song.innerHTML;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -367,15 +367,8 @@ addListener("click", "#ethereum-address", function(e) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addListener("click", ".pagination-results a", function(e) {
|
addListener("click", ".prev-results-button", pagination_results);
|
||||||
event.preventDefault();
|
addListener("click", ".next-results-button", pagination_results);
|
||||||
var that = this;
|
|
||||||
var pageToken = that.getAttribute("data-pagination");
|
|
||||||
var searchInput = that.getAttribute("data-original-search");
|
|
||||||
|
|
||||||
Helper.addClass(".pagination-results a", "disabled");
|
|
||||||
Search.search(searchInput, false, false, pageToken);
|
|
||||||
});
|
|
||||||
|
|
||||||
addListener("click", "#settings", function(e) {
|
addListener("click", "#settings", function(e) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -395,7 +388,6 @@ addListener("click", ".accept-delete", function(e) {
|
|||||||
|
|
||||||
|
|
||||||
addListener("click", "#chat_submit", function(e){
|
addListener("click", "#chat_submit", function(e){
|
||||||
console.log(event);
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
Chat.chat(document.getElementById("chatForm").input);
|
Chat.chat(document.getElementById("chatForm").input);
|
||||||
@@ -472,7 +464,7 @@ addListener("click", ".copy-context-menu", function(e) {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var that = this;
|
var that = this;
|
||||||
var parent = that.parentElement;
|
var parent = that.parentElement;
|
||||||
var id = parent.attr("data-id");
|
var id = parent.getAttribute("data-id");
|
||||||
if(id != "") {
|
if(id != "") {
|
||||||
Helper.css(".copy_video_id", "display", "block");
|
Helper.css(".copy_video_id", "display", "block");
|
||||||
Helper.setHtml(".copy_video_id", "https://www.youtube.com/watch?v=" + id);
|
Helper.setHtml(".copy_video_id", "https://www.youtube.com/watch?v=" + id);
|
||||||
@@ -495,9 +487,9 @@ addListener("click", ".find-context-menu", function(e) {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var that = this;
|
var that = this;
|
||||||
var parent = that.parentElement;
|
var parent = that.parentElement;
|
||||||
var id = parent.attr("data-id");
|
var id = parent.getAttribute("data-id");
|
||||||
Search.search(id, false, true);
|
Search.search(id, false, true);
|
||||||
if(Helper.contains(document.getElementsByClassName(".search-container")[0].getAttribute("class").split(" "), "hide")) {
|
if(Helper.contains(document.getElementsByClassName("search-container")[0].getAttribute("class").split(" "), "hide")) {
|
||||||
Search.showSearch();
|
Search.showSearch();
|
||||||
}
|
}
|
||||||
Helper.addClass(".context-menu-root", "hide");
|
Helper.addClass(".context-menu-root", "hide");
|
||||||
@@ -654,9 +646,7 @@ document.addEventListener("keyup", function(e) {
|
|||||||
} else if((event.keyCode == 91 || event.keyCode == 17) && !find_started){
|
} else if((event.keyCode == 91 || event.keyCode == 17) && !find_started){
|
||||||
find_start = false;
|
find_start = false;
|
||||||
}
|
}
|
||||||
console.log("target = ", event.target);
|
|
||||||
if(event.target.classList.contains("search_input")) {
|
if(event.target.classList.contains("search_input")) {
|
||||||
console.log("To search");
|
|
||||||
searchTimeout(event);
|
searchTimeout(event);
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
@@ -696,7 +686,6 @@ document.addEventListener("input", function(e) {
|
|||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
document.addEventListener("change", function(e) {
|
document.addEventListener("change", function(e) {
|
||||||
console.log(e);
|
|
||||||
handleEvent(e, e.target, false, "change");
|
handleEvent(e, e.target, false, "change");
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
@@ -726,6 +715,7 @@ addListener("click", ".modal-close", function(e){
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
addListener("change", ".password_protected", function(e) {
|
addListener("change", ".password_protected", function(e) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if(this.checked) {
|
if(this.checked) {
|
||||||
@@ -736,7 +726,7 @@ addListener("change", ".password_protected", function(e) {
|
|||||||
Helper.addClass(".change_user_pass", "hide");
|
Helper.addClass(".change_user_pass", "hide");
|
||||||
Admin.save(true);
|
Admin.save(true);
|
||||||
}
|
}
|
||||||
});
|
});*/
|
||||||
|
|
||||||
addListener("submit", "#user-password-channel-form", function(e) {
|
addListener("submit", "#user-password-channel-form", function(e) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -808,7 +798,7 @@ addListener("click", ".delete-all-songs", function(e){
|
|||||||
M.Modal.getInstance(document.getElementById("delete_song_alert")).open();
|
M.Modal.getInstance(document.getElementById("delete_song_alert")).open();
|
||||||
});
|
});
|
||||||
|
|
||||||
addListener("click", ".not-exported-container .not-exported-element #extra-export-container-text .extra-add-text", function(){
|
addListener("click", ".extra-add-text", function(){
|
||||||
this.select();
|
this.select();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -889,7 +879,19 @@ addListener("change", '.offline_switch_class', function()
|
|||||||
|
|
||||||
addListener("change", '.conf', function()
|
addListener("change", '.conf', function()
|
||||||
{
|
{
|
||||||
Admin.save(false);
|
event.preventDefault();
|
||||||
|
if(this.classList.contains("password_protected")) {
|
||||||
|
if(this.checked) {
|
||||||
|
M.Modal.getInstance(document.getElementById("user_password")).open();
|
||||||
|
document.getElementById("user-pass-input").focus();
|
||||||
|
} else {
|
||||||
|
userpass = "";
|
||||||
|
Helper.addClass(".change_user_pass", "hide");
|
||||||
|
Admin.save(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Admin.save(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addListener("click", "#clickme", function(){
|
addListener("click", "#clickme", function(){
|
||||||
@@ -971,6 +973,7 @@ addListener("submit", "#listImport", function(e){
|
|||||||
addListener("submit", "#listImportZoff", function(e) {
|
addListener("submit", "#listImportZoff", function(e) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var new_channel = document.getElementById("import_zoff").value;
|
var new_channel = document.getElementById("import_zoff").value;
|
||||||
|
document.getElementById("import_zoff").value = "";
|
||||||
if(new_channel == "") {
|
if(new_channel == "") {
|
||||||
M.toast({html: "It seems you've entered a invalid channel-name.", displayLength: 4000});
|
M.toast({html: "It seems you've entered a invalid channel-name.", displayLength: 4000});
|
||||||
return;
|
return;
|
||||||
@@ -1410,7 +1413,6 @@ addListener("click", ".del_user_suggested", function(e){
|
|||||||
});
|
});
|
||||||
|
|
||||||
addListener("click", '#toast-container', function(){
|
addListener("click", '#toast-container', function(){
|
||||||
console.log(this);
|
|
||||||
var toastElement = document.querySelector('.toast');
|
var toastElement = document.querySelector('.toast');
|
||||||
var toastInstance = M.Toast.getInstance(toastElement);
|
var toastInstance = M.Toast.getInstance(toastElement);
|
||||||
toastInstance.dismiss();
|
toastInstance.dismiss();
|
||||||
@@ -1439,8 +1441,8 @@ addListener("click", ".generate-channel-name", function(e) {
|
|||||||
type: "GET",
|
type: "GET",
|
||||||
url: "/api/generate_name",
|
url: "/api/generate_name",
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
document.getElementsByClassName(".room_namer")[0].value = "";
|
document.getElementsByClassName("room-namer")[0].value = "";
|
||||||
document.getElementsByClassName(".room_namer")[0].value = response;
|
document.getElementsByClassName("room-namer")[0].value = response;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ var Player = {
|
|||||||
if(full_playlist[0].id == video_id && !mobile_beginning){
|
if(full_playlist[0].id == video_id && !mobile_beginning){
|
||||||
List.song_change(full_playlist[0].added);
|
List.song_change(full_playlist[0].added);
|
||||||
}
|
}
|
||||||
Suggestions.fetchYoutubeSuggests(video_id);
|
if(!client) Suggestions.fetchYoutubeSuggests(video_id);
|
||||||
}catch(e){}
|
}catch(e){}
|
||||||
|
|
||||||
Player.getTitle(song_title, viewers);
|
Player.getTitle(song_title, viewers);
|
||||||
@@ -533,7 +533,7 @@ var Player = {
|
|||||||
//var getTitleViews = document.getElementById('viewers');
|
//var getTitleViews = document.getElementById('viewers');
|
||||||
|
|
||||||
document.getElementById("song-title").innerText = title;
|
document.getElementById("song-title").innerText = title;
|
||||||
document.getElementById("viewers").innerHtml = outPutWord + " " + v;
|
if(!client) document.getElementById("viewers").innerHTML = outPutWord + " " + v;
|
||||||
document.getElementById("song-title").setAttribute("title", title);
|
document.getElementById("song-title").setAttribute("title", title);
|
||||||
//elem.title = title;
|
//elem.title = title;
|
||||||
if(chromecastAvailable){
|
if(chromecastAvailable){
|
||||||
@@ -624,7 +624,6 @@ var Player = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setBGimage: function(c){
|
setBGimage: function(c){
|
||||||
console.log(c);
|
|
||||||
var color = c.color;
|
var color = c.color;
|
||||||
if(window.location.pathname != "/" && ((offline && c.only) || (!offline && !c.only) || (!offline && c.only))) {
|
if(window.location.pathname != "/" && ((offline && c.only) || (!offline && !c.only) || (!offline && c.only))) {
|
||||||
document.getElementById("main-container").style.backgroundColor = Helper.rgbToHsl(color,true);
|
document.getElementById("main-container").style.backgroundColor = Helper.rgbToHsl(color,true);
|
||||||
|
|||||||
@@ -35,19 +35,15 @@ window.addEventListener("DOMContentLoaded", function (){
|
|||||||
|
|
||||||
|
|
||||||
function handleEvent(e, target, tried, type) {
|
function handleEvent(e, target, tried, type) {
|
||||||
//console.log(target, dynamicListeners);
|
|
||||||
//console.log(e.path, target);
|
|
||||||
for(var y = 0; y < e.path.length; y++) {
|
for(var y = 0; y < e.path.length; y++) {
|
||||||
var target = e.path[y];
|
var target = e.path[y];
|
||||||
if(dynamicListeners[type] && dynamicListeners[type]["#" + target.id]) {
|
if(dynamicListeners[type] && dynamicListeners[type]["#" + target.id]) {
|
||||||
//console.log(target.id);
|
|
||||||
dynamicListeners[type]["#" + target.id].call(target);
|
dynamicListeners[type]["#" + target.id].call(target);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if(target.classList == undefined) return;
|
if(target.classList == undefined) return;
|
||||||
for(var i = 0; i < target.classList.length; i++) {
|
for(var i = 0; i < target.classList.length; i++) {
|
||||||
if(dynamicListeners[type] && dynamicListeners[type]["." + target.classList[i]]) {
|
if(dynamicListeners[type] && dynamicListeners[type]["." + target.classList[i]]) {
|
||||||
//console.log(target.id);
|
|
||||||
dynamicListeners[type]["." + target.classList[i]].call(target);
|
dynamicListeners[type]["." + target.classList[i]].call(target);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ var Search = {
|
|||||||
document.getElementById("results").innerHTML = "";
|
document.getElementById("results").innerHTML = "";
|
||||||
Helper.css("#results", "display", "block");
|
Helper.css("#results", "display", "block");
|
||||||
//$("<div style='display:none;' id='inner-results' class='empty-inner-results'>"+empty_results_html+"</div>").appendTo($("#results")).show("blind", 83.33);
|
//$("<div style='display:none;' id='inner-results' class='empty-inner-results'>"+empty_results_html+"</div>").appendTo($("#results")).show("blind", 83.33);
|
||||||
document.getElementById("results").insertAdjacentHTML("beforeend", "<div style='display:none;' id='inner-results' class='empty-inner-results'>"+empty_results_html+"</div>");
|
document.getElementById("results").insertAdjacentHTML("beforeend", "<div style='display:block;' id='inner-results' style='height:calc(100vh - 64px);' class='empty-inner-results'>"+empty_results_html+"</div>");
|
||||||
Helper.removeClass(".search_loader_spinner", "active");
|
Helper.removeClass(".search_loader_spinner", "active");
|
||||||
|
|
||||||
} else if(response.items){
|
} else if(response.items){
|
||||||
@@ -84,7 +84,6 @@ var Search = {
|
|||||||
success: function(response){
|
success: function(response){
|
||||||
response = JSON.parse(response);
|
response = JSON.parse(response);
|
||||||
var output = "";
|
var output = "";
|
||||||
console.log(result_html);
|
|
||||||
var pre_result = document.createElement("div");
|
var pre_result = document.createElement("div");
|
||||||
pre_result.innerHTML = result_html.outerHTML;
|
pre_result.innerHTML = result_html.outerHTML;
|
||||||
|
|
||||||
@@ -104,7 +103,6 @@ var Search = {
|
|||||||
|
|
||||||
//$("#results").append(result_html);
|
//$("#results").append(result_html);
|
||||||
var songs = pre_result.cloneNode(true);
|
var songs = pre_result.cloneNode(true);
|
||||||
console.log(songs);
|
|
||||||
songs.querySelector(".search-title").innerText = title;
|
songs.querySelector(".search-title").innerText = title;
|
||||||
songs.querySelector(".result_info").innerText = Helper.pad(_temp_duration[0]) + ":" + Helper.pad(_temp_duration[1]);
|
songs.querySelector(".result_info").innerText = Helper.pad(_temp_duration[0]) + ":" + Helper.pad(_temp_duration[1]);
|
||||||
songs.querySelector(".thumb").setAttribute("src", thumb);
|
songs.querySelector(".thumb").setAttribute("src", thumb);
|
||||||
@@ -154,7 +152,7 @@ var Search = {
|
|||||||
Helper.addClass(".prev-results-button", "disabled");
|
Helper.addClass(".prev-results-button", "disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
Helper.attr(".pagination-results a", "data-original-search", search_input);
|
document.querySelector(".pagination-results a").setAttribute("data-original-search", search_input);
|
||||||
|
|
||||||
//setTimeout(function(){$(".thumb").lazyload({container: $("#results")});}, 250);
|
//setTimeout(function(){$(".thumb").lazyload({container: $("#results")});}, 250);
|
||||||
|
|
||||||
@@ -165,7 +163,7 @@ var Search = {
|
|||||||
Search.search(search_input, true);
|
Search.search(search_input, true);
|
||||||
} else {
|
} else {
|
||||||
//$("<div style='display:none;' id='inner-results'>"+empty_results_html+"</div>").appendTo($("#results")).show("blind", 83.33);
|
//$("<div style='display:none;' id='inner-results'>"+empty_results_html+"</div>").appendTo($("#results")).show("blind", 83.33);
|
||||||
document.getElementById("results").insertAdjacentHTML("beforeend", "<div style='display:block;' id='inner-results'>"+empty_results_html+"</div>");
|
document.getElementById("results").insertAdjacentHTML("beforeend", "<div style='display:block;' id='inner-results' style='height:calc(100vh - 64px);'>"+empty_results_html+"</div>");
|
||||||
Helper.css("#results", "display", "block");
|
Helper.css("#results", "display", "block");
|
||||||
Helper.removeClass(".search_loader_spinner", "active");
|
Helper.removeClass(".search_loader_spinner", "active");
|
||||||
}
|
}
|
||||||
@@ -212,7 +210,7 @@ var Search = {
|
|||||||
document.querySelector(".not-imported-container").insertAdjacentHTML("beforeend", not_added_song.innerHTML);
|
document.querySelector(".not-imported-container").insertAdjacentHTML("beforeend", not_added_song.innerHTML);
|
||||||
Helper.removeClass(".not-imported", "hide");
|
Helper.removeClass(".not-imported", "hide");
|
||||||
} else if(response.items.length > 0) {
|
} else if(response.items.length > 0) {
|
||||||
for(var i = 0; i < response.items; i++) {
|
for(var i = 0; i < response.items.length; i++) {
|
||||||
var data = response.items[i];
|
var data = response.items[i];
|
||||||
vid_url += data.id.videoId+",";
|
vid_url += data.id.videoId+",";
|
||||||
}
|
}
|
||||||
@@ -225,8 +223,8 @@ var Search = {
|
|||||||
response = JSON.parse(response);
|
response = JSON.parse(response);
|
||||||
if(response.items.length > 0) {
|
if(response.items.length > 0) {
|
||||||
var matched = false;
|
var matched = false;
|
||||||
for(var i = 0; i < response.items.length; i++) {
|
for(var y = 0; y < response.items.length; y++) {
|
||||||
var data = response.items[i];
|
var data = response.items[y];
|
||||||
//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);
|
||||||
@@ -276,10 +274,15 @@ var Search = {
|
|||||||
Helper.removeClass(".not-imported", "hide");
|
Helper.removeClass(".not-imported", "hide");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
error: function(e) {
|
||||||
|
console.log(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}, error: function(e) {
|
||||||
|
console.log(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -399,12 +402,45 @@ var Search = {
|
|||||||
}
|
}
|
||||||
document.getElementById("import").value = "";
|
document.getElementById("import").value = "";
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
error: function(e) {
|
||||||
|
if(e.status == 403){
|
||||||
|
var nonce = Helper.randomString(29);
|
||||||
|
window.callback = function(data) {
|
||||||
|
access_token_data_youtube = data;
|
||||||
|
if(access_token_data_youtube.state == nonce){
|
||||||
|
youtube_authenticated = true;
|
||||||
|
setTimeout(function(){
|
||||||
|
youtube_authenticated = false;
|
||||||
|
access_token_data_youtube = {};
|
||||||
|
}, access_token_data_youtube.expires_in * 1000);
|
||||||
|
Search.importPlaylist(pId, pageToken);
|
||||||
|
} else {
|
||||||
|
access_token_data_youtube = "";
|
||||||
|
console.error("Nonce doesn't match");
|
||||||
|
}
|
||||||
|
youtube_window.close();
|
||||||
|
window.callback = "";
|
||||||
|
};
|
||||||
|
youtube_window = window.open("/o_callback#youtube=true&nonce=" + nonce, "", "width=600, height=600");
|
||||||
|
} else {
|
||||||
|
Helper.log([
|
||||||
|
"import list error: ",
|
||||||
|
response.error
|
||||||
|
]);
|
||||||
|
document.getElementById("import").disabled = false;
|
||||||
|
Helper.addClass("#playlist_loader", "hide");
|
||||||
|
Helper.removeClass("#import", "hide");
|
||||||
|
before_toast();
|
||||||
|
M.toast({html: "It seems you've entered a invalid url.", displayLength: 4000});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
importSpotifyPlaylist: function(url){
|
importSpotifyPlaylist: function(url){
|
||||||
Helper.ajax({
|
Helper.ajax({
|
||||||
|
method: "get",
|
||||||
url: url,
|
url: url,
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': 'Bearer ' + access_token_data.access_token
|
'Authorization': 'Bearer ' + access_token_data.access_token
|
||||||
@@ -421,7 +457,7 @@ var Search = {
|
|||||||
Search.importSpotifyPlaylist(response.next);
|
Search.importSpotifyPlaylist(response.next);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function(e) {
|
||||||
document.getElementById("import_spotify").disabled = false;
|
document.getElementById("import_spotify").disabled = false;
|
||||||
Helper.removeClass("#import_spotify", "hide");
|
Helper.removeClass("#import_spotify", "hide");
|
||||||
Helper.addClass("#playlist_loader_spotify", "hide");
|
Helper.addClass("#playlist_loader_spotify", "hide");
|
||||||
@@ -434,7 +470,7 @@ var Search = {
|
|||||||
addVideos: function(ids){
|
addVideos: function(ids){
|
||||||
var more = false;
|
var more = false;
|
||||||
var next_ids = [];
|
var next_ids = [];
|
||||||
var request_url="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key=***REMOVED***&id=";
|
var request_url="https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet,id&key=" + api_key + "&id=";
|
||||||
for(var i = 0; i < ids.length; i++) {
|
for(var i = 0; i < ids.length; i++) {
|
||||||
if(i > 48) {
|
if(i > 48) {
|
||||||
more = true;
|
more = true;
|
||||||
@@ -443,11 +479,9 @@ var Search = {
|
|||||||
}
|
}
|
||||||
request_url += ids[i] + ",";
|
request_url += ids[i] + ",";
|
||||||
}
|
}
|
||||||
|
|
||||||
Helper.ajax({
|
Helper.ajax({
|
||||||
type: "POST",
|
type: "GET",
|
||||||
url: request_url,
|
url: request_url,
|
||||||
dataType:"jsonp",
|
|
||||||
success: function(response){
|
success: function(response){
|
||||||
response = JSON.parse(response);
|
response = JSON.parse(response);
|
||||||
var x = 0;
|
var x = 0;
|
||||||
@@ -470,6 +504,9 @@ var Search = {
|
|||||||
Search.submitYouTubeArray = [];
|
Search.submitYouTubeArray = [];
|
||||||
Search.submitYouTubeExpected = 0;
|
Search.submitYouTubeExpected = 0;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
error: function(e) {
|
||||||
|
console.log(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user