Skip to content

Commit

Permalink
fix jupyter URL handling logic
Browse files Browse the repository at this point in the history
Signed-off-by: Lance-Drane <[email protected]>
  • Loading branch information
Lance-Drane committed Oct 24, 2024
1 parent 6a2de79 commit 378cb46
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions ipsportal/static/jupyter_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@

const NERSC_URL_HELPER_STORAGE_KEY = "username__jupyter.nersc.gov";

function onJupyterUrlBtnClick() {
const nersc_username = prompt(
"Enter the username you authenticate with on NERSC Shibboleth.",
function onJupyterUrlBtnClick(event) {
const nerscUsername = window.prompt(
"Enter your NERSC username.",
window.localStorage.getItem(NERSC_URL_HELPER_STORAGE_KEY) || ""
);
if (nersc_username != null) {
window.localStorage.setItem(NERSC_URL_HELPER_STORAGE_KEY, nersc_username);
const result = jupyterUrlBtn
if (nerscUsername != null) {
window.localStorage.setItem(NERSC_URL_HELPER_STORAGE_KEY, nerscUsername);
const result = event.currentTarget
.getAttribute("data-original-url")
.replace(new RegExp("/user/[^/]+/"), `/user/${nersc_username}/`);
window.location.href = result;
.replace(new RegExp("/user/[^/]+/"), `/user/${nerscUsername}/`);
window.open(result);
}
}

for (jupyterUrlBtn of document.getElementsByClassName("jupyter-url-btn")) {
for (let jupyterUrlBtn of document.getElementsByClassName("jupyter-url-btn")) {
jupyterUrlBtn.addEventListener("click", onJupyterUrlBtnClick);
}

0 comments on commit 378cb46

Please sign in to comment.