]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/qwebircinterface.js
support CHANTYPES
[irc/quakenet/qwebirc.git] / js / qwebircinterface.js
index aae64009d6005444b41bf071321f7fefb0f5c49b..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({
@@ -17,14 +19,29 @@ qwebirc.ui.Interface = new Class({
     appTitle: "ExampleNetwork Web IRC",
     searchURL: true,
     theme: undefined,
-    baseURL: null
+    baseURL: null,
+    hue: null,
+    saturation: null,
+    lightness: null,
+    thue: null,
+    tsaturation: null,
+    tlightness: null,
+    uiOptionsArg: null,
+    nickValidation: null,
+    dynamicBaseURL: "/",
+    staticBaseURL: "/"
   },
   initialize: function(element, ui, options) {
     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 ui_ = new ui($(element), new qwebirc.ui.Theme(this.options.theme), this.options);
-      
       var callback = function(options) {
         var IRC = new qwebirc.irc.IRCClient(options, ui_);
         IRC.connect();
@@ -40,7 +57,17 @@ 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.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"];
+
         var url = args["url"];
         var chans, nick = args["nick"];
         
@@ -61,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(",");
@@ -100,6 +128,8 @@ qwebirc.ui.Interface = new Class({
         }
       }
   
+      var ui_ = new ui($(element), new qwebirc.ui.Theme(this.options.theme), this.options);
+
       var usingAutoNick = !$defined(nick);
       if(usingAutoNick && autoConnect)
         inick = this.options.initialNickname;
@@ -107,6 +137,33 @@ qwebirc.ui.Interface = new Class({
       var details = ui_.loginBox(callback, inick, ichans, autoConnect, usingAutoNick);
     }.bind(this));
   },
+  getHueArg: function(args, t) {
+    var hue = args[t + "hue"];
+    if(!$defined(hue))
+      return null;
+    hue = parseInt(hue);
+    if(hue > 360 || hue < 0)
+      return null;
+    return hue;
+  },
+  getSaturationArg: function(args, t) {
+    var saturation = args[t + "saturation"];
+    if(!$defined(saturation))
+      return null;
+    saturation = parseInt(saturation);
+    if(saturation > 100 || saturation < -100)
+      return null;
+    return saturation;
+  },
+  getLightnessArg: function(args, t) {
+    var lightness = args[t + "lightness"];
+    if(!$defined(lightness))
+      return null;
+    lightness = parseInt(lightness);
+    if(lightness > 100 || lightness < -100)
+      return null;
+    return lightness;
+  },
   randSub: function(nick) {
     var getDigit = function() { return Math.floor(Math.random() * 10); }