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 globalSelectedLocation = findOrgUnit(paramObj.__location);
131 if(globalSelectedLocation == null)
132 debug("Invalid location in url : " + paramObj.__location);
134 debug("Setting selected location to " + globalSelectedLocation.name() );
138 if(paramObj.__depth != null) {
139 debug("Passed in depth from search params: " + paramObj.__depth);
140 globalSearchDepth = parseInt(paramObj.__depth);
141 debug("Setting selected depth to " + globalSearchDepth );
144 globalPage.setLocDisplay();
145 globalPage.locationTree = globalOrgTreeWidget;
146 globalPage.setPageTrail();
148 if(globalSearchBarChunk)
149 globalSearchBarChunk.reset();
151 if( globalSearchBarFormChunk != null)
152 globalSearchBarFormChunk.resetPage();
159 /* we only do this on loading of the outer frame (i.e. only once) */
160 function GlobalInitLoad() {
162 debug("Global Init is doing its primary load");
163 globalOrgTreeWidget = new LocationTree(globalOrgTree);
169 ses = G['auth_ses'][0]; /* G is shoved in by XUL */
170 org = G['user_ou']; /* the desired location of the user */
173 if(paramObj.__logout) {
178 globalUser = UserSession.instance();
179 if(globalUser.verifySession(ses)) {
180 globalUser.grabOrgUnit(org);
184 globalLocation = globalOrgTree;
185 if(globalSearchDepth == null)
186 globalSearchDepth = findOrgDepth(globalOrgTree.ou_type());
194 function grabCopyStatus() {
195 if(globalCopyStatus) return;
197 debug("Grabbing copy statuses");
198 var req = new RemoteRequest(
200 "open-ils.search.config.copy_status.retrieve.all" );
203 //if(paramObj.__sub_frame) {
205 globalCopyStatus = req.getResultObject();
206 if(!globalCopyStatus) {
207 userMessage("Retrieving copy statuses");
213 req.setCompleteCallback(function(r) {
214 debug("Got globalCopyStatus");
215 globalCopyStatus = r.getResultObject(); });