]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/main/data.xul
preload/cache some JSAN libraries at login
[Evergreen.git] / Open-ILS / xul / staff_client / server / main / data.xul
1 <?xml version="1.0"?>
2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Main, Authentication Window -->
4
5 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
6 <!-- PRESENTATION -->
7 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
8 <?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
9 <?xml-stylesheet href="chrome://open_ils_staff_client/skin/auth.css" type="text/css"?>
10
11 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
12 <!-- LOCALIZATION -->
13 <!DOCTYPE window PUBLIC "" ""[
14         <!--#include virtual="/opac/locale/en-US/lang.dtd"-->
15 ]>
16
17 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
18 <!-- OVERLAYS -->
19 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
20
21 <window id="data_win" 
22         onload="try { data_init(); } catch(E) { alert(E); }"
23         title="&staff.auth.title;"
24         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
25
26
27         <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
28         <!-- BEHAVIOR -->
29         <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
30         <scripts id="openils_util_scripts"/>
31
32         <script type="text/javascript" src="chrome://open_ils_staff_client/content/main/lang.js"/>
33         <script type="text/javascript" src="/xul/server/main/lang.js"/>
34         <script type="text/javascript" src="chrome://open_ils_staff_client/content/main/JSAN.js"/>
35         <script>
36         <![CDATA[
37                 dump("entities['lang.version'] = " + entities['lang.version'] + '\n');
38
39                 function data_init() {
40
41                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
42
43                         if (typeof JSAN == 'undefined') {
44                                 throw(
45                                         "The JSAN library object is missing."
46                                 );
47                         }
48                         /////////////////////////////////////////////////////////////////////////////
49
50                         JSAN.errorLevel = "die"; // none, warn, or die
51                         JSAN.addRepository('/xul/server/');
52
53                         // load these just so they'll get cached
54                         JSAN.use('util.barcode'); JSAN.use('util.controller'); JSAN.use('util.deck'); JSAN.use('util.exec');
55                         JSAN.use('util.fm_utils'); JSAN.use('util.list'); JSAN.use('util.network'); JSAN.use('util.sound');
56                         JSAN.use('util.widgets'); JSAN.use('util.browser'); JSAN.use('util.error'); JSAN.use('util.file');
57                         JSAN.use('util.functional'); JSAN.use('util.money'); JSAN.use('util.print'); JSAN.use('util.text');
58                         JSAN.use('util.window');
59
60                         JSAN.use('patron.bills'); JSAN.use('patron.display'); JSAN.use('patron.holds'); JSAN.use('patron.items');
61                         JSAN.use('patron.search_form'); JSAN.use('patron.search_result'); JSAN.use('patron.summary');
62                         JSAN.use('patron.util');
63
64                         JSAN.use('circ.checkin'); JSAN.use('circ.checkout'); JSAN.use('circ.copy_status'); JSAN.use('circ.hold_capture');
65                         JSAN.use('circ.in_house_use'); JSAN.use('circ.print_list_template_editor'); JSAN.use('circ.util');
66
67                         JSAN.use('cat.copy_browser'); JSAN.use('cat.copy_buckets'); JSAN.use('cat.record_buckets');
68                         JSAN.use('cat.util'); JSAN.use('cat.z3950');
69
70                         // ----
71
72                         JSAN.use('OpenILS.data');
73                         g.data = new OpenILS.data()
74                         g.data.on_error = xulG.auth.logoff;
75                         g.data.entities = entities;
76                         g.data.stash('entities');
77
78                         g.data.session = {};
79                         g.data.session.key = xulG.auth.session.key;
80                         g.data.session.authtime = xulG.auth.session.authtime;
81                         g.data.stash('session');
82                         g.data.on_complete = function () {
83
84                                 g.data.stash('list','hash','tree','temp','cached_request');
85
86                                 setInterval(
87                                         function() {
88                                                 try {
89                                                         var remove_me = [];
90                                                         var n = Number( new Date() );
91                                                         for (var i in g.data.cached_request) {
92                                                                 if (g.data.cached_request[i].expire_time < n && g.data.cached_request[i].status != 'pending') remove_me.push(i);
93                                                         }
94                                                         dump('trimming ' + remove_me.length + ' requests from cache\n');
95                                                         for (var i in remove_me) delete g.data.cached_request[i];
96                                                 } catch(E) {
97                                                         alert(E);
98                                                 }
99                                         }, 180000
100                                 );
101
102                                 g.data._debug_stash();
103
104                                 document.getElementById('iframe').setAttribute(
105                                         'src',
106                                         urls.XUL_OFFLINE_GENERATE_WIDGETS       
107                                 );
108
109                                 document.getElementById('caption').setAttribute('label','Data loaded.');
110
111                                 xulG.window.open(urls.XUL_MENU_FRAME
112                                         + '?server='+window.escape(xulG.url),
113                                         'main'+xulG.window.window_name_increment(),'chrome,resizable'
114                                 );
115
116                         }
117
118                         g.data.init();
119         
120                         g.data.init_observer_functions();
121
122                 }
123         ]]>
124         </script>
125
126         <groupbox id="data_groupbox" flex="1" class="my_overflow"> 
127                 <caption id="caption" label="Loading data..."/> 
128                 <description id="data_progress"/>
129                 <iframe id="iframe" />
130         </groupbox>
131
132 </window>
133