Skip to content

Instantly share code, notes, and snippets.

@quasiyoke
Created June 1, 2014 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quasiyoke/f6ef825da4d04d57291f to your computer and use it in GitHub Desktop.
Save quasiyoke/f6ef825da4d04d57291f to your computer and use it in GitHub Desktop.
function setResult(n){
var interval = setInterval(
function(){
var qe = $('#question');
var ae = $('#answer');
var q=qe.text();
var m = /^(\d+)\s(.)\s(\d+)/.exec(q);
var v1 = m[1] - 0;
var op = m[2];
var v2 = m[3] - 0;
var a;
switch(op){
case 'x':
a = v1*v2;
break;
case '+':
a = v1+v2;
break;
case '-':
a = v1-v2;
break;
case '÷':
a = v1/v2;
break;
}
ae.val('' + a);
ae.trigger('keyup');
},
30e3/n
);
$('#runner').on('runnerFinish', function(){
clearInterval(interval);
});
}
setResult(100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment