add comment cleanup and add globals

This commit is contained in:
Alf Hammerseth
2019-11-16 21:13:45 +01:00
parent 54b745ec68
commit 33e6220e43
31 changed files with 4480 additions and 2552 deletions

View File

@@ -1,5 +1,9 @@
import {
VERSION
} from "../../../VERSION";
var Channel = {
init: function() {
init: function () {
if (window.location.hash == "#small" || inIframe()) {
small_player = true;
document.querySelector("footer").style.display = "none";
@@ -37,7 +41,6 @@ var Channel = {
document.querySelector("#hide-playlist").offsetWidth +
"px";
}
//Player.soundcloud_player = document.querySelector("#soundcloud_player");
}
List.calculate_song_heights();
Admin.logged_in = false;
@@ -45,7 +48,6 @@ var Channel = {
number_suggested = 0;
var no_socket = true;
//chan = Helper.decodeChannelName(Helper.html("#chan"));
var _p = window.location.pathname;
if (_p.substring(0, 1) == "/") _p = _p.substring(1);
if (_p.substring(_p.length - 1) == "/") _p = _p.substring(0, _p.length - 1);
@@ -60,7 +62,7 @@ var Channel = {
ga("send", "pageview", page);
}
window.onpopstate = function(e) {
window.onpopstate = function (e) {
Channel.onepage_load();
};
@@ -81,9 +83,8 @@ var Channel = {
}
if (!client) {
//Helper.tabs('.playlist-tabs');
Helper.tabs(".playlist-tabs-loggedIn", {
onShow: function(e) {
onShow: function (e) {
if (this.index == 2) {
document.getElementById("text-chat-input").focus();
Chat.channel_received = 0;
@@ -103,9 +104,6 @@ var Channel = {
.getElementsByClassName("chat-link")[0]
.setAttribute("style", "color: white !important;");
blinking = false;
//Helper.css("#chat-container", "display", "block");
//Helper.css("#wrapper", "display", "none");
//Helper.css("#suggestions", "display", "none");
document.getElementById("text-chat-input").focus();
Helper.css("#pageButtons", "display", "none");
scrollChat();
@@ -137,23 +135,22 @@ var Channel = {
edge: side,
closeOnClick: false,
draggable: Helper.mobilecheck(),
onOpenStart: function(el) {
onOpenStart: function (el) {
Helper.addClass(".hamburger-sidenav", "open");
},
onCloseStart: function(el) {
onCloseStart: function (el) {
Helper.removeClass(".hamburger-sidenav", "open");
}
});
M.Collapsible.init(
document.getElementsByClassName("settings-collapsible")[0],
{
document.getElementsByClassName("settings-collapsible")[0], {
accordion: true
}
);
if (!client) {
M.Modal.init(document.getElementById("embed"), {
onCloseStart: function() {
onCloseStart: function () {
document.querySelector(".embed-preview").innerHTML = "";
}
});
@@ -163,12 +160,12 @@ var Channel = {
Helper.removeElement(".tabs");
}
M.Modal.init(document.getElementById("advanced_filter"), {
onCloseEnd: function() {
onCloseEnd: function () {
document.querySelector(".filter-results").innerHTML = "";
document.getElementById("filtersearch_input").value = "";
document.getElementById("filtersearch_input").blur();
},
onOpenEnd: function() {
onOpenEnd: function () {
document.getElementById("filtersearch_input").focus();
}
});
@@ -190,7 +187,7 @@ var Channel = {
pagination_buttons_html =
"<div class='pagination-results'>" +
document.getElementsByClassName("pagination-results")[0].cloneNode(true)
.innerHTML +
.innerHTML +
"</div>";
empty_results_html = Helper.html("#empty-results-container");
not_import_html = Helper.html(".not-imported-container");
@@ -207,7 +204,7 @@ var Channel = {
"" + add,
connection_options
);
socket.on("update_required", function(msg) {
socket.on("update_required", function (msg) {
if (window.location.hostname == "localhost") {
console.error(msg);
return;
@@ -229,7 +226,7 @@ var Channel = {
(document.querySelectorAll("#alreadychannel").length === 0 ||
!Hostcontroller.old_id ||
document.getElementById("code-text").innerText.toUpperCase() ==
"ABBADUR")
"ABBADUR")
)
setup_host_initialization();
setup_suggested_listener();
@@ -278,7 +275,7 @@ var Channel = {
.setAttribute(
"src",
"https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl=" +
codeURL
codeURL
);
document.getElementById("code-link").setAttribute("href", codeURL);
}
@@ -300,15 +297,15 @@ var Channel = {
.setAttribute(
"src",
"https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl=" +
shareCodeUrl
shareCodeUrl
);
Helper.setHtml(
"#channel-name-join",
"client." +
window.location.hostname +
port +
"/" +
encodeURIComponent(chan.toLowerCase())
window.location.hostname +
port +
"/" +
encodeURIComponent(chan.toLowerCase())
);
}
} else {
@@ -380,7 +377,7 @@ var Channel = {
} else {
Player.loadSoundCloudPlayer();
}
//}
if (Helper.mobilecheck()) {
if (!client) {
@@ -424,12 +421,11 @@ var Channel = {
});
}
addListener("click", ".sp-choose-link", function(e) {
addListener("click", ".sp-choose-link", function (e) {
event.preventDefault();
document.getElementsByClassName("sp-choose")[0].click();
});
//$("#results" ).hover( function() { Helper.removeClass(".result", "hoverResults"); i = 0; }, function(){ });
document.getElementById("search").focus();
Helper.css("#embed-button", "display", "inline-block");
document.getElementById("search").setAttribute("placeholder", "Search...");
@@ -464,9 +460,9 @@ var Channel = {
} else if (chromecastReady && !client) {
initializeCastApi();
} else if (!client) {
window["__onGCastApiAvailable"] = function(loaded, errorInfo) {
window["__onGCastApiAvailable"] = function (loaded, errorInfo) {
if (loaded) {
setTimeout(function() {
setTimeout(function () {
chromecastReady = true;
initializeCastApi();
}, 1000);
@@ -479,13 +475,13 @@ var Channel = {
Channel.add_context_menu();
if (!Helper.mobilecheck() && navigator.userAgent.match(/iPad/i) == null) {
setTimeout(function() {
setTimeout(function () {
Channel.set_title_width();
}, 100);
}
},
set_title_width: function(start) {
set_title_width: function (start) {
if (window.innerWidth > 600) {
var add_width = document.getElementsByClassName("brand-logo")[0]
.offsetWidth;
@@ -506,7 +502,7 @@ var Channel = {
}
},
spotify_is_authenticated: function(bool) {
spotify_is_authenticated: function (bool) {
if (bool) {
Helper.log([
"Spotify is authenticated",
@@ -524,8 +520,8 @@ var Channel = {
}
},
add_context_menu: function() {
addListener("contextmenu", ".vote-container", function(e) {
add_context_menu: function () {
addListener("contextmenu", ".vote-container", function (e) {
if (hostMode) {
return;
}
@@ -535,58 +531,58 @@ var Channel = {
contextListener(e, that);
});
addListener("contextmenu", ".add-suggested", function(e) {
addListener("contextmenu", ".add-suggested", function (e) {
this.preventDefault();
var that = this;
contextListener(e, that);
});
addListener("click", ".list-remove", function(e) {
addListener("click", ".list-remove", function (e) {
this.preventDefault();
var that = this;
contextListener(e, that);
});
},
share_link_modifier: function() {
share_link_modifier: function () {
document
.getElementById("facebook-code-link")
.setAttribute(
"href",
"https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/" +
chan.toLowerCase()
chan.toLowerCase()
);
document
.getElementById("facebook-code-link")
.setAttribute(
"onclick",
"window.open('https://www.facebook.com/sharer/sharer.php?u=https://zoff.me/" +
chan.toLowerCase() +
"', 'Share Playlist','width=600,height=300'); return false;"
chan.toLowerCase() +
"', 'Share Playlist','width=600,height=300'); return false;"
);
document
.getElementById("twitter-code-link")
.setAttribute(
"href",
"https://twitter.com/intent/tweet?url=https://zoff.me/" +
chan.toLowerCase() +
"&amp;text=Check%20out%20this%20playlist%20" +
chan.toLowerCase() +
"%20on%20Zoff!&amp;via=zoffmusic"
chan.toLowerCase() +
"&amp;text=Check%20out%20this%20playlist%20" +
chan.toLowerCase() +
"%20on%20Zoff!&amp;via=zoffmusic"
);
document
.getElementById("twitter-code-link")
.setAttribute(
"onclick",
"window.open('https://twitter.com/intent/tweet?url=https://zoff.me/" +
chan.toLowerCase() +
"/&amp;text=Check%20out%20this%20playlist%20" +
chan.toLowerCase() +
"%20on%20Zoff!&amp;via=zoffmusic','Share Playlist','width=600,height=300'); return false;"
chan.toLowerCase() +
"/&amp;text=Check%20out%20this%20playlist%20" +
chan.toLowerCase() +
"%20on%20Zoff!&amp;via=zoffmusic','Share Playlist','width=600,height=300'); return false;"
);
},
window_width_volume_slider: function() {
window_width_volume_slider: function () {
if (window.innerWidth <= 600 && slider_type == "horizontal") {
slider_type = "vertical";
Playercontrols.initSlider();
@@ -597,25 +593,25 @@ var Channel = {
}
},
listeners: function(on) {
var scrollListener = function(e) {
listeners: function (on) {
var scrollListener = function (e) {
if (!programscroll) {
userscroll = true;
if (
document.getElementById("chatchannel").scrollTop +
document.getElementById("chatchannel").offsetHeight >=
document.getElementById("chatchannel").offsetHeight >=
document.getElementById("chatchannel").scrollHeight
) {
userscroll = false;
}
}
};
var scrollAllListener = function(e) {
var scrollAllListener = function (e) {
if (!programscroll) {
userscroll = true;
if (
document.getElementById("chatall").scrollTop +
document.getElementById("chatall").offsetHeight >=
document.getElementById("chatall").offsetHeight >=
document.getElementById("chatall").scrollHeight
) {
userscroll = false;
@@ -641,7 +637,7 @@ var Channel = {
}
},
onepage_load: function() {
onepage_load: function () {
if (changing_to_frontpage) return;
if (user_auth_started) {
clearTimeout(durationTimeout);
@@ -651,7 +647,6 @@ var Channel = {
Helper.tooltip(".castButton", "destroy");
Helper.tooltip("#viewers", "destroy");
Helper.tooltip("#addToOtherList", "destroy");
//$('.castButton-unactive').tooltip("destroy");
Helper.tooltip("#offline-mode", "destroy");
Helper.tooltip("#admin-lock", "destroy");
}
@@ -671,9 +666,8 @@ var Channel = {
document.getElementById("chan").innerHTML = Helper.upperFirst(chan);
var add = "";
w_p = true;
//if(private_channel) add = Crypt.getCookie("_uI") + "_";
socket.emit("list", {
version: parseInt(_VERSION),
version: VERSION,
channel: add + chan.toLowerCase()
});
} else if (url_split[3] === "") {
@@ -696,7 +690,6 @@ var Channel = {
Helper.css("#channel-load", "display", "block");
window.scrollTo(0, 0);
//Player.stopInterval = true;
Admin.beginning = true;
began = false;
durationBegun = false;
@@ -734,12 +727,8 @@ var Channel = {
}
}
clearTimeout(tap_target_timeout);
//before_toast();
if (Helper.mobilecheck() || user_auth_avoid || client) {
Helper.log(["Removing all listeners"]);
//socket.emit("change_channel");
//removeAllListeners();
//socket.removeEventListener(id);
socket.emit("left_channel", {
channel: channel_before_move
});
@@ -750,14 +739,12 @@ var Channel = {
socket.removeEventListener("np");
socket.removeEventListener("id");
socket.removeEventListener(id);
//socket.disconnect();
}
socket.removeEventListener("chat.all");
socket.removeEventListener("chat");
socket.removeEventListener("conf");
socket.removeEventListener("pw");
socket.removeEventListener("toast");
//socket.removeEventListener("id");
socket.removeEventListener("channel");
socket.removeEventListener("auth_required");
socket.removeEventListener("auth_accepted");
@@ -767,7 +754,7 @@ var Channel = {
Helper.ajax({
url: "/",
method: "GET",
success: function(e) {
success: function (e) {
if (!client) {
document.querySelector("#hide-playlist").remove();
if (hiddenPlaylist)
@@ -857,7 +844,6 @@ var Channel = {
"afterend",
response.querySelectorAll(".section.mega")[0].outerHTML
);
//document.getElementsByTagName("header")[0].insertAdjacentHTML("afterend", response.querySelectorAll(".section.mobile-search")[0].innerHTML);
if (Helper.mobilecheck() || user_auth_avoid) {
document.getElementsByTagName(
"main"
@@ -868,7 +854,7 @@ var Channel = {
.insertAdjacentHTML(
"beforeend",
response.querySelectorAll("#main_section_frontpage")[0]
.outerHTML
.outerHTML
);
}
Helper.removeClass(".page-footer", "padding-bottom-extra");
@@ -915,11 +901,17 @@ function get_history() {
if(p == undefined) p = "";
var c = Crypt.crypt_pass(p, true);
if(c == undefined) c = "";*/
socket.emit("get_history", { channel: chan.toLowerCase(), all: false });
socket.emit("get_history", { channel: chan.toLowerCase(), all: true });
socket.emit("get_history", {
channel: chan.toLowerCase(),
all: false
});
socket.emit("get_history", {
channel: chan.toLowerCase(),
all: true
});
} else {
setTimeout(function() {
setTimeout(function () {
get_history();
}, 50);
}
}
}

View File

@@ -5,13 +5,6 @@ var song_title = "";
var paused = false;
var intelligentList = false;
var client = false;
var _VERSION;
try {
_VERSION = localStorage.getItem("VERSION");
if (_VERSION == null || _VERSION == undefined) throw "Some error";
} catch (e) {
_VERSION = 6;
}
var SC_widget;
var scUsingWidget = false;
var zoff_api_token = "DwpnKVkaMH2HdcpJT2YPy783SY33byF5/32rbs0+xdU=";
@@ -79,10 +72,10 @@ var connection_options = {
};
var Crypt = {
crypt_pass: function(pass) {
crypt_pass: function (pass) {
return pass;
},
get_background_color: function() {
get_background_color: function () {
return "dynamic";
}
};
@@ -97,12 +90,16 @@ function receiveMessage(event) {
} else if (event.data == "reset") {
window.setVolume(100);
} else if (event.data == "get_info") {
window.parentWindow.postMessage(
{ type: "np", title: song_title },
window.parentWindow.postMessage({
type: "np",
title: song_title
},
window.parentOrigin
);
window.parentWindow.postMessage(
{ type: "controller", id: Hostcontroller.old_id },
window.parentWindow.postMessage({
type: "controller",
id: Hostcontroller.old_id
},
window.parentOrigin
);
try {
@@ -117,11 +114,11 @@ function receiveMessage(event) {
}
window.addEventListener("message", receiveMessage, false);
window.addEventListener("DOMContentLoaded", function() {});
window.addEventListener("DOMContentLoaded", function () {});
var Channel = {
set_title_width: function() {},
window_width_volume_slider: function() {}
set_title_width: function () {},
window_width_volume_slider: function () {}
};
function getSearch(elem) {
@@ -138,7 +135,7 @@ function getSearch(elem) {
return result;
}
window.addEventListener("load", function() {
window.addEventListener("load", function () {
if (autoplay) {
Helper.css("#player", "visibility", "hidden");
}
@@ -156,8 +153,6 @@ window.addEventListener("load", function() {
});
add = "https://zoff.me";
//if(window.location.hostname == "localhost") add = "localhost";
//add = "localhost";
socket = io.connect(
"" + add,
connection_options
@@ -167,7 +162,7 @@ window.addEventListener("load", function() {
change_offline(true, false);
}
socket.on("auth_required", function() {
socket.on("auth_required", function () {
M.Modal.getInstance(document.getElementById("locked_channel")).open();
});
@@ -175,9 +170,9 @@ window.addEventListener("load", function() {
"https://zoff.me/" + chan.toLowerCase();
document.querySelector(".channel-title").innerText = "/" + chan.toLowerCase();
socket.on("get_list", function() {
socket.on("get_list", function () {
socket_connected = true;
setTimeout(function() {
setTimeout(function () {
socket.emit("list", {
version: VERSION,
channel: chan.toLowerCase(),
@@ -186,13 +181,15 @@ window.addEventListener("load", function() {
}, 1000);
});
socket.on("self_ping", function() {
socket.on("self_ping", function () {
if (chan != undefined && chan.toLowerCase() != "") {
socket.emit("self_ping", { channel: chan.toLowerCase() });
socket.emit("self_ping", {
channel: chan.toLowerCase()
});
}
});
socket.on("viewers", function(view) {
socket.on("viewers", function (view) {
viewers = view;
if (song_title !== undefined) Player.getTitle(song_title, viewers);
@@ -217,7 +214,6 @@ window.addEventListener("load", function() {
.getElementById("playpause")
.addEventListener("click", Playercontrols.play_pause);
window.setVolume = setVolume;
//Helper.css("#controls", "background-color", color);
document.querySelector("body").style.backgroundColor = color;
if (embedOptions.hasOwnProperty("control") && embedOptions.control) {
@@ -227,14 +223,14 @@ window.addEventListener("load", function() {
}
});
window.addEventListener("resize", function() {
window.addEventListener("resize", function () {
resizeFunction();
});
function resizePlaylistPlaying() {}
function startWaitTimerPlay() {
setTimeout(function() {
setTimeout(function () {
if (videoSource == "youtube") {
Player.player.playVideo();
} else if (videoSource == "soundcloud") {
@@ -256,7 +252,7 @@ function setup_now_playing_listener() {
}
function setup_list_listener() {
socket.on("channel", function(msg) {
socket.on("channel", function (msg) {
Helper.addClass(".site_loader", "hide");
List.channel_function(msg);
});
@@ -268,6 +264,7 @@ function setVolume(val) {
}
function updateChromecastMetadata() {}
function loadChromecastVideo() {}
function toast(msg) {
@@ -364,7 +361,10 @@ function toast(msg) {
break;
}
before_toast();
M.toast({ html: msg, displayLength: 4000 });
M.toast({
html: msg,
displayLength: 4000
});
}
function emit() {
@@ -396,23 +396,23 @@ function change_offline(enabled, already_offline) {
}
}
var mouseEnter = function(e) {
var mouseEnter = function (e) {
Helper.removeClass("#seekToDuration", "hide");
};
var mouseLeave = function(e) {
var mouseLeave = function (e) {
dragging = false;
Helper.addClass("#seekToDuration", "hide");
};
var mouseDown = function(e) {
var mouseDown = function (e) {
var acceptable = ["bar", "controls", "duration"];
if (acceptable.indexOf(e.target.id) >= 0) {
dragging = true;
}
};
var mouseUp = function(e) {
var mouseUp = function (e) {
dragging = false;
};
if (enabled) {
@@ -467,68 +467,61 @@ function change_offline(enabled, already_offline) {
}
function before_toast() {
/*if($('.toast').length > 0) {
var toastElement = $('.toast').first()[0];
var toastInstance = toastElement.M_Toast;
toastInstance.remove();
}*/
M.Toast.dismissAll();
//Materialize.Toast.removeAll();
}
document.addEventListener(
"click",
function(e) {
function (e) {
handleEvent(e, e.target, false, "click");
},
false
);
addListener("click", ".channel-info-container", function(e) {
addListener("click", ".channel-info-container", function (e) {
this.preventDefault();
Player.pauseVideo();
window.open("https://zoff.me/" + chan.toLowerCase() + "/", "_blank");
});
addListener("click", ".vote-container", function(e) {
addListener("click", ".vote-container", function (e) {
var that = e;
var id = that.getAttribute("data-video-id");
List.vote(id, "pos");
});
addListener("click", ".prev_page", function(e) {
addListener("click", ".prev_page", function (e) {
event.preventDefault();
List.dynamicContentPage(-1);
});
addListener("click", "#player_overlay", function(event) {
addListener("click", "#player_overlay", function (event) {
if (videoSource == "soundcloud") Playercontrols.play_pause();
});
addListener("click", ".next_page", function(e) {
addListener("click", ".next_page", function (e) {
event.preventDefault();
List.dynamicContentPage(1);
});
addListener("click", ".prev", function(event) {
addListener("click", ".prev", function (event) {
this.preventDefault();
if (!offline) return;
List.skip(false);
});
addListener("click", ".skip", function(event) {
addListener("click", ".skip", function (event) {
this.preventDefault();
//if(!offline) return;
List.skip(true);
});
addListener("click", ".last_page", function(e) {
addListener("click", ".last_page", function (e) {
event.preventDefault();
List.dynamicContentPage(10);
});
addListener("click", ".first_page", function(e) {
addListener("click", ".first_page", function (e) {
event.preventDefault();
List.dynamicContentPage(-10);
});
});

View File

@@ -1,3 +1,7 @@
import {
VERSION
} from "../../../VERSION";
function removeAllListeners() {
Helper.log(["Removing all listeners"]);
socket.removeEventListener("chat.all");
@@ -9,14 +13,12 @@ function removeAllListeners() {
socket.removeEventListener("channel");
socket.removeEventListener("np");
socket.removeEventListener("get_list");
//socket.removeEventListener("self_ping");
socket.removeEventListener("viewers");
socket.removeEventListener("auth_required");
socket.removeEventListener("auth_accepted");
socket.removeEventListener("suggested");
socket.removeEventListener("color");
socket.removeEventListener("chat_history");
//socket.removeEventListener("name");
socket.removeEventListener(id);
}
@@ -44,7 +46,7 @@ function filterPlaylistElements(page) {
page: page,
type: search_type
},
success: function(data) {
success: function (data) {
var json = JSON.parse(data);
document.querySelector(".filter-results").innerHTML = "";
if (json.results.search_results.length > 0) {
@@ -70,7 +72,7 @@ function filterPlaylistElements(page) {
"Couldn't find any items with those tags..";
}
},
error: function(e) {
error: function (e) {
if (e.status != 429) {
toast("Couldn't find any items with those tags..", "red");
@@ -111,11 +113,10 @@ function addFilterButtons(position, json) {
}
function say_updated() {
setTimeout(function() {
setTimeout(function () {
before_toast();
M.toast({
html:
"The list was updated, want to refresh? <a class='waves-effect waves-light btn light-green' href='#' id='refresh_mobile' style='cursor:pointer;pointer-events:all;margin-left:10px;'> yes</a><a class='waves-effect waves-light btn red lighten' id='dont_refresh_list' style='cursor:pointer;pointer-events:all;margin-left:10px;'>no</a>",
html: "The list was updated, want to refresh? <a class='waves-effect waves-light btn light-green' href='#' id='refresh_mobile' style='cursor:pointer;pointer-events:all;margin-left:10px;'> yes</a><a class='waves-effect waves-light btn red lighten' id='dont_refresh_list' style='cursor:pointer;pointer-events:all;margin-left:10px;'>no</a>",
displayLength: 10000000
});
}, 500);
@@ -150,9 +151,9 @@ function resizeFunction() {
if (document.querySelector("#wrapper") == null) return;
if (!client && !embed)
document.querySelector("#hide-playlist").style.left =
document.querySelector("#video-container").offsetWidth -
document.querySelector("#hide-playlist").offsetWidth +
"px";
document.querySelector("#video-container").offsetWidth -
document.querySelector("#hide-playlist").offsetWidth +
"px";
if (
((window.innerWidth > 600 && !embed) ||
(window.innerWidth > 500 && embed)) &&
@@ -171,7 +172,7 @@ function resizeFunction() {
var scPlaying = false;
var ytPlaying = false;
if (scUsingWidget) {
Player.soundcloud_player.isPaused(function(paused) {
Player.soundcloud_player.isPaused(function (paused) {
try {
ytPlaying =
Player.player.getPlayerState() == YT.PlayerState.PLAYING ||
@@ -213,7 +214,7 @@ function resizeFunction() {
Helper.computedStyle("header", "height") -
64 -
40) /
71
71
) + 1;
List.element_height =
(window.innerHeight -
@@ -221,7 +222,7 @@ function resizeFunction() {
Helper.computedStyle("header", "height") -
64 -
40) /
temp_fit -
temp_fit -
5;
} else {
temp_fit =
@@ -238,7 +239,7 @@ function resizeFunction() {
Helper.computedStyle("header", "height") -
64 -
40) /
71
71
);
List.element_height =
(window.innerHeight -
@@ -246,17 +247,16 @@ function resizeFunction() {
Helper.computedStyle("header", "height") -
64 -
40) /
temp_fit -
temp_fit -
5;
} else if (List.element_height < 55.2 && embed) {
//List.can_fit = List.can_fit - 1;
temp_fit = Math.round(
(window.innerHeight -
Helper.computedStyle(".tabs", "height") -
Helper.computedStyle("header", "height") -
64 -
40) /
71
71
);
List.element_height =
(window.innerHeight -
@@ -264,7 +264,7 @@ function resizeFunction() {
Helper.computedStyle("header", "height") -
64 -
40) /
temp_fit -
temp_fit -
5;
temp_fit = temp_fit - 2;
}
@@ -295,7 +295,6 @@ function resizeFunction() {
}
}
List.can_fit = temp_fit;
//List.element_height = (Helper.computedStyle("#wrapper", "height") / List.can_fit)-5.3;
Helper.css(".list-song", "height", List.element_height + "px");
Channel.set_title_width();
if (!client) {
@@ -354,14 +353,19 @@ function getColor(id) {
Helper.ajax({
method: "POST",
url: "/api/color",
headers: { "Content-Type": "application/json;charset=UTF-8" },
headers: {
"Content-Type": "application/json;charset=UTF-8"
},
data: JSON.stringify({
id: id
}),
success: function(c) {
success: function (c) {
c = JSON.parse(c);
if (typeof c == "object") {
Player.setBGimage({ color: c, only: true });
Player.setBGimage({
color: c,
only: true
});
}
}
});
@@ -384,14 +388,11 @@ function hide_native(way) {
}
Helper.toggleClass("#duration", "hide");
Helper.toggleClass("#fullscreen", "hide");
try {
if (videoSource == "youtube") {
Player.player.stopVideo();
} else if (videoSource == "soundcloud") {
Player.soundcloud_player.pause();
}
} catch (e) {}
//clearTimeout(durationTimeout);
if (videoSource == "youtube") {
Player.player.stopVideo();
} else if (videoSource == "soundcloud") {
Player.soundcloud_player.pause();
}
Player.stopInterval = true;
if (Helper.mobilecheck()) {
if (document.querySelector("#pause").classList.contains("hide")) {
@@ -412,7 +413,7 @@ function hide_native(way) {
var thisThumbnail;
if (Player.np.thumbnail == undefined)
thisThumbnail =
"https://img.youtube.com/vi/" + video_id + "/hqdefault.jpg";
"https://img.youtube.com/vi/" + video_id + "/hqdefault.jpg";
else thisThumbnail = Player.np.thumbnail;
Helper.removeClass("#player_overlay", "hide");
Helper.css("#player_overlay", "display", "block");
@@ -472,7 +473,9 @@ function hide_native(way) {
Helper.setHtml("#chromecast_text", "");
Helper.css("#playing_on", "display", "none");
if (!offline) {
socket.emit("pos", { channel: chan.toLowerCase() });
socket.emit("pos", {
channel: chan.toLowerCase()
});
} else {
Player.loadVideoById(video_id);
}
@@ -521,7 +524,6 @@ function start_auth() {
Helper.css("#player_overlay", "display", "block");
M.Modal.getInstance(document.getElementById("user_password")).open();
document.querySelector("#user-pass-input").focus();
//Crypt.remove_userpass(chan.toLowerCase());
before_toast();
M.toast({
html: "That is not the correct password, try again..",
@@ -532,32 +534,30 @@ function start_auth() {
function emit_list() {
var add = "";
//if(private_channel) add = Crypt.getCookie("_uI") + "_";
/*var p = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
if(p == undefined) p = "";*/
if (socket.id) {
socket.emit("list", {
version: parseInt(_VERSION),
version: parseInt(VERSION),
channel: add + chan.toLowerCase()
});
} else {
setTimeout(function() {
setTimeout(function () {
emit_list();
}, 50);
}
}
function get_list_ajax() {
//var c = Crypt.get_userpass(chan.toLowerCase());
Helper.ajax({
type: "POST",
data: {
userpass: "",
token: zoff_api_token
},
headers: { "Content-Type": "application/json;charset=UTF-8" },
headers: {
"Content-Type": "application/json;charset=UTF-8"
},
url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()),
success: function(response) {
success: function (response) {
response = JSON.parse(response);
if (response.results.length > 0) {
if (response.status == 403) {
@@ -569,19 +569,17 @@ function get_list_ajax() {
List.populate_list(response.results);
}
},
error: function(response) {
//response = JSON.parse(response);
error: function (response) {
if (response.status == 403) {
start_auth();
} else if (response.status == 429) {
setTimeout(function() {
setTimeout(function () {
get_list_ajax();
}, xmlhttp.getResponseHeader("Retry-After") * 1000);
} else if (response.status == 404) return;
if (client) {
Helper.removeElement("#channel-load");
}
//List.populate_list(response.responseJSON.results);
}
});
}
@@ -638,14 +636,14 @@ function inIframe() {
}
function mouseContext(left, top) {
var moveFunction = function(event) {
var moveFunction = function (event) {
if (
event.pageX < left - 60 ||
event.pageX >
left + document.querySelector(".context-menu-root").offsetWidth + 60 ||
left + document.querySelector(".context-menu-root").offsetWidth + 60 ||
event.pageY < top - 60 ||
event.pageY >
top + document.querySelector(".context-menu-root").offsetHeight + 60
top + document.querySelector(".context-menu-root").offsetHeight + 60
) {
Helper.addClass(".context-menu-root", "hide");
Helper.addClass("#context-menu-overlay", "hide");
@@ -659,8 +657,6 @@ function mouseContext(left, top) {
}
function get_np_ajax() {
/*var c = Crypt.get_userpass(chan.toLowerCase());
if(c == undefined) c = "";*/
Helper.ajax({
type: "POST",
data: {
@@ -668,19 +664,19 @@ function get_np_ajax() {
fetch_song: true,
token: zoff_api_token
},
headers: { "Content-Type": "application/json;charset=UTF-8" },
url:
"/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/__np__",
success: function(response) {
headers: {
"Content-Type": "application/json;charset=UTF-8"
},
url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/__np__",
success: function (response) {
response = JSON.parse(response);
Player.getTitle(response.results[0].title, 1);
},
error: function(response, xmlhttp) {
//response = JSON.parse(response);
error: function (response, xmlhttp) {
if (response.status == 403) {
start_auth();
} else if (response.status == 429) {
setTimeout(function() {
setTimeout(function () {
get_np_ajax();
}, xmlhttp.getResponseHeader("Retry-After") * 1000);
}
@@ -689,10 +685,6 @@ function get_np_ajax() {
}
function del_ajax(id) {
/*var a = Crypt.get_pass(chan.toLowerCase());
var u = Crypt.get_userpass(chan.toLowerCase());
if(a == undefined) a = "";
if(u == undefined) u = "";*/
Helper.ajax({
type: "DELETE",
data: {
@@ -700,18 +692,19 @@ function del_ajax(id) {
userpass: "",
token: zoff_api_token
},
headers: { "Content-Type": "application/json;charset=UTF-8" },
headers: {
"Content-Type": "application/json;charset=UTF-8"
},
url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/" + id,
success: function(response) {
success: function (response) {
toast("deletesong");
get_list_ajax();
},
error: function(response, xmlhttp) {
//response = JSON.parse(response);
error: function (response, xmlhttp) {
if (response.status == 403) {
toast("listhaspass");
} else if (response.status == 429) {
setTimeout(function() {
setTimeout(function () {
del_ajax(id);
}, xmlhttp.getResponseHeader("Retry-After") * 1000);
}
@@ -731,10 +724,6 @@ function add_ajax(
source,
thumbnail
) {
/*var a = Crypt.get_pass(chan.toLowerCase());
var u = Crypt.get_userpass(chan.toLowerCase());
if(a == undefined) a = "";
if(u == undefined) u = "";*/
Helper.ajax({
type: "POST",
data: {
@@ -748,20 +737,21 @@ function add_ajax(
source: source,
token: zoff_api_token
},
headers: { "Content-Type": "application/json;charset=UTF-8" },
headers: {
"Content-Type": "application/json;charset=UTF-8"
},
url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/" + id,
success: function(response) {
success: function (response) {
toast("addedsong");
get_list_ajax();
},
error: function(response, xmlhttp) {
//response = JSON.parse(response);
error: function (response, xmlhttp) {
if (response.status == 403) {
toast("listhaspass");
} else if (response.status == 409) {
vote_ajax(id);
} else if (response.status == 429) {
setTimeout(function() {
setTimeout(function () {
add_ajax(id, title, duration, playlist, num, full_num, start, end);
}, xmlhttp.getResponseHeader("Retry-After") * 1000);
}
@@ -770,10 +760,6 @@ function add_ajax(
}
function vote_ajax(id) {
/*var a = Crypt.get_pass(chan.toLowerCase());
var u = Crypt.get_userpass(chan.toLowerCase());
if(a == undefined) a = "";
if(u == undefined) u = "";*/
Helper.ajax({
type: "PUT",
data: {
@@ -781,18 +767,19 @@ function vote_ajax(id) {
userpass: "",
token: zoff_api_token
},
headers: { "Content-Type": "application/json;charset=UTF-8" },
headers: {
"Content-Type": "application/json;charset=UTF-8"
},
url: "/api/list/" + Helper.encodeChannelName(chan.toLowerCase()) + "/" + id,
success: function(response) {
success: function (response) {
toast("voted");
get_list_ajax();
},
error: function(response, xmlhttp) {
//response = JSON.parse(response);
error: function (response, xmlhttp) {
if (response.status == 403) {
toast("listhaspass");
} else if (response.status == 429) {
setTimeout(function() {
setTimeout(function () {
vote_ajax(id);
}, xmlhttp.getResponseHeader("Retry-After") * 1000);
}
@@ -801,22 +788,21 @@ function vote_ajax(id) {
}
function setup_auth_listener() {
socket.on("auth_required", function() {
socket.on("auth_required", function () {
start_auth();
});
socket.on("auth_accepted", function(msg) {
socket.on("auth_accepted", function (msg) {
if (msg.hasOwnProperty("value") && msg.value) {
if (temp_user_pass != "") {
userpass = temp_user_pass;
//Crypt.set_userpass(chan.toLowerCase(), userpass);
}
}
});
}
function setup_no_connection_listener() {
socket.on("connect_failed", function() {
socket.on("connect_failed", function () {
Helper.log(["Connection Failed"]);
if (!connect_error) {
connect_error = true;
@@ -828,7 +814,7 @@ function setup_no_connection_listener() {
}
});
socket.on("connect_error", function() {
socket.on("connect_error", function () {
Helper.log(["Connection Failed."]);
if (!connect_error) {
connect_error = true;
@@ -871,16 +857,14 @@ function loadChromecastVideo() {
seekTo: _seekTo,
channel: chan.toLowerCase(),
source: videoSource,
thumbnail:
Player.np.thumbnail != undefined
? Player.np.thumbnail
: "https://img.youtube.com/vi/" + video_id + "/mqdefault.jpg"
thumbnail: Player.np.thumbnail != undefined ?
Player.np.thumbnail : "https://img.youtube.com/vi/" + video_id + "/mqdefault.jpg"
};
castSession.loadMedia(request).then(
function() {
function () {
console.log("Loaded chromecast-video. Don't look here, look at your TV!");
},
function(errorCode) {
function (errorCode) {
console.log("Error code: " + errorCode);
}
);
@@ -1027,10 +1011,10 @@ function enable_host_mode(enabled) {
.insertAdjacentHTML(
"beforeend",
"<div id='join-sidebar' style='color:white;'>" +
document
.querySelector("#channel-share-modal")
.querySelector(".modal-content").innerHTML +
"</div>"
document
.querySelector("#channel-share-modal")
.querySelector(".modal-content").innerHTML +
"</div>"
);
document.addEventListener("webkitfullscreenchange", exitHandler, false);
document.addEventListener("mozfullscreenchange", exitHandler, false);
@@ -1069,19 +1053,16 @@ function enable_host_mode(enabled) {
}
function get_list_listener() {
socket.on("get_list", function() {
socket.on("get_list", function () {
var add = "";
socket_connected = true;
//if(private_channel) add = Crypt.getCookie("_uI") + "_";
/*var p = Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()), true);
if(p == undefined) p = "";*/
socket.emit("list", {
offline: offline,
version: parseInt(_VERSION),
version: VERSION,
channel: add + chan.toLowerCase()
});
});
socket.on("id_chromecast", function(msg) {
socket.on("id_chromecast", function (msg) {
chromecast_specs_sent = true;
castSession.sendMessage("urn:x-cast:zoff.me", {
type: "mobilespecs",
@@ -1094,7 +1075,7 @@ function get_list_listener() {
function setup_suggested_listener() {
if (client) return;
socket.on("suggested", function(params) {
socket.on("suggested", function (params) {
var single = true;
if (params.id === undefined) single = false;
Suggestions.catchUserSuggests(params, single);
@@ -1102,9 +1083,9 @@ function setup_suggested_listener() {
}
function setup_viewers_listener() {
socket.on("viewers", function(view) {
socket.on("viewers", function (view) {
viewers = view;
var outPutWord = "<i class='material-icons'>visibility</i>"; //v > 1 ? "viewers" : "viewer";
var outPutWord = "<i class='material-icons'>visibility</i>";
Helper.setHtml("#viewers", outPutWord + " " + view);
@@ -1119,7 +1100,7 @@ function setup_admin_listener() {
}
function setup_chat_listener() {
socket.on("chat_history", function(msg) {
socket.on("chat_history", function (msg) {
var data = msg.data;
for (var i = 0; i < data.length; i++) {
if (msg.all) {
@@ -1225,23 +1206,23 @@ function change_offline(enabled, already_offline) {
}
}
var mouseEnter = function(e) {
var mouseEnter = function (e) {
Helper.removeClass("#seekToDuration", "hide");
};
var mouseLeave = function(e) {
var mouseLeave = function (e) {
dragging = false;
Helper.addClass("#seekToDuration", "hide");
};
var mouseDown = function(e) {
var mouseDown = function (e) {
var acceptable = ["bar", "controls", "duration"];
if (acceptable.indexOf(e.target.id) >= 0) {
dragging = true;
}
};
var mouseUp = function(e) {
var mouseUp = function (e) {
dragging = false;
};
@@ -1348,7 +1329,9 @@ function change_offline(enabled, already_offline) {
.removeEventListener("click", seekToClick);
Helper.removeElement("#seekToDuration");
socket.on("color", Player.setBGimage);
socket.emit("pos", { channel: chan.toLowerCase() });
socket.emit("pos", {
channel: chan.toLowerCase()
});
var add = "";
socket.emit("list", {
version: parseInt(_VERSION),
@@ -1481,7 +1464,7 @@ function resizePlaylistPlaying(playing, resizing) {
Helper.computedStyle("header", "height") -
64 -
40) /
71
71
);
List.element_height =
(window.innerHeight -
@@ -1489,7 +1472,7 @@ function resizePlaylistPlaying(playing, resizing) {
Helper.computedStyle("header", "height") -
64 -
40) /
temp_fit -
temp_fit -
5;
}
@@ -1510,7 +1493,6 @@ function resizePlaylistPlaying(playing, resizing) {
);
}
} else if (List.can_fit > temp_fit) {
//Helper.css(document.querySelector("#wrapper").children, "display", "none");
Helper.css(
document.querySelector("#wrapper").children[List.page + temp_fit],
"display",
@@ -1676,8 +1658,7 @@ function toast(msg, _class) {
if (embed) return;
if (Search.submitYouTubeError) {
M.toast({
html:
"Added most of your playlist, but something was wrong. Check the playlist..",
html: "Added most of your playlist, but something was wrong. Check the playlist..",
displayLength: 4000,
classes: "red lighten connect_error"
});
@@ -1714,7 +1695,6 @@ function toast(msg, _class) {
"Nope, wrong password!",
"Wrong password. The authorities have been notified."
]);
//Crypt.remove_pass(chan.toLowerCase());
Admin.display_logged_out();
Helper.css("#thumbnail_form", "display", "none");
Helper.css("#description_form", "display", "none");
@@ -1804,7 +1784,6 @@ function toast(msg, _class) {
"I can't let you do that",
"Please log in to do that"
]);
//Crypt.remove_pass(chan.toLowerCase());
Admin.display_logged_out();
Helper.css("#thumbnail_form", "display", "none");
Helper.css("#description_form", "display", "none");
@@ -1851,9 +1830,9 @@ function toast(msg, _class) {
if (embed) return;
tried_again = false;
adminpass =
Crypt.get_pass(chan.toLowerCase()) == undefined
? Crypt.tmp_pass
: Crypt.get_pass(chan.toLowerCase());
Crypt.get_pass(chan.toLowerCase()) == undefined ?
Crypt.tmp_pass :
Crypt.get_pass(chan.toLowerCase());
msg =
"Correct password. You now have access to the sacred realm of The Admin.";
Helper.css("#thumbnail_form", "display", "inline-block");
@@ -1875,7 +1854,11 @@ function toast(msg, _class) {
}
before_toast();
var classes = _class == undefined ? "" : _class;
M.toast({ html: msg, displayLength: 4000, classes: classes });
M.toast({
html: msg,
displayLength: 4000,
classes: classes
});
}
function emit() {
@@ -1955,23 +1938,14 @@ function searchTimeout(event) {
code != 27
) {
clearTimeout(timeout_search);
/*if(search_input.length < 3){
Helper.css(".results-tabs", "display", "none");
document.querySelector("#results").innerHTML = "";
document.querySelector("#results_soundcloud").innerHTML = "";
Helper.css("")
if(search_input.length == 0) {
document.querySelector("body").setAttribute("style", "overflow-y: auto");
}
}*/
if (code == 13) {
Search.search(search_input);
Search.soundcloudSearch(search_input);
} else {
timeout_search = setTimeout(function() {
timeout_search = setTimeout(function () {
Search.search(search_input);
Search.soundcloudSearch(search_input);
}, 1000);
}
}
}
}

View File

@@ -1,9 +1,13 @@
import {
VERSION
} from "../../../VERSION";
var Hostcontroller = {
enabled: true,
old_id: null,
host_listener: function(id) {
host_listener: function (id) {
if (client) return;
Helper.log(["Host-listener triggered", "Host-listener id:" + id]);
if (Hostcontroller.old_id === null) Hostcontroller.old_id = id;
@@ -16,8 +20,10 @@ var Hostcontroller = {
window.location.protocol + "//remote." + window.location.host + "/" + id;
if (embed) {
if (window.parentWindow && window.parentOrigin) {
window.parentWindow.postMessage(
{ type: "controller", id: id },
window.parentWindow.postMessage({
type: "controller",
id: id
},
window.parentOrigin
);
}
@@ -29,7 +35,7 @@ var Hostcontroller = {
.setAttribute(
"src",
"https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl=" +
codeURL
codeURL
);
document.querySelector("#code-link").setAttribute("href", codeURL);
}
@@ -39,7 +45,7 @@ var Hostcontroller = {
}
},
host_on_action: function(arr) {
host_on_action: function (arr) {
if (client) return;
if (Hostcontroller.enabled) {
if (arr.type == "volume") {
@@ -71,20 +77,19 @@ var Hostcontroller = {
.setAttribute(
"src",
"https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl=" +
shareCodeUrl
shareCodeUrl
);
Helper.setHtml(
"#channel-name-join",
"client." +
window.location.hostname +
"/" +
encodeURIComponent(chan.toLowerCase())
window.location.hostname +
"/" +
encodeURIComponent(chan.toLowerCase())
);
w_p = true;
var add = "";
//if(private_channel) add = Crypt.getCookie("_uI") + "_";
socket.emit("list", {
version: parseInt(_VERSION),
version: parseInt(VERSION),
channel: add + chan.toLowerCase()
});
@@ -103,7 +108,7 @@ var Hostcontroller = {
}
},
change_enabled: function(val) {
change_enabled: function (val) {
if (client) return;
Hostcontroller.enabled = val;
try {
@@ -111,4 +116,4 @@ var Hostcontroller = {
Hostcontroller.enabled;
} catch (e) {}
}
};
};

File diff suppressed because it is too large Load Diff