1var pars={}; 2window.location.search 3 .replace(/[?&]+([^=&]+)=([^&]*)/gi, function(str,key,value) { 4 pars[key] = value.replace(/%20/g, " ").replace(/\+/g, "#") 5 } 6); 7 8function login_ok(response) { 9 var id_token, name = "", email = ""; 10 if (response && response.credential) { 11 // Google Identity Services 12 id_token = response.credential; 13 try { 14 var payload = JSON.parse(atob(id_token.split('.')[1].replace(/-/g,'+').replace(/_/g,'/'))); 15 name = payload.name || ""; 16 email = payload.email || ""; 17 } catch(e) {} 18 } else if (response && response.getBasicProfile) { 19 // Legacy gapi (fallback) 20 id_token = response.getAuthResponse().id_token; 21 name = response.getBasicProfile().getName(); 22 email = response.getBasicProfile().getEmail(); 23 } else { return; } 24 google_user = response; 25 $("#btn_signin").hide(); 26 $("#btn_signout").show(); 27 $("#menu_signin_sidebar").hide(); 28 $("#menu_profile_sidebar").show(); 29 $("#div_user_detail").show(); 30 $("#tr_user_news").show(); 31 $("#tr_user_email").show(); 32 $("#btn_signout").html('<a class="nav-link text-nowrap" href="javascript:open_profile();" id="link_profile"><i class="far fa-smile" style="margin-right: 4px;"></i>' + name + '</a>'); 33 $("#profile_note").html(""); 34 $("#profile_email").html(email); 35 $("#profile_btn_signout").html('<img src=media/signout.png height=13 style="margin-top:-3px;vertical-align:middle; padding-right: 3px;"><a href="#" onclick="signOut();">Sign out</a>'); 36 // update last login 37 post_data = {}; 38 post_data["action"] = "login"; 39 post_data["id_token"] = id_token; 40 $.post('/expressrna_gw/index.py', post_data) 41 .always(function(result) { 42 try { 43 db["user"] = $.parseJSON(result); 44 if (db["user"]["session_token"]) { 45 try { localStorage.setItem("expressrna_session", db["user"]["session_token"]); } catch(e) {} 46 } 47 $("#chk_user_news").prop("checked", db["user"]["news"]); 48 $("#lbl_user_name").val(db["user"]["name"]); 49 display_user_tickets(db["user"]["tickets"]); 50 display_user_access(); 51 update_admin_link(); 52 try { if (typeof _mcp_init_token_ui === "function") _mcp_init_token_ui(db["user"]["session_token"]); } catch(e) {} 53 try { _update_impersonation_banner(null, ""); } catch(e) {} // a fresh Google login is always the real account 54 } catch(e) {} 55 // Re-render the page the user is currently on, now that they are logged in. 56 try { 57 if (typeof all_samples !== "undefined") all_samples = []; 58 var cur = {}; 59 window.location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(s, k, v) { 60 cur[k] = v.replace(/%20/g, " ").replace(/\+/g, "#"); 61 }); 62 if (typeof process_login_parameters === "function") { 63 process_login_parameters(cur["action"], cur); 64 } 65 } catch(e) {} 66 }) 67} 68 69// Refresh the logged-in user's group membership into db["user"] (it is cached at 70// login time, so group changes made during the session would otherwise be invisible). 71function refresh_user_groups(cb) { 72 if (typeof db === "undefined" || !db["user"] || !db["user"]["session_token"]) { if (cb) cb(); return; } 73 $.post("/expressrna_gw/index.py", { action: "my_groups", session_token: db["user"]["session_token"] }) 74 .done(function(result) { 75 try { 76 var r = JSON.parse(result); 77 if (r.status === "ok") { 78 db["user"]["groups"] = r.groups; 79 db["user"]["primary_group_id"] = r.primary_group_id; 80 } 81 } catch(e) {} 82 }) 83 .always(function() { if (cb) cb(); }); 84} 85 86function update_admin_link() { 87 if (typeof db !== "undefined" && db["user"] && db["user"]["usertype"] === "admin") { 88 $("#menu_admin").show(); 89 } else { 90 $("#menu_admin").hide(); 91 } 92} 93 94function update_user_usage() { 95 if (!db["user"] || !db["user"]["session_token"]) return; 96 post_data = {}; 97 post_data["action"] = "update_user_usage"; 98 post_data["session_token"] = db["user"]["session_token"]; 99 $.post('/expressrna_gw/index.py', post_data) 100 .done(function(result) { 101 data = $.parseJSON(result); 102 if (data["status"] !== "ok") return; 103 db["user"]["libs"] = data["libs"]; 104 db["user"]["experiments"] = data["experiments"]; 105 db["user"]["counts"] = data["counts"]; 106 db["user"]["limits"] = data["limits"]; 107 display_user_access(); 108 }) 109 .fail(function(){ 110 }) 111} 112 113function login_fail(error) { 114 google_user = undefined; 115 $("#btn_signin").show(); 116 $("#btn_signout").hide(); 117 $("#menu_signin_sidebar").show(); 118 $("#menu_profile_sidebar").hide(); 119 $("#profile_note").html("Your are currently not signed in to expressRNA."); 120} 121function renderButton() { 122 google.accounts.id.initialize({ 123 client_id: "791006066118-1m577h8b7nplonckttm8qtql82ijj6pc.apps.googleusercontent.com", 124 callback: login_ok,
125 auto_select: true, 126 use_fedcm_for_prompt: true 127 }); 128 google.accounts.id.renderButton(document.getElementById("btn_signin"), { 129 type: "standard", 130 theme: "outline", 131 size: "small", 132 text: "signin" 133 }); 134 // Only show the One Tap / FedCM popup when there is no stored session. 135 // If a session token exists, _try_restore_session() handles auth silently; 136 // if that token turns out to be invalid, it calls prompt() as a fallback. 137 var hasSession = false; 138 try { hasSession = !!localStorage.getItem("expressrna_session"); } catch(e) {} 139 if (!hasSession) google.accounts.id.prompt(); 140} 141function signOut() { 142 if (db["user"]["session_token"]) { 143 $.post('/expressrna_gw/index.py', {action: "logout", session_token: db["user"]["session_token"]}); 144 db["user"]["session_token"] = ""; 145 } 146 try { 147 localStorage.removeItem("expressrna_session"); 148 localStorage.removeItem("expressrna_admin_session"); // signing out fully exits any impersonation too 149 } catch(e) {} 150 google.accounts.id.disableAutoSelect(); 151 $("#btn_signin").show(); 152 $("#btn_signout").hide(); 153 $("#menu_signin_sidebar").show(); 154 $("#menu_profile_sidebar").hide(); 155 $("#lbl_name").html(''); 156 $("#menu_admin").hide(); 157 try { _update_impersonation_banner(null, ""); } catch(e) {} 158 db["user"] = {}; 159 email = "public"; 160 open_splash(); 161} 162function menu_clear() { 163 $("#menu_home, #menu_info, #menu_help, #menu_quickstart, #menu_contact, #menu_contributors, #menu_profile, #menu_samples, #menu_genomes, #menu_analyses, #menu_libraries, #menu_clips, #menu_species, #menu_admin, #btn_signout, #menu_profile_sidebar").removeClass('menu_active'); 164} 165 166function menu_select(name) { 167 menu_clear(); 168 $("#" + name).addClass('menu_active'); 169} 170 171function add_history(data, url) { 172 if (pop_state==false) { 173 if (last_url!=url) { 174 window.history.pushState(data, '', url); 175 //console.log("add history:"+url+":"+data); 176 } 177 last_url = url; 178 } 179 pop_state = false; 180} 181 182window.addEventListener('popstate', function(e) { 183 pop_state = true; 184 if (e.state==null) { 185 location.reload(); 186 pop_state = false; 187 return; 188 } 189 //console.log("popstate"); 190 process_login_parameters(e.state["action"], e.state) 191}); 192 193function _try_restore_session() { 194 var saved_token; 195 try { saved_token = localStorage.getItem("expressrna_session"); } catch(e) {} 196 if (!saved_token) return; 197 $.post('/expressrna_gw/index.py', {action: "session_restore", session_token: saved_token}) 198 .done(function(result) { 199 try { 200 var data = $.parseJSON(result); 201 if (data.status !== "ok") { 202 try { localStorage.removeItem("expressrna_session"); } catch(e) {} 203 // Token was invalid/expired â show the login prompt now. 204 try { google.accounts.id.prompt(); } catch(e) {} 205 return; 206 } 207 db["user"] = data; 208 var name = data.name || "", email = data.email || ""; 209 $("#btn_signin").hide(); 210 $("#btn_signout").show(); 211 $("#menu_signin_sidebar").hide(); 212 $("#menu_profile_sidebar").show(); 213 $("#div_user_detail").show(); 214 $("#tr_user_news").show(); 215 $("#tr_user_email").show(); 216 $("#btn_signout").html('<a class="nav-link text-nowrap" href="javascript:open_profile();" id="link_profile"><i class="far fa-smile" style="margin-right: 4px;"></i>' + name + '</a>'); 217 $("#profile_note").html(""); 218 $("#profile_email").html(email); 219 $("#profile_btn_signout").html('<img src=media/signout.png height=13 style="margin-top:-3px;vertical-align:middle; padding-right: 3px;"><a href="#" onclick="signOut();">Sign out</a>');
220 try { $("#chk_user_news").prop("checked", data.news); } catch(e) {} 221 try { if (data.name) $("#lbl_user_name").val(data.name); } catch(e) {} 222 try { if (typeof display_user_tickets === "function") display_user_tickets(data.tickets); } catch(e) {} 223 try { if (typeof display_user_access === "function") display_user_access(); } catch(e) {} 224 try { if (typeof update_admin_link === "function") update_admin_link(); } catch(e) {} 225 try { if (typeof _mcp_init_token_ui === "function") _mcp_init_token_ui(data.session_token); } catch(e) {} 226 try { _update_impersonation_banner(data.impersonated_by, email); } catch(e) {} 227 // Re-render current page with authenticated state 228 try { 229 if (typeof all_samples !== "undefined") all_samples = []; 230 var cur = {}; 231 window.location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(s, k, v) { 232 cur[k] = v.replace(/%20/g, " ").replace(/\+/g, "#"); 233 }); 234 if (typeof process_login_parameters === "function") process_login_parameters(cur["action"], cur); 235 } catch(e) {} 236 } catch(e) { 237 try { localStorage.removeItem("expressrna_session"); } catch(e) {} 238 } 239 }); 240} 241 242// ââ Admin impersonation banner ââââââââââââââââââââââââââââââââââââââââââââââ 243// Driven by session_restore's `impersonated_by` field (not client-side click 244// state), so it shows correctly on every page load for as long as the 245// impersonation session lives â including a plain refresh, not just right 246// after clicking "Login as this user" on the admin profile view. 247 248function _update_impersonation_banner(impersonated_by, email) { 249 var $b = $("#impersonation_banner"); 250 if (impersonated_by) { 251 $("#impersonation_banner_email").text(email || ""); 252 $b.css("display", "flex"); 253 } else { 254 $b.hide(); 255 } 256} 257 258function _return_to_admin() { 259 var admin_token; 260 try { admin_token = localStorage.getItem("expressrna_admin_session"); } catch(e) {} 261 if (!admin_token) { location.href = "index.html"; return; } 262 // best-effort cleanup of the impersonation session; not required for the switch itself 263 if (db["user"] && db["user"]["session_token"]) { 264 $.post('/expressrna_gw/index.py', {action: "logout", session_token: db["user"]["session_token"]}); 265 } 266 try { 267 localStorage.setItem("expressrna_session", admin_token); 268 localStorage.removeItem("expressrna_admin_session"); 269 } catch(e) {} 270 location.href = "index.html"; 271}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.