You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2010/11/26 17:23:08 UTC

svn commit: r1039442 - in /karaf/branches/karaf-2.1.x/webconsole/gogo/src/main: java/org/apache/karaf/webconsole/gogo/Terminal.java resources/res/ui/gogo.js

Author: gnodet
Date: Fri Nov 26 16:23:08 2010
New Revision: 1039442

URL: http://svn.apache.org/viewvc?rev=1039442&view=rev
Log:
[KARAF-300] Incorrect behavior of backspace/delete keys in web console Gogo plugin

Modified:
    karaf/branches/karaf-2.1.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/Terminal.java
    karaf/branches/karaf-2.1.x/webconsole/gogo/src/main/resources/res/ui/gogo.js

Modified: karaf/branches/karaf-2.1.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/Terminal.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.1.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/Terminal.java?rev=1039442&r1=1039441&r2=1039442&view=diff
==============================================================================
--- karaf/branches/karaf-2.1.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/Terminal.java (original)
+++ karaf/branches/karaf-2.1.x/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/Terminal.java Fri Nov 26 16:23:08 2010
@@ -1023,7 +1023,7 @@ public class Terminal {
         String[] values = new String[n];
         for (int i = 0; i < n; i++) {
             String value = null;
-            if (i < ps.length) {
+            if (i < ps.length && ps[i].length() > 0) {
                 value = prefix + ps[i];
             }
             if (value == null && i < defaults.length) {

Modified: karaf/branches/karaf-2.1.x/webconsole/gogo/src/main/resources/res/ui/gogo.js
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.1.x/webconsole/gogo/src/main/resources/res/ui/gogo.js?rev=1039442&r1=1039441&r2=1039442&view=diff
==============================================================================
--- karaf/branches/karaf-2.1.x/webconsole/gogo/src/main/resources/res/ui/gogo.js (original)
+++ karaf/branches/karaf-2.1.x/webconsole/gogo/src/main/resources/res/ui/gogo.js Fri Nov 26 16:23:08 2010
@@ -24,7 +24,6 @@ gogo = { };
 
 gogo.Terminal_ctor = function(div, width, height) {
 
-   var ie = (window.ActiveXObject) ? 0 : 1;
    var query0 = "w=" + width + "&h=" + height;
    var query1 = query0 + "&k=";
    var buf = "";
@@ -98,14 +97,14 @@ gogo.Terminal_ctor = function(div, width
        }
    }
 
-   function keypress(ev) {
+   function keypress(ev, fromkeydown) {
         // Translate to standard keycodes
         if (!ev)
             ev = window.event;
         var kc;
         if (ev.keyCode)
             kc = ev.keyCode;
-        if (ev.which)
+        if (!fromkeydown && ev.which)
             kc = ev.which;
         if (ev.ctrlKey) {
             if (kc >= 0 && kc <= 32)
@@ -124,7 +123,7 @@ gogo.Terminal_ctor = function(div, width
                     default: return true;
                 }
             }
-        } else if (ev.which == 0) {
+        } else if (fromkeydown) {
             switch(kc) {
                 case 8: break;			     // Backspace
                 case 9: break;               // Tab
@@ -154,8 +153,6 @@ gogo.Terminal_ctor = function(div, width
                 default: return true;
             }
         }
-        if (kc == 8)
-            kc = 127;
 
         var k = "";
         // Build character
@@ -185,6 +182,11 @@ gogo.Terminal_ctor = function(div, width
             case 63247: k = "~l"; break; // F12
             default:    k = String.fromCharCode(kc); break;
         }
+
+//        debug("fromkeydown=" + fromkeydown + ", ev.keyCode=" + ev.keyCode + ", " +
+//              "ev.which=" + ev.which + ", ev.ctrlKey=" + ev.ctrlKey + ", " +
+//              "kc=" + kc + ", k=" + k);
+
         queue(encodeURIComponent(k));
 
         ev.cancelBubble = true;
@@ -197,14 +199,11 @@ gogo.Terminal_ctor = function(div, width
    function keydown(ev) {
        if (!ev)
           ev = window.event;
-       if (ie) {
            o = { 9:1, 8:1, 27:1, 33:1, 34:1, 35:1, 36:1, 37:1, 38:1, 39:1, 40:1, 45:1, 46:1, 112:1,
                  113:1, 114:1, 115:1, 116:1, 117:1, 118:1, 119:1, 120:1, 121:1, 122:1, 123:1 };
            if (o[ev.keyCode] || ev.ctrlKey || ev.altKey) {
-               ev.which = 0;
-               return keypress(ev);
+               keypress(ev, true);
            }
-       }
    }
 
    function init() {