3 var globalPage = null; /* the current top level page object */
4 var globalUser = null; /* the user session */
5 var globalOrgTreeWidget = null;
6 var globalLocation = null;
7 var globalOrgTreeWidgetBox = null;
8 var globalSelectedLocation = null;
9 var globalSearchDepth = null;
10 var globalMenuManager = null;
11 var globalCopyStatus = null;
12 var locationStack = new Array();
13 var globalCopyLocations = null;
15 var lastSearchString = null;
16 var lastSearchType = null;
18 /* this is true if we directed to the record detail page
19 becuase of only having one hit on the record result
20 page. this allows us to back up from the detail
21 page to the mr_result page */
22 var recordResultRedirect = false;
27 function addLocation(type, title) {
30 var obj = new Object();
31 obj.location = globalAppFrame.location.href;
33 locationStack[type] = obj;
40 debug("At: " + (new RegExp(".+").exec(
41 arguments.callee.toString()))[0].replace("{", "") );
45 function globalInit() {
49 debug(" --- XUL IS " + isXUL() );
52 if( isXUL() && globalAppFrame )
53 globalAppFrame.document.body.style.background = "#FFF";
55 getDocument().body.onunload = cleanIEMemory;
58 var page_name = globalPageTarget;
61 throw new EXArg("globalInit requires globalPageTarget to be set");
63 debug("globalInit init-ing page: " + page_name );
68 globalPage = new OPACStartPage();
69 addLocation("start", "Home");
70 locationStack["advanced_search"] = null;
73 case "advanced_search":
74 globalPage = new AdvancedSearchPage();
75 addLocation("advanced_search", "Advanced Search");
76 locationStack["start"] = null;
80 //globalPage = new MRResultPage();
81 globalPage = MRResultPage.instance();
82 addLocation("mr_result", "Title Group Results");
86 //globalPage = new RecordResultPage();
87 globalPage = RecordResultPage.instance();
88 addLocation("record_result", "Title Results");
92 globalPage = new LoginPage();
96 globalPage = new LogoutPage();
100 globalPage = new MyOPACPage();
103 case "record_detail":
104 globalPage = new RecordDetailPage();
105 addLocation("record_detail", "Title Details");
109 globalPage = new AboutPage();
116 "globalInit requires a valid page target: " + page_name );
118 if(!loaded) { loaded = true; GlobalInitLoad(); }
120 globalMenuManager = new ContextMenuManager();
122 /* hide all context menus on body click */
123 getDocument().body.onclick = function() {
124 globalMenuManager.hideAll();
129 if(paramObj.__location != null) {
130 debug("Someone passed us a location ID of " + paramObj.__location);
132 globalSelectedLocation = findOrgUnit(paramObj.__location);
134 if(paramObj.__depth == null) {
135 paramObj.__depth = findOrgType(globalSelectedLocation.ou_type()).depth();
138 if(globalSelectedLocation == null)
139 debug("Invalid location in url : " + paramObj.__location);
141 debug("Setting selected location to " + globalSelectedLocation.name() );
144 debug("No location provided in URL");
148 if(paramObj.__depth != null) {
149 debug("Passed in depth from search params: " + paramObj.__depth);
150 globalSearchDepth = parseInt(paramObj.__depth);
151 debug("Setting selected depth to " + globalSearchDepth );
154 globalPage.setLocDisplay();
155 globalPage.locationTree = globalOrgTreeWidget;
156 globalPage.setPageTrail();
158 if(globalSearchBarChunk)
159 globalSearchBarChunk.reset();
161 if( globalSearchBarFormChunk != null)
162 globalSearchBarFormChunk.resetPage();
169 /* we only do this on loading of the outer frame (i.e. only once) */
170 function GlobalInitLoad() {
172 debug("Global Init is doing its primary load");
173 globalOrgTreeWidget = new LocationTree(globalOrgTree);
179 ses = G['auth_ses'][0]; /* G is shoved in by XUL */
180 org = G['user_ou']; /* the desired location of the user */
183 if(paramObj.__logout) {
188 globalUser = UserSession.instance();
189 if(globalUser.verifySession(ses)) {
190 globalUser.grabOrgUnit(org);
194 globalLocation = globalOrgTree;
195 if(globalSearchDepth == null)
196 globalSearchDepth = findOrgDepth(globalOrgTree.ou_type());
204 function grabCopyStatus() {
205 if(globalCopyStatus) return;
207 debug("Grabbing copy statuses");
208 var req = new RemoteRequest(
210 "open-ils.search.config.copy_status.retrieve.all" );
213 //if(paramObj.__sub_frame) {
215 globalCopyStatus = req.getResultObject();
216 if(!globalCopyStatus) {
217 userMessage("Retrieving copy statuses");
223 req.setCompleteCallback(function(r) {
224 debug("Got globalCopyStatus");
225 globalCopyStatus = r.getResultObject(); });