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);
6 //attachEvt("common", "unload", sidebarTreesFree );
8 function prevRResults() {
9 return buildOPACLink({ page : RRESULT });
12 function prevMResults() {
13 return buildOPACLink({ page : MRESULT });
16 function initSideBar() {
17 var page = findCurrentPage();
20 unHideMe($("sidebar_results_wrapper"));
22 if( page == RRESULT ) {
23 unHideMe($("sidebar_results_wrapper"));
24 unHideMe(G.ui.sidebar[MRESULT]);
25 if( getRtype() == RTYPE_MRID )
26 $("sidebar_title_group_results").setAttribute("href", prevMResults());
27 else hideMe($("sidebar_title_group_results").parentNode);
30 /* if( page == RDETAIL ) {
31 unHideMe($("sidebar_results_wrapper"));
32 unHideMe(G.ui.sidebar[MRESULT]);
34 $("sidebar_title_results").setAttribute("href", prevRResults());
35 unHideMe(G.ui.sidebar[RRESULT]);
37 if( getRtype() == RTYPE_MRID )
38 $("sidebar_title_group_results").setAttribute("href", prevMResults());
39 else hideMe($("sidebar_title_group_results").parentNode);
42 unHideMe(G.ui.sidebar[page]);
43 addCSSClass(G.ui.sidebar[page], "sidebar_item_active");
45 /* if we're logged in, show it and replace the Login link with the Logout link */
47 //G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
48 //unHideMe(G.ui.sidebar.logoutbox);
49 unHideMe(G.ui.sidebar.logged_in_as);
50 hideMe(G.ui.sidebar.loginbox);
53 if(G.ui.sidebar.login) G.ui.sidebar.login.onclick = initLogin;
54 //if(G.ui.sidebar.logout) G.ui.sidebar.logout.onclick = doLogout;
56 if(isXUL()) hideMe( G.ui.sidebar.logoutbox );
59 /* sets up the login ui components */
60 var loginBoxVisible = false;
61 function loginDance() {
62 var rem = $('remember_me');
63 if(rem) rem = rem.checked; else rem = false;
64 rem = rem?"persist":"opac";
66 if(doLogin(true, rem)) {
68 if(!strongPassword( G.ui.login.password.value ) ) {
70 cookieManager.write(COOKIE_SES, "");
71 hideMe($('login_box'));
72 unHideMe($('change_pw_table'));
73 $('change_pw_current').focus();
74 $('change_pw_button').onclick = changePassword;
75 setEnterFunc($('change_pw_2'), changePassword);
83 function loggedInOK() {
85 //G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
86 //unHideMe(G.ui.sidebar.logoutbox);
87 unHideMe(G.ui.sidebar.logged_in_as);
88 hideMe(G.ui.sidebar.loginbox);
89 runEvt( 'common', 'loggedIn');
91 var org = G.user.prefs[PREF_DEF_LOCATION];
92 // KCLS wants the defautl search location to be the consortium
93 //if(!org) org = G.user.home_ou();
94 if(!org) org = globalOrgTree.id();
96 var depth = G.user.prefs[PREF_DEF_DEPTH];
97 if(! ( depth && depth <= findOrgDepth(org)) )
98 depth = findOrgDepth(org);
100 runEvt( "common", "locationChanged", org, depth);
104 function changePassword() {
106 var pc = $('change_pw_current').value;
107 var p1 = $('change_pw_1').value;
108 var p2 = $('change_pw_2').value;
111 alert($('pw_no_match').innerHTML);
115 if(!strongPassword(p2, true) ) return;
117 var req = new Request(UPDATE_PASSWORD, G.user.session, p2, pc );
120 alert($('pw_update_successful').innerHTML);
126 function strongPassword(pass, alrt) {
128 /* first, let's see if there is a configured regex */
129 if(!pwRegexSetting) {
130 var regex = fetchOrgSettingDefault(G.user.home_ou(), 'global.password_regex');
132 if(pass.match(new RegExp(regex))) {
136 alert($('pw_not_strong').innerHTML);
142 /* no regex configured, use the default */
148 if(pass.length < 7) break;
149 if(!pass.match(/.*\d+.*/)) break;
150 if(!pass.match(/.*[A-Za-z]+.*/)) break;
155 if(!good && alrt) alert($('pw_not_strong').innerHTML);
159 function initLogin() {
160 if(G.ui.login.button) G.ui.login.button.onclick = function(){$('login_form_submit').click();};
162 if(G.ui.login.username) G.ui.login.username.onkeydown = function(evt) {if(userPressedEnter(evt)) $('login_form_submit').click();};
163 if(G.ui.login.password) G.ui.login.password.onkeydown = function(evt) {if(userPressedEnter(evt)) $('login_form_submit').click();};
166 //if(findCurrentPage()==MYOPAC) {
167 swapCanvas(G.ui.login.box);
168 try{G.ui.login.username.focus();}catch(e){}
171 G.ui.login.cancel.onclick = function(evt) {
173 runEvt("common", "loginCanceled");
176 if(findCurrentPage() == MYOPAC)
177 G.ui.login.cancel.onclick = goHome;
180 function setSidebarLinks() {
181 G.ui.sidebar.home_link.setAttribute("href", buildOPACLink({page:HOME}));
182 G.ui.sidebar.advanced_link.setAttribute("href", buildOPACLink({page:ADVANCED}));
183 G.ui.sidebar.myopac_link.setAttribute("href", buildOPACLink({page:MYOPAC}, false, true));
186 function sidebarTreesFree() {
188 removeChildren($(subjectSidebarTree.rootid));
189 removeChildren($(authorSidebarTree.rootid));
190 removeChildren($(seriesSidebarTree.rootid));
191 subjectSidebarTree = null;
192 authorSidebarTree = null;
193 seriesSidebarTree = null;
199 /* --------------------------------------------------------------------------------- */
200 /* Code to support GALILEO links for PINES. Fails gracefully
201 /* --------------------------------------------------------------------------------- */
202 attachEvt('common', 'init', buildEGGalLink);
203 function buildEGGalLink() {
205 /* we're in a lib, nothing to do here */
206 if( getOrigLocation() ) return;
207 if(!$('eg_gal_link')) return;
209 //var link = 'http://demo.galib.uga.edu/express?pinesid=';
210 var link = 'http://www.galileo.usg.edu/express?pinesid=';
212 $('eg_gal_link').setAttribute('href', link + G.user.session);
216 $('eg_gal_link').setAttribute('href', 'javascript:void(0);');
217 $('eg_gal_link').setAttribute('target', '');
218 $('eg_gal_link').onclick = function() {
219 /* we're not logged in. go ahead and login */
220 detachAllEvt('common','locationChanged');
221 detachAllEvt('common','loggedIn');
222 attachEvt('common','loggedIn', function() { goTo(link + G.user.session); })
226 /* --------------------------------------------------------------------------------- */