2017-05-18 20:08:54 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const $ = require("jquery");
|
|
|
|
const socket = require("../socket");
|
|
|
|
const render = require("../render");
|
2018-03-15 08:37:32 +00:00
|
|
|
const templates = require("../../views");
|
2017-05-18 20:08:54 +00:00
|
|
|
const sidebar = $("#sidebar");
|
2018-05-08 21:40:39 +00:00
|
|
|
const utils = require("../utils");
|
2017-05-18 20:08:54 +00:00
|
|
|
|
|
|
|
socket.on("network", function(data) {
|
2017-08-28 20:06:28 +00:00
|
|
|
render.renderNetworks(data, true);
|
2017-05-18 20:08:54 +00:00
|
|
|
|
|
|
|
sidebar.find(".chan")
|
|
|
|
.last()
|
|
|
|
.trigger("click");
|
|
|
|
|
|
|
|
$("#connect")
|
|
|
|
.find(".btn")
|
2017-09-12 12:52:16 +00:00
|
|
|
.prop("disabled", false);
|
2017-05-18 20:08:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
socket.on("network_changed", function(data) {
|
2018-04-26 09:06:01 +00:00
|
|
|
sidebar.find(`.network[data-uuid="${data.network}"]`).data("options", data.serverOptions);
|
2017-05-18 20:08:54 +00:00
|
|
|
});
|
2018-02-19 11:12:01 +00:00
|
|
|
|
|
|
|
socket.on("network:status", function(data) {
|
|
|
|
sidebar
|
2018-04-26 09:06:01 +00:00
|
|
|
.find(`.network[data-uuid="${data.network}"]`)
|
2018-02-19 11:12:01 +00:00
|
|
|
.toggleClass("not-connected", !data.connected)
|
|
|
|
.toggleClass("not-secure", !data.secure);
|
|
|
|
});
|
2018-03-15 08:37:32 +00:00
|
|
|
|
|
|
|
socket.on("network:info", function(data) {
|
|
|
|
$("#connect")
|
|
|
|
.html(templates.windows.connect(data))
|
|
|
|
.find("form").on("submit", function() {
|
|
|
|
const uuid = $(this).find("input[name=uuid]").val();
|
|
|
|
const newName = $(this).find("#connect\\:name").val();
|
|
|
|
|
|
|
|
sidebar.find(`.network[data-uuid="${uuid}"] .chan.lobby .name`)
|
|
|
|
.attr("title", newName)
|
|
|
|
.text(newName)
|
|
|
|
.click();
|
|
|
|
});
|
2018-05-08 21:40:39 +00:00
|
|
|
|
2018-05-10 18:37:10 +00:00
|
|
|
utils.togglePasswordField("#connect .reveal-password");
|
2018-03-15 08:37:32 +00:00
|
|
|
});
|