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 if( getRtype() == RTYPE_MRID )
27 $("sidebar_title_group_results").setAttribute("href", prevMResults());
30 if( page == RDETAIL ) {
31 unHideMe($("sidebar_results_wrapper"));
32 if( getRtype() == RTYPE_MRID )
33 $("sidebar_title_group_results").setAttribute("href", prevMResults());
34 unHideMe(G.ui.sidebar[MRESULT]);
36 $("sidebar_title_results").setAttribute("href", prevRResults());
37 unHideMe(G.ui.sidebar[RRESULT]);
40 unHideMe(G.ui.sidebar[page]);
41 addCSSClass(G.ui.sidebar[page], "sidebar_item_active");
43 /* if we're logged in, show it and replace the Login link with the Logout link */
45 G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
46 unHideMe(G.ui.sidebar.logoutbox);
47 unHideMe(G.ui.sidebar.logged_in_as);
48 hideMe(G.ui.sidebar.loginbox);
51 if(G.ui.sidebar.login) G.ui.sidebar.login.onclick = initLogin;
52 if(G.ui.sidebar.logout) G.ui.sidebar.logout.onclick = doLogout;
54 if(isXUL()) hideMe( G.ui.sidebar.logoutbox );
57 /* sets up the login ui components */
58 var loginBoxVisible = false;
60 function loginDance() {
64 if(!strongPassword( G.ui.login.password.value ) ) {
66 cookieManager.write(COOKIE_SES, "");
67 hideMe($('login_table'));
68 unHideMe($('change_pw_table'));
69 $('change_pw_current').focus();
70 $('change_pw_button').onclick = changePassword;
71 setEnterFunc($('change_pw_2'), changePassword);
79 function loggedInOK() {
81 G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
82 unHideMe(G.ui.sidebar.logoutbox);
83 unHideMe(G.ui.sidebar.logged_in_as);
84 hideMe(G.ui.sidebar.loginbox);
85 runEvt( 'common', 'loggedIn');
87 var org = G.user.prefs[PREF_DEF_LOCATION];
88 if(!org) org = G.user.home_ou();
90 var depth = G.user.prefs[PREF_DEF_DEPTH];
91 if(! ( depth && depth <= findOrgDepth(org)) )
92 depth = findOrgDepth(org);
94 runEvt( "common", "locationChanged", org, depth);
98 function changePassword() {
100 var pc = $('change_pw_current').value;
101 var p1 = $('change_pw_1').value;
102 var p2 = $('change_pw_2').value;
105 alert($('pw_no_match').innerHTML);
109 if(!strongPassword(p2, true) ) return;
111 var req = new Request(UPDATE_PASSWORD, G.user.session, p2, pc );
114 alert($('pw_update_successful').innerHTML);
119 function strongPassword(pass, alrt) {
124 if(pass.length < 7) break;
125 if(!pass.match(/.*\d+.*/)) break;
126 if(!pass.match(/.*[A-Za-z]+.*/)) break;
131 if(!good && alrt) alert($('pw_not_strong').innerHTML);
135 function initLogin() {
137 G.ui.login.button.onclick = loginDance;
138 G.ui.login.username.onkeydown =
139 function(evt) {if(userPressedEnter(evt)) loginDance();};
140 G.ui.login.password.onkeydown =
141 function(evt) {if(userPressedEnter(evt)) loginDance();};
143 if(loginBoxVisible) {
146 swapCanvas(G.ui.login.box);
147 try{G.ui.login.username.focus();}catch(e){}
150 loginBoxVisible = !loginBoxVisible;
151 G.ui.login.cancel.onclick = showCanvas;
152 if(findCurrentPage() == MYOPAC)
153 G.ui.login.cancel.onclick = goHome;
156 function setSidebarLinks() {
157 G.ui.sidebar.home_link.setAttribute("href", buildOPACLink({page:HOME}));
158 G.ui.sidebar.advanced_link.setAttribute("href", buildOPACLink({page:ADVANCED}));
159 G.ui.sidebar.myopac_link.setAttribute("href", buildOPACLink({page:MYOPAC}, false, true));
162 function sidebarTreesFree() {
163 removeChildren($(subjectSidebarTree.rootid));
164 removeChildren($(authorSidebarTree.rootid));
165 removeChildren($(seriesSidebarTree.rootid));
166 subjectSidebarTree = null;
167 authorSidebarTree = null;
168 seriesSidebarTree = null;
174 /* --------------------------------------------------------------------------------- */
175 /* Code to support GALILEO links for PINES. Fails gracefully
176 /* --------------------------------------------------------------------------------- */
177 attachEvt('common', 'init', buildEGGalLink);
178 function buildEGGalLink() {
180 /* we're in a lib, nothing to do here */
181 if( getOrigLocation() ) return;
182 if(!$('eg_gal_link')) return;
184 var link = 'http://demo.galib.uga.edu/express?pinesid=';
186 $('eg_gal_link').setAttribute('href', link + G.user.session);
190 $('eg_gal_link').setAttribute('href', 'javascript:void(0);');
191 $('eg_gal_link').setAttribute('target', '');
192 $('eg_gal_link').onclick = function() {
193 /* we're not logged in. go ahead and login */
194 detachAllEvt('common','locationChanged');
195 detachAllEvt('common','loggedIn');
196 attachEvt('common','loggedIn', function() { goTo(link + G.user.session); })
200 /* --------------------------------------------------------------------------------- */