generic wrapper for web browsing. goal is page navigation and printing
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 6 Jan 2006 21:58:40 +0000 (21:58 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 6 Jan 2006 21:58:40 +0000 (21:58 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2644 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/evergreen/util/browser.js [new file with mode: 0644]
Open-ILS/xul/staff_client/chrome/content/evergreen/util/browser.xul [new file with mode: 0644]

diff --git a/Open-ILS/xul/staff_client/chrome/content/evergreen/util/browser.js b/Open-ILS/xul/staff_client/chrome/content/evergreen/util/browser.js
new file mode 100644 (file)
index 0000000..c4e97e2
--- /dev/null
@@ -0,0 +1,125 @@
+dump('entering util.browser.js\n');
+
+if (typeof util == 'undefined') util = {};
+util.browser = function (params) {
+       try {
+               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+               JSAN.use('util.error'); this.error = new util.error();
+       } catch(E) {
+               dump('util.browser: ' + E + '\n');
+       }
+}
+
+util.browser.prototype = {
+
+       'init' : function( params ) {
+
+               try {
+                       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+                       var obj = this;
+
+                       obj.session = params['session'];
+                       obj.url = params['url'];
+
+                       JSAN.use('util.controller'); obj.controller = new util.controller();
+                       obj.controller.init(
+                               {
+                                       control_map : {
+                                               'cmd_broken' : [
+                                                       ['command'],
+                                                       function() { alert('Not Yet Implemented'); }
+                                               ],
+                                               'cmd_print' : [
+                                                       ['command'],
+                                                       function() {
+                                                               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                                                               obj.controller.view.browser_browser.contentWindow.print();
+                                                       }
+                                               ],
+                                       }
+                               }
+                       );
+                       obj.controller.view.browser_browser = document.getElementById('browser_browser');
+
+                       obj.buildProgressListener();
+                       dump('obj.controller.view.browser_browser.addProgressListener = ' 
+                               + obj.controller.view.browser_browser.addProgressListener + '\n');
+                       obj.controller.view.browser_browser.addProgressListener(obj.progressListener,
+                                       Components.interfaces.nsIWebProgress.NOTIFY_ALL );
+
+                       obj.controller.view.browser_browser.setAttribute('src',obj.url);
+
+               } catch(E) {
+                       this.error.sdump('D_ERROR','util.browser.init: ' + E + '\n');
+               }
+       },
+
+       'push_variables' : function() {
+
+               try {
+                       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                       this.controller.view.browser_browser.contentWindow.IAMXUL = true;
+                       if (window.xulG) this.controller.view.browser_browser.contentWindow.xulG = xulG;
+               } catch(E) {
+                       this.error.sdump('D_ERROR','util.browser.push_variables: ' + E + '\n');
+               }
+       },
+       
+       'buildProgressListener' : function() {
+
+               try {
+                       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+                       var obj = this;
+                       obj.progressListener = {
+                               onProgressChange        : function(){},
+                               onLocationChange        : function(){},
+                               onStatusChange          : function(){},
+                               onSecurityChange        : function(){},
+                               onStateChange           : function ( webProgress, request, stateFlags, status) {
+                                       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                                       var s = '';
+                                       const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
+                                       const nsIChannel = Components.interfaces.nsIChannel;
+                                       if (stateFlags == 65540 || stateFlags == 65537 || stateFlags == 65552) { return; }
+                                       s = ('onStateChange: stateFlags = ' + stateFlags + ' status = ' + status + '\n');
+                                       if (stateFlags & nsIWebProgressListener.STATE_IS_REQUEST) {
+                                               s += ('\tSTATE_IS_REQUEST\n');
+                                       }
+                                       if (stateFlags & nsIWebProgressListener.STATE_IS_DOCUMENT) {
+                                               s += ('\tSTATE_IS_DOCUMENT\n');
+                                               if( stateFlags & nsIWebProgressListener.STATE_STOP ) obj.push_variables(); 
+                                       }
+                                       if (stateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
+                                               s += ('\tSTATE_IS_NETWORK\n');
+                                       }
+                                       if (stateFlags & nsIWebProgressListener.STATE_IS_WINDOW) {
+                                               s += ('\tSTATE_IS_WINDOW\n');
+                                       }
+                                       if (stateFlags & nsIWebProgressListener.STATE_START) {
+                                               s += ('\tSTATE_START\n');
+                                       }
+                                       if (stateFlags & nsIWebProgressListener.STATE_REDIRECTING) {
+                                               s += ('\tSTATE_REDIRECTING\n');
+                                       }
+                                       if (stateFlags & nsIWebProgressListener.STATE_TRANSFERING) {
+                                               s += ('\tSTATE_TRANSFERING\n');
+                                       }
+                                       if (stateFlags & nsIWebProgressListener.STATE_NEGOTIATING) {
+                                               s += ('\tSTATE_NEGOTIATING\n');
+                                       }
+                                       if (stateFlags & nsIWebProgressListener.STATE_STOP) {
+                                               s += ('\tSTATE_STOP\n');
+                                       }
+                                       obj.error.sdump('D_OPAC',s);    
+                               }
+                       }
+                       obj.progressListener.QueryInterface = function(){return this;};
+               } catch(E) {
+                       this.error.sdump('D_ERROR','util.browser.buildProgressListener: ' + E + '\n');
+               }
+       },
+}
+
+dump('exiting util.browser.js\n');
diff --git a/Open-ILS/xul/staff_client/chrome/content/evergreen/util/browser.xul b/Open-ILS/xul/staff_client/chrome/content/evergreen/util/browser.xul
new file mode 100644 (file)
index 0000000..9ae0730
--- /dev/null
@@ -0,0 +1,85 @@
+<?xml version="1.0"?>
+<!-- Application: Evergreen Staff Client -->
+<!-- Screen: Patron Display -->
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- STYLESHEETS -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/evergreen.css" type="text/css"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- LOCALIZATION -->
+<!DOCTYPE window SYSTEM "chrome://evergreen/locale/lang.dtd">
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- OVERLAYS -->
+<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+
+<window id="util_browser_win" 
+       onload="my_init()"
+       xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+       <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+       <!-- BEHAVIOR -->
+        <script type="text/javascript">
+               var myPackageDir = 'evergreen'; var IAMXUL = true; var g = {};
+               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+       </script>
+        <scripts id="openils_util_scripts"/>
+
+       <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
+       <script>
+       <![CDATA[
+               function my_init() {
+                       try {
+                               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                               if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
+                               JSAN.errorLevel = "die"; // none, warn, or die
+                               JSAN.addRepository('/xul/server/');
+                               JSAN.use('util.error'); g.error = new util.error();
+                               g.error.sdump('D_TRACE','my_init() for util_browser.xul');
+
+                               g.cgi = new CGI();
+                               var session = g.cgi.param('session');
+                               var url = g.cgi.param('url');
+                               if (!url) url = urls.browser;
+
+                               JSAN.use('util.browser'); g.browser = new util.browser();
+
+                               g.browser.init( 
+                                       { 
+                                               'url' : url,
+                                               'session' : session,
+                                       } 
+                               );
+
+                               if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+                                       try { window.xulG.set_tab_name('Catalog'); } catch(E) { alert(E); }
+                               }
+
+                       } catch(E) {
+                               var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
+                                       "system administrator or software developer the following:\n" + E + '\n';
+                               try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
+                               alert(err_msg);
+                       }
+               }
+
+       ]]>
+       </script>
+
+       <commandset id="util_browser_cmds">
+               <command id="cmd_broken" />
+               <command id="cmd_print" />
+       </commandset>
+
+       <vbox flex="1">
+               <hbox>
+                       <spacer flex="1"/>
+                       <button id="browser_print" label="Print Page" command="cmd_print"/>
+               </hbox>
+               <browser id="browser_browser" flex="1"/>
+       </vbox>
+
+</window>
+