|
2 | 2 | * Initialize the API keys page |
3 | 3 | */ |
4 | 4 | function initApiKeysPage() { |
5 | | - // Set up tab switching |
| 5 | + // Set up main tab switching |
6 | 6 | const tabButtons = document.querySelectorAll(".tab-button"); |
7 | 7 | tabButtons.forEach((button) => { |
8 | 8 | button.addEventListener("click", () => { |
@@ -37,6 +37,40 @@ function initApiKeysPage() { |
37 | 37 | if (firstTabContent) { |
38 | 38 | firstTabContent.style.display = "block"; |
39 | 39 | } |
| 40 | + |
| 41 | + // Set up code example tabs |
| 42 | + const codeTabsContainers = document.querySelectorAll(".code-tabs"); |
| 43 | + codeTabsContainers.forEach((container) => { |
| 44 | + const codeTabs = container.querySelectorAll(".code-tab"); |
| 45 | + const codeContents = container.closest(".code-examples").querySelectorAll(".code-content"); |
| 46 | + |
| 47 | + codeTabs.forEach((tab) => { |
| 48 | + tab.addEventListener("click", () => { |
| 49 | + const codeType = tab.dataset.code; |
| 50 | + console.log("Code tab clicked:", codeType); |
| 51 | + |
| 52 | + // Remove active class from all tabs in this container |
| 53 | + codeTabs.forEach((t) => t.classList.remove("active")); |
| 54 | + |
| 55 | + // Add active class to clicked tab |
| 56 | + tab.classList.add("active"); |
| 57 | + |
| 58 | + // Hide all code content for this container |
| 59 | + codeContents.forEach((content) => { |
| 60 | + content.style.display = "none"; |
| 61 | + }); |
| 62 | + |
| 63 | + // Show selected code content |
| 64 | + const codeContent = Array.from(codeContents).find( |
| 65 | + (content) => content.dataset.code === codeType |
| 66 | + ); |
| 67 | + |
| 68 | + if (codeContent) { |
| 69 | + codeContent.style.display = "block"; |
| 70 | + } |
| 71 | + }); |
| 72 | + }); |
| 73 | + }); |
40 | 74 | } |
41 | 75 |
|
42 | 76 | // Initialize the page when the DOM is loaded |
|
0 commit comments