hardlounge/client/js/socket-events/quit.js
2018-04-26 12:37:28 +03:00

27 lines
530 B
JavaScript

"use strict";
const $ = require("jquery");
const chat = $("#chat");
const socket = require("../socket");
const sidebar = $("#sidebar");
socket.on("quit", function(data) {
const id = data.network;
const network = sidebar.find(`.network[data-uuid="${id}"]`);
network.children(".chan").each(function() {
// this = child
chat.find($(this).data("target")).remove();
});
network.remove();
const chan = sidebar.find(".chan")
.eq(0)
.trigger("click");
if (chan.length === 0) {
sidebar.find(".empty").show();
}
});