]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/chrome/content/main/simple_auth.xul
wording
[working/Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / main / simple_auth.xul
1 <?xml version="1.0"?>
2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Example Template for remote xul -->
4
5 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
6 <!-- STYLESHEETS -->
7 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
8 <?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
9
10 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
11 <!-- LOCALIZATION -->
12 <!DOCTYPE window PUBLIC "" ""[
13         <!--#include virtual="/opac/locale/en-US/lang.dtd"-->
14 ]>
15
16 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
17 <!-- OVERLAYS -->
18 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
19
20 <window id="simple_auth_win" 
21         onload="try { my_init(); } catch(E) { alert(E); }"
22         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
23
24         <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
25         <!-- BEHAVIOR -->
26         <script type="text/javascript">
27                 var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
28         </script>
29         <scripts id="openils_util_scripts"/>
30
31         <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
32         <script>
33         <![CDATA[
34                 function my_init() {
35                         try {
36                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
37                                 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
38                                 JSAN.errorLevel = "die"; // none, warn, or die
39                                 JSAN.addRepository('/xul/server/');
40                                 JSAN.use('util.error'); g.error = new util.error();
41                                 g.error.sdump('D_TRACE','my_init() for simple_auth.xul');
42
43                                 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
44                                 g.data.temporary_session = ''; g.data.stash('temporary_session');
45
46                                 $('server').value = g.data.server_unadorned;
47
48                                 g.cgi = new CGI();
49
50                                 if (g.cgi.param('desc_brief')) {
51                                         $('desc').hidden = false;
52                                         $('desc_brief').appendChild( document.createTextNode( g.cgi.param('desc_brief') ) );
53                                 }
54                                 if (g.cgi.param('desc_full')) {
55                                         $('desc').hidden = false;
56                                         $('desc_full').appendChild( document.createTextNode( g.cgi.param('desc_full') ) );
57                                 }
58
59                                 $('username').focus();
60
61                                 $('username').addEventListener('keypress',handle_keypress,false);
62                                 $('password').addEventListener('keypress',handle_keypress,false);
63
64                         } catch(E) {
65                                 var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
66                                         "system administrator or software developer the following:\nquick_auth.xul\n" + E + '\n';
67                                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
68                                 alert(err_msg);
69                         }
70                 }
71
72                 function $(id) { return document.getElementById(id); }
73
74                 function handle_keypress(ev) {
75                         if ( (! ev.keyCode) || (ev.keyCode != 13) ) return;
76                         switch(ev.target) {
77                                 case $('username') : $('password').focus(); break;
78                                 case $('password') : authorize(); break;
79                                 default: break;
80                         }
81                 }
82
83                 function authorize() {
84                         try {
85                                 JSAN.use('auth.session');
86                                 g.session = new auth.session(
87                                         {
88                                                 'name_prompt' : $('username'),
89                                                 'password_prompt' : $('password'),
90                                                 'server_prompt' : $('server'),
91                                         },
92                                         g.cgi.param('login_type') || 'temp'
93                                 );
94                                 g.session.on_init = function() { 
95                                         g.data.temporary_session = g.session.key;
96                                         g.data.stash('temporary_session');
97                                         window.close();
98                                 }
99                                 g.session.on_init_error = function() { 
100                                         $('password').value = '';
101                                         $('username').focus();
102                                         $('username').select();
103                                  }
104                                 g.session.init();
105                         } catch(E) {
106                                 alert(E);
107                         }
108                 }
109
110         ]]>
111         </script>
112
113         <commandset id="simple_auth_cmds">
114                 <command id="cmd_broken" />
115         </commandset>
116
117         <vbox id="simple_auth_main">
118         <groupbox id="desc" hidden="true">
119                 <caption label="Exception"/>
120                 <description id="desc_brief" style="color: red"/>
121                 <description id="desc_full"/>
122         </groupbox>
123         <groupbox>
124                 <caption label="Authorization"/>
125                 <grid>
126                         <columns><column /><column /></columns>
127                         <rows>
128                                 <row>
129                                         <label value="Username:" control="username" accesskey="U"/>
130                                         <textbox id="username" />
131                                 </row>
132                                 <row>
133                                         <label value="Password:" control="password" accesskey="P"/>
134                                         <textbox id="password" type="password"/>
135                                 </row>
136                                 <row>
137                                         <button label="Cancel" accesskey="C" oncommand="window.close()"/>
138                                         <button label="Authorize" accesskey="A" oncommand="authorize()"/>
139                                 </row>
140                         </rows>
141                 </grid>
142                 <label id="server" hidden="true"/>
143         </groupbox>
144         </vbox>
145 </window>
146