]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/opac/common/js/init.js
fixed typo and repaired boolean test (to be safe) in opac init to enforce user depth...
[Evergreen.git] / Open-ILS / web / opac / common / js / init.js
1
2 /* these events should be used by all */
3
4 window.onunload = windowUnload;
5
6 attachEvt("common", "init", loadUIObjects);
7 //attachEvt("common", "init", initParams);
8 attachEvt("common", "init", initCookies);
9
10 attachEvt("common", "unload", _tree_killer);
11 try{ attachEvt("common", "unload", cleanRemoteRequests);} catch(e){}
12
13 function init() {
14
15         initParams();
16
17         if( getLocation() == null && getOrigLocation() != null )
18                 LOCATION = getOrigLocation();
19
20         if( getLocation() == null && getOrigLocation() == null )
21                 LOCATION = globalOrgTree.id();
22
23         /* if they click on the home page and the origlocation is set
24                 take the opac back to the origlocation */
25         if( findCurrentPage() == HOME && getOrigLocation() != null )
26                 LOCATION = getOrigLocation();
27
28         if(getDepth() == null) DEPTH = findOrgDepth(getLocation());
29
30
31         runEvt('common','init');
32
33         var cgi = new CGI();
34         if( grabUser() ) {
35                 if( cgi.param(PARAM_LOCATION) == null ) {
36                         var org = G.user.prefs[PREF_DEF_LOCATION];
37                         var depth = G.user.prefs[PREF_DEF_DEPTH];
38
39                         if(org == null) org = G.user.ws_ou();
40                         if(depth == null) depth = findOrgDepth(org);
41
42                         LOCATION = org;
43                         DEPTH = depth;
44                 }
45         }
46
47         runEvt("common", "run");
48         //checkUserSkin();
49         G.ui.common.now_searching.appendChild(text(findOrgUnit(getLocation()).name()));
50 }
51
52 function windowUnload() { runEvt("common", "unload"); }