Images and Sentences HIT Helper

"Relate a phrase to an image (10 questions)". Press 1, 2, or 3 to select options. Press the same key again to hit the next button. (1, 1 selects option one and hits next. 1, 2 ends up selecting option 2 and waiting for you to hit 2).

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Images and Sentences HIT Helper
// @namespace    http://ericfraze.com
// @version      0.1
// @description  "Relate a phrase to an image (10 questions)". Press 1, 2, or 3 to select options. Press the same key again to hit the next button. (1, 1 selects option one and hits next. 1, 2 ends up selecting option 2 and waiting for you to hit 2).
// @author       Eric Fraze
// @match    https://web.engr.illinois.edu/*
// @grant        none
// ==/UserScript==


$(document).ready(function() {
	$(document).keyup(function (event) {
      var key = toCharacter(event.keyCode);
        if (key=='1'){
            if ($("#draw").prop("checked")) {
            	nextQuestion();
            }else{
      			$("#draw").prop("checked", true);
            }
        }
        
        if (key=='2'){
            if ($("#scene").prop("checked")) {
            	nextQuestion();
            }else{
      			$("#scene").prop("checked", true);
            }
        }
        
        if (key=='3'){
            if ($("#nodraw").prop("checked")) {
            	nextQuestion();
            }else{
      			$("#nodraw").prop("checked", true);
            }
        }
 	});
});

function toCharacter(keyCode) {

	// delta to convert num-pad key codes to QWERTY codes.
	var numPadToKeyPadDelta = 48;

	// if a numeric key on the num pad was pressed.
	if (keyCode >= 96 && keyCode <= 105) {
	    keyCode = keyCode - numPadToKeyPadDelta;
	    return String.fromCharCode(keyCode);
	}

	if (keyCode == 106)
	    return "*";

	if (keyCode == 107)
	    return "+";

	if (keyCode == 109)
	    return "-";

	if (keyCode == 110)
	    return ".";

	if (keyCode == 111)
	    return "/";

	// the 'Enter' key was pressed
	if (keyCode == 13)
	    return "=";  //TODO: you should change this to interpret the 'Enter' key as needed by your app.

	return String.fromCharCode(keyCode);
}