打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

微件:倒计时

来自EaseCation Wiki

<head>

 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <style>

@font-face {

   font-family: 'UnifontPixel';
   src: url('/resources/assets/unifont.woff2') format('woff2');
   font-weight: normal;
   font-style: normal;
   font-display: swap;

}

  1. countdown {
   font-family: 'UnifontPixel', 'Courier New', monospace;
   background: rgba(0, 0, 0, 0.3);
   color: #fff;
   display: block;
   font-size: 36px;
   margin: 20px auto;
   padding: 2px 10px;;
   text-shadow: 2px 2px 0 #000;
   text-align: center;
   width: fit-content;
   border-radius: 4px;
   letter-spacing: 2px;

}

 </style>

</head> <body>

 <script>
     const targetTime = parseCompactTime("");
     const text1 = "";
     const text2 = "";
     function updateCountdown() {
         const now = new Date().getTime();
         const distance = targetTime - now;
         if (distance < 0) {
             document.getElementById('countdown').innerHTML = ;
             return;
         }
         
         var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)).toString().padStart(2, '0') + ":";
         var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)).toString().padStart(2, '0') + ":";
         var seconds = Math.floor((distance % (1000 * 60)) / 1000).toString().padStart(2, '0');
         var milliseconds = (distance % 1000).toString().padStart(3, '0');
         if (hours === "00:") {
             hours = "";
         }
         const timestr = ` ${hours}${minutes}${seconds}.${milliseconds} `;
         document.getElementById('countdown').innerHTML = `${text1}${timestr}${text2}`;
     }
     updateCountdown();
     setInterval(updateCountdown, 1);
     function parseCompactTime(str) {
         const year = parseInt(str.slice(0, 4));
         const month = parseInt(str.slice(4, 6)) - 1;
         const day = parseInt(str.slice(6, 8));
         const hour = parseInt(str.slice(8, 10));
         const minute = parseInt(str.slice(10, 12));
         const second = parseInt(str.slice(12, 14));
         return new Date(year, month, day, hour, minute, second).getTime();
     }
 </script>

</body>