Fixup various lint

Touched up callbacks and paginator
This commit is contained in:
Xaekai 2022-01-22 19:05:02 -08:00 committed by Calvin Montgomery
parent 4fada9a8d2
commit ba80c1591d
2 changed files with 26 additions and 31 deletions

View File

@ -1,4 +1,4 @@
Callbacks = { const Callbacks = {
/* fired when socket connection completes */ /* fired when socket connection completes */
connect: function() { connect: function() {
HAS_CONNECTED_BEFORE = true; HAS_CONNECTED_BEFORE = true;
@ -658,8 +658,7 @@ Callbacks = {
} }
$("#drinkcount").text(text); $("#drinkcount").text(text);
$("#drinkbar").show(); $("#drinkbar").show();
} } else {
else {
$("#drinkbar").hide(); $("#drinkbar").hide();
} }
}, },
@ -752,8 +751,7 @@ Callbacks = {
if(data.temp) { if(data.temp) {
btn.html(btn.html().replace("Make Temporary", btn.html(btn.html().replace("Make Temporary",
"Make Permanent")); "Make Permanent"));
} } else {
else {
btn.html(btn.html().replace("Make Permanent", btn.html(btn.html().replace("Make Permanent",
"Make Temporary")); "Make Temporary"));
} }
@ -867,8 +865,7 @@ Callbacks = {
$("#qlockbtn").find("span") $("#qlockbtn").find("span")
.removeClass("glyphicon-lock") .removeClass("glyphicon-lock")
.addClass("glyphicon-ok"); .addClass("glyphicon-ok");
} } else {
else {
$("#qlockbtn").removeClass("btn-success") $("#qlockbtn").removeClass("btn-success")
.addClass("btn-danger") .addClass("btn-danger")
.attr("title", "Playlist Locked"); .attr("title", "Playlist Locked");
@ -932,7 +929,7 @@ Callbacks = {
$("<button/>").addClass("btn btn-danger btn-sm pull-right").text("End Poll") $("<button/>").addClass("btn btn-danger btn-sm pull-right").text("End Poll")
.appendTo(poll) .appendTo(poll)
.on('click', function() { .on('click', function() {
socket.emit("closePoll") socket.emit("closePoll");
}); });
} }
@ -949,7 +946,7 @@ Callbacks = {
}); });
$(this).addClass("active"); $(this).addClass("active");
$(this).parent().addClass("option-selected"); $(this).parent().addClass("option-selected");
} };
$("<button/>").addClass("btn btn-default btn-sm").text(data.counts[i]) $("<button/>").addClass("btn btn-default btn-sm").text(data.counts[i])
.prependTo($("<div/>").addClass("option").html(data.options[i]) .prependTo($("<div/>").addClass("option").html(data.options[i])
.appendTo(poll)) .appendTo(poll))
@ -981,7 +978,7 @@ Callbacks = {
$(this).attr("disabled", true); $(this).attr("disabled", true);
}); });
poll.find(".btn-danger").each(function() { poll.find(".btn-danger").each(function() {
$(this).remove() $(this).remove();
}); });
} }
}, },
@ -1000,14 +997,14 @@ Callbacks = {
updateEmote: function (data) { updateEmote: function (data) {
data.regex = new RegExp(data.source, "gi"); data.regex = new RegExp(data.source, "gi");
var found = false; var found = false;
for (var i = 0; i < CHANNEL.emotes.length; i++) { for (let i = 0; i < CHANNEL.emotes.length; i++) {
if (CHANNEL.emotes[i].name === data.name) { if (CHANNEL.emotes[i].name === data.name) {
found = true; found = true;
CHANNEL.emotes[i] = data; CHANNEL.emotes[i] = data;
break; break;
} }
} }
for (var i = 0; i < CHANNEL.badEmotes.length; i++) { for (let i = 0; i < CHANNEL.badEmotes.length; i++) {
if (CHANNEL.badEmotes[i].name === data.name) { if (CHANNEL.badEmotes[i].name === data.name) {
CHANNEL.badEmotes[i] = data; CHANNEL.badEmotes[i] = data;
break; break;
@ -1050,22 +1047,20 @@ Callbacks = {
if(!badBefore){ if(!badBefore){
CHANNEL.badEmotes.push(data); CHANNEL.badEmotes.push(data);
delete CHANNEL.emoteMap[oldName]; delete CHANNEL.emoteMap[oldName];
}
// Was bad before too: Update // Was bad before too: Update
else { } else {
for (var i = 0; i < CHANNEL.badEmotes.length; i++) { for (let i = 0; i < CHANNEL.badEmotes.length; i++) {
if (CHANNEL.badEmotes[i].name === oldName) { if (CHANNEL.badEmotes[i].name === oldName) {
CHANNEL.badEmotes[i] = data; CHANNEL.badEmotes[i] = data;
break; break;
} }
} }
} }
}
// Not bad now // Not bad now
else { } else {
// But was bad before: Drop from list // But was bad before: Drop from list
if(badBefore){ if(badBefore){
for (var i = 0; i < CHANNEL.badEmotes.length; i++) { for (let i = 0; i < CHANNEL.badEmotes.length; i++) {
if (CHANNEL.badEmotes[i].name === oldName) { if (CHANNEL.badEmotes[i].name === oldName) {
CHANNEL.badEmotes.splice(i, 1); CHANNEL.badEmotes.splice(i, 1);
break; break;
@ -1083,7 +1078,7 @@ Callbacks = {
removeEmote: function (data) { removeEmote: function (data) {
var found = -1; var found = -1;
for (var i = 0; i < CHANNEL.emotes.length; i++) { for (let i = 0; i < CHANNEL.emotes.length; i++) {
if (CHANNEL.emotes[i].name === data.name) { if (CHANNEL.emotes[i].name === data.name) {
found = i; found = i;
break; break;
@ -1093,9 +1088,9 @@ Callbacks = {
if (found !== -1) { if (found !== -1) {
var row = $("code:contains('" + data.name + "')").parent().parent(); var row = $("code:contains('" + data.name + "')").parent().parent();
row.hide("fade", row.remove.bind(row)); row.hide("fade", row.remove.bind(row));
CHANNEL.emotes.splice(i, 1); CHANNEL.emotes.splice(found, 1);
delete CHANNEL.emoteMap[data.name]; delete CHANNEL.emoteMap[data.name];
for (var i = 0; i < CHANNEL.badEmotes.length; i++) { for (let i = 0; i < CHANNEL.badEmotes.length; i++) {
if (CHANNEL.badEmotes[i].name === data.name) { if (CHANNEL.badEmotes[i].name === data.name) {
CHANNEL.badEmotes.splice(i, 1); CHANNEL.badEmotes.splice(i, 1);
break; break;
@ -1171,7 +1166,7 @@ Callbacks = {
$("#voteskip").attr("disabled", false); $("#voteskip").attr("disabled", false);
} }
} }
} };
var SOCKET_DEBUG = { var SOCKET_DEBUG = {
enabled: (localStorage.getItem('cytube_socket_debug') === 'true'), enabled: (localStorage.getItem('cytube_socket_debug') === 'true'),
@ -1179,9 +1174,9 @@ var SOCKET_DEBUG = {
const frames = data === null ? [] : JSON.parse(data); const frames = data === null ? [] : JSON.parse(data);
return frames; return frames;
})(localStorage.getItem('cytube_socket_omissions'))) })(localStorage.getItem('cytube_socket_omissions')))
} };
setupCallbacks = function() { function setupCallbacks() {
for(var key in Callbacks) { for(var key in Callbacks) {
(function(key) { (function(key) {
socket.on(key, function(data) { socket.on(key, function(data) {
@ -1218,7 +1213,7 @@ setupCallbacks = function() {
.appendTo($("#announcements")); .appendTo($("#announcements"));
} }
}); });
}; }
function ioServerConnect(socketConfig) { function ioServerConnect(socketConfig) {
if (socketConfig.error) { if (socketConfig.error) {
@ -1300,7 +1295,7 @@ function initSocketIO(socketConfig) {
function checkLetsEncrypt(socketConfig, nonLetsEncryptError) { function checkLetsEncrypt(socketConfig, nonLetsEncryptError) {
var servers = socketConfig.servers.filter(function (server) { var servers = socketConfig.servers.filter(function (server) {
return !server.secure && !server.ipv6Only return !server.secure && !server.ipv6Only;
}); });
if (servers.length === 0) { if (servers.length === 0) {

View File

@ -31,7 +31,7 @@
s = s + this.opts.maxPages < pages ? s : pages - this.opts.maxPages; s = s + this.opts.maxPages < pages ? s : pages - this.opts.maxPages;
s = s < 0 ? 0 : s; s = s < 0 ? 0 : s;
if(endcaps) { if(endcaps) {
var li = $("<li/>").appendTo(ul); let li = $("<li/>").appendTo(ul);
$("<a/>").attr("href", "javascript:void(0)") $("<a/>").attr("href", "javascript:void(0)")
.html("&laquo;") .html("&laquo;")
.on('click', function () { .on('click', function () {
@ -43,7 +43,7 @@
li.addClass("disabled"); li.addClass("disabled");
if(s > 0) { if(s > 0) {
var sep = $("<li/>").addClass("disabled") let sep = $("<li/>").addClass("disabled")
.appendTo(ul); .appendTo(ul);
$("<a/>").attr("href", "javascript:void(0)") $("<a/>").attr("href", "javascript:void(0)")
.html("&hellip;") .html("&hellip;")
@ -52,7 +52,7 @@
} }
for(var i = s; i < s + this.opts.maxPages && i < s + pages; i++) { for(var i = s; i < s + this.opts.maxPages && i < s + pages; i++) {
(function (i) { (function (i) {
var li = $("<li/>").appendTo(ul); let li = $("<li/>").appendTo(ul);
if(i == p) if(i == p)
li.addClass("active"); li.addClass("active");
$("<a/>").attr("href", "javascript:void(0)") $("<a/>").attr("href", "javascript:void(0)")
@ -65,14 +65,14 @@
} }
if(endcaps) { if(endcaps) {
if(s + this.opts.maxPages < pages) { if(s + this.opts.maxPages < pages) {
var sep = $("<li/>").addClass("disabled") let sep = $("<li/>").addClass("disabled")
.appendTo(ul); .appendTo(ul);
$("<a/>").attr("href", "javascript:void(0)") $("<a/>").attr("href", "javascript:void(0)")
.html("&hellip;") .html("&hellip;")
.appendTo(sep); .appendTo(sep);
} }
var li = $("<li/>").appendTo(ul); let li = $("<li/>").appendTo(ul);
$("<a/>").attr("href", "javascript:void(0)") $("<a/>").attr("href", "javascript:void(0)")
.html("&raquo;") .html("&raquo;")
.on('click', function () { .on('click', function () {