]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/qwebircinterface.js
Add configuration of dynamic and static base URLs.
[irc/quakenet/qwebirc.git] / js / qwebircinterface.js
index 2ea6ac1a9bcf511f3535abd42869b7ed67c40571..381ecbd76a77b4f7e0af9721d42719f7b7be1c85 100644 (file)
@@ -1,3 +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;
+}
+
 qwebirc.ui.Interface = new Class({
   Implements: [Options],
   options: {
@@ -10,16 +18,21 @@ qwebirc.ui.Interface = new Class({
     searchURL: true,
     theme: undefined,
     baseURL: null,
-    hue: null
+    hue: null,
+    dynamicBaseURL: "/",
+    staticBaseURL: "/"
   },
   initialize: function(element, ui, options) {
+    qwebirc.global = {dynamicBaseURL: options.dynamicBaseURL, staticBaseURL: options.staticBaseURL}; /* HACK */
+
     this.setOptions(options);
 
     window.addEvent("domready", function() {
       var callback = function(options) {
         var IRC = new qwebirc.irc.IRCClient(options, ui_);
         IRC.connect();
-        window.addEvent("beforeunload", function() {
+        window.onbeforeunload = qwebirc_ui_onbeforeunload;
+        window.addEvent("unload", function() {
           IRC.quit("Page closed");
         });
       };