[open-ils-commits] r12032 - in branches/staff-client-experiment/Open-ILS: web/opac/locale/en-US xul/staff_client/chrome/content/auth xul/staff_client/chrome/content/main xul/staff_client/chrome/content/util xul/staff_client/server/main

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Feb 1 01:30:04 EST 2009


Author: phasefx
Date: 2009-02-01 01:30:01 -0500 (Sun, 01 Feb 2009)
New Revision: 12032

Modified:
   branches/staff-client-experiment/Open-ILS/web/opac/locale/en-US/lang.dtd
   branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/auth/controller.js
   branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/main/main.js
   branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/main/main.xul
   branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/util/shell.html
   branches/staff-client-experiment/Open-ILS/xul/staff_client/server/main/menu_frame_menus.xul
Log:
upgrade javascript shell and give it a chrome entrypoint

Modified: branches/staff-client-experiment/Open-ILS/web/opac/locale/en-US/lang.dtd
===================================================================
--- branches/staff-client-experiment/Open-ILS/web/opac/locale/en-US/lang.dtd	2009-02-01 04:50:17 UTC (rev 12031)
+++ branches/staff-client-experiment/Open-ILS/web/opac/locale/en-US/lang.dtd	2009-02-01 06:30:01 UTC (rev 12032)
@@ -571,6 +571,8 @@
 <!ENTITY staff.main.auth.debug.inspector.accesskey "I">
 <!ENTITY staff.main.auth.debug.chrome_list "Chrome List">
 <!ENTITY staff.main.auth.debug.chrome_list.accesskey "">
+<!ENTITY staff.main.auth.debug.js_shell "Javascript Shell">
+<!ENTITY staff.main.auth.debug.js_shell.accesskey "">
 <!ENTITY staff.main.auth.hostname "Hostname">
 <!ENTITY staff.main.auth.hostname.accesskey "H">
 <!ENTITY staff.main.auth.offline.caption "Offline Use">
@@ -597,6 +599,8 @@
 <!ENTITY staff.main.menu.admin.cmd_console.label "JavaScript Console">
 <!ENTITY staff.main.menu.admin.cmd_shell.accesskey "H">
 <!ENTITY staff.main.menu.admin.cmd_shell.label "JavaScript Shell">
+<!ENTITY staff.main.menu.admin.cmd_chrome_shell.accesskey "">
+<!ENTITY staff.main.menu.admin.cmd_chrome_shell.label "JavaScript Shell (Chrome)">
 <!ENTITY staff.main.menu.admin.cmd_test.label "Test Module">
 <!ENTITY staff.main.menu.admin.copy_location_edit.accesskey "L">
 <!ENTITY staff.main.menu.admin.copy_location_edit.label "Copy Location Editor">

Modified: branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/auth/controller.js
===================================================================
--- branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/auth/controller.js	2009-02-01 04:50:17 UTC (rev 12031)
+++ branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/auth/controller.js	2009-02-01 06:30:01 UTC (rev 12032)
@@ -78,6 +78,12 @@
                             start_chrome_list();
                         }
                     ],
+                    'cmd_js_shell' : [
+                        ['command'],
+                        function() {
+                            start_js_shell();
+                        }
+                    ],
 					'cmd_override' : [
 						['command'],
 						function() {

Modified: branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/main/main.js
===================================================================
--- branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/main/main.js	2009-02-01 04:50:17 UTC (rev 12031)
+++ branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/main/main.js	2009-02-01 06:30:01 UTC (rev 12032)
@@ -64,6 +64,14 @@
     );
 };
 
