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();
14 var lastSearchString = null;
15 var lastSearchType = null;
17 /* this is true if we directed to the record detail page
18 becuase of only having one hit on the record result
19 page. this allows us to back up from the detail
20 page to the mr_result page */
21 var recordResultRedirect = false;
26 function addLocation(type, title) {
29 var obj = new Object();
30 obj.location = globalAppFrame.location.href;
32 locationStack[type] = obj;
39 function globalInit() {
41 debug(" --- XUL IS " + isXUL() );
44 if( isXUL() && globalAppFrame )
45 globalAppFrame.document.body.style.background = "#FFF";
49 var page_name = globalPageTarget;
52 throw new EXArg("globalInit requires globalPageTarget to be set");
54 debug("globalInit init-ing page: " + page_name );
59 globalPage = new OPACStartPage();
60 addLocation("start", "Home");
61 locationStack["advanced_search"] = null;
64 case "advanced_search":
65 globalPage = new AdvancedSearchPage();
66 addLocation("advanced_search", "Advanced Search");
67 locationStack["start"] = null;
71 globalPage = new MRResultPage();
72 addLocation("mr_result", "Title Group Results");
76 globalPage = new RecordResultPage();
77 addLocation("record_result", "Title Results");
81 globalPage = new LoginPage();
85 globalPage = new LogoutPage();
89 globalPage = new MyOPACPage();
93 globalPage = new RecordDetailPage();
94 addLocation("record_detail", "Title Details");
98 globalPage = new AboutPage();
105 "globalInit requires a valid page target: " + page_name );
107 if(!loaded) { loaded = true; GlobalInitLoad(); }
109 globalMenuManager = new ContextMenuManager();
111 /* hide all context menus on body click */
112 getDocument().body.onclick = function() {
113 globalMenuManager.hideAll();
118 if(paramObj.__location != null) {
119 globalSelectedLocation = findOrgUnit(paramObj.__location);
120 debug("Setting selected location to " + globalSelectedLocation.name() );
124 if(paramObj.__depth != null) {
125 debug("Passed in depth from search params: " + paramObj.__depth);
126 globalSearchDepth = parseInt(paramObj.__depth);
127 debug("Setting selected depth to " + globalSearchDepth );
130 globalPage.setLocDisplay();
131 globalPage.locationTree = globalOrgTreeWidget;
132 globalPage.setPageTrail();
134 if(globalSearchBarChunk)
135 globalSearchBarChunk.reset();
137 if( globalSearchBarFormChunk != null)
138 globalSearchBarFormChunk.resetPage();
145 /* we only do this on loading of the outer frame (i.e. only once) */
146 function GlobalInitLoad() {
148 debug("Global Init is doing its primary load");
149 globalOrgTreeWidget = new LocationTree(globalOrgTree);
150 globalUser = UserSession.instance();
156 ses = G['auth_ses'][0]; /* G is shoved in by XUL */
157 org = G['user_ou']; /* the desired location of the user */
160 if(globalUser.verifySession(ses)) {
161 globalUser.grabOrgUnit(org);
165 globalLocation = globalOrgTree;
166 if(globalSearchDepth == null)
167 globalSearchDepth = findOrgDepth(globalOrgTree.ou_type());
174 function grabCopyStatus() {
175 if(globalCopyStatus) return;
177 debug("Grabbing copy statuses");
178 var req = new RemoteRequest(
180 "open-ils.search.config.copy_status.retrieve.all" );
182 if(paramObj.__sub_frame) {
183 /* we have to grab the copy statuses synchronously */
185 globalCopyStatus = r.getResultObject();
189 req.setCompleteCallback(function(r) {
190 debug("Got globalCopyStatus");
191 globalCopyStatus = r.getResultObject(); });