Images and Sentences HIT Helper

"Relate a phrase to an image (10 questions)" and "Identify if two phrases are related (10 questions)". Press 1, 2, or 3 to select options and hit next.

当前为 2014-10-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Images and Sentences HIT Helper
  3. // @namespace http://ericfraze.com
  4. // @version 0.2
  5. // @description "Relate a phrase to an image (10 questions)" and "Identify if two phrases are related (10 questions)". Press 1, 2, or 3 to select options and hit next.
  6. // @author Eric Fraze
  7. // @match https://web.engr.illinois.edu/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11.  
  12. $(document).ready(function() {
  13. $(document).keyup(function (event) {
  14. var key = toCharacter(event.keyCode);
  15. if ( $("#corefprompt:contains('Do the highlighted phrases in the caption(s) refer to the same things in the image?')").length ) {
  16. if (key=='1'){
  17. $("#corefTrue").click();
  18. $("#save").click();
  19. }
  20. if (key=='2'){
  21. $("#corefFalse").click();
  22. $("#save").click();
  23. }
  24. }else{
  25. if (key=='1'){
  26. $("#good").prop("checked", true);
  27. $("#draw").prop("checked", true);
  28. $("#corefTrue").click();
  29. nextQuestion();
  30. }
  31. if (key=='2'){
  32. $("#bad").prop("checked", true);
  33. $("#scene").prop("checked", true);
  34. $("#corefFalse").click();
  35. nextQuestion();
  36. }
  37. if (key=='3'){
  38. $("#nodraw").prop("checked", true);
  39. nextQuestion();
  40. }
  41. }
  42. });
  43. });
  44.  
  45. function toCharacter(keyCode) {
  46.  
  47. // delta to convert num-pad key codes to QWERTY codes.
  48. var numPadToKeyPadDelta = 48;
  49.  
  50. // if a numeric key on the num pad was pressed.
  51. if (keyCode >= 96 && keyCode <= 105) {
  52. keyCode = keyCode - numPadToKeyPadDelta;
  53. return String.fromCharCode(keyCode);
  54. }
  55.  
  56. if (keyCode == 106)
  57. return "*";
  58.  
  59. if (keyCode == 107)
  60. return "+";
  61.  
  62. if (keyCode == 109)
  63. return "-";
  64.  
  65. if (keyCode == 110)
  66. return ".";
  67.  
  68. if (keyCode == 111)
  69. return "/";
  70.  
  71. // the 'Enter' key was pressed
  72. if (keyCode == 13)
  73. return "="; //TODO: you should change this to interpret the 'Enter' key as needed by your app.
  74.  
  75. return String.fromCharCode(keyCode);
  76. }