-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adding 'Load this SAE' popup to docs table
- Loading branch information
Showing
4 changed files
with
141 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
.saetable-loadSaeId { | ||
display: inline-block; | ||
margin-top: 10px; | ||
cursor: pointer; | ||
} | ||
/* Modal styles */ | ||
.saetable-modal { | ||
display: none; | ||
position: fixed; | ||
z-index: 1000; | ||
left: 0; | ||
top: 0; | ||
width: 100%; | ||
height: 100%; | ||
margin: 0 !important; | ||
background-color: rgba(0,0,0,0.4); | ||
} | ||
|
||
.saetable-modalContent { | ||
background-color: white; | ||
margin: 15% auto; | ||
padding: 2px; | ||
border: 1px solid #888; | ||
width: 80%; | ||
max-width: 600px; | ||
border-radius: 5px; | ||
position: relative; | ||
} | ||
|
||
.saetable-close { | ||
color: #aaa; | ||
font-size: 28px; | ||
font-weight: bold; | ||
cursor: pointer; | ||
position: absolute; | ||
right: 15px; | ||
top: 0; | ||
z-index: 1001; | ||
} | ||
|
||
.saetable-close:hover { | ||
color: black; | ||
} | ||
|
||
.saetable-modalContent pre { | ||
padding: 5px; | ||
border-radius: 5px; | ||
overflow-x: auto; | ||
margin: 0; | ||
} | ||
|
||
.saetable-copyButton { | ||
margin: 0 5px 5px 5px; | ||
padding: 8px 16px; | ||
background-color: #4CAF50; | ||
color: white; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
} | ||
|
||
.saetable-copyButton:hover { | ||
background-color: #45a049; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
window.SaeTable = { | ||
showCode: function (release, saeId) { | ||
const modal = document.getElementById("codeModal"); | ||
const codeContent = document.getElementById("codeContent"); | ||
codeContent.textContent = `from sae_lens import SAE | ||
release = "${release}" | ||
sae_id = "${saeId}" | ||
sae = SAE.from_pretrained(release, sae_id)[0]`; | ||
modal.style.display = "block"; | ||
return false; // Prevent default link behavior | ||
}, | ||
|
||
closeCode: function () { | ||
document.getElementById("codeModal").style.display = "none"; | ||
}, | ||
|
||
copyCode: function () { | ||
const codeContent = document.getElementById("codeContent"); | ||
const textArea = document.createElement("textarea"); | ||
textArea.value = codeContent.textContent; | ||
document.body.appendChild(textArea); | ||
textArea.select(); | ||
document.execCommand("copy"); | ||
document.body.removeChild(textArea); | ||
|
||
// Show feedback | ||
const copyButton = document.querySelector(".saetable-copyButton"); | ||
const originalText = copyButton.textContent; | ||
copyButton.textContent = "Copied!"; | ||
setTimeout(() => { | ||
copyButton.textContent = originalText; | ||
}, 2000); | ||
}, | ||
|
||
selectCode: function (element) { | ||
const range = document.createRange(); | ||
range.selectNodeContents(element); | ||
const selection = window.getSelection(); | ||
selection.removeAllRanges(); | ||
selection.addRange(range); | ||
}, | ||
}; | ||
|
||
// Close modal when clicking the X | ||
document | ||
.querySelector(".saetable-close") | ||
.addEventListener("click", function () { | ||
document.getElementById("codeModal").style.display = "none"; | ||
}); | ||
|
||
window.addEventListener("click", function (event) { | ||
const modal = document.getElementById("codeModal"); | ||
if (event.target == modal) { | ||
modal.style.display = "none"; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters