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 { | ||||
|     height: calc(100vh - 64px); | ||||
|     height: calc(100vh - 64px - 76px); | ||||
|     overflow-y: scroll; | ||||
|     overflow-x: hidden; | ||||
| } | ||||
|  | ||||
| .empty-inner-results { | ||||
|     height: calc(100vh - 64px) !important; | ||||
| } | ||||
|  | ||||
| #empty-results { | ||||
|     text-align:center; | ||||
|     height:100px; | ||||
|     height:calc(100vh - 64px); | ||||
|     cursor: default; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -117,7 +117,9 @@ var Channel = { | ||||
|             setup_youtube_listener(); | ||||
|             get_list_listener(); | ||||
|             setup_suggested_listener(); | ||||
|             if(!client) { | ||||
|                 setup_viewers_listener(); | ||||
|             } | ||||
|         } else { | ||||
|             Helper.css("#channel-load", "display", "none"); | ||||
|             Helper.css("#player", "opacity", "1"); | ||||
| @@ -273,11 +275,11 @@ var Channel = { | ||||
|         //$("#results" ).hover( function() { Helper.removeClass(".result", "hoverResults"); i = 0; }, function(){ }); | ||||
|         document.getElementById("search").focus(); | ||||
|         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..."); | ||||
|  | ||||
|         if(!client) { | ||||
|             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){ | ||||
| @@ -451,6 +453,7 @@ var Channel = { | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         if(!client) { | ||||
|             if(on) { | ||||
|                 document.getElementById("chatchannel").addEventListener("scroll", scrollListener); | ||||
|                 document.getElementById("chatall").addEventListener("scroll", scrollListener); | ||||
| @@ -458,6 +461,7 @@ var Channel = { | ||||
|                 document.getElementById("chatchannel").removeEventListener("scroll", scrollListener); | ||||
|                 document.getElementById("chatall").removeEventListener("scroll", scrollAllListener); | ||||
|             } | ||||
|         } | ||||
|     }, | ||||
|  | ||||
|     onepage_load: function(){ | ||||
|   | ||||
| @@ -66,9 +66,9 @@ function receiveMessage(event) { | ||||
| } | ||||
|  | ||||
| window.addEventListener("message", receiveMessage, false); | ||||
|  | ||||
| window.addEventListener("load", function() { | ||||
|  | ||||
| console.log("qq"); | ||||
| window.addEventListener("DOMContentLoaded", function() { | ||||
|     console.log("ads"); | ||||
|     if(hash.length >= 3 && hash[2] == "autoplay"){ | ||||
|         autoplay = true; | ||||
|         Helper.css("#player", "visibility", "hidden"); | ||||
| @@ -374,21 +374,21 @@ addListener("click", ".vote-container", function(e) { | ||||
| }); | ||||
|  | ||||
| addListener("click", ".prev_page", function(e) { | ||||
|     e.preventDefault(); | ||||
|     event.preventDefault(); | ||||
|     List.dynamicContentPage(-1); | ||||
| }); | ||||
|  | ||||
| addListener("click", ".next_page", function(e) { | ||||
|     e.preventDefault(); | ||||
|     event.preventDefault(); | ||||
|     List.dynamicContentPage(1); | ||||
| }); | ||||
|  | ||||
| addListener("click", ".last_page", function(e){ | ||||
|     e.preventDefault(); | ||||
|     event.preventDefault(); | ||||
|     List.dynamicContentPage(10); | ||||
| }); | ||||
|  | ||||
| addListener("click", ".first_page", function(e){ | ||||
|     e.preventDefault(); | ||||
|     event.preventDefault(); | ||||
|     List.dynamicContentPage(-10); | ||||
| }); | ||||
|   | ||||
| @@ -112,7 +112,6 @@ var Frontpage = { | ||||
|                     } | ||||
|  | ||||
|                     document.getElementById("channels").insertAdjacentHTML("beforeend", card.children[0].innerHTML); | ||||
|                     //console.log(card.children[0].children[0]); | ||||
|                 } else { | ||||
|                     num--; | ||||
|                 } | ||||
| @@ -312,7 +311,6 @@ var Frontpage = { | ||||
|     }, | ||||
|  | ||||
|     to_channel: function(new_channel, popstate) { | ||||
|         console.log(new_channel); | ||||
|         Helper.css("#channel-load", "display", "block"); | ||||
|         window.scrollTo(0, 0); | ||||
|         frontpage = false; | ||||
| @@ -375,7 +373,7 @@ var Frontpage = { | ||||
|                     document.getElementsByTagName("main")[0].innerHTML = response.querySelectorAll("main")[0].innerHTML; | ||||
|                 } else { | ||||
|                     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>"); | ||||
|                     Helper.removeClass("#player", "player_bottom"); | ||||
|                     Helper.removeClass("#main-row", "frontpage_modified_heights"); | ||||
|   | ||||
| @@ -216,7 +216,6 @@ function get_list_ajax() { | ||||
| } | ||||
|  | ||||
| function contextListener(that, e) { | ||||
|     console.log("here"); | ||||
|     var parent = that.parentElement; | ||||
|     var suggested = false; | ||||
|     if(parent.id.indexOf("suggested-") > -1) suggested = true; | ||||
| @@ -235,7 +234,6 @@ function contextListener(that, e) { | ||||
|     } else if(top < 0) { | ||||
|         top = 15; | ||||
|     } | ||||
|     console.log(event.pageX); | ||||
|     Helper.css(".context-menu-root", "left", left + "px"); | ||||
|     Helper.css(".context-menu-root", "top", top + "px"); | ||||
|     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) { | ||||
|     //console.log(target, dynamicListeners); | ||||
|     //console.log(e.path, target); | ||||
|     console.log(target); | ||||
|     for(var y = 0; y < e.path.length; y++) { | ||||
|         var target = e.path[y]; | ||||
|         if(dynamicListeners[type] && dynamicListeners[type]["#" + target.id]) { | ||||
|             //console.log(target.id); | ||||
|             dynamicListeners[type]["#" + target.id].call(target); | ||||
|             return; | ||||
|         } else { | ||||
|             if(target.classList == undefined) return; | ||||
|             for(var i = 0; i < target.classList.length; i++) { | ||||
|                 if(dynamicListeners[type] && dynamicListeners[type]["." + target.classList[i]]) { | ||||
|                     //console.log(target.id); | ||||
|                     dynamicListeners[type]["." + target.classList[i]].call(target); | ||||
|                     return; | ||||
|                 } | ||||
|   | ||||
| @@ -2,11 +2,11 @@ var Helper = { | ||||
|     logs: [], | ||||
|     log: function(to_log) { | ||||
|         if(localStorage.debug === "true") { | ||||
|             console.log("------------ " + new Date() + " ------------"); | ||||
|             console.log("------------ " + new Date() + " ------------");/*RemoveLogging:skip*/ | ||||
|             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()}); | ||||
|         if(Helper.logs.length > 10) { | ||||
| @@ -19,6 +19,7 @@ var Helper = { | ||||
|     }, | ||||
|  | ||||
|     toggleClass: function(element, className) { | ||||
|         try { | ||||
|             if(typeof(element) == "object") { | ||||
|                 if(element.className.indexOf(className) == -1) { | ||||
|                     Helper.addClass(element, className); | ||||
| @@ -59,6 +60,7 @@ var Helper = { | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         }catch(e) {} | ||||
|     }, | ||||
|  | ||||
|     css: function(element, attribute, value) { | ||||
| @@ -260,7 +262,6 @@ var Helper = { | ||||
|                         } | ||||
|                     } | ||||
|                 } catch(e) { | ||||
|                     console.log(element); | ||||
|                     if(element.className.indexOf(className) == -1) { | ||||
|                         element.className += " " + className; | ||||
|                     } | ||||
| @@ -294,7 +295,7 @@ var Helper = { | ||||
|         var xmlhttp = new XMLHttpRequest(); | ||||
|         xmlhttp.onreadystatechange = function() { | ||||
|             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); | ||||
|                } | ||||
|                else if(obj.hasOwnProperty("error")){ | ||||
| @@ -310,12 +311,6 @@ var Helper = { | ||||
|             } | ||||
|         } | ||||
|         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); | ||||
|             //xmlhttp.send(sendRequest); | ||||
|             xmlhttp.send(obj.data); | ||||
|   | ||||
| @@ -5,6 +5,7 @@ var Hostcontroller = { | ||||
|     old_id: null, | ||||
|  | ||||
|     host_listener: function(id) { | ||||
|         if(client) return; | ||||
|         Helper.log([ | ||||
|             "Host-listener triggered", | ||||
|             "Host-listener id:" + id | ||||
| @@ -15,15 +16,16 @@ var Hostcontroller = { | ||||
|             began = false; | ||||
|             Hostcontroller.old_id = id; | ||||
|         } | ||||
|         var codeURL = window.location.protocol + "//remote."+window.location.hostname+"/"+id; | ||||
|         if(embed) { | ||||
|             if(window.parentWindow && window.parentOrigin) { | ||||
|                 window.parentWindow.postMessage({type: "controller", id: id}, window.parentOrigin); | ||||
|             } | ||||
|         } | ||||
|         var codeURL = window.location.protocol + "//remote."+window.location.hostname+"/"+id; | ||||
|         } 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); | ||||
|         } | ||||
|         if(!began) { | ||||
|             began = true; | ||||
|             setup_host_listener(id); | ||||
| @@ -31,6 +33,7 @@ var Hostcontroller = { | ||||
|     }, | ||||
|  | ||||
|     host_on_action: function(arr) { | ||||
|         if(client) return; | ||||
|         if(enabled){ | ||||
|             if(arr.type == "volume") { | ||||
|                 Playercontrols.visualVolume(arr.value); | ||||
| @@ -61,7 +64,10 @@ var Hostcontroller = { | ||||
|     }, | ||||
|  | ||||
|     change_enabled:function(val){ | ||||
|         if(client) return; | ||||
|         enabled = val; | ||||
|         try { | ||||
|             document.querySelector(".remote_switch_class").checked = enabled; | ||||
|         }catch(e) {} | ||||
|     } | ||||
| }; | ||||
|   | ||||
| @@ -2,8 +2,8 @@ var List = { | ||||
|  | ||||
|     empty: false, | ||||
|     page: 0, | ||||
|     can_fit: document.querySelectorAll("#wrapper").length > 0 ? Math.round((window.getComputedStyle(document.querySelector("#wrapper"), null).getPropertyValue("height")) / 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, | ||||
|     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 ? (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: [], | ||||
|     not_found: [], | ||||
|     num_songs: 0, | ||||
| @@ -159,17 +159,17 @@ var List = { | ||||
|             List.can_fit = Math.round((document.querySelector("#wrapper").offsetHeight) / 91) + 1; | ||||
|             List.element_height = ((document.querySelector("#wrapper").offsetHeight) / List.can_fit)-4; | ||||
|         } 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.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.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 - 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 { | ||||
|             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.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.can_fit = Math.round((window.innerHeight - parseInt(window.getComputedStyle(document.querySelector("header"), null).getPropertyValue("height").replace("px", ""))) / 80)+1; | ||||
|             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){ | ||||
|             List.can_fit = List.can_fit - 1; | ||||
|             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.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.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 - 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"); | ||||
|         full_playlist = msg; | ||||
| @@ -316,7 +316,6 @@ var List = { | ||||
|             if(way==-10) { | ||||
|                 Helper.css(wrapperChildren.slice(List.page, List.page + List.can_fit), "display", "none"); | ||||
|                 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"); | ||||
|             } else { | ||||
|                 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)], "height", List.element_height + "px"); | ||||
|             } | ||||
|             console.log(List.element_height); | ||||
|             if(List.page >= document.querySelector("#wrapper").children.length - 1){ | ||||
|                 List.dynamicContentPage(-1); | ||||
|                 Helper.css(".next_page_hide", "display", "inline-flex"); | ||||
| @@ -643,8 +641,11 @@ var List = { | ||||
|                         var i = 0; | ||||
|                         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); | ||||
|                         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>"); | ||||
|                     } | ||||
|                     for(var i = 0; i < List.not_found.length; i++) { | ||||
| @@ -854,7 +855,7 @@ var List = { | ||||
|                 if(num == full_playlist.length - 1){ | ||||
|                     Helper.log(["All videoes added!"]); | ||||
|                     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(".current_number", "hide"); | ||||
|                     //$(".youtube_export_button").removeClass("hide"); | ||||
| @@ -967,8 +968,9 @@ var List = { | ||||
|             list_image.className += " 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(".list-title").innerText = video_title; | ||||
|         song.querySelector(".list-title").setAttribute("title", video_title); | ||||
|         song.querySelector(attr).setAttribute("data-video-id", video_id); | ||||
| @@ -976,7 +978,6 @@ var List = { | ||||
|         if(song.querySelectorAll(".list-suggested-image").length > 0) { | ||||
|             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); | ||||
|         return song.innerHTML; | ||||
|     }, | ||||
|   | ||||
| @@ -367,15 +367,8 @@ addListener("click", "#ethereum-address", function(e) { | ||||
|     } | ||||
| }); | ||||
|  | ||||
| addListener("click", ".pagination-results a", function(e) { | ||||
|     event.preventDefault(); | ||||
|     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", ".prev-results-button", pagination_results); | ||||
| addListener("click", ".next-results-button", pagination_results); | ||||
|  | ||||
| addListener("click", "#settings", function(e) { | ||||
|     event.preventDefault(); | ||||
| @@ -395,7 +388,6 @@ addListener("click", ".accept-delete", function(e) { | ||||
|  | ||||
|  | ||||
| addListener("click", "#chat_submit", function(e){ | ||||
|     console.log(event); | ||||
|     event.preventDefault(); | ||||
|     event.stopPropagation(); | ||||
|     Chat.chat(document.getElementById("chatForm").input); | ||||
| @@ -472,7 +464,7 @@ addListener("click", ".copy-context-menu", function(e) { | ||||
|     event.preventDefault(); | ||||
|     var that = this; | ||||
|     var parent = that.parentElement; | ||||
|     var id = parent.attr("data-id"); | ||||
|     var id = parent.getAttribute("data-id"); | ||||
|     if(id != "") { | ||||
|         Helper.css(".copy_video_id", "display", "block"); | ||||
|         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(); | ||||
|     var that = this; | ||||
|     var parent = that.parentElement; | ||||
|     var id = parent.attr("data-id"); | ||||
|     var id = parent.getAttribute("data-id"); | ||||
|     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(); | ||||
|     } | ||||
|     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){ | ||||
|         find_start = false; | ||||
|     } | ||||
|     console.log("target = ", event.target); | ||||
|     if(event.target.classList.contains("search_input")) { | ||||
|         console.log("To search"); | ||||
|         searchTimeout(event); | ||||
|     } | ||||
| }, false); | ||||
| @@ -696,7 +686,6 @@ document.addEventListener("input", function(e) { | ||||
| }, true); | ||||
|  | ||||
| document.addEventListener("change", function(e) { | ||||
|     console.log(e); | ||||
|     handleEvent(e, e.target, false, "change"); | ||||
| }, true); | ||||
|  | ||||
| @@ -726,6 +715,7 @@ addListener("click", ".modal-close", function(e){ | ||||
|     event.preventDefault(); | ||||
| }); | ||||
|  | ||||
| /* | ||||
| addListener("change", ".password_protected", function(e) { | ||||
|     event.preventDefault(); | ||||
|     if(this.checked) { | ||||
| @@ -736,7 +726,7 @@ addListener("change", ".password_protected", function(e) { | ||||
|         Helper.addClass(".change_user_pass", "hide"); | ||||
|         Admin.save(true); | ||||
|     } | ||||
| }); | ||||
| });*/ | ||||
|  | ||||
| addListener("submit", "#user-password-channel-form", function(e) { | ||||
|     event.preventDefault(); | ||||
| @@ -808,7 +798,7 @@ addListener("click", ".delete-all-songs", function(e){ | ||||
|     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(); | ||||
| }); | ||||
|  | ||||
| @@ -889,7 +879,19 @@ addListener("change", '.offline_switch_class', function() | ||||
|  | ||||
| addListener("change", '.conf', function() | ||||
| { | ||||
|     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(){ | ||||
| @@ -971,6 +973,7 @@ addListener("submit", "#listImport", function(e){ | ||||
| addListener("submit", "#listImportZoff", function(e) { | ||||
|     event.preventDefault(); | ||||
|     var new_channel = document.getElementById("import_zoff").value; | ||||
|     document.getElementById("import_zoff").value = ""; | ||||
|     if(new_channel == "") { | ||||
|         M.toast({html: "It seems you've entered a invalid channel-name.", displayLength: 4000}); | ||||
|         return; | ||||
| @@ -1410,7 +1413,6 @@ addListener("click", ".del_user_suggested", function(e){ | ||||
| }); | ||||
|  | ||||
| addListener("click", '#toast-container', function(){ | ||||
|     console.log(this); | ||||
|     var toastElement = document.querySelector('.toast'); | ||||
|      var toastInstance = M.Toast.getInstance(toastElement); | ||||
|      toastInstance.dismiss(); | ||||
| @@ -1439,8 +1441,8 @@ addListener("click", ".generate-channel-name", function(e) { | ||||
|         type: "GET", | ||||
|         url: "/api/generate_name", | ||||
|         success: function(response) { | ||||
|             document.getElementsByClassName(".room_namer")[0].value = ""; | ||||
|             document.getElementsByClassName(".room_namer")[0].value = response; | ||||
|             document.getElementsByClassName("room-namer")[0].value = ""; | ||||
|             document.getElementsByClassName("room-namer")[0].value = response; | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|   | ||||
| @@ -164,7 +164,7 @@ var Player = { | ||||
|                     if(full_playlist[0].id == video_id && !mobile_beginning){ | ||||
|                         List.song_change(full_playlist[0].added); | ||||
|                     } | ||||
|                     Suggestions.fetchYoutubeSuggests(video_id); | ||||
|                     if(!client) Suggestions.fetchYoutubeSuggests(video_id); | ||||
|                 }catch(e){} | ||||
|  | ||||
|                 Player.getTitle(song_title, viewers); | ||||
| @@ -533,7 +533,7 @@ var Player = { | ||||
|             //var getTitleViews = document.getElementById('viewers'); | ||||
|  | ||||
|             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); | ||||
|             //elem.title        = title; | ||||
|             if(chromecastAvailable){ | ||||
| @@ -624,7 +624,6 @@ var Player = { | ||||
|     }, | ||||
|  | ||||
|     setBGimage: function(c){ | ||||
|         console.log(c); | ||||
|         var color = c.color; | ||||
|         if(window.location.pathname != "/" && ((offline && c.only) || (!offline && !c.only) || (!offline && c.only))) { | ||||
|             document.getElementById("main-container").style.backgroundColor = Helper.rgbToHsl(color,true); | ||||
|   | ||||
| @@ -35,19 +35,15 @@ window.addEventListener("DOMContentLoaded", function (){ | ||||
|  | ||||
|  | ||||
| function handleEvent(e, target, tried, type) { | ||||
|     //console.log(target, dynamicListeners); | ||||
|     //console.log(e.path, target); | ||||
|     for(var y = 0; y < e.path.length; y++) { | ||||
|         var target = e.path[y]; | ||||
|         if(dynamicListeners[type] && dynamicListeners[type]["#" + target.id]) { | ||||
|             //console.log(target.id); | ||||
|             dynamicListeners[type]["#" + target.id].call(target); | ||||
|             return; | ||||
|         } else { | ||||
|             if(target.classList == undefined) return; | ||||
|             for(var i = 0; i < target.classList.length; i++) { | ||||
|                 if(dynamicListeners[type] && dynamicListeners[type]["." + target.classList[i]]) { | ||||
|                     //console.log(target.id); | ||||
|                     dynamicListeners[type]["." + target.classList[i]].call(target); | ||||
|                     return; | ||||
|                 } | ||||
|   | ||||
| @@ -69,7 +69,7 @@ var Search = { | ||||
|                         document.getElementById("results").innerHTML = ""; | ||||
|                         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); | ||||
|                         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"); | ||||
|  | ||||
|                     } else if(response.items){ | ||||
| @@ -84,7 +84,6 @@ var Search = { | ||||
|                             success: function(response){ | ||||
|                                 response = JSON.parse(response); | ||||
|                                 var output = ""; | ||||
|                                 console.log(result_html); | ||||
|                                 var pre_result = document.createElement("div"); | ||||
|                                 pre_result.innerHTML = result_html.outerHTML; | ||||
|  | ||||
| @@ -104,7 +103,6 @@ var Search = { | ||||
|  | ||||
|                                         //$("#results").append(result_html); | ||||
|                                         var songs = pre_result.cloneNode(true); | ||||
|                                         console.log(songs); | ||||
|                                         songs.querySelector(".search-title").innerText = title; | ||||
|                                         songs.querySelector(".result_info").innerText = Helper.pad(_temp_duration[0]) + ":" + Helper.pad(_temp_duration[1]); | ||||
|                                         songs.querySelector(".thumb").setAttribute("src", thumb); | ||||
| @@ -154,7 +152,7 @@ var Search = { | ||||
|                                         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); | ||||
|  | ||||
| @@ -165,7 +163,7 @@ var Search = { | ||||
|                                     Search.search(search_input, true); | ||||
|                                 } else { | ||||
|                                     //$("<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.removeClass(".search_loader_spinner", "active"); | ||||
|                                 } | ||||
| @@ -212,7 +210,7 @@ var Search = { | ||||
|                     document.querySelector(".not-imported-container").insertAdjacentHTML("beforeend", not_added_song.innerHTML); | ||||
|                     Helper.removeClass(".not-imported", "hide"); | ||||
|                 } 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]; | ||||
|                         vid_url += data.id.videoId+","; | ||||
|                     } | ||||
| @@ -225,8 +223,8 @@ var Search = { | ||||
|                             response = JSON.parse(response); | ||||
|                             if(response.items.length > 0) { | ||||
|                                 var matched = false; | ||||
|                                 for(var i = 0; i < response.items.length; i++) { | ||||
|                                     var data = response.items[i]; | ||||
|                                 for(var y = 0; y < response.items.length; y++) { | ||||
|                                     var data = response.items[y]; | ||||
|                                     //Helper.log(data); | ||||
|                                     //var title = data.snippet.title; | ||||
|                                     var duration = Search.durationToSeconds(data.contentDetails.duration); | ||||
| @@ -276,10 +274,15 @@ var Search = { | ||||
|                                     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 = ""; | ||||
|                 } | ||||
|             }, | ||||
|             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){ | ||||
|         Helper.ajax({ | ||||
|             method: "get", | ||||
|             url: url, | ||||
|             headers: { | ||||
|                 'Authorization': 'Bearer ' + access_token_data.access_token | ||||
| @@ -421,7 +457,7 @@ var Search = { | ||||
|                     Search.importSpotifyPlaylist(response.next); | ||||
|                 } | ||||
|             }, | ||||
|             error: function() { | ||||
|             error: function(e) { | ||||
|                 document.getElementById("import_spotify").disabled = false; | ||||
|                 Helper.removeClass("#import_spotify", "hide"); | ||||
|                 Helper.addClass("#playlist_loader_spotify", "hide"); | ||||
| @@ -434,7 +470,7 @@ var Search = { | ||||
|     addVideos: function(ids){ | ||||
|         var more = false; | ||||
|         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++) { | ||||
|             if(i > 48) { | ||||
|                 more = true; | ||||
| @@ -443,11 +479,9 @@ var Search = { | ||||
|             } | ||||
|             request_url += ids[i] + ","; | ||||
|         } | ||||
|  | ||||
|         Helper.ajax({ | ||||
|             type: "POST", | ||||
|             type: "GET", | ||||
|             url: request_url, | ||||
|             dataType:"jsonp", | ||||
|             success: function(response){ | ||||
|                 response = JSON.parse(response); | ||||
|                 var x = 0; | ||||
| @@ -470,6 +504,9 @@ var Search = { | ||||
|                     Search.submitYouTubeArray = []; | ||||
|                     Search.submitYouTubeExpected = 0; | ||||
|                 } | ||||
|             }, | ||||
|             error: function(e) { | ||||
|                 console.log(e); | ||||
|             } | ||||
|         }); | ||||
|     }, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user