Skip to content

Instantly share code, notes, and snippets.

@baorv
Created May 10, 2017 17:17
Show Gist options
  • Save baorv/1dcf272cf56b3a381089747f3e4d424f to your computer and use it in GitHub Desktop.
Save baorv/1dcf272cf56b3a381089747f3e4d424f to your computer and use it in GitHub Desktop.
var enterInput = document.getElementsByTagName("input")[0];
function getCurrent(){
var current = null;
for (i = 0; i < 99; i ++) {
current = document.getElementById("nhwMiddlegwt-uid-" + i);
if (current != null) break;
}
return current;
}
function setCurrent(){
var currentComma = null;
for(j = 0; j < 99; j ++){
currentComma = document.getElementById("nhwMiddleCommagwt-uid-" + j);
if(currentComma != null) break;
}
if(currentComma != null){
enterInput.value = getCurrent().innerHTML + currentComma.innerHTML;
}else{
enterInput.value = getCurrent().innerHTML;
}
}
setCurrent();
document.addEventListener("keypress", function(e) {
if (e.keyCode == 32) setCurrent();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment