Skip to content

Commit b1d7563

Browse files
committed
Add code examples with language tabs for API key endpoints
1 parent 60e6b58 commit b1d7563

File tree

2 files changed

+577
-12
lines changed

2 files changed

+577
-12
lines changed

public/js/views/api-keys.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Initialize the API keys page
33
*/
44
function initApiKeysPage() {
5-
// Set up tab switching
5+
// Set up main tab switching
66
const tabButtons = document.querySelectorAll(".tab-button");
77
tabButtons.forEach((button) => {
88
button.addEventListener("click", () => {
@@ -37,6 +37,40 @@ function initApiKeysPage() {
3737
if (firstTabContent) {
3838
firstTabContent.style.display = "block";
3939
}
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+
});
4074
}
4175

4276
// Initialize the page when the DOM is loaded

0 commit comments

Comments
 (0)