From 06bd770c9ba71f61d1348961f3fc4b5eabb438b0 Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Thu, 19 Jun 2014 01:21:20 +0200 Subject: [PATCH] Remember active window --- client/js/chat.js | 16 ++++++++++++---- lib/models/chan.js | 4 +--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/client/js/chat.js b/client/js/chat.js index 672a041..228771f 100644 --- a/client/js/chat.js +++ b/client/js/chat.js @@ -120,11 +120,17 @@ $(function() { e.stopPropagation(); }); - var networks = $("#networks") - .html(render("networks", {networks: data.networks})) - .find("a") - .last() + var networks = render("networks", {networks: data.networks}); + var current = $("#networks") + .html(networks) + .find("a[href='" + $.cookie("current") + "']") .trigger("click"); + if (!current.length) { + $("#networks") + .find("a") + .last() + .trigger("click"); + } break; case "part": @@ -197,6 +203,8 @@ $(function() { .removeClass("highlight") .empty(); + $.cookie("current", target); + if (sidebar.find(".highlight").length == 0) { favicon.badge(""); } diff --git a/lib/models/chan.js b/lib/models/chan.js index 2493334..67dcf09 100644 --- a/lib/models/chan.js +++ b/lib/models/chan.js @@ -29,9 +29,6 @@ Chan.prototype.addMsg = function(msg) { fs.mkdir(dir); } - var date = moment().format("YYYY-MM-DD"); - var file = dir + this.name + ".log"; - var line = "[" + msg.time + "] "; if (msg.type == "normal") { // Format: @@ -46,6 +43,7 @@ Chan.prototype.addMsg = function(msg) { } } + var file = dir + this.name + ".log"; fs.appendFile( file, line + "\n"