1 /* set up the colors in the sidebar
\r
2 Disables/Enables certain components based on various state data */
\r
4 attachEvt("common", "init", initSideBar);
\r
5 //attachEvt("common", "init", setSidebarLinks);
\r
6 //attachEvt("common", "unload", sidebarTreesFree );
\r
8 function prevRResults() {
\r
9 return buildOPACLink({ page : RRESULT });
\r
12 function prevMResults() {
\r
13 return buildOPACLink({ page : MRESULT });
\r
16 function initSideBar() {
\r
17 var page = findCurrentPage();
\r
19 if( page == MRESULT )
\r
20 unHideMe($("sidebar_results_wrapper"));
\r
22 if( page == RRESULT ) {
\r
23 unHideMe($("sidebar_results_wrapper"));
\r
24 unHideMe(G.ui.sidebar[MRESULT]);
\r
25 if( getRtype() == RTYPE_MRID )
\r
26 $("sidebar_title_group_results").setAttribute("href", prevMResults());
\r
27 else hideMe($("sidebar_title_group_results").parentNode);
\r
30 /* if( page == RDETAIL ) {
\r
31 unHideMe($("sidebar_results_wrapper"));
\r
32 unHideMe(G.ui.sidebar[MRESULT]);
\r
34 $("sidebar_title_results").setAttribute("href", prevRResults());
\r
35 unHideMe(G.ui.sidebar[RRESULT]);
\r
37 if( getRtype() == RTYPE_MRID )
\r
38 $("sidebar_title_group_results").setAttribute("href", prevMResults());
\r
39 else hideMe($("sidebar_title_group_results").parentNode);
\r
42 unHideMe(G.ui.sidebar[page]);
\r
43 addCSSClass(G.ui.sidebar[page], "sidebar_item_active");
\r
45 /* if we're logged in, show it and replace the Login link with the Logout link */
\r
47 //G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
\r
48 //unHideMe(G.ui.sidebar.logoutbox);
\r
49 unHideMe(G.ui.sidebar.logged_in_as);
\r
50 hideMe(G.ui.sidebar.loginbox);
\r
53 if(G.ui.sidebar.login) G.ui.sidebar.login.onclick = initLogin;
\r
54 //if(G.ui.sidebar.logout) G.ui.sidebar.logout.onclick = doLogout;
\r
56 if(isXUL()) hideMe( G.ui.sidebar.logoutbox );
\r
59 /* sets up the login ui components */
\r
60 var loginBoxVisible = false;
\r
61 function loginDance() {
\r
62 var rem = $('remember_me');
\r
63 if(rem) rem = rem.checked; else rem = false;
\r
64 rem = rem?"persist":"opac";
\r
66 if(doLogin(true, rem)) {
\r
68 if(!strongPassword( G.ui.login.password.value ) ) {
\r
70 cookieManager.write(COOKIE_SES, "");
\r
71 hideMe($('login_box'));
\r
72 unHideMe($('change_pw_table'));
\r
73 $('change_pw_current').focus();
\r
74 $('change_pw_button').onclick = changePassword;
\r
75 setEnterFunc($('change_pw_2'), changePassword);
\r
83 function loggedInOK() {
\r
85 //G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
\r
86 //unHideMe(G.ui.sidebar.logoutbox);
\r
87 unHideMe(G.ui.sidebar.logged_in_as);
\r
88 hideMe(G.ui.sidebar.loginbox);
\r
89 runEvt( 'common', 'loggedIn');
\r
91 var org = G.user.prefs[PREF_DEF_LOCATION];
\r
92 if(!org) org = G.user.home_ou();
\r
94 var depth = G.user.prefs[PREF_DEF_DEPTH];
\r
95 if(! ( depth && depth <= findOrgDepth(org)) )
\r
96 depth = findOrgDepth(org);
\r
98 runEvt( "common", "locationChanged", org, depth);
\r
102 function changePassword() {
\r
104 var pc = $('change_pw_current').value;
\r
105 var p1 = $('change_pw_1').value;
\r
106 var p2 = $('change_pw_2').value;
\r
109 alert($('pw_no_match').innerHTML);
\r
113 if(!strongPassword(p2, true) ) return;
\r
115 var req = new Request(UPDATE_PASSWORD, G.user.session, p2, pc );
\r
118 alert($('pw_update_successful').innerHTML);
\r
123 var pwRegexSetting;
\r
124 function strongPassword(pass, alrt) {
\r
126 /* first, let's see if there is a configured regex */
\r
127 if(!pwRegexSetting) {
\r
128 var regex = fetchOrgSettingDefault(G.user.home_ou(), 'global.password_regex');
\r
130 if(pass.match(new RegExp(regex))) {
\r
134 alert($('pw_not_strong').innerHTML);
\r
140 /* no regex configured, use the default */
\r
146 if(pass.length < 7) break;
\r
147 if(!pass.match(/.*\d+.*/)) break;
\r
148 if(!pass.match(/.*[A-Za-z]+.*/)) break;
\r
153 if(!good && alrt) alert($('pw_not_strong').innerHTML);
\r
157 function initLogin() {
\r
159 if(G.ui.login.button) G.ui.login.button.onclick = function(){$('login_form_submit').click();};
\r
161 if(G.ui.login.username) G.ui.login.username.onkeydown = function(evt) {if(userPressedEnter(evt)) $('login_form_submit').click();};
\r
162 if(G.ui.login.password) G.ui.login.password.onkeydown = function(evt) {if(userPressedEnter(evt)) $('login_form_submit').click();};
\r
165 //if(findCurrentPage()==MYOPAC) {
\r
166 swapCanvas(G.ui.login.box);
\r
167 try{G.ui.login.username.focus();}catch(e){}
\r
170 G.ui.login.cancel.onclick = function(evt) {
\r
172 runEvt("common", "loginCanceled");
\r
175 if(findCurrentPage() == MYOPAC)
\r
176 G.ui.login.cancel.onclick = goHome;
\r
179 function setSidebarLinks() {
\r
180 G.ui.sidebar.home_link.setAttribute("href", buildOPACLink({page:HOME}));
\r
181 G.ui.sidebar.advanced_link.setAttribute("href", buildOPACLink({page:ADVANCED}));
\r
182 G.ui.sidebar.myopac_link.setAttribute("href", buildOPACLink({page:MYOPAC}, false, true));
\r
185 function sidebarTreesFree() {
\r
187 removeChildren($(subjectSidebarTree.rootid));
\r
188 removeChildren($(authorSidebarTree.rootid));
\r
189 removeChildren($(seriesSidebarTree.rootid));
\r
190 subjectSidebarTree = null;
\r
191 authorSidebarTree = null;
\r
192 seriesSidebarTree = null;
\r
198 /* --------------------------------------------------------------------------------- */
\r
199 /* Code to support GALILEO links for PINES. Fails gracefully
\r
200 /* --------------------------------------------------------------------------------- */
\r
201 attachEvt('common', 'init', buildEGGalLink);
\r
202 function buildEGGalLink() {
\r
204 /* we're in a lib, nothing to do here */
\r
205 if( getOrigLocation() ) return;
\r
206 if(!$('eg_gal_link')) return;
\r
208 //var link = 'http://demo.galib.uga.edu/express?pinesid=';
\r
209 var link = 'http://www.galileo.usg.edu/express?pinesid=';
\r
211 $('eg_gal_link').setAttribute('href', link + G.user.session);
\r
215 $('eg_gal_link').setAttribute('href', 'javascript:void(0);');
\r
216 $('eg_gal_link').setAttribute('target', '');
\r
217 $('eg_gal_link').onclick = function() {
\r
218 /* we're not logged in. go ahead and login */
\r
219 detachAllEvt('common','locationChanged');
\r
220 detachAllEvt('common','loggedIn');
\r
221 attachEvt('common','loggedIn', function() { goTo(link + G.user.session); })
\r
225 /* --------------------------------------------------------------------------------- */
\r