Skip to content

Commit

Permalink
Use a details element
Browse files Browse the repository at this point in the history
  • Loading branch information
randomairborne committed Nov 25, 2024
1 parent 38b866a commit d57722d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
10 changes: 10 additions & 0 deletions assets/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ pre > code {

.ip {
cursor: pointer;
margin: 2px;
}

details.ip[open] summary {
display: none;
}

.user-ip-stack {
display: flex;
align-items: center;
}

.root-api-status {
Expand Down
17 changes: 4 additions & 13 deletions templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,15 @@
<div class="small-vspacer"></div>
<div class="user-ip-stack">
<span id="ip-descriptor" class="ip">Your IP:</span>
<span id="ip-msg" class="ip">Click to Reveal</span>
<span id="user-ip" class="ip" hidden></span>
<details id="ip-msg" class="ip">
<summary class="ip">Click to Reveal</summary>
<span id="user-ip">(javascript required to load your IP)</span>
</details>
</div>
</div>
<a href="/api/">API</a>
<script nonce="{{ nonce }}">
const ipElement = document.getElementById("user-ip");
const ipMsgElement = document.getElementById("ip-msg");
const ipDescriptorElement = document.getElementById("ip-descriptor");
function ipClick() {
ipElement.hidden = !ipElement.hidden;
ipMsgElement.hidden = !ipMsgElement.hidden;
}
ipElement.addEventListener("click", ipClick);
ipMsgElement.addEventListener("click", ipClick);
ipDescriptorElement.addEventListener("click", ipClick);
fetch("https://v4.giveip.io/raw")
.then((rsp) => rsp.text())
Expand Down

0 comments on commit d57722d

Please sign in to comment.