]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/opac/common/js/init.js
ea349b629620137d63f9564899cc4c2577a3c216
[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( getLocation() != null && getOrigLocation() == null )
24                 ORIGLOC = getLocation();
25
26         if(getDepth() == null) DEPTH = findOrgDepth(getLocation());
27
28
29         runEvt('common','init');
30
31         var cgi = new CGI();
32         if( grabUser() ) {
33                 if( cgi.param(PARAM_LOCATION) == null ) {
34                         var org = G.user.prefs[PREF_DEF_LOCATION];
35                         var depth = G.user.prefs[PREF_DEF_DEPTH];
36
37                         if(!org) org = G.user.ws_ou();
38                         if(!depth) depth = findOrgDepth(org);
39
40                         LOCATION = org;
41                         DEPTH = DEPTH;
42                 }
43         }
44
45         runEvt("common", "run");
46         //checkUserSkin();
47         G.ui.common.now_searching.appendChild(text(findOrgUnit(getLocation()).name()));
48 }
49
50 function windowUnload() { runEvt("common", "unload"); }