瀏覽代碼

Add default port logic to include/ui.js

Correctly identifies the use of http/https and forces the value of port to 80 and 443
respectively, as in this situation window.location.port is blank.

This is patch includes the same changes as made in vnc_auto.html
Will Rouesnel 12 年之前
父節點
當前提交
c42136d537
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      include/ui.js

+ 12 - 0
include/ui.js

@@ -55,6 +55,18 @@ start: function(callback) {
     // call twice to get around webkit bug
     // call twice to get around webkit bug
     WebUtil.selectStylesheet(UI.getSetting('stylesheet'));
     WebUtil.selectStylesheet(UI.getSetting('stylesheet'));
 
 
+    // if port == 80 (or 443) then it won't be present and should be
+    // set manually
+    port = window.location.port;
+    if (!port) {
+        if (window.location.protocol.substring(0,4) == 'http') {            
+            port = 80;
+        }
+        else if (window.location.protocol.substring(0,5) == 'https') {            
+            port = 443;
+        }
+    }
+
     /* Populate the controls if defaults are provided in the URL */
     /* Populate the controls if defaults are provided in the URL */
     UI.initSetting('host', window.location.hostname);
     UI.initSetting('host', window.location.hostname);
     UI.initSetting('port', window.location.port);
     UI.initSetting('port', window.location.port);