From 82c3c7f50b726615e1f4f4db587431c33730bbf6 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 8 Nov 2018 10:46:07 +0100 Subject: [PATCH] Improve the Typing Test in pad --- www/common/TypingTests.js | 20 ++++++++++++++++++++ www/pad/inner.js | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/www/common/TypingTests.js b/www/common/TypingTests.js index 16db8c0d5..f35018881 100644 --- a/www/common/TypingTests.js +++ b/www/common/TypingTests.js @@ -56,8 +56,28 @@ define(function () { }; }; + var testInput2 = function (editor) { + var i = 0, + input = " The quick red fox jumps over the lazy brown dog.", + l = input.length, + interval; + var cancel = function () { + if (interval) { interval.cancel(); } + }; + + interval = setRandomizedInterval(function () { + editor.insertText(input.charAt(i)); + i = (i + 1) % l; + }, 200, 50); + + return { + cancel: cancel + }; + }; + return { testInput: testInput, + testInput2: testInput2, setRandomizedInterval: setRandomizedInterval }; }); diff --git a/www/pad/inner.js b/www/pad/inner.js index 387d27311..7df4b45f9 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -699,7 +699,8 @@ define([ window.easyTest = function () { cursor.update(); var start = cursor.Range.start; - var test = TypingTest.testInput(inner, start.el, start.offset, framework.localChange); + //var test = TypingTest.testInput(inner, start.el, start.offset, framework.localChange); + var test = TypingTest.testInput2(editor); framework.localChange(); return test; };