Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
算了,聪明反被聪明误,当用户做对题时,不要自动跳转到下一道题,而是像做错题一样,按回车或单击字块进入下一道题
这是因为在移动设备上,用户必须有触摸屏幕的动作才能触发输入框,否则光靠 .focus() 方法是无法自动打开虚拟键盘的,所以这里的自动跳转到下一道题在移动端并不好用(虚拟键盘打不开)

https://stackoverflow.com/a/6021037/559676
https://stackoverflow.com/a/10243010/559676
  • Loading branch information
yihui committed Feb 27, 2021
1 parent a6f94c0 commit 2a073fc
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions js/learn-chars.js
Expand Up @@ -3,6 +3,9 @@
var s = document.currentScript;
if (!s) return alert('抱歉,本程序不支持您的古董浏览器,请尝试使用 Chrome/Firefox/Edge 等现代浏览器');

// 学习字库、总字库、挑战字库
var chars = [], freqs = zDict.freqs.split(''), cChars = freqs.slice();

// 安插基本元素,用来存放拼音、汉字等信息
s.insertAdjacentHTML('afterend', '<div id="learn-chars">' +
'<div id="learn-toolbar"></div>' +
Expand Down Expand Up @@ -74,8 +77,6 @@
return x ? x.split('') : [];
}

// 学习字库、总字库、挑战字库
var chars = [], freqs = zDict.freqs.split(''), cChars = freqs.slice(), cCancel = true;
function setChars() {
p = [-1, 0, -1];
chars = lc.value.split('');
Expand Down Expand Up @@ -120,7 +121,6 @@
function renderChar(char) {
py.innerText = zi.innerText = mn.innerText = '';
if (mode != 3) sc.innerText = '';
if (mode >= 2) clearTimeout(cCancel);
py.setAttribute('contenteditable', true);
cb.classList.remove('correct', 'wrong');
var num; // 挑战模式下的字符编号
Expand Down Expand Up @@ -230,7 +230,6 @@
if (checkPinyin(v.trim(), ans)) {
cb.classList.add('correct');
this.innerText = ans;
cCancel = setTimeout(renderChar, 2000);
} else {
if (mode !== 2 || !/^\s+$/.test(v)) cb.classList.add('wrong');
if (mode === 3) nw++;
Expand Down

0 comments on commit 2a073fc

Please sign in to comment.