Skip to content

Commit

Permalink
Hotkeys link and rotate board with l/r arrows
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel_Alvarez authored and qu1ck committed Jun 7, 2022
1 parent 5af3176 commit 6ce89a7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions InteractiveHtmlBom/web/ibom.css
Original file line number Diff line number Diff line change
Expand Up @@ -792,3 +792,14 @@ a {
.column-width-handle:hover {
background-color: #4f99bd;
}

.help-link {
border: 1px solid #0278a4;
padding-inline: 0.3rem;
border-radius: 3px;
cursor: pointer;
}

.dark .help-link {
border: 1px solid #00b9fd;
}
1 change: 1 addition & 0 deletions InteractiveHtmlBom/web/ibom.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
<span class="shameless-plug">
<span>Created using</span>
<a id="github-link" target="blank" href="https://github.com/openscopeproject/InteractiveHtmlBom">InteractiveHtmlBom</a>
<a target="blank" title="Mouse and keyboard help" href="https://github.com/openscopeproject/InteractiveHtmlBom/wiki/Usage#bom-page-mouse-actions" style="text-decoration: none;"><label class="help-link">?</label></a>
</span>
</label>
</div>
Expand Down
21 changes: 21 additions & 0 deletions InteractiveHtmlBom/web/ibom.js
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,10 @@ function updateCheckboxStats(checkbox) {
td.lastChild.innerHTML = checked + "/" + total + " (" + Math.round(percent) + "%)";
}

function constrain(number, min, max){
return Math.min(Math.max(parseInt(number), min), max);
}

document.onkeydown = function (e) {
switch (e.key) {
case "n":
Expand All @@ -1119,6 +1123,23 @@ document.onkeydown = function (e) {
highlightNextRow();
e.preventDefault();
break;
case "ArrowLeft":
case "ArrowRight":
if (document.activeElement.type != "text"){
e.preventDefault();
let boardRotationElement = document.getElementById("boardRotation")
settings.boardRotation = parseInt(boardRotationElement.value); // degrees / 5
if (e.key == "ArrowLeft"){
settings.boardRotation += 3; // 15 degrees
}
else{
settings.boardRotation -= 3;
}
settings.boardRotation = constrain(settings.boardRotation, boardRotationElement.min, boardRotationElement.max);
boardRotationElement.value = settings.boardRotation
setBoardRotation(settings.boardRotation);
}
break;
default:
break;
}
Expand Down

0 comments on commit 6ce89a7

Please sign in to comment.