Skip to content

Commit

Permalink
Restore the javascript logic
Browse files Browse the repository at this point in the history
Somehow loading old version of jquery
  • Loading branch information
epugh committed Jan 6, 2025
1 parent c5aea5d commit d1a002f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions app/views/judgements/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ judgement.id: <%= judgement.id %>
</style>

<script>
var $j = jQuery.noConflict();

function rate(rating, key_name) {
keyDown(key_name);
resetStylesExcept(key_name);
document.getElementById("judgement_rating").value = rating;
//party.confetti(document.getElementById("judgement_rating"));
delay(100).then(() => (document.getElementsByName("commit")[0].click()));
}

$(document).ready(function() {
$("#keyPressed_count").text("0");
$j(document).ready(function() {
$j("#keyPressed_count").text("0");
});

var count = 0;
Expand All @@ -77,8 +77,8 @@ judgement.id: <%= judgement.id %>
function resetStyles() {
let keyboard_shortcuts_suffixes = ["a", "s", "d", "f", "g", "h", "j", "k", "l", "sc"];
keyboard_shortcuts_suffixes.forEach(suffix => {
$("#span-for-" + suffix).css("color", "gray").css("font-weight", "normal");
$("#button-for-" + suffix).removeClass("btn-preselected");
$j("#span-for-" + suffix).css("color", "gray").css("font-weight", "normal");
$j("#button-for-" + suffix).removeClass("btn-preselected");
}
);
}
Expand All @@ -87,28 +87,28 @@ judgement.id: <%= judgement.id %>
let keyboard_shortcuts_suffixes = ["a", "s", "d", "f", "g", "h", "j", "k", "l", "sc"];
keyboard_shortcuts_suffixes.forEach(suffix => {
if (suffix !== except_suffix) {
$("#span-for-" + suffix).css("color", "gray").css("font-weight", "normal");
$("#button-for-" + suffix).removeClass("btn-preselected");
$j("#span-for-" + suffix).css("color", "gray").css("font-weight", "normal");
$j("#button-for-" + suffix).removeClass("btn-preselected");
}
}
);
}

function keyDown(suffix) {
resetStyles();
$("#span-for-" + suffix).css("color", "black").css("font-weight", "bold");
$("#button-for-" + suffix).addClass("btn-preselected");
$j("#span-for-" + suffix).css("color", "black").css("font-weight", "bold");
$j("#button-for-" + suffix).addClass("btn-preselected");
}

function delay(time) {
return new Promise(resolve => setTimeout(resolve, time));
}

function keyPressed(suffix) {
delay(500).then(() => ($("#button-for-" + suffix).click()));
delay(500).then(() => ($j("#button-for-" + suffix).click()));
}

$(document).on('keypress', function(e) {
$j(document).on('keypress', function(e) {
var tag = e.target.tagName.toLowerCase();
if (tag == 'textarea') {
return;
Expand Down Expand Up @@ -139,7 +139,7 @@ judgement.id: <%= judgement.id %>
}
});

$(document).on('keydown', function(e) {
$j(document).on('keydown', function(e) {
var tag = e.target.tagName.toLowerCase();

if (e.which == 97 || e.which == 65) {
Expand Down

0 comments on commit d1a002f

Please sign in to comment.