]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/qwebircinterface.js
enhancements:
[irc/quakenet/qwebirc.git] / js / qwebircinterface.js
index 046ddc681a65f058659c1bf3a1a9741b5e4d0414..c451287177b03efa404674c5c98fd946d5447f9c 100644 (file)
@@ -1,9 +1,11 @@
 function qwebirc_ui_onbeforeunload(e) { /* IE sucks */
-  var message = "This action will close all active IRC connections.";
-  var e = e || window.event;
-  if(e)
-    e.returnValue = message;
-  return message;
+  if(qwebirc.connected) {
+    var message = "This action will close all active IRC connections.";
+    var e = e || window.event;
+    if(e)
+      e.returnValue = message;
+    return message;
+  }
 }
 
 qwebirc.ui.Interface = new Class({
@@ -21,14 +23,23 @@ qwebirc.ui.Interface = new Class({
     hue: null,
     saturation: null,
     lightness: null,
+    thue: null,
+    tsaturation: null,
+    tlightness: null,
     uiOptionsArg: null,
+    nickValidation: null,
     dynamicBaseURL: "/",
     staticBaseURL: "/"
   },
   initialize: function(element, ui, options) {
-    qwebirc.global = {dynamicBaseURL: options.dynamicBaseURL, staticBaseURL: options.staticBaseURL}; /* HACK */
-
     this.setOptions(options);
+    
+    /* HACK */
+    qwebirc.global = {
+      dynamicBaseURL: options.dynamicBaseURL,
+      staticBaseURL: options.staticBaseURL,
+      nicknameValidator: $defined(options.nickValidation) ? new qwebirc.irc.NicknameValidator(options.nickValidation) : new qwebirc.irc.DummyNicknameValidator()
+    };
 
     window.addEvent("domready", function() {
       var callback = function(options) {
@@ -46,9 +57,13 @@ qwebirc.ui.Interface = new Class({
       
       if(this.options.searchURL) {
         var args = qwebirc.util.parseURI(String(document.location));
-        this.options.hue = this.getHueArg(args);
-        this.options.saturation = this.getSaturationArg(args);
-        this.options.lightness = this.getLightnessArg(args);
+        this.options.hue = this.getHueArg(args, "");
+        this.options.saturation = this.getSaturationArg(args, "");
+        this.options.lightness = this.getLightnessArg(args, "");
+
+        this.options.thue = this.getHueArg(args, "t");
+        this.options.tsaturation = this.getSaturationArg(args, "t");
+        this.options.tlightness = this.getLightnessArg(args, "t");
         
         if($defined(args["uio"]))
           this.options.uiOptionsArg = args["uio"];
@@ -73,8 +88,9 @@ qwebirc.ui.Interface = new Class({
           
             for(var i=0;i<chans.length;i++) {
               chans2[i] = chans[i];
-            
-              if(chans[i].charAt(0) != '#')
+
+                var prefix = chans[i].charAt(0);
+                if(prefix != '#' && prefix != '&')
                 chans2[i] = "#" + chans2[i]
             }
             cdata[0] = chans2.join(",");
@@ -121,8 +137,8 @@ qwebirc.ui.Interface = new Class({
       var details = ui_.loginBox(callback, inick, ichans, autoConnect, usingAutoNick);
     }.bind(this));
   },
-  getHueArg: function(args) {
-    var hue = args["hue"];
+  getHueArg: function(args, t) {
+    var hue = args[t + "hue"];
     if(!$defined(hue))
       return null;
     hue = parseInt(hue);
@@ -130,8 +146,8 @@ qwebirc.ui.Interface = new Class({
       return null;
     return hue;
   },
-  getSaturationArg: function(args) {
-    var saturation = args["saturation"];
+  getSaturationArg: function(args, t) {
+    var saturation = args[t + "saturation"];
     if(!$defined(saturation))
       return null;
     saturation = parseInt(saturation);
@@ -139,8 +155,8 @@ qwebirc.ui.Interface = new Class({
       return null;
     return saturation;
   },
-  getLightnessArg: function(args) {
-    var lightness = args["lightness"];
+  getLightnessArg: function(args, t) {
+    var lightness = args[t + "lightness"];
     if(!$defined(lightness))
       return null;
     lightness = parseInt(lightness);