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());
28 else hideMe($("sidebar_title_group_results").parentNode);
31 if( page == RDETAIL ) {
32 unHideMe($("sidebar_results_wrapper"));
35 unHideMe(G.ui.sidebar[MRESULT]);
37 $("sidebar_title_results").setAttribute("href", prevRResults());
38 unHideMe(G.ui.sidebar[RRESULT]);
40 if( getRtype() == RTYPE_MRID )
41 $("sidebar_title_group_results").setAttribute("href", prevMResults());
42 else hideMe($("sidebar_title_group_results").parentNode);
45 unHideMe(G.ui.sidebar[page]);
46 addCSSClass(G.ui.sidebar[page], "sidebar_item_active");
48 /* if we're logged in, show it and replace the Login link with the Logout link */
50 G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
51 unHideMe(G.ui.sidebar.logoutbox);
52 unHideMe(G.ui.sidebar.logged_in_as);
53 hideMe(G.ui.sidebar.loginbox);
56 if(G.ui.sidebar.login) G.ui.sidebar.login.onclick = initLogin;
57 if(G.ui.sidebar.logout) G.ui.sidebar.logout.onclick = doLogout;
59 if(isXUL()) hideMe( G.ui.sidebar.logoutbox );
62 /* sets up the login ui components */
63 var loginBoxVisible = false;
65 function loginDance() {
69 if(!strongPassword( G.ui.login.password.value ) ) {
71 cookieManager.write(COOKIE_SES, "");
72 hideMe($('login_table'));
73 unHideMe($('change_pw_table'));
74 $('change_pw_current').focus();
75 $('change_pw_button').onclick = changePassword;
76 setEnterFunc($('change_pw_2'), changePassword);
84 function loggedInOK() {
86 G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
87 unHideMe(G.ui.sidebar.logoutbox);
88 unHideMe(G.ui.sidebar.logged_in_as);
89 hideMe(G.ui.sidebar.loginbox);
90 runEvt( 'common', 'loggedIn');
92 var org = G.user.prefs[PREF_DEF_LOCATION];
93 if(!org) org = G.user.home_ou();
95 var depth = G.user.prefs[PREF_DEF_DEPTH];
96 if(! ( depth && depth <= findOrgDepth(org)) )
97 depth = findOrgDepth(org);
99 runEvt( "common", "locationChanged", org, depth);
103 function changePassword() {
105 var pc = $('change_pw_current').value;
106 var p1 = $('change_pw_1').value;
107 var p2 = $('change_pw_2').value;
110 alert($('pw_no_match').innerHTML);
114 if(!strongPassword(p2, true) ) return;
116 var req = new Request(UPDATE_PASSWORD, G.user.session, p2, pc );
119 alert($('pw_update_successful').innerHTML);
125 function strongPassword(pass, alrt) {
127 /* first, let's see if there is a configured regex */
128 if(!pwRegexSetting) {
129 var regex = fetchOrgSettingDefault(G.user.home_ou(), 'global.password_regex');
131 if(pass.match(new RegExp(regex))) {
135 alert($('pw_not_strong').innerHTML);
141 /* no regex configured, use the default */
147 if(pass.length < 7) break;
148 if(!pass.match(/.*\d+.*/)) break;
149 if(!pass.match(/.*[A-Za-z]+.*/)) break;
154 if(!good && alrt) alert($('pw_not_strong').innerHTML);
158 function initLogin() {
160 G.ui.login.button.onclick = function(evt) { G.ui.login.form.setAttribute('action','javascript:loginDance();'); };
161 G.ui.login.username.onkeydown =
162 function(evt) {if(userPressedEnter(evt)) G.ui.login.form.setAttribute('action','javascript:loginDance();');};
163 G.ui.login.password.onkeydown =
164 function(evt) {if(userPressedEnter(evt)) G.ui.login.form.setAttribute('action','javascript:loginDance();');};
166 // if(loginBoxVisible) {
169 swapCanvas(G.ui.login.box);
170 try{G.ui.login.username.focus();}catch(e){}
173 // loginBoxVisible = !loginBoxVisible;
174 G.ui.login.cancel.onclick = function(evt) { G.ui.login.form.setAttribute('action','javascript:showCanvas();'); };
175 if(findCurrentPage() == MYOPAC)
176 G.ui.login.cancel.onclick = function(evt) { G.ui.login.form.setAttribute('action','javascript:goHome();'); };
179 function setSidebarLinks() {
180 G.ui.sidebar.home_link.setAttribute("href", buildOPACLink({page:HOME}));
181 G.ui.sidebar.advanced_link.setAttribute("href", buildOPACLink({page:ADVANCED}));
182 G.ui.sidebar.myopac_link.setAttribute("href", buildOPACLink({page:MYOPAC}, false, true));
185 function sidebarTreesFree() {
187 removeChildren($(subjectSidebarTree.rootid));
188 removeChildren($(authorSidebarTree.rootid));
189 removeChildren($(seriesSidebarTree.rootid));
190 subjectSidebarTree = null;
191 authorSidebarTree = null;
192 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 /* --------------------------------------------------------------------------------- */