1 /* set up the colors in the sidebar
2 Disables/Enables certain components based on various state data */
4 attachEvt("common", "init", initSideBar);
5 attachEvt("common", "init", setSidebarLinks);
7 attachEvt("common", "unload", sidebarTreesFree );
9 function prevRResults() {
10 return buildOPACLink({ page : RRESULT });
13 function prevMResults() {
14 return buildOPACLink({ page : MRESULT });
17 function initSideBar() {
18 var page = findCurrentPage();
21 unHideMe($("sidebar_results_wrapper"));
23 if( page == RRESULT ) {
24 unHideMe($("sidebar_results_wrapper"));
25 unHideMe(G.ui.sidebar[MRESULT]);
26 $("sidebar_title_group_results").setAttribute("href", prevMResults());
29 if( page == RDETAIL ) {
30 unHideMe($("sidebar_results_wrapper"));
31 $("sidebar_title_group_results").setAttribute("href", prevMResults());
32 unHideMe(G.ui.sidebar[MRESULT]);
33 $("sidebar_title_results").setAttribute("href", prevRResults());
34 unHideMe(G.ui.sidebar[RRESULT]);
37 unHideMe(G.ui.sidebar[page]);
38 addCSSClass(G.ui.sidebar[page], "sidebar_item_active");
40 /* if we're logged in, show it and replace the Login link with the Logout link */
42 G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
43 unHideMe(G.ui.sidebar.logoutbox);
44 unHideMe(G.ui.sidebar.logged_in_as);
45 hideMe(G.ui.sidebar.loginbox);
48 if(G.ui.sidebar.login) G.ui.sidebar.login.onclick = initLogin;
49 if(G.ui.sidebar.logout) G.ui.sidebar.logout.onclick = doLogout;
51 if(isXUL()) hideMe( G.ui.sidebar.logoutbox );
54 /* sets up the login ui components */
55 var loginBoxVisible = false;
57 function loginDance() {
61 if(!strongPassword( G.ui.login.password.value ) ) {
63 cookieManager.write(COOKIE_SES, "");
64 hideMe($('login_table'));
65 unHideMe($('change_pw_table'));
66 $('change_pw_current').focus();
67 $('change_pw_button').onclick = changePassword;
68 setEnterFunc($('change_pw_2'), changePassword);
76 function loggedInOK() {
78 G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
79 unHideMe(G.ui.sidebar.logoutbox);
80 unHideMe(G.ui.sidebar.logged_in_as);
81 hideMe(G.ui.sidebar.loginbox);
82 runEvt( 'common', 'loggedIn');
84 var org = G.user.prefs[PREF_DEF_LOCATION];
85 if(!org) org = G.user.home_ou();
87 var depth = G.user.prefs[PREF_DEF_DEPTH];
88 if(! ( depth && depth <= findOrgDepth(org)) )
89 depth = findOrgDepth(org);
91 runEvt( "common", "locationChanged", org, depth);
95 function changePassword() {
97 var pc = $('change_pw_current').value;
98 var p1 = $('change_pw_1').value;
99 var p2 = $('change_pw_2').value;
102 alert($('pw_no_match').innerHTML);
106 if(!strongPassword(p2, true) ) return;
108 var req = new Request(UPDATE_PASSWORD, G.user.session, p2, pc );
111 alert($('pw_update_successful').innerHTML);
116 function strongPassword(pass, alrt) {
121 if(pass.length < 7) break;
122 if(!pass.match(/.*\d+.*/)) break;
123 if(!pass.match(/.*[A-Za-z]+.*/)) break;
128 if(!good && alrt) alert($('pw_not_strong').innerHTML);
132 function initLogin() {
134 G.ui.login.button.onclick = loginDance;
135 G.ui.login.username.onkeydown =
136 function(evt) {if(userPressedEnter(evt)) loginDance();};
137 G.ui.login.password.onkeydown =
138 function(evt) {if(userPressedEnter(evt)) loginDance();};
140 if(loginBoxVisible) {
143 swapCanvas(G.ui.login.box);
144 try{G.ui.login.username.focus();}catch(e){}
147 loginBoxVisible = !loginBoxVisible;
148 G.ui.login.cancel.onclick = showCanvas;
149 if(findCurrentPage() == MYOPAC)
150 G.ui.login.cancel.onclick = goHome;
153 function setSidebarLinks() {
154 G.ui.sidebar.home_link.setAttribute("href", buildOPACLink({page:HOME}));
155 G.ui.sidebar.advanced_link.setAttribute("href", buildOPACLink({page:ADVANCED}));
156 G.ui.sidebar.myopac_link.setAttribute("href", buildOPACLink({page:MYOPAC}, false, true));
159 function sidebarTreesFree() {
160 removeChildren($(subjectSidebarTree.rootid));
161 removeChildren($(authorSidebarTree.rootid));
162 removeChildren($(seriesSidebarTree.rootid));
163 subjectSidebarTree = null;
164 authorSidebarTree = null;
165 seriesSidebarTree = null;
171 /* --------------------------------------------------------------------------------- */
172 /* Code to support GALILEO links for PINES. Fails gracefully
173 /* --------------------------------------------------------------------------------- */
174 attachEvt('common', 'init', buildEGGalLink);
175 function buildEGGalLink() {
177 /* we're in a lib, nothing to do here */
178 if( getOrigLocation() ) return;
179 if(!$('eg_gal_link')) return;
181 var link = 'http://demo.galib.uga.edu/express?pinesid=';
183 $('eg_gal_link').setAttribute('href', link + G.user.session);
187 $('eg_gal_link').setAttribute('href', 'javascript:void(0);');
188 $('eg_gal_link').setAttribute('target', '');
189 $('eg_gal_link').onclick = function() {
190 /* we're not logged in. go ahead and login */
191 detachAllEvt('common','locationChanged');
192 detachAllEvt('common','loggedIn');
193 attachEvt('common','loggedIn', function() { goTo(link + G.user.session); })
197 /* --------------------------------------------------------------------------------- */