mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Created dynamic listeners, and functions to add/remove listeners
This commit is contained in:
@@ -122,7 +122,6 @@ var Admin = {
|
|||||||
if(Helper.html("#admin-lock") != "lock") {
|
if(Helper.html("#admin-lock") != "lock") {
|
||||||
if(!Helper.mobilecheck()) {
|
if(!Helper.mobilecheck()) {
|
||||||
Helper.tooltip('#admin-lock', "destroy");
|
Helper.tooltip('#admin-lock', "destroy");
|
||||||
//$('#admin-lock').tooltip('destroy');
|
|
||||||
}
|
}
|
||||||
Helper.removeClass("#admin-lock", "clickable");
|
Helper.removeClass("#admin-lock", "clickable");
|
||||||
document.getElementById("admin-lock").innerHTML = "lock";
|
document.getElementById("admin-lock").innerHTML = "lock";
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ var Channel = {
|
|||||||
Helper.addClass(".tabs", "hide");
|
Helper.addClass(".tabs", "hide");
|
||||||
Helper.removeClass("#wrapper", "tabs_height");
|
Helper.removeClass("#wrapper", "tabs_height");
|
||||||
Helper.addClass("#wrapper", "client-wrapper");
|
Helper.addClass("#wrapper", "client-wrapper");
|
||||||
//$(".embed-button-footer").addClass("hide");
|
|
||||||
//$(".skip_next_client").removeClass("hide");
|
|
||||||
if(!Helper.mobilecheck()) {
|
if(!Helper.mobilecheck()) {
|
||||||
Helper.tooltip(".skip_next_client", {
|
Helper.tooltip(".skip_next_client", {
|
||||||
delay: 5,
|
delay: 5,
|
||||||
@@ -69,9 +67,7 @@ var Channel = {
|
|||||||
if(!client) {
|
if(!client) {
|
||||||
M.Modal.init(document.getElementById("embed"));
|
M.Modal.init(document.getElementById("embed"));
|
||||||
} else {
|
} else {
|
||||||
//$("#help").remove();
|
|
||||||
Helper.removeElement("#embed");
|
Helper.removeElement("#embed");
|
||||||
//$(".help-button-footer").remove();
|
|
||||||
Helper.removeElement(".embed-button-footer");
|
Helper.removeElement(".embed-button-footer");
|
||||||
Helper.removeElement(".tabs");
|
Helper.removeElement(".tabs");
|
||||||
}
|
}
|
||||||
@@ -87,13 +83,13 @@ var Channel = {
|
|||||||
|
|
||||||
Channel.spotify_is_authenticated(spotify_authenticated);
|
Channel.spotify_is_authenticated(spotify_authenticated);
|
||||||
|
|
||||||
result_html = $("#temp-results-container");
|
result_html = document.getElementById("temp-results-container");
|
||||||
pagination_buttons_html = $("<div>").append($(".pagination-results").clone()).html();
|
pagination_buttons_html = "<div>" + document.getElementsByClassName("pagination-results")[0].cloneNode(true).innerHTML + "</div>";
|
||||||
empty_results_html = Helper.html("#empty-results-container");
|
empty_results_html = Helper.html("#empty-results-container");
|
||||||
not_import_html = Helper.html(".not-imported-container");
|
not_import_html = Helper.html(".not-imported-container");
|
||||||
not_export_html = Helper.html(".not-exported-container");
|
not_export_html = Helper.html(".not-exported-container");
|
||||||
$(".not-imported-container").empty();
|
Helper.setHtml(".not-imported-container", "");
|
||||||
$(".not-exported-container").empty();
|
Helper.setHtml(".not-exported-container", "");
|
||||||
|
|
||||||
if(socket === undefined){
|
if(socket === undefined){
|
||||||
no_socket = false;
|
no_socket = false;
|
||||||
@@ -123,10 +119,10 @@ var Channel = {
|
|||||||
setup_suggested_listener();
|
setup_suggested_listener();
|
||||||
setup_viewers_listener();
|
setup_viewers_listener();
|
||||||
} else {
|
} else {
|
||||||
$("#channel-load").css("display", "none");
|
Helper.css("#channel-load", "display", "none");
|
||||||
$("#player").css("opacity", "1");
|
Helper.css("#player", "opacity", "1");
|
||||||
$("#controls").css("opacity", "1");
|
Helper.css("#controls", "opacity", "1");
|
||||||
$(".playlist").css("opacity", "1");
|
Helper.css(".playlist", "opacity", "1");
|
||||||
if(!client) {
|
if(!client) {
|
||||||
Player.readyLooks();
|
Player.readyLooks();
|
||||||
Playercontrols.initYoutubeControls(Player.player);
|
Playercontrols.initYoutubeControls(Player.player);
|
||||||
@@ -136,17 +132,17 @@ var Channel = {
|
|||||||
}
|
}
|
||||||
Helper.removeClass(".video-container", "no-opacity");
|
Helper.removeClass(".video-container", "no-opacity");
|
||||||
var codeURL = "https://remote."+window.location.hostname+"/"+id;
|
var codeURL = "https://remote."+window.location.hostname+"/"+id;
|
||||||
$("#code-text").text(id);
|
Helper.setHtml("#code-text", id);
|
||||||
$("#code-qr").attr("src", "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+codeURL);
|
document.getElementById("code-qr").setAttribute("src", "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+codeURL);
|
||||||
$("#code-link").attr("href", codeURL);
|
document.getElementById("code-link").setAttribute("href", codeURL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!client) {
|
if(!client) {
|
||||||
var shareCodeUrl = window.location.protocol + "//client."+window.location.hostname+"/"+chan.toLowerCase();
|
var shareCodeUrl = window.location.protocol + "//client."+window.location.hostname+"/"+chan.toLowerCase();
|
||||||
$("#share-join-qr").attr("src", "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+shareCodeUrl);
|
document.getElementById("share-join-qr").setAttribute("src", "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+shareCodeUrl);
|
||||||
$("#channel-name-join").text("client." + window.location.hostname + "/" + chan.toLowerCase());
|
Helper.setHtml("#channel-name-join", "client." + window.location.hostname + "/" + chan.toLowerCase());
|
||||||
} else {
|
} else {
|
||||||
Helper.removeElement(".video-container");
|
Helper.removeElement(".video-container");
|
||||||
Helper.removeElement(".offline-panel");
|
Helper.removeElement(".offline-panel");
|
||||||
@@ -160,10 +156,10 @@ var Channel = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(((!localStorage.getItem("_jSeen") || localStorage.getItem("_jSeen") != "seen") && !Helper.mobilecheck()) && !client) {
|
if(((!localStorage.getItem("_jSeen") || localStorage.getItem("_jSeen") != "seen") && !Helper.mobilecheck()) && !client) {
|
||||||
$('.tap-target-join').tapTarget();
|
var instance = M.TapTarget.init(document.getElementsByClassName('tap-target-join')[0]);
|
||||||
$('.tap-target-join').tapTarget('open');
|
instance.open();
|
||||||
tap_target_timeout = setTimeout(function() {
|
tap_target_timeout = setTimeout(function() {
|
||||||
$('.tap-target-join').tapTarget('close');
|
instance.close();
|
||||||
}, 4000);
|
}, 4000);
|
||||||
localStorage.setItem("_jSeen", "seen");
|
localStorage.setItem("_jSeen", "seen");
|
||||||
}
|
}
|
||||||
@@ -221,7 +217,7 @@ var Channel = {
|
|||||||
}
|
}
|
||||||
Helper.addClass(".close-settings", "hide");
|
Helper.addClass(".close-settings", "hide");
|
||||||
} else {
|
} else {
|
||||||
$('input#chan_description').characterCounter();
|
//$('input#chan_description').characterCounter();
|
||||||
if(!client) {
|
if(!client) {
|
||||||
Channel.window_width_volume_slider();
|
Channel.window_width_volume_slider();
|
||||||
}
|
}
|
||||||
@@ -241,7 +237,7 @@ var Channel = {
|
|||||||
|
|
||||||
if(!Helper.msieversion() && !Helper.mobilecheck() && !client) Notification.requestPermission();
|
if(!Helper.msieversion() && !Helper.mobilecheck() && !client) Notification.requestPermission();
|
||||||
|
|
||||||
$(".search_input").focus();
|
document.getElementsByClassName("search_input")[0].focus();
|
||||||
|
|
||||||
Helper.sample();
|
Helper.sample();
|
||||||
if(!Helper.mobilecheck() && !client) {
|
if(!Helper.mobilecheck() && !client) {
|
||||||
@@ -275,10 +271,10 @@ var Channel = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#results" ).hover( function() { Helper.removeClass(".result", "hoverResults"); i = 0; }, function(){ });
|
$("#results" ).hover( function() { Helper.removeClass(".result", "hoverResults"); i = 0; }, function(){ });
|
||||||
$("#search").focus();
|
document.getElementById("search").focus();
|
||||||
$("#embed-button").css("display", "inline-block");
|
Helper.css("#embed-button", "display", "inline-block");
|
||||||
$("#embed-area").val(embed_code(embed_autoplay, embed_width, embed_height, color));
|
document.getElementById("embed-area").value = embed_code(embed_autoplay, embed_width, embed_height, color);
|
||||||
$("#search").attr("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");
|
||||||
@@ -317,7 +313,7 @@ var Channel = {
|
|||||||
seekToClick: function(e){
|
seekToClick: function(e){
|
||||||
var acceptable = ["bar", "controls", "duration"];
|
var acceptable = ["bar", "controls", "duration"];
|
||||||
|
|
||||||
if(acceptable.indexOf($(e.target).attr("id")) >= 0) {
|
if(acceptable.indexOf(e.target.getAttribute("id")) >= 0) {
|
||||||
var total = full_playlist[full_playlist.length - 1].duration / $("#controls").width();
|
var total = full_playlist[full_playlist.length - 1].duration / $("#controls").width();
|
||||||
total = total * e.clientX;
|
total = total * e.clientX;
|
||||||
|
|
||||||
@@ -359,10 +355,10 @@ var Channel = {
|
|||||||
var _time = Helper.secondsToOther(total);
|
var _time = Helper.secondsToOther(total);
|
||||||
var _minutes = Helper.pad(_time[0]);
|
var _minutes = Helper.pad(_time[0]);
|
||||||
var _seconds = Helper.pad(Math.ceil(_time[1]));
|
var _seconds = Helper.pad(Math.ceil(_time[1]));
|
||||||
$("#seekToDuration").text(_minutes + ":" + _seconds);
|
Helper.setHtml("#seekToDuration", _minutes + ":" + _seconds);
|
||||||
|
|
||||||
var acceptable = ["bar", "controls", "duration"];
|
var acceptable = ["bar", "controls", "duration"];
|
||||||
if(acceptable.indexOf($(e.target).attr("id")) >= 0 && dragging) {
|
if(acceptable.indexOf(e.target.getAttribute("id")) >= 0 && dragging) {
|
||||||
$("#bar").width(((100 / duration) * total) + "%");
|
$("#bar").width(((100 / duration) * total) + "%");
|
||||||
}
|
}
|
||||||
} catch(e){}
|
} catch(e){}
|
||||||
@@ -391,30 +387,30 @@ var Channel = {
|
|||||||
"expires_in: " + access_token_data.expires_in
|
"expires_in: " + access_token_data.expires_in
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$(".spotify_authenticated").css("display", "block");
|
Helper.css(".spotify_authenticated", "display", "block");
|
||||||
$(".spotify_unauthenticated").css("display", "none");
|
Helper.css(".spotify_unauthenticated", "display", "none");
|
||||||
} else {
|
} else {
|
||||||
Helper.log(["Spotify is not authenticated"]);
|
Helper.log(["Spotify is not authenticated"]);
|
||||||
$(".spotify_authenticated").css("display", "none");
|
Helper.css(".spotify_authenticated", "display", "none");
|
||||||
$(".spotify_unauthenticated").css("display", "block");
|
Helper.css(".spotify_unauthenticated", "display", "block");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
add_context_menu: function() {
|
add_context_menu: function() {
|
||||||
$(document).on("contextmenu", ".vote-container", function(e) {
|
addListener("contextmenu", ".vote-container", function(e) {
|
||||||
e.preventDefault();
|
event.preventDefault();
|
||||||
var that = this;
|
var that = this;
|
||||||
contextListener(that, e);
|
contextListener(that, e);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("contextmenu", ".add-suggested", function(e) {
|
addListener("contextmenu", ".add-suggested", function(e) {
|
||||||
e.preventDefault();
|
event.preventDefault();
|
||||||
var that = this;
|
var that = this;
|
||||||
contextListener(that, e);
|
contextListener(that, e);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("click", ".list-remove", function(e) {
|
addListener("click", ".list-remove", function(e) {
|
||||||
e.preventDefault();
|
event.preventDefault();
|
||||||
var that = this;
|
var that = this;
|
||||||
contextListener(that, e);
|
contextListener(that, e);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,6 +18,49 @@ var Helper = {
|
|||||||
return arr[Math.floor(Math.random() * arr.length)];
|
return arr[Math.floor(Math.random() * arr.length)];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
toggleClass: function(element, className) {
|
||||||
|
if(typeof(element) == "object") {
|
||||||
|
if(element.className.indexOf(className) == -1) {
|
||||||
|
Helper.addClass(element, className);
|
||||||
|
} else {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
css: function(element, attribute, value) {
|
css: function(element, attribute, value) {
|
||||||
try {
|
try {
|
||||||
if(typeof(element) == "object") {
|
if(typeof(element) == "object") {
|
||||||
@@ -95,7 +138,9 @@ var Helper = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setHtml: function(element, html) {
|
setHtml: function(element, html) {
|
||||||
if(element.substring(0,1) == "#") {
|
if(typeof(element) == "object") {
|
||||||
|
element.innerHTML = html;
|
||||||
|
} else if(element.substring(0,1) == "#") {
|
||||||
var elem = document.getElementById(element.substring(1));
|
var elem = document.getElementById(element.substring(1));
|
||||||
elem.innerHTML = html;
|
elem.innerHTML = html;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -519,32 +519,32 @@ addListener("click", ".connect_error", function(e){
|
|||||||
|
|
||||||
addListener("click", ".extra-button-search", function(e){
|
addListener("click", ".extra-button-search", function(e){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$("#search").val($(this).attr("data-text"));
|
document.getElementById("search").value = this.getAttribute("data-text");
|
||||||
Search.search($(this).attr("data-text"));
|
Search.search(this.getAttribute("data-text"));
|
||||||
});
|
});
|
||||||
|
|
||||||
addListener("click", ".extra-button-delete", function(e){
|
addListener("click", ".extra-button-delete", function(e){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$(this).parent().remove();
|
this.parentElement.remove();
|
||||||
if($(".not-imported-container").children().length === 0){
|
if($(".not-imported-container").children().length === 0){
|
||||||
$(".not-imported").toggleClass("hide");
|
$(".not-imported").toggleClass("hide");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addListener("click", "#context-menu-overlay", function(e) {
|
addListener("click", "#context-menu-overlay", function(e) {
|
||||||
$(".context-menu-root").addClass("hide");
|
Helper.addClass(".context-menu-root", "hide");
|
||||||
$("#context-menu-overlay").addClass("hide");
|
Helper.addClass("#context-menu-overlay", "hide");
|
||||||
$(".context-menu-root").attr("data-id", "");
|
Helper.addClass(".context-menu-root", "data-id", "");
|
||||||
});
|
});
|
||||||
|
|
||||||
addListener("click", ".copy-context-menu", function(e) {
|
addListener("click", ".copy-context-menu", function(e) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var that = this;
|
var that = this;
|
||||||
var parent = $(that).parent();
|
var parent = that.parentElement;
|
||||||
var id = parent.attr("data-id");
|
var id = parent.attr("data-id");
|
||||||
if(id != "") {
|
if(id != "") {
|
||||||
$(".copy_video_id").css("display", "block");
|
Helper.css(".copy_video_id", "display", "block");
|
||||||
$(".copy_video_id").text("https://www.youtube.com/watch?v=" + id);
|
Helper.setHtml(".copy_video_id", "https://www.youtube.com/watch?v=" + id);
|
||||||
var copyTextarea = document.querySelector('.copy_video_id');
|
var copyTextarea = document.querySelector('.copy_video_id');
|
||||||
copyTextarea.select();
|
copyTextarea.select();
|
||||||
var successful = document.execCommand('copy');
|
var successful = document.execCommand('copy');
|
||||||
@@ -553,52 +553,52 @@ addListener("click", ".copy-context-menu", function(e) {
|
|||||||
} else {
|
} else {
|
||||||
M.toast({html: "Error copying..", displayLength: 2000, classes: "red lighten"});
|
M.toast({html: "Error copying..", displayLength: 2000, classes: "red lighten"});
|
||||||
}
|
}
|
||||||
$(".copy_video_id").css("display", "none");
|
Helper.css(".copy_video_id", "display", "none");
|
||||||
}
|
}
|
||||||
$(".context-menu-root").addClass("hide");
|
Helper.addClass(".context-menu-root", "hide");
|
||||||
$("#context-menu-overlay").addClass("hide");
|
Helper.addClass("#context-menu-overlay", "hide");
|
||||||
$(".context-menu-root").attr("data-id", "");
|
document.getElementsByClassName("context-menu-root")[0].setAttribute("data-id", "");
|
||||||
});
|
});
|
||||||
|
|
||||||
addListener("click", ".find-context-menu", function(e) {
|
addListener("click", ".find-context-menu", function(e) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var that = this;
|
var that = this;
|
||||||
var parent = $(that).parent();
|
var parent = that.parentElement;
|
||||||
var id = parent.attr("data-id");
|
var id = parent.attr("data-id");
|
||||||
Search.search(id, false, true);
|
Search.search(id, false, true);
|
||||||
if(Helper.contains($(".search-container").attr("class").split(" "), "hide")) {
|
if(Helper.contains(document.getElementsByClassName(".search-container")[0].getAttribute("class").split(" "), "hide")) {
|
||||||
Search.showSearch();
|
Search.showSearch();
|
||||||
}
|
}
|
||||||
$(".context-menu-root").addClass("hide");
|
Helper.addClass(".context-menu-root", "hide");
|
||||||
$("#context-menu-overlay").addClass("hide");
|
Helper.addClass("#context-menu-overlay", "hide");
|
||||||
$(".context-menu-root").attr("data-id", "");
|
document.getElementsByClassName("context-menu-root")[0].setAttribute("data-id", "");
|
||||||
});
|
});
|
||||||
|
|
||||||
addListener("click", ".delete-context-menu", function(e) {
|
addListener("click", ".delete-context-menu", function(e) {
|
||||||
var that = this;
|
var that = this;
|
||||||
if($(that).hasClass("context-menu-disabled")) {
|
if(that.classList.indexOf("context-menu-disabled") > -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var parent = $(that).parent();
|
var parent = that.parentElement;
|
||||||
var id = parent.attr("data-id");
|
var id = parent.getAttribute("data-id");
|
||||||
var suggested = parent.attr("data-suggested");
|
var suggested = parent.getAttribute("data-suggested");
|
||||||
|
|
||||||
if(suggested == "true") {
|
if(suggested == "true") {
|
||||||
number_suggested = number_suggested - 1;
|
number_suggested = number_suggested - 1;
|
||||||
if(number_suggested < 0) number_suggested = 0;
|
if(number_suggested < 0) number_suggested = 0;
|
||||||
|
|
||||||
var to_display = number_suggested > 9 ? "9+" : number_suggested;
|
var to_display = number_suggested > 9 ? "9+" : number_suggested;
|
||||||
if(!$(".suggested-link span.badge.new.white").hasClass("hide") && to_display == 0){
|
if(to_display == 0){
|
||||||
$(".suggested-link span.badge.new.white").addClass("hide");
|
Helper.addClass(".suggested-link span badge new white", "hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".suggested-link span.badge.new.white").text(to_display);
|
Helper.setHtml(".suggested-link span badge new white", to_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
List.vote(id, "del");
|
List.vote(id, "del");
|
||||||
$(".context-menu-root").addClass("hide");
|
Helper.addClass(".context-menu-root", "hide");
|
||||||
$("#context-menu-overlay").addClass("hide");
|
Helper.addClass("#context-menu-overlay", "hide");
|
||||||
$(".context-menu-root").attr("data-id", "");
|
document.getElementsByClassName("context-menu-root").setAttribute("data-id", "");
|
||||||
})
|
})
|
||||||
|
|
||||||
addListener("click", "#closePlayer", function(e){
|
addListener("click", "#closePlayer", function(e){
|
||||||
@@ -610,16 +610,16 @@ addListener("click", "#closePlayer", function(e){
|
|||||||
castSession.endSession(true);
|
castSession.endSession(true);
|
||||||
}
|
}
|
||||||
Player.player.destroy();
|
Player.player.destroy();
|
||||||
$("#player_bottom_overlay").toggleClass("hide");
|
Helper.toggleClass("#player_bottom_overlay", "hide");
|
||||||
$("#player").remove();
|
Helper.removeElement("#player");
|
||||||
} catch(error){}
|
} catch(error){}
|
||||||
socket.removeEventListener("np");
|
socket.removeEventListener("np");
|
||||||
socket.removeEventListener("id");
|
socket.removeEventListener("id");
|
||||||
socket.removeEventListener(id);
|
socket.removeEventListener(id);
|
||||||
$("#alreadychannel").remove();
|
Helper.removeElement("#alreadychannel");
|
||||||
Player.player = "";
|
Player.player = "";
|
||||||
document.title = "Zoff - the shared YouTube based radio";
|
document.title = "Zoff - the shared YouTube based radio";
|
||||||
$("#closePlayer").remove();
|
Helper.removeElement("#closePlayer");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -653,10 +653,10 @@ addListener("change", ".password_protected", function(e) {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if(this.checked) {
|
if(this.checked) {
|
||||||
M.Modal.getInstance(document.getElementById("user_password")).open();
|
M.Modal.getInstance(document.getElementById("user_password")).open();
|
||||||
$("#user-pass-input").focus();
|
document.getElementById("user-pass-input").focus();
|
||||||
} else {
|
} else {
|
||||||
userpass = "";
|
userpass = "";
|
||||||
if(!$(".change_user_pass").hasClass("hide")) $(".change_user_pass").addClass("hide");
|
Helper.addClass(".change_user_pass", "hide");
|
||||||
Admin.save(true);
|
Admin.save(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -664,15 +664,15 @@ addListener("change", ".password_protected", function(e) {
|
|||||||
addListener("submit", "#user-password-channel-form", function(e) {
|
addListener("submit", "#user-password-channel-form", function(e) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if(user_auth_started) {
|
if(user_auth_started) {
|
||||||
temp_user_pass = $("#user-pass-input").val();
|
temp_user_pass = document.getElementById("user-pass-input").value;
|
||||||
|
|
||||||
$("#user-pass-input").val("");
|
document.getElementById("user-pass-input").value = "";
|
||||||
socket.emit("list", {version: parseInt(localStorage.getItem("VERSION")), channel: chan.toLowerCase(), pass: Crypt.crypt_pass(temp_user_pass)});
|
socket.emit("list", {version: parseInt(localStorage.getItem("VERSION")), channel: chan.toLowerCase(), pass: Crypt.crypt_pass(temp_user_pass)});
|
||||||
} else {
|
} else {
|
||||||
M.Modal.getInstance(document.getElementById("user_password")).close();
|
M.Modal.getInstance(document.getElementById("user_password")).close();
|
||||||
userpass = $("#user-pass-input").val();
|
userpass = document.getElementById("user-pass-input").value;
|
||||||
user_change_password = false;
|
user_change_password = false;
|
||||||
$("#user-pass-input").val("");
|
document.getElementById("user-pass-input").value = "";
|
||||||
Admin.save(true);
|
Admin.save(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -681,7 +681,7 @@ addListener("click", ".change_user_pass_btn", function(e) {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
user_change_password = true;
|
user_change_password = true;
|
||||||
M.Modal.getInstance(document.getElementById("user_password")).open();
|
M.Modal.getInstance(document.getElementById("user_password")).open();
|
||||||
$("#user-pass-input").focus();
|
document.getElementById("user-pass-input").focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
addListener("contextmenu", "#context-menu-overlay", function(e) {
|
addListener("contextmenu", "#context-menu-overlay", function(e) {
|
||||||
@@ -691,14 +691,14 @@ addListener("contextmenu", "#context-menu-overlay", function(e) {
|
|||||||
addListener("click", ".submit-user-password", function(e) {
|
addListener("click", ".submit-user-password", function(e) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if(user_auth_started) {
|
if(user_auth_started) {
|
||||||
temp_user_pass = $("#user-pass-input").val();
|
temp_user_pass = document.getElementById("user-pass-input").value;
|
||||||
$("#user-pass-input").val("");
|
document.getElementById("user-pass-input").value = "";
|
||||||
socket.emit("list", {version: parseInt(localStorage.getItem("VERSION")), channel: chan.toLowerCase(), pass: Crypt.crypt_pass(temp_user_pass)});
|
socket.emit("list", {version: parseInt(localStorage.getItem("VERSION")), channel: chan.toLowerCase(), pass: Crypt.crypt_pass(temp_user_pass)});
|
||||||
} else {
|
} else {
|
||||||
M.Modal.getInstance(document.getElementById("user_password")).close();
|
M.Modal.getInstance(document.getElementById("user_password")).close();
|
||||||
userpass = $("#user-pass-input").val();
|
userpass = document.getElementById("user-pass-input").value;
|
||||||
user_change_password = false;
|
user_change_password = false;
|
||||||
$("#user-pass-input").val("");
|
document.getElementById("user-pass-input").value = "";
|
||||||
Admin.save(true);
|
Admin.save(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -718,9 +718,9 @@ addListener("click", ".close-user-password", function() {
|
|||||||
window.history.pushState("to the frontpage!", "Title", "/");
|
window.history.pushState("to the frontpage!", "Title", "/");
|
||||||
Channel.onepage_load();
|
Channel.onepage_load();
|
||||||
} else {
|
} else {
|
||||||
$("#user-pass-input").val("");
|
document.getElementById("user-pass-input").value = "";
|
||||||
if(!user_change_password) {
|
if(!user_change_password) {
|
||||||
$(".password_protected").prop("checked", false);
|
document.getElementsByClassName("password_protected")[0].checked = false;
|
||||||
}
|
}
|
||||||
user_change_password = false;
|
user_change_password = false;
|
||||||
}
|
}
|
||||||
@@ -761,8 +761,8 @@ addListener("click", '#toast-container', function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
addListener("click", "#aprilfools", function(){
|
addListener("click", "#aprilfools", function(){
|
||||||
$(".mega").css("-webkit-transform", "rotate(0deg)");
|
Helper.css(".mega", "-webkit-transform", "rotate(0deg)");
|
||||||
$(".mega").css("-moz-transform", "rotate(0deg)");
|
Helper.css(".mega", "-moz-transform", "rotate(0deg)");
|
||||||
});
|
});
|
||||||
|
|
||||||
addListener("change", '#view_channels_select', function(e) {
|
addListener("change", '#view_channels_select', function(e) {
|
||||||
@@ -1180,14 +1180,14 @@ $(window).resize(function(){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on( "click", ".result-object", function(e){
|
addListener("click", ".result-object", function(e){
|
||||||
var $html = $(e.target);
|
var $html = $(e.target);
|
||||||
|
|
||||||
var substr = $html.prop('outerHTML').substring(0,4);
|
var substr = $html.prop('outerHTML').substring(0,4);
|
||||||
if(substr != "<i c" && $html.prop('class').indexOf("waves-effect") == -1 && $html.attr("class") != "result-start" && $html.attr("class") != "result-end" && $html.attr("class") != "result-get-more-info"){
|
if(substr != "<i c" && $html.prop('class').indexOf("waves-effect") == -1 && $html.attr("class") != "result-start" && $html.attr("class") != "result-end" && $html.attr("class") != "result-get-more-info"){
|
||||||
var id = $(this).attr("data-video-id");
|
var id = this.getAttribute("data-video-id");
|
||||||
var title = $(this).attr("data-video-title");
|
var title = this.getAttribute("data-video-title");
|
||||||
var original_length = $(this).attr("data-video-length");
|
var original_length = this.getAttribute("data-video-length");
|
||||||
var start = parseInt($(this).find(".result-start").val());
|
var start = parseInt($(this).find(".result-start").val());
|
||||||
var end = parseInt($(this).find(".result-end").val());
|
var end = parseInt($(this).find(".result-end").val());
|
||||||
if(end > original_length) {
|
if(end > original_length) {
|
||||||
@@ -1210,35 +1210,35 @@ $(document).on( "click", ".result-object", function(e){
|
|||||||
|
|
||||||
addListener("click", ".result-get-more-info", function(e) {
|
addListener("click", ".result-get-more-info", function(e) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var that = $(this);
|
var that = this;
|
||||||
var parent = that.parent().parent().parent().parent();
|
var parent = that.parentElement.parentElement.parentElement.parentElement;
|
||||||
|
var videoId = parent.getAttribute("data-video-id");
|
||||||
var to_toggle = $("#inner-results").find("[data-video-id='" + parent.attr("data-video-id") + "']")[0];
|
var to_toggle = document.getElementById("inner-results").querySelectorAll("[data-video-id='" + videoId + "']")[0];
|
||||||
to_toggle = $(to_toggle).children()[0];
|
to_toggle = to_toggle.children[0];
|
||||||
$(to_toggle).toggleClass("result-object-slid");
|
Helper.toggleClass(to_toggle, "result-object-slid");
|
||||||
if($(that.children()[0]).text() == "keyboard_arrow_right") {
|
if(Helper.html(that.children[0]) == "keyboard_arrow_right") {
|
||||||
$(that.children()[0]).text("keyboard_arrow_left")
|
Helper.setHtml(that.children[0], "keyboard_arrow_left");
|
||||||
} else {
|
} else {
|
||||||
$(that.children()[0]).text("keyboard_arrow_right")
|
Helper.setHtml(that.children[0], "keyboard_arrow_right");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
addListener("click", '#submit-contact-form', function(e) {
|
addListener("click", '#submit-contact-form', function(e) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$("#contact-form").submit();
|
document.getElementById("contact-form").submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
addListener("submit", '#contact-form', function(e){
|
addListener("submit", '#contact-form', function(e){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var message = $("#contact-form-message").val();
|
var message = document.getElementById("contact-form-message").value;
|
||||||
var from = $("#contact-form-from").val();
|
var from = document.getElementById("contact-form-from").value;
|
||||||
|
|
||||||
Helper.send_mail(from, message);
|
Helper.send_mail(from, message);
|
||||||
});
|
});
|
||||||
|
|
||||||
addListener("click", ".send-error-modal", function(e) {
|
addListener("click", ".send-error-modal", function(e) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$("#error-report-form").submit();
|
document.getElementById("error-report-form").submit();
|
||||||
})
|
})
|
||||||
|
|
||||||
addListener("submit", "#error-report-form", function(e) {
|
addListener("submit", "#error-report-form", function(e) {
|
||||||
@@ -1249,7 +1249,7 @@ addListener("submit", "#error-report-form", function(e) {
|
|||||||
type: "POST",
|
type: "POST",
|
||||||
data: {
|
data: {
|
||||||
from: "no-reply@zoff.me",
|
from: "no-reply@zoff.me",
|
||||||
message: $("#error-report-code").text(),
|
message: Helper.html("#error-report-code"),
|
||||||
"g-recaptcha-response": captcha_response,
|
"g-recaptcha-response": captcha_response,
|
||||||
},
|
},
|
||||||
url: "/api/mail",
|
url: "/api/mail",
|
||||||
@@ -1258,25 +1258,26 @@ addListener("submit", "#error-report-form", function(e) {
|
|||||||
Helper.removeElement(".send-error-modal");
|
Helper.removeElement(".send-error-modal");
|
||||||
Helper.removeElement("#error-report-form");
|
Helper.removeElement("#error-report-form");
|
||||||
Helper.removeElement(".error-code-container");
|
Helper.removeElement(".error-code-container");
|
||||||
$(".error-report-success").text("Error report sent!");
|
Helper.setHtml(".error-report-success", "Error report sent!");
|
||||||
Helper.setHtml("#contact-container", "Mail has been sent, we'll be back with you shortly.");
|
Helper.setHtml("#contact-container", "Mail has been sent, we'll be back with you shortly.");
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
}else{
|
}else{
|
||||||
$(".error-report-success").text("Mail was not sent, try again");
|
Helper.setHtml(".error-report-success", "Mail was not sent, try again");
|
||||||
}
|
}
|
||||||
Helper.addClass("#send-loader", "hide");
|
Helper.addClass("#send-loader", "hide");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on( "click", "#add-many", function(e){
|
addListener("click", "#add-many", function(e){
|
||||||
var id = $(this).attr("data-video-id");
|
var id = this.getAttribute("data-video-id");
|
||||||
var title = $(this).attr("data-video-title");
|
var title = this.getAttribute("data-video-title");
|
||||||
var original_length = $(this).attr("data-video-length");
|
var original_length = this.getAttribute("data-video-length");
|
||||||
var parent = $(this).parent().parent();
|
console.log(id, title, original_length);
|
||||||
|
var parent = this.parentElement.parentElement;
|
||||||
|
|
||||||
var start = parseInt($(parent).find(".result-start").val());
|
var start = parseInt(parent.querySelectorAll(".result-start")[0].value);
|
||||||
var end = parseInt($(parent).find(".result-end").val());
|
var end = parseInt(parent.querySelectorAll(".result-end")[0].value);
|
||||||
if(end > original_length) {
|
if(end > original_length) {
|
||||||
end = original_length;
|
end = original_length;
|
||||||
}
|
}
|
||||||
@@ -1287,8 +1288,8 @@ $(document).on( "click", "#add-many", function(e){
|
|||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
var length = parseInt(end) - parseInt(start);
|
var length = parseInt(end) - parseInt(start);
|
||||||
$(this).parent().parent().parent().remove();
|
this.parentElement.parentElement.parentElement.remove();
|
||||||
Search.submit(id, title, length, false, 0, 1, start, end);
|
//Search.submit(id, title, length, false, 0, 1, start, end);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
M.toast({html: "Only numbers are accepted as song start and end parameters..", displayLength: 3000, classes: "red lighten"});
|
M.toast({html: "Only numbers are accepted as song start and end parameters..", displayLength: 3000, classes: "red lighten"});
|
||||||
}
|
}
|
||||||
@@ -1296,23 +1297,23 @@ $(document).on( "click", "#add-many", function(e){
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on( "click", ".vote-container", function(e){
|
addListener("click", ".vote-container", function(e){
|
||||||
if(!$(this).parent().hasClass("side_away")) {
|
if(this.parentElement.classList.indexOf("side_away") == -1) {
|
||||||
var id = $(this).attr("data-video-id");
|
var id = this.getAttribute("data-video-id");
|
||||||
List.vote(id, "pos");
|
List.vote(id, "pos");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on( "click", ".delete_button", function(e){
|
addListener("click", ".delete_button", function(e){
|
||||||
var id = $(this).attr("data-video-id");
|
var id = this.getAttribute("data-video-id");
|
||||||
List.vote(id, "del");
|
List.vote(id, "del");
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on( "click", ".add-suggested", function(e){
|
addListener("click", ".add-suggested", function(e){
|
||||||
var id = $(this).attr("data-video-id");
|
var id = this.getAttribute("data-video-id");
|
||||||
var title = $(this).attr("data-video-title");
|
var title = this.getAttribute("data-video-title");
|
||||||
var length = $(this).attr("data-video-length");
|
var length = this.getAttribute("data-video-length");
|
||||||
var added_by = $(this).attr("data-added-by");
|
var added_by = this.getAttribute("data-added-by");
|
||||||
Search.submit(id, title, parseInt(length), false, 0, 1, 0, parseInt(length));
|
Search.submit(id, title, parseInt(length), false, 0, 1, 0, parseInt(length));
|
||||||
if(added_by == "user") {
|
if(added_by == "user") {
|
||||||
number_suggested = number_suggested - 1;
|
number_suggested = number_suggested - 1;
|
||||||
@@ -1330,14 +1331,14 @@ $(document).on( "click", ".add-suggested", function(e){
|
|||||||
Helper.removeElement("#suggested-" + id);
|
Helper.removeElement("#suggested-" + id);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on( "click", ".del_suggested", function(e){
|
addListener("click", ".del_suggested", function(e){
|
||||||
var id = $(this).attr("data-video-id");
|
var id = this.getAttribute("data-video-id");
|
||||||
|
|
||||||
Helper.removeElement("#suggested-" + id);
|
Helper.removeElement("#suggested-" + id);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on( "click", ".del_user_suggested", function(e){
|
addListener("click", ".del_user_suggested", function(e){
|
||||||
var id = $(this).attr("data-video-id");
|
var id = this.getAttribute("data-video-id");
|
||||||
Helper.removeElement("#suggested-" + id);
|
Helper.removeElement("#suggested-" + id);
|
||||||
|
|
||||||
number_suggested = number_suggested - 1;
|
number_suggested = number_suggested - 1;
|
||||||
@@ -1371,7 +1372,7 @@ addListener("click", ".brand-logo-navigate", function(e){
|
|||||||
});
|
});
|
||||||
|
|
||||||
addListener("click", "#player_bottom_overlay", function(e){
|
addListener("click", "#player_bottom_overlay", function(e){
|
||||||
if($(e.target).attr("id") == "closePlayer") return;
|
if(event.target.id == "closePlayer") return;
|
||||||
Frontpage.to_channel(chan.toLowerCase(), false);
|
Frontpage.to_channel(chan.toLowerCase(), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user