]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
save nick and channels in a cookie on connect. 321/head
authorChris Porter <redacted>
Sat, 29 Jul 2017 19:59:19 +0000 (20:59 +0100)
committerChris Porter <redacted>
Sat, 29 Jul 2017 20:00:00 +0000 (21:00 +0100)
fixes issue #320

js/qwebircinterface.js
js/ui/panes/connect.js

index 4655e0fc53470c49995d745f71eb72787bd81e74..3b23ffe90df84992d9b6763268a4f90e2c06ab83 100644 (file)
@@ -11,8 +11,8 @@ function qwebirc_ui_onbeforeunload(e) { /* IE sucks */
 qwebirc.ui.Interface = new Class({
   Implements: [Options],
   options: {
-    initialNickname: "qwebirc" + Math.ceil(Math.random() * 100000),
-    initialChannels: "",
+    initialNickname: null,
+    initialChannels: null,
     networkName: "ExampleNetwork",
     networkServices: [],
     loginRegex: null,
index 8548dc78968354ae3046e40bd6eb2dd1e37a9a9a..44ae2414d0ad2e57d85a632ba8211d4ec3a85930 100644 (file)
@@ -3,6 +3,7 @@ qwebirc.ui.ConnectPane = new Class({
   initialize: function(parent, options) {
     var callback = options.callback, initialNickname = options.initialNickname, initialChannels = options.initialChannels, autoConnect = options.autoConnect, autoNick = options.autoNick;
     this.options = options;
+    this.cookie = new Hash.Cookie("optconn", {duration: 3650, autoSave: false});
     var uiOptions = options.uiOptions;
     this.__windowName = "authgate_" + Math.floor(Math.random() * 100000);
 
@@ -34,6 +35,20 @@ qwebirc.ui.ConnectPane = new Class({
         }
       }
 
+      if(initialNickname === null && initialChannels === null) {
+        var n2 = this.cookie.get("nickname");
+        if(n2 !== null)
+          initialNickname = n2;
+
+        var c2 = this.cookie.get("autojoin");
+        if(c2 !== null)
+          initialChannels = c2;
+      }
+
+      if(initialChannels === null) {
+        initialChannels = "";
+      }
+
       exec("[name=nickname]", util.setText(initialNickname));
       exec("[name=channels]", util.setText(initialChannels));
       exec("[name=prettychannels]", function(node) { this.__buildPrettyChannels(node, initialChannels); }.bind(this));
@@ -105,7 +120,8 @@ qwebirc.ui.ConnectPane = new Class({
       return;
 
     this.__cancelLogin();
-    this.fireEvent("close");
+    this.cookie.extend(data);
+    this.cookie.save();
     this.options.callback(data);
   },
   __cancelLogin: function(noUIModifications) {