Skip to content

Commit

Permalink
Close some div by esc pressing too
Browse files Browse the repository at this point in the history
From now closing:

- AlbumCoverViewer div.
- About div.
- ErrorDialog div.
  • Loading branch information
rafael-santiago committed Nov 15, 2024
1 parent 59da49f commit 36c8a89
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/internal/renders/test-data/expected-eutherpe.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h2 class="info-banner">&#x1F9A5; Wait... &#x23F3;</h2>
</div>
<div id="ErrorDialog" class="configcontent" style="text-align: center; padding: 5%; display:none;">
<p class="info-banner" id="messageBuffer" style="font-size: 20px;"></p><br><br>
<input class="eutherpeBUTTON" type="button" value="Ok" onclick="openConfig('');">
<input class="eutherpeBUTTON" type="button" value="Ok" id="closeErrorBtn" onclick="openConfig('');">
</div>
<div id="QueryDialog" class="configcontent" style="text-align: center; padding: 5%; display:none;">
<p class="info-banner" id="queryBuffer" style="font-size: 20px;"></p><br><br>
Expand Down
2 changes: 1 addition & 1 deletion src/web/html/eutherpe.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h2 class="info-banner">&#x1F9A5; Wait... &#x23F3;</h2>
</div>
<div id="ErrorDialog" class="configcontent" style="text-align: center; padding: 5%; display:none;">
<p class="info-banner" id="messageBuffer" style="font-size: 20px;"></p><br><br>
<input class="eutherpeBUTTON" type="button" value="Ok" onclick="openConfig('{{.CURRENT-CONFIG}}');">
<input class="eutherpeBUTTON" type="button" value="Ok" id="closeErrorBtn" onclick="openConfig('{{.CURRENT-CONFIG}}');">
</div>
<div id="QueryDialog" class="configcontent" style="text-align: center; padding: 5%; display:none;">
<p class="info-banner" id="queryBuffer" style="font-size: 20px;"></p><br><br>
Expand Down
13 changes: 13 additions & 0 deletions src/web/js/eutherpe.js
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,19 @@ function installKeyShortcuts() {
installEnterEscKeyShortcuts(document.getElementById("hostName"),
setHostName,
function(){});
// INFO(Rafael): The document as whole.
document.onkeydown = function(e) {
e = e || e.event;
if (e.keyCode == 27) {
if (document.getElementById("AlbumCoverViewer").style.display === "block") {
closeAlbumCoverViewer();
} else if (document.getElementById("About").style.display === "block") {
closeAbout();
} else if (document.getElementById("ErrorDialog").style.display === "block") {
document.getElementById("closeErrorBtn").click();
}
}
};
}

function openConfig(configName) {
Expand Down

0 comments on commit 36c8a89

Please sign in to comment.