]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
hack to fix beeping in debug mode
authorChris Porter <redacted>
Tue, 12 Aug 2014 02:07:10 +0000 (03:07 +0100)
committerChris Porter <redacted>
Tue, 12 Aug 2014 02:07:10 +0000 (03:07 +0100)
js/jslib.js
js/qwebircinterface.js

index aa8f32de74f5189b0526a48867bb5aff10a2c085..86bca97679c1bdf0ab0b7ad33fac9d154450dd2a 100644 (file)
@@ -197,6 +197,10 @@ String.prototype.startsWith = function(what) {
   return this.substring(0, what.length) == what;
 }
 
+String.prototype.endsWith = function(what) {
+  return this.substring(this.length - what.length, this.length) == what;
+};
+
 /* NOT cryptographically secure! */
 qwebirc.util.randHexString = function(numBytes) {
   var getByte = function() {
index b22b206c72c306018ec63196119a3a48cdd5de59..8ce1bdc011c1260945249d28299bf0971b59feec 100644 (file)
@@ -34,21 +34,20 @@ qwebirc.ui.Interface = new Class({
   },
   initialize: function(element, ui, options) {
     this.setOptions(options);
-    var extractHost = function(uri) {
-      var start = uri.indexOf('?');
-      if(start != -1)
-        uri = uri.substring(0, start);
-      var start = uri.indexOf('#');
-      if(start != -1)
-        uri = uri.substring(0, start);
+    var extractHost = function() {
+      var uri = document.location.origin + document.location.pathname;
 
+      if(QWEBIRC_DEBUG && uri.endsWith(".html")) {
+        var last = uri.lastIndexOf("/");
+        uri = uri.substring(0, last + 1);
+      }
       if(uri.substr(uri.length - 1) != "/")
         uri = uri + "/";
 
       return uri;
     };
 
-    options.baseURL = extractHost(document.location.href);
+    options.baseURL = extractHost();
     
     /* HACK */
     qwebirc.global = {