限时优惠活动
亲爱的苦力吧用户,我们为了回馈新老用户一直以来的鼎力支持,即日起(2025-02-06至2025-03-06)凡是购买苦力吧VIP/充值K币的新老用户,都直接可获得买一送一的优惠馈赠。例如:购买一个月的VIP会员可直接获得两个月的VIP会员;充值100K币可直接获得200K币,以此类推!有任何疑问可联系在线客服,感谢各位用户对苦力吧素材的信任与厚爱,我们将一如既往的给大家上新更多优质的素材源码,祝大家开工大吉、工作顺利、心想事成。

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可自定义table表格数据转换器插件

一款table表格数据number转换器插件,可转为:百分比、小数点后两位、货币单位。
  实用工具
 7331  0

jquery支持移动端触屏的橡皮擦工具插件

支持鼠标长按和手机端触屏橡皮擦特效,即时显示操作百分比进度,类似于刮刮乐刮彩票。带有重置、一键清理、关闭橡皮擦功能。
  实用工具
 1378  0

jquery按下键盘任意键自动显示unicode键值和按键名称

一款键盘按键检测器,检测JavaScript keydown事件,并在按下时显示键盘键的Unicode和名称。
  实用工具
 7465  0

javascript支持针手机端触摸拖拽移动的脚本库

subjx是一个JavaScript库,可以对HTML元素和/或SVG上实现触摸友好的拖拽旋转、调整大小和拖放功能。
  实用工具
 9527  0

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

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