js在线检测打字速度和输入字符准确性实用工具

所属分类: 网页特效-实用工具    2023-11-29 01:32:38

js在线检测打字速度和输入字符准确性实用工具 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

js在线检测打字速度和输入字符准确性实用工具(共3个文件)

    • index.html

使用方法

const testWrapper = document.querySelector(".test-wrapper");
const testArea = document.querySelector("#test-area");
const originText = document.querySelector("#origin-text p").innerHTML;
const resetButton = document.querySelector("#reset");
const theTimer = document.querySelector(".timer");


var timer = [0,0,0,0];
var interval;
var timerRunning = false;

// Add leading zero to numbers 9 or below (purely for aesthetics):
function leadingZero(time) {
    
    if (time <= 9) {
        
        time = "0" + time;
    }
    
    return time;
}

// Run a standard minute/second/hundredths timer:
function runTimer() {
    
    let currentTime = leadingZero(timer[0]) + ":" + leadingZero(timer[1]) + ":" + leadingZero(timer[2]);
    
    theTimer.innerHTML = currentTime;
    timer[3]++;
    
    timer[0] = Math.floor((timer[3]/100)/60);
    timer[1] = Math.floor((timer[3]/100) - (timer[0] * 60));
    timer[2] = Math.floor(timer[3] - (timer[1] * 100) - (timer[0] * 6000));
}

// Match the text entered with the provided text on the page:
function spellCheck() {
    
    let textEntered = testArea.value;
    let originTextMatch = originText.substring(0, textEntered.length);
    
    if(textEntered == originText) {
        
        clearInterval(interval);
        
        testWrapper.style.borderColor = "#339900";
        
    } else {
        
        if(textEntered  == originTextMatch) {
            
            testWrapper.style.borderColor = "#E55400";
        } else {
            
            testWrapper.style.borderColor = "#FF0000";
        }
    }
    
}

// Start the timer:
function start() {
    
    let textEnteredLength = testArea.value.length;
    
    if (textEnteredLength === 0 && !timerRunning ){
        
        timerRunning = true;
        interval = setInterval(runTimer, 10);
    }
    
    console.log(textEnteredLength);
}

// Reset everything:
function reset() {
    
    clearInterval(interval);
    interval = null;
    
    timer = [0,0,0,0];
    timerRunning = false;
    
    testArea.value = "";
    theTimer.innerHTML = "00:00:00";
    testWrapper.style.borderColor = "grey";
}


// Event listeners for keyboard input and the reset button:
testArea.addEventListener("keypress", start, false);
testArea.addEventListener("keyup", spellCheck, false );
resetButton.addEventListener("click", reset, false);

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 实用工具

jquery带动画特效的天气信息卡片

一款极简风格天气卡片,带有水位波动的动画效果,非常好看。
  实用工具
 5479  0

jquery轻量级可拖拽移动关闭的对话框窗口

jDoor是一个轻量级精仿windows窗口插件,支持鼠标拖放移动关闭,还可以自定义加载外部网站视频位于窗口内,超实用。
  实用工具
 6642  0

javascript创建的随机密码生成器工具

一个简洁的界面、一个文本字段和一个密码生成按钮。当单击“生成”按钮时,立即会生成以小写字母、大写字母、数字和特殊字符的随机组合字符串。这是一个简单的在线生成工具,你可以根据自身需求创建不同复杂程度的密码。
  实用工具
 4663  0

javascript实现的在线网速测试实用工具

一款当前网络速度测试工具插件,点击“开始”按钮,它会从指定的URL下载图片,并实时计算你当前的网络速度。然后,它会以Bps、KBps或MBps显示网速数值。
  实用工具
 71028  0

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论