Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/keybinding ASWD for speed 🚀 #3

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions static/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ function decision(chosen, id) {
console.log(chosen, id);
}

function undoCard(){
toggleSettings();
function undoCard(trigger){

if (trigger)
toggleSettings();

var moveOutWidth = document.body.clientWidth;
if(lastid == null) return;
fetch('/undo-review?db_id=' + lastid + '&polarity=' + lastdecision)
Expand Down Expand Up @@ -246,3 +249,17 @@ var neuListener = createButtonListener(0);
nope.addEventListener('click', nopeListener);
love.addEventListener('click', loveListener);
neu.addEventListener('click', neuListener);

// add button listener like A, S, D, W

document.addEventListener('keydown', function (event) {
if (event.key === 'a' || event.key === 'ArrowLeft') {
nope.click();
} else if (event.key === 'd' || event.key === 'ArrowRight') {
love.click();
} else if (event.key === 'w' || event.key === 'ArrowUp') {
neu.click();
} else if (event.key === 's' || event.key === 'ArrowDown') {
undoCard(false);
}
});
2 changes: 1 addition & 1 deletion templates/approval.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1 class="md:text-[30px] text-[20px] z-20 text-primary font-sharetechmono">
<!-- a dialog box in the center of the screen -->
<div id="settings-dialog" class="hidden absolute z-50 rounded-lg border-4 p-8 border-background bg-background w-[80%] md:w-[50%] text-primary font-sharetechmono" style="top: 50%; left: 50%; transform: translate(-50%, -50%);">
<div class="w-full text-center">
<button onclick="undoCard()" class="settings">Undo</button>
<button onclick="undoCard(true)" class="settings">Undo</button>
<button class="settings">Export to JSON</button>
<button onclick="toggleSettings();" class="settings">Close</button>
</div>
Expand Down