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 debug("At: " + (new RegExp(".+").exec(
40 arguments.callee.toString()))[0].replace("{", "") );
44 function globalInit() {
48 debug(" --- XUL IS " + isXUL() );
51 if( isXUL() && globalAppFrame )
52 globalAppFrame.document.body.style.background = "#FFF";
54 getDocument().body.onunload = cleanIEMemory;
57 var page_name = globalPageTarget;
60 throw new EXArg("globalInit requires globalPageTarget to be set");
62 debug("globalInit init-ing page: " + page_name );
67 globalPage = new OPACStartPage();
68 addLocation("start", "Home");
69 locationStack["advanced_search"] = null;
72 case "advanced_search":
73 globalPage = new AdvancedSearchPage();
74 addLocation("advanced_search", "Advanced Search");
75 locationStack["start"] = null;
79 //globalPage = new MRResultPage();
80 globalPage = MRResultPage.instance();
81 addLocation("mr_result", "Title Group Results");
85 //globalPage = new RecordResultPage();
86 globalPage = RecordResultPage.instance();
87 addLocation("record_result", "Title Results");
91 globalPage = new LoginPage();
95 globalPage = new LogoutPage();
99 globalPage = new MyOPACPage();
102 case "record_detail":
103 globalPage = new RecordDetailPage();
104 addLocation("record_detail", "Title Details");
108 globalPage = new AboutPage();
115 "globalInit requires a valid page target: " + page_name );
117 if(!loaded) { loaded = true; GlobalInitLoad(); }
119 globalMenuManager = new ContextMenuManager();
121 /* hide all context menus on body click */
122 getDocument().body.onclick = function() {
123 globalMenuManager.hideAll();
128 if(paramObj.__location != null) {
129 globalSelectedLocation = findOrgUnit(paramObj.__location);
130 if(globalSelectedLocation == null)
131 debug("Invalid location in url : " + paramObj.__location);
133 debug("Setting selected location to " + globalSelectedLocation.name() );
137 if(paramObj.__depth != null) {
138 debug("Passed in depth from search params: " + paramObj.__depth);
139 globalSearchDepth = parseInt(paramObj.__depth);
140 debug("Setting selected depth to " + globalSearchDepth );
143 globalPage.setLocDisplay();
144 globalPage.locationTree = globalOrgTreeWidget;
145 globalPage.setPageTrail();
147 if(globalSearchBarChunk)
148 globalSearchBarChunk.reset();
150 if( globalSearchBarFormChunk != null)
151 globalSearchBarFormChunk.resetPage();
158 /* we only do this on loading of the outer frame (i.e. only once) */
159 function GlobalInitLoad() {
161 debug("Global Init is doing its primary load");
162 globalOrgTreeWidget = new LocationTree(globalOrgTree);
163 globalUser = UserSession.instance();
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(globalUser.verifySession(ses)) {
174 globalUser.grabOrgUnit(org);
178 globalLocation = globalOrgTree;
179 if(globalSearchDepth == null)
180 globalSearchDepth = findOrgDepth(globalOrgTree.ou_type());
187 function grabCopyStatus() {
188 if(globalCopyStatus) return;
190 debug("Grabbing copy statuses");
191 var req = new RemoteRequest(
193 "open-ils.search.config.copy_status.retrieve.all" );
195 if(paramObj.__sub_frame) {
196 /* we have to grab the copy statuses synchronously */
198 globalCopyStatus = r.getResultObject();
202 req.setCompleteCallback(function(r) {
203 debug("Got globalCopyStatus");
204 globalCopyStatus = r.getResultObject(); });