+function start_js_shell() {
+    setTimeout(
+        function() {
+            try { window.open('chrome://open_ils_staff_client/content/util/shell.html','shell','chrome,resizable,scrollbars'); } catch(E) { alert(E); }
+        }, 0
+    );
+};
+
 function main_init() {
 	dump('entering main_init()\n');
 	try {

Modified: branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/main/main.xul
===================================================================
--- branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/main/main.xul	2009-02-01 04:50:17 UTC (rev 12031)
+++ branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/main/main.xul	2009-02-01 06:30:01 UTC (rev 12032)
@@ -74,6 +74,7 @@
 		<command id="cmd_debugger"/>
 		<command id="cmd_inspector"/>
 		<command id="cmd_chrome_list"/>
+		<command id="cmd_js_shell"/>
 		<command id="cmd_clear_cache"/>
 		<command id="cmd_test_server"/>
 		<command id="cmd_ssl_exception" hidden="true"/>
@@ -188,6 +189,7 @@
                     <button label="&staff.main.auth.debug.debugger;" accesskey="&staff.main.auth.debug.debugger.accesskey;" command="cmd_debugger"/>
                     <button label="&staff.main.auth.debug.inspector;" accesskey="&staff.main.auth.debug.inspector.accesskey;" command="cmd_inspector"/>
                     <button label="&staff.main.auth.debug.chrome_list;" accesskey="&staff.main.auth.debug.chrome_list.accesskey;" command="cmd_chrome_list"/>
+                    <button label="&staff.main.auth.debug.js_shell;" accesskey="&staff.main.auth.debug.js_shell.accesskey;" command="cmd_js_shell"/>
                     <button label="&staff.main.auth.debug.clear;" accesskey="&staff.main.auth.debug.clear.accesskey;" command="cmd_clear_cache"/>
                 </arrowscrollbox>
             </hbox>

Modified: branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/util/shell.html
===================================================================
--- branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/util/shell.html	2009-02-01 04:50:17 UTC (rev 12031)
+++ branches/staff-client-experiment/Open-ILS/xul/staff_client/chrome/content/util/shell.html	2009-02-01 06:30:01 UTC (rev 12032)
@@ -3,10 +3,9 @@
 <html onclick="keepFocusInTextbox(event)">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<title>JavaScript Shell 1.3.1</title>
+<title>JavaScript Shell 1.4</title>
 
 <script type="text/javascript">
-// Modified by Jason for Evergreen
 var 
 histList = [""], 
 histPos = 0, 
@@ -94,11 +93,11 @@
     setTimeout(function() { _in.value = ""; }, 0); // can't preventDefault on input, so clear it later
   } else if (e.keyCode == 38) { // up
     // go up in history if at top or ctrl-up
-    if (e.ctrlKey || _in.selectionStart == null || _in.selectionStart == 0)
+    if (e.ctrlKey || caretInFirstLine(_in))
       hist(true);
   } else if (e.keyCode == 40) { // down
     // go down in history if at end or ctrl-down
-    if (e.ctrlKey || _in.selectionStart == null || _in.selectionEnd == _in.textLength)
+    if (e.ctrlKey || caretInLastLine(_in))
       hist(false);
   } else if (e.keyCode == 9) { // tab
     tabcomplete();
@@ -110,6 +109,28 @@
   //return true;
 };
 
+function caretInFirstLine(textbox)
+{
+  // IE doesn't support selectionStart/selectionEnd
+  if (textbox.selectionStart == undefined)
+    return true;
+
+  var firstLineBreak = textbox.value.indexOf("\n");
+  
+  return ((firstLineBreak == -1) || (textbox.selectionStart <= firstLineBreak));
+}
+
+function caretInLastLine(textbox)
+{
+  // IE doesn't support selectionStart/selectionEnd
+  if (textbox.selectionEnd == undefined)
+    return true;
+
+  var lastLineBreak = textbox.value.lastIndexOf("\n");
+  
+  return (textbox.selectionEnd > lastLineBreak);
+}
+
 function recalculateInputHeight()
 {
   var rows = _in.value.split(/\n/).length
@@ -152,6 +173,13 @@
   println("Loading " + url + "...", "message");
 },
 
+clear : function clear()
+{
+  var CHILDREN_TO_PRESERVE = 3;
+  while (_out.childNodes[CHILDREN_TO_PRESERVE]) 
+    _out.removeChild(_out.childNodes[CHILDREN_TO_PRESERVE]);
+},
+
 print : function print(s) { println(s, "print"); },
 
 // the normal function, "print", shouldn't return a value
@@ -162,8 +190,18 @@
   return s;
 },
 
-props : function props(e)
+props : function props(e, onePerLine)
 {
+  if (e === null) {
+    println("props called with null argument", "error");
+    return;
+  }
+
+  if (e === undefined) {
+    println("props called with undefined argument", "error");
+    return;
+  }
+
   var ns = ["Methods", "Fields", "Unreachables"];
   var as = [[], [], []]; // array of (empty) arrays of arrays!
   var p, j, i; // loop variables, several used multiple times
@@ -205,7 +243,11 @@
   for (j=0; j<protoLevels; ++j)
     for (i=0;i<ns.length;++i)
       if (as[i][j].length) 
-        printWithRunin(ns[i] + times(" of prototype", j), as[i][j].join(", "), "propList");
+        printWithRunin(
+          ns[i] + times(" of prototype", j), 
+          (onePerLine ? "\n\n" : "") + as[i][j].sort().join(onePerLine ? "\n" : ", ") + (onePerLine ? "\n\n" : ""), 
+          "propList"
+        );
 },
 
 blink : function blink(node)
@@ -264,12 +306,7 @@
   printWithRunin("Math methods", "abs, acos, asin, atan, atan2, ceil, cos, exp, floor, log, max, min, pow, random, round, sin, sqrt, tan", "propList");
 },
 
-ans : undefined,
-
-cls : function cls()
-{
-	while (_out.lastChild) { _out.removeChild( _out.lastChild ); }
-}
+ans : undefined
 };
 
 
@@ -301,9 +338,10 @@
       setTimeout(
         function() {
           _in.value = ''; 
-          _in.value = histList[histPos]; 
+          _in.value = histList[histPos];
+          var caretPos = _in.value.length;
           if (_in.setSelectionRange) 
-            _in.setSelectionRange(0, 0);
+            _in.setSelectionRange(caretPos, caretPos);
         },
         0
       );
