/* fore.st is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. fore.st is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with fore.st. If not, see < http://www.gnu.org/licenses/ >. (C) 2022- by rainbownapkin, Original cytube license: MIT License Copyright (c) 2013-2022 Calvin Montgomery Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ Callbacks = { /* fired when socket connection completes */ connect: function() { HAS_CONNECTED_BEFORE = true; SOCKETIO_CONNECT_ERROR_COUNT = 0; $("#socketio-connect-error").remove(); socket.emit("joinChannel", { name: CHANNEL.name }); if (CHANNEL.opts.password) { socket.emit("channelPassword", CHANNEL.opts.password); } if (CLIENT.name && CLIENT.guest) { socket.emit("login", { name: CLIENT.name }); } $("
").addClass("server-msg-reconnect") .text("Connected") .appendTo($("#messagebuffer")); scrollChat(); stopQueueSpinner(null); }, disconnect: function() { if(KICKED) return; $("
") .addClass("server-msg-disconnect") .text("Disconnected from server.") .appendTo($("#messagebuffer")); scrollChat(); }, reconnect: function () { socket.emit("reportReconnect"); }, // Socket.IO error callback error: function (msg) { window.SOCKET_ERROR_REASON = msg; $("
") .addClass("server-msg-disconnect") .text("Unable to connect: " + msg) .appendTo($("#messagebuffer")); }, errorMsg: function(data) { if (data.alert) { alert(data.msg); } else { errDialog(data.msg); } }, costanza: function (data) { $("#costanza-modal").modal("hide"); var modal = makeModal(); modal.attr("id", "costanza-modal") .appendTo($("body")); var body = $("
").addClass("modal-body") .appendTo(modal.find(".modal-content")); $("").attr("src", "http://i0.kym-cdn.com/entries/icons/original/000/005/498/1300044776986.jpg") .appendTo(body); $("").text(data.msg).appendTo(body); modal.modal(); }, announcement: function(data) { // Suppress this announcement for people who have already closed it if (data.id && CyTube.ui.suppressedAnnouncementId && data.id === CyTube.ui.suppressedAnnouncementId) { return; } $("#announcements").html(""); var signature = "
\u2014" + data.from; var announcement = makeAlert(data.title, data.text + signature) .appendTo($("#announcements")); if (data.id) { announcement.find(".close").click(function suppressThisAnnouncement() { CyTube.ui.suppressedAnnouncementId = data.id; setOpt("suppressed_announcement_id", data.id); }); } }, kick: function(data) { KICKED = true; $("
").addClass("server-msg-disconnect") .text("Kicked: " + data.reason) .appendTo($("#messagebuffer")); scrollChat(); }, noflood: function(data) { $("
") .addClass("server-msg-disconnect") .text(data.action + ": " + data.msg) .appendTo($("#messagebuffer")); scrollChat(); }, spamFiltered: function(data) { var message = "Spam Filtered."; switch (data.reason) { case "NEW_USER_CHAT": message = "Your account is too new to chat in this channel. " + "Please wait a while and try again."; break; case "NEW_USER_CHAT_LINK": message = "Your account is too new to post links in this channel. " + "Please wait a while and try again."; break; } errDialog(message); }, needPassword: function (wrongpw) { var div = $("
"); $("").text("Channel Password") .appendTo(div); if (wrongpw) { $("
").appendTo(div); $("").addClass("text-error") .text("Wrong Password") .appendTo(div); } var pwbox = $("").addClass("form-control") .attr("type", "password") .appendTo(div); var submit = $("