PI Search with Keyboard Shortcuts

Autoselects 'Perfect' for each item entry. Adds Keyboard shortcuts: 1 -> PERFECT, 2 -> GOOD, 3 -> NOT REALLY, 4 -> NOT GOOD, 5 -> DON'T KNOW, N -> Goes to NEXT item, B -> Goes BACK to last item

Από την 30/04/2015. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         PI Search with Keyboard Shortcuts
// @namespace    https://greasyfork.org/en/users/10782
// @version      0.1
// @description  Autoselects 'Perfect' for each item entry. Adds Keyboard shortcuts: 1 -> PERFECT, 2 -> GOOD, 3 -> NOT REALLY, 4 -> NOT GOOD, 5 -> DON'T KNOW, N -> Goes to NEXT item, B -> Goes BACK to last item
// @author       tismyname
// @require      https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js  
// @include      https://s3.amazonaws.com/*
// ==/UserScript==

// Makes Instructions Hidable
$(".panel-heading").before('<label><input type="checkbox" id="toggler">Show/Hide Instructions</input><br></label>')
$(".panel-heading").hide();
$(".panel-body").hide();

// Button to show or hide instructions
$('#toggler').click(function() {
    $(".panel-heading").toggle();
    $(".panel-body").toggle();
});    

var ITEMS = 6;
var currentQ = 1;

// Auto Select First Option
for(var i = 1; i <= ITEMS; i++) {
     $('#Q'+i+'_5').click();    
}

// Auto focuses on first radio button
 $('#Q'+currentQ+'_5').focus();

// Checks for keypresses
 $(document).keyup(function (event) {
	        var key = toCharacter(event.keyCode);
	        
	        if (key=='1') {
	            $('#Q'+currentQ+'_5').click();	            
	        }
	        
	        if (key=='2') {
                $('#Q'+currentQ+'_4').click();
	        }
	        
	        if (key=='3') {
	           $('#Q'+currentQ+'_3').click();
	        }
            
            if (key=='4') {
	           $('#Q'+currentQ+'_2').click();
	        }
     
            if (key=='5') {
	           $('#Q'+currentQ+'_1').click();
	        } 
     
            if(key=='N') {
               if(currentQ > ITEMS)
                   currentQ = 1;
                else {
                   currentQ++;
                   $('#Q'+currentQ+'_5').focus();
                }
            }
     
            if(key=='B') {
               if(currentQ <= 1)
                   currentQ = 6;
                else {
                   currentQ--;
                   $('#Q'+currentQ+'_5').focus();
                }
            }   
});

// code from https://greasyfork.org/en/scripts/5978-mturk-dave-cobb-hit-helper
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 == 13)
        return "ENTER"; // not sure if I need to add code to hit the submit button
	
    return String.fromCharCode(keyCode);
}