Skip to content

Instantly share code, notes, and snippets.

@alexstorer
Created February 14, 2013 16:03
Show Gist options
  • Save alexstorer/4953783 to your computer and use it in GitHub Desktop.
Save alexstorer/4953783 to your computer and use it in GitHub Desktop.
Here is the RT script we worked on.
<script type="text/javascript">
shuffle = function(o){ //v1.0
for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};
document.onkeyup = KeyCheck;
var input = new Array();
var correct = new Array();
//var neworder = shuffle([0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47]);
var neworder = shuffle([0, 1, 2, 3, 4, 5, 6]);
var t = 0;var trialNum = 0;var d;var running = 0;
var totalTrials = 7
input[0]="<b style='color:chartreuse'>Tradition</b>";
input[1]="<b style='color:chartreuse'>Values</b>";
input[2]="<b style='color:chartreuse'>Politics</b>";
input[3]="<b style='color:chartreuse'>Friends</b>";
input[4]="<b style='color:chartreuse'>Sports</b>";
input[5]="<b style='color:chartreuse'>Friends</b>";
input[6]="<b style='color:chartreuse'>Values</b>";
function start_it() {
if (trialNum<totalTrials) {
var day = new Date(); trialstart = day.getTime();
document.getElementById("Message").innerHTML = "<br>" + input[neworder[trialNum]];
}
else {
clearInterval(t)
document.getElementById("Message").innerHTML = "<br>You may now proceed to the next section";
document.getElementById("QR~QID6").value = document.getElementById("QR~QID6").value + "END";
}
}
function KeyCheck(e) {
var KeyID = (window.event) ? event.keyCode : e.keyCode;
var American = 73; // The 'i' key on the right
var Chinese = 69; // The 'e' key on the left
var Both = 71; // The 'g' key
if (trialNum<totalTrials) {
d=neworder[trialNum]; if (d<=9) {d="0"+d;}
if(KeyID == American) {
var day = new Date(); trialend = day.getTime();
rt = trialend - trialstart;
document.getElementById("QR~QID6").value = document.getElementById("QR~QID6").value + d + ":A:" + rt + ",";
document.getElementById("Message").innerHTML = "<br>+";
trialNum=trialNum+1;
t = setTimeout('start_it();',500);
}
if(KeyID == Chinese) {
var day = new Date(); trialend = day.getTime();
rt = trialend - trialstart;
document.getElementById("QR~QID6").value = document.getElementById("QR~QID6").value + d + ":C:" + rt + ",";
document.getElementById("Message").innerHTML = "<br>+";
trialNum=trialNum+1;
t = setTimeout('start_it();',500);
}
if(KeyID == Both) {
var day = new Date(); trialend = day.getTime();
rt = trialend - trialstart;
document.getElementById("QR~QID6").value = document.getElementById("QR~QID6").value + d + ":B:" + rt + ",";
document.getElementById("Message").innerHTML = "<br>+";
trialNum=trialNum+1;
t = setTimeout('start_it();',500);
}
if(KeyID == 32) {
if (running == 0) {
document.getElementById('instructions').style.display = "none";
running = 1;
start_it();
}
}
}
}
</script>
<center>
<b style="color:chartreuse;font-size:30px">Chinese &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Both &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; American</b><br>
<h2 id="Message" style="font-size:30px">+</h2><br>
<p id="instructions">Please place your left and right fingers on the <b>E</b> and <b>I</b> keys respectively. At the top of the screen, you will see 2 categories, one on the right and one on the left. Words will start appearing in the middle of the screen, one by one. When the word belongs to the category on the left, press the <b>E</b> key on your keyboard as fast as you can. When the word belongs to the category on the right, press the <b>I</b> key on your keyboard as fast as you can. If you make an error, a red <b style="color:red">X</b> will appear. Please try to make as few errors as possible.<br><br>When you are ready, please press the [Space] bar to begin.<br><br>
Part 1 of 7</p></center>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment