|
1 | 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); |
| 2 | + const targetContainer = document.querySelector(".launch-buttons"); |
16 | 3 |
|
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"; |
22 | 15 |
|
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"; |
40 | 20 |
|
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 | + } |
45 | 24 | }); |
0 commit comments