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 initSideBar() {
10 var page = findCurrentPage();
13 unHideMe($("sidebar_results_wrapper"));
15 if( page == RRESULT ) {
16 unHideMe($("sidebar_results_wrapper"));
17 unHideMe(G.ui.sidebar[MRESULT]);
18 $("sidebar_title_group_results").setAttribute("href", buildOPACLink({ page: MRESULT }));
21 if( page == RDETAIL ) {
22 unHideMe($("sidebar_results_wrapper"));
23 $("sidebar_title_group_results").setAttribute("href", buildOPACLink({ page: MRESULT }));
24 unHideMe(G.ui.sidebar[MRESULT]);
25 $("sidebar_title_results").setAttribute("href", buildOPACLink({ page : RRESULT }));
26 unHideMe(G.ui.sidebar[RRESULT]);
29 unHideMe(G.ui.sidebar[page]);
30 addCSSClass(G.ui.sidebar[page], "sidebar_item_active");
32 /* if we're logged in, show it and replace the Login link with the Logout link */
34 G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
35 unHideMe(G.ui.sidebar.logoutbox);
36 unHideMe(G.ui.sidebar.logged_in_as);
37 hideMe(G.ui.sidebar.loginbox);
40 if(G.ui.sidebar.login) G.ui.sidebar.login.onclick = initLogin;
41 if(G.ui.sidebar.logout) G.ui.sidebar.logout.onclick = doLogout;
43 if(isXUL()) hideMe( G.ui.sidebar.logoutbox );
46 /* sets up the login ui components */
47 var loginBoxVisible = false;
49 function loginDance() {
53 if(!strongPassword( G.ui.login.password.value ) ) {
55 cookieManager.write(COOKIE_SES, "");
56 hideMe($('login_table'));
57 unHideMe($('change_pw_table'));
58 $('change_pw_current').focus();
59 $('change_pw_button').onclick = changePassword;
60 setEnterFunc($('change_pw_2'), changePassword);
68 function loggedInOK() {
70 G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
71 unHideMe(G.ui.sidebar.logoutbox);
72 unHideMe(G.ui.sidebar.logged_in_as);
73 hideMe(G.ui.sidebar.loginbox);
74 runEvt( "common", "locationChanged", G.user.home_ou(), findOrgDepth(G.user.home_ou()) );
78 function changePassword() {
80 var pc = $('change_pw_current').value;
81 var p1 = $('change_pw_1').value;
82 var p2 = $('change_pw_2').value;
85 alert($('pw_no_match').innerHTML);
89 if(!strongPassword(p2, true) ) return;
91 var req = new Request(UPDATE_PASSWORD, G.user.session, p2, pc );
94 alert($('pw_update_successful').innerHTML);
99 function strongPassword(pass, alrt) {
104 if(pass.length < 7) break;
105 if(!pass.match(/.*\d+.*/)) break;
106 if(!pass.match(/.*[A-Za-z]+.*/)) break;
111 if(!good && alrt) alert($('pw_not_strong').innerHTML);
115 function initLogin() {
117 G.ui.login.button.onclick = loginDance;
118 G.ui.login.username.onkeydown =
119 function(evt) {if(userPressedEnter(evt)) loginDance();};
120 G.ui.login.password.onkeydown =
121 function(evt) {if(userPressedEnter(evt)) loginDance();};
123 if(loginBoxVisible) {
126 swapCanvas(G.ui.login.box);
127 try{G.ui.login.username.focus();}catch(e){}
130 loginBoxVisible = !loginBoxVisible;
131 G.ui.login.cancel.onclick = showCanvas;
132 if(findCurrentPage() == MYOPAC)
133 G.ui.login.cancel.onclick = goHome;
136 function setSidebarLinks() {
137 G.ui.sidebar.home_link.setAttribute("href", buildOPACLink({page:HOME}));
138 G.ui.sidebar.advanced_link.setAttribute("href", buildOPACLink({page:ADVANCED}));
139 G.ui.sidebar.myopac_link.setAttribute("href", buildOPACLink({page:MYOPAC}, false, true));
142 function sidebarTreesFree() {
143 removeChildren($(subjectSidebarTree.rootid));
144 removeChildren($(authorSidebarTree.rootid));
145 removeChildren($(seriesSidebarTree.rootid));
146 subjectSidebarTree = null;
147 authorSidebarTree = null;
148 seriesSidebarTree = null;