Skip to content

Commit fc9d412

Browse files
committed
testing custom launch button
1 parent 894a71b commit fc9d412

File tree

2 files changed

+64
-40
lines changed

2 files changed

+64
-40
lines changed
Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,24 @@
11
window.addEventListener("DOMContentLoaded", () => {
2-
// Create modal HTML
3-
const modalHTML = `
4-
<div id="customModal" style="display:none; position:fixed; top:0; left:0; width:100%; height:100%; background-color:rgba(0,0,0,0.5); z-index:1000;">
5-
<div style="background:white; padding:20px; max-width:400px; margin:100px auto; border-radius:8px; box-shadow:0 2px 10px rgba(0,0,0,0.3);">
6-
<h3>Enter your JupyterHub URL</h3>
7-
<input type="text" id="jupyterUrlInput" placeholder="https://yourhub.domain" style="width:100%; padding:8px; margin-top:10px;"/>
8-
<div style="margin-top:15px; text-align:right;">
9-
<button id="launchBtn" style="padding:8px 12px; margin-right:10px;">Launch</button>
10-
<button id="cancelBtn" style="padding:8px 12px;">Cancel</button>
11-
</div>
12-
</div>
13-
</div>
14-
`;
15-
document.body.insertAdjacentHTML("beforeend", modalHTML);
2+
const targetContainer = document.querySelector(".launch-buttons");
163

17-
const launchButton = document.querySelector(".jb-button.launch-button");
18-
const modal = document.getElementById("customModal");
19-
const input = document.getElementById("jupyterUrlInput");
20-
const launchBtn = document.getElementById("launchBtn");
21-
const cancelBtn = document.getElementById("cancelBtn");
4+
if (targetContainer) {
5+
// Create the new button
6+
const customButton = document.createElement("a");
7+
customButton.textContent = "Launch Custom JupyterHub";
8+
customButton.className = "jb-button custom-launch-button";
9+
customButton.style.marginLeft = "10px";
10+
customButton.style.backgroundColor = "#007ACC";
11+
customButton.style.color = "white";
12+
customButton.style.padding = "6px 12px";
13+
customButton.style.borderRadius = "4px";
14+
customButton.style.textDecoration = "none";
2215

23-
if (launchButton) {
24-
launchButton.addEventListener("click", (event) => {
25-
event.preventDefault();
26-
modal.style.display = "block";
27-
});
28-
}
29-
30-
launchBtn.addEventListener("click", () => {
31-
const url = input.value.trim();
32-
if (url.startsWith("https://")) {
33-
window.open(`${url}/lab`, "_blank");
34-
modal.style.display = "none";
35-
input.value = "";
36-
} else {
37-
alert("Please enter a valid HTTPS URL.");
38-
}
39-
});
16+
// Set your custom URL here
17+
const customUrl = "https://your-custom-jupyterhub-url/lab";
18+
customButton.href = customUrl;
19+
customButton.target = "_blank";
4020

41-
cancelBtn.addEventListener("click", () => {
42-
modal.style.display = "none";
43-
input.value = "";
44-
});
21+
// Add the button to the page
22+
targetContainer.appendChild(customButton);
23+
}
4524
});
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
window.addEventListener("DOMContentLoaded", () => {
2+
// Create modal HTML
3+
const modalHTML = `
4+
<div id="customModal" style="display:none; position:fixed; top:0; left:0; width:100%; height:100%; background-color:rgba(0,0,0,0.5); z-index:1000;">
5+
<div style="background:white; padding:20px; max-width:400px; margin:100px auto; border-radius:8px; box-shadow:0 2px 10px rgba(0,0,0,0.3);">
6+
<h3>Enter your JupyterHub URL</h3>
7+
<input type="text" id="jupyterUrlInput" placeholder="https://yourhub.domain" style="width:100%; padding:8px; margin-top:10px;"/>
8+
<div style="margin-top:15px; text-align:right;">
9+
<button id="launchBtn" style="padding:8px 12px; margin-right:10px;">Launch</button>
10+
<button id="cancelBtn" style="padding:8px 12px;">Cancel</button>
11+
</div>
12+
</div>
13+
</div>
14+
`;
15+
document.body.insertAdjacentHTML("beforeend", modalHTML);
16+
17+
const launchButton = document.querySelector(".jb-button.launch-button");
18+
const modal = document.getElementById("customModal");
19+
const input = document.getElementById("jupyterUrlInput");
20+
const launchBtn = document.getElementById("launchBtn");
21+
const cancelBtn = document.getElementById("cancelBtn");
22+
23+
if (launchButton) {
24+
launchButton.addEventListener("click", (event) => {
25+
event.preventDefault();
26+
modal.style.display = "block";
27+
});
28+
}
29+
30+
launchBtn.addEventListener("click", () => {
31+
const url = input.value.trim();
32+
if (url.startsWith("https://")) {
33+
window.open(`${url}/lab`, "_blank");
34+
modal.style.display = "none";
35+
input.value = "";
36+
} else {
37+
alert("Please enter a valid HTTPS URL.");
38+
}
39+
});
40+
41+
cancelBtn.addEventListener("click", () => {
42+
modal.style.display = "none";
43+
input.value = "";
44+
});
45+
});

0 commit comments

Comments
 (0)