@@ -394,18 +432,22 @@
     return i;
   }
 
+  // XXX should be used more consistently (instead of using selectionStart/selectionEnd throughout code)
+  // XXX doesn't work in IE, even though it contains IE-specific code
   function getcaretpos(inp)
   {
-    if(inp.selectionEnd)
+    if(inp.selectionEnd != null)
       return inp.selectionEnd;
-
+      
     if(inp.createTextRange)
     {
-      //dump('using createTextRange\n');
       var docrange = _win.Shell.document.selection.createRange();
       var inprange = inp.createTextRange();
-      inprange.setEndPoint('EndToStart', docrange);
-      return inprange.text.length;
+      if (inprange.setEndPoint)
+      {
+        inprange.setEndPoint('EndToStart', docrange);
+        return inprange.text.length;
+      }
     }
 
     return inp.value.length; // sucks, punt
@@ -667,7 +709,7 @@
 h3 + div { margin: 0; }
 
 form { margin: 0; padding: 0; }
-#input { width: 100%; border: none; padding: 0; }
+#input { width: 100%; border: none; padding: 0; overflow: auto; }
 
 .input { color: blue; background: white; font: inherit; font-weight: bold; margin-top: .5em; /* background: #E6E6FF; */ }
 .normalOutput { color: black; background: white; }
@@ -679,12 +721,12 @@
 </style>
 </head>
 
-<body onload="try { init(); } catch(E) { dump(E+'\n'); alert(E); }"> 
+<body onload="init()">
 
- <div id="output"><h3>JavaScript Shell 1.3.1</h3><div>Features: autocompletion of property names with Tab, multiline input with Shift+Enter, input history with (Ctrl+) Up/Down, <a accesskey=M href="javascript:go('scope(Math); mathHelp();');">Math</a>, <a accesskey=H href="http://www.squarefree.com/shell/?ignoreReferrerFrom=shell1.3.1">help</a></div><div>Values and functions: ans, print(string), <a accesskey=P href="javascript:go('props(ans)')">props(object)</a>, <a accesskey=B href="javascript:go('blink(ans)')">blink(node)</a>, load(scriptURL), scope(object), cls()</div></div>
+<div id="output"><h3>JavaScript Shell 1.4</h3><div>Features: autocompletion of property names with Tab, multiline input with Shift+Enter, input history with (Ctrl+) Up/Down, <a accesskey="M" href="javascript:go('scope(Math); mathHelp();');" title="Accesskey: M">Math</a>, <a accesskey="H" href="http://www.squarefree.com/shell/?ignoreReferrerFrom=shell1.4"  title="Accesskey: H">help</a></div><div>Values and functions: ans, print(string), <a accesskey="P" href="javascript:go('props(ans)')" title="Accesskey: P">props(object)</a>, <a accesskey="B" href="javascript:go('blink(ans)')" title="Accesskey: B">blink(node)</a>, <a accesskey="C" href="javascript:go('clear()')" title="Accesskey: C">clear()</a>, load(scriptURL), scope(object)</div></div>
 
 <div><textarea id="input" class="input" wrap="off" onkeydown="inputKeydown(event)" rows="1"></textarea></div>
 
 </body>
 
-</html>
+</html>
\ No newline at end of file

Modified: branches/staff-client-experiment/Open-ILS/xul/staff_client/server/main/menu_frame_menus.xul
===================================================================
--- branches/staff-client-experiment/Open-ILS/xul/staff_client/server/main/menu_frame_menus.xul	2009-02-01 04:50:17 UTC (rev 12031)
+++ branches/staff-client-experiment/Open-ILS/xul/staff_client/server/main/menu_frame_menus.xul	2009-02-01 06:30:01 UTC (rev 12032)
@@ -222,6 +222,8 @@
 				<menuitem label="&staff.main.menu.admin.fieldmapper.label;" accesskey="&staff.main.menu.admin.fieldmapper.accesskey;" command="cmd_fieldmapper"/>
 				<menuitem label="&staff.main.menu.admin.cmd_console.label;" accesskey="&staff.main.menu.admin.cmd_console.accesskey;" command="cmd_console"/>
 				<menuitem label="&staff.main.menu.admin.cmd_shell.label;" accesskey="&staff.main.menu.admin.cmd_shell.accesskey;" command="cmd_shell"/>
+				<menuitem label="&staff.main.menu.admin.cmd_chrome_shell.label;" accesskey="&staff.main.menu.admin.cmd_chrome_shell.accesskey;" 
+                    oncommand="try{xulG.window.win.start_js_shell();}catch(E){alert(E);}"/>
 				<menuitem label="server/main/test.html" accesskey="1" command="cmd_test_html"/>
 				<menuitem label="server/main/test.xul" accesskey="2" command="cmd_test_xul"/>
 				<menuitem label="&staff.main.menu.admin.clear_cache.label;" accesskey="&staff.main.menu.admin.clear_cache.accesskey;" command="cmd_clear_cache"/>



More information about the open-ils-commits mailing list