HTML OInet

· · 个人记录

<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8">
        <title>OInet by myself, for myself</title>
        <style>
            body{

                background: url("https://www.freeforai.com//uploads/images/compressed/compressed_1ac9fd4046d85db84191853dd655104d.jpg") no-repeat center / cover fixed;
                margin:0; 
                background-color:#303030;
                color: #ffffff;
            }
            .header{
                background-color:rgba(0, 35, 115, 0.7);
                color: #ffffff;
                padding:20px;
                font-size:28px;
                font-weight:bold;
            }
            .box{
                margin: 20px;
                background: rgba(0, 38, 197, 0.6);
                border: none;
                padding:15px;
                min-width:100px;
                color:white;
                border-radius: 15px;
                text-align: center;
            }
            .wrap{
                display: flex;
                flex-wrap: wrap;
            }
            .wrap a{
                text-decoration: none;
            }
            .box:hover{
                background: rgba(0, 45, 177, 0.9);
                transition: all 0.2s ease;
            }
            .padd{
                padding:20px;
            }
            .nice-input{
                width: 250px;
                padding: 12px 16px;
                font-size: 16px;
                color: #ffffff;
                outline: none;
                border: 1px solid #444444;
                border-radius: 5px;
                background-color: rgba(34, 34, 34, 0.6);
                transition: all 0.25s ease;
            }
            .nice-input:focus {
                border-color: #eeeeee;
                box-shadow: 0 0 0 3px rgba(31, 31, 31, 0.2);
            }
            .nice-input:hover {
                border-color: #9ca3af;
                box-shadow: 0 0 0 2px rgba(15,15,15,0.04);
                background-color: rgba(34, 34, 34, 0.6);
            }
            .nice-input:disabled {
                background-color: #f3f4f6;
                border-color: #e5e7eb;
                color: #999;
                cursor: not-allowed;
            }
            .mybutton{
                border: none;
                outline: none;
                cursor: pointer;
                padding: 12px 30px;
                font-size: 16px;
                font-weight: 500;
                background-color: rgba(128, 128, 128, 0.7);
                color: #ffffff;
                border-radius: 4px;
                box-shadow: 0 4px 12px #111111;
            }
            .mybutton:hover{
                background-color: rgba(187, 187, 187, 1);
                box-shadow: 0 4px 12px #0a0a0a;
                transition: all 0.2s ease;
            }
            .sbox{
                margin: 20px;
                background-color:rgba(0, 25, 147, 0.7);
                border: none;
                padding:15px;
                color:white;
                border-radius: 15px;
                text-align: center;
            }
            .thx {
                text-align: center;
                font-size: 12px;
                color: #888888;
                padding: 20px 0;
                margin-top: 30px;
            }
            .thx a {
                color: #888888;
                text-decoration: none;
            }
            .thx a:hover {
                color: #555555;
                text-decoration: underline;
            }
            .timer-display{
                font-size:36px;
                margin:12px 0;
                font-family:Consolas,monospace;
            }
            .timer-btn-group{
                display:flex;
                gap:10px;
                justify-content:center;
                flex-wrap:wrap;
            }
            /* ==========新增倒计时样式========== */
            .countdown-area{
                margin-top:20px;
            }
        </style>
    </head>
    <body>
        <!-- OJ导航部分,搜索 -->
        <div class="header">OI-net</div>
        <div class = "sbox wrap">
            <b>OJ导航</b>
        </div>
        <div class = "wrap padd">
            <input type="text" id="Problem" class="nice-input" placeholder="输入题号,只支持vjudge">
            <button id="btn" class="mybutton"> 搜索 </button>
            <script>
                const inputEle = document.getElementById('Problem');
                const btn = document.getElementById('btn');
                inputEle.onkeydown = function(e){
                    if(e.key === 'Enter') btn.click();
                }
                btn.onclick = function(){
                    let pb = inputEle.value.trim();
                    if (!pb){
                        return;
                    }
                    let url = "https://vjudge.net/problem#OJId=All&probNum="+pb+"&title=&source=&category=all";
                    window.open(url);
                }
            </script>
        </div>
        <!-- OJ跳转选项 -->
        <div class = "wrap">
            <a href="https://www.luogu.com.cn" target="_blank">
                <div class = "box">
                    <p>洛谷</p>
                </div>
            </a>
            <a href="https://codeforces.com" target="_blank">
                <div class = "box">
                    <p>Codeforces</p>
                </div>
            </a>
            <a href="https://atcoder.jp" target="_blank">
                <div class = "box">
                    <p>Atcoder</p>
                </div>
            </a>
            <a href="https://vjudge.net" target="_blank">
                <div class = "box">
                    <p>Vjudge</p>
                </div>
            </a>
            <a href="https://htoj.com.cn" target="_blank">
                <div class = "box">
                    <p>核桃OJ</p>
                </div>
            </a>
        </div>
        <div class = "sbox wrap">
            <b>工具</b>
        </div>
        <div class = "wrap">
            <a href="https://www.oi-wiki.org" target="_blank">
                <div class = "box">
                    <p>OI Wiki</p>
                </div>
            </a>
            <a href="https://www.doubao.com" target="_blank">
                <div class = "box">
                    <p>豆包AI</p>
                </div>
            </a>
            <a href="https://www.luogu.me" target="_blank">
                <div class = "box">
                    <p>洛谷文章保存站</p>
                </div>
            </a>
            <a href="https://cn.bing.com" target="_blank">
                <div class = "box">
                    <p>必应搜索</p>
                </div>
            </a>
            <a href="https://cn.bing.com/translator" target="_blank">
                <div class = "box">
                    <p>必应翻译</p>
                </div>
            </a>
            <a href="https://runoob.com/" target="_blank">
                <div class = "box">
                    <p>菜鸟教程</p>
                </div>
            </a>
        </div>
        <!-- ==========新增计时器模块(在thx上方)========== -->
        <div class="sbox" style="background-color:rgba(0, 25, 147, 0.85);">
            <b>做题计时器</b>
            <div class="timer-display" id="timerText">00:00.000</div>
            <div class="timer-btn-group">
                <button class="mybutton" id="startBtn">开始</button>
                <button class="mybutton" id="pauseBtn">暂停</button>
                <button class="mybutton" id="resetBtn">重置</button>
            </div>

            <!-- ==========【新增:考试倒计时模块】========== -->
            <div class="countdown-area">
                <p>考试倒计时(输入分钟)</p>
                <input class="nice-input" id="cdInput" placeholder="例如填45">
                <div class="timer-btn-group" style="margin-top:10px;">
                    <button class="mybutton" id="cdStart">倒计时开始</button>
                    <button class="mybutton" id="cdStop">倒计时停止</button>
                </div>
                <div class="timer-display" id="cdText">00:00</div>
            </div>
        </div>
        <!-- 计时器(by doubao) -->
        <script>
            let startTime = 0;
            let elapsed = 0;
            let timerId = null;
            const timerText = document.getElementById("timerText");
            const startBtn = document.getElementById("startBtn");
            const pauseBtn = document.getElementById("pauseBtn");
            const resetBtn = document.getElementById("resetBtn");

            function formatTime(ms){
                let totalSec = Math.floor(ms / 1000);
                let min = String(Math.floor(totalSec / 60)).padStart(2,'0');
                let sec = String(totalSec % 60).padStart(2,'0');
                let mil = String(ms % 1000).padStart(3,'0');
                return `${min}:${sec}.${mil}`;
            }

            function update(){
                let now = Date.now();
                elapsed = now - startTime;
                timerText.innerText = formatTime(elapsed);
            }

            startBtn.onclick = function(){
                if(timerId) return;
                startTime = Date.now() - elapsed;
                timerId = setInterval(update,10);
            };
            pauseBtn.onclick = function(){
                if(timerId){
                    clearInterval(timerId);
                    timerId = null;
                }
            };
            resetBtn.onclick = function(){
                clearInterval(timerId);
                timerId = null;
                elapsed = 0;
                timerText.innerText = "00:00.000";
            };
            let cdTimer = null;
            let remainSecond = 0;
            const cdInput = document.getElementById("cdInput");
            const cdStart = document.getElementById("cdStart");
            const cdStop = document.getElementById("cdStop");
            const cdText = document.getElementById("cdText");

            function formatCd(s){
                let m = Math.floor(s / 60);
                let sec = s % 60;
                return String(m).padStart(2,'0') + ":" + String(sec).padStart(2,'0');
            }

            cdStart.onclick = function(){
                if(cdTimer !== null){
                    clearInterval(cdTimer);
                }
                let minute = Number(cdInput.value);
                remainSecond = minute * 60;
                cdText.innerText = formatCd(remainSecond);

                cdTimer = setInterval(function(){
                    remainSecond = remainSecond - 1;
                    cdText.innerText = formatCd(remainSecond);
                    if(remainSecond <= 0){
                        clearInterval(cdTimer);
                        cdTimer = null;
                        alert("时间到!考试结束!");
                    }
                },1000);
            }
            cdStop.onclick = function(){
                if(cdTimer !== null){
                    clearInterval(cdTimer);
                    cdTimer = null;
                }
            }
        </script>
        <!-- 神秘赞助方 -->
        <div class="thx">
            <p> 赞助方与指导网站:我,我爸妈,菜鸟教程 </p>
            <p> 朝鲜备案号-1919810-6767 </p>
        </div>
    </body>
</html>