297 lines
7.7 KiB
HTML
297 lines
7.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>awesome johnruina site</title>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@600;800;900&display=swap" rel="stylesheet">
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
|
|
body {
|
|
min-height: 100vh;
|
|
background: #0f0f0f;
|
|
font-family: 'Inter', sans-serif;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
user-select: none;
|
|
}
|
|
|
|
.top-bar {
|
|
position: fixed;
|
|
top: 0; left: 0; right: 0;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 1rem 1.5rem;
|
|
z-index: 10;
|
|
pointer-events: none;
|
|
}
|
|
|
|
.top-bar > * { pointer-events: auto; }
|
|
|
|
.back-btn {
|
|
text-decoration: none;
|
|
color: #888;
|
|
font-family: 'Inter', sans-serif;
|
|
font-size: 0.75rem;
|
|
font-weight: 700;
|
|
letter-spacing: 0.5px;
|
|
text-transform: uppercase;
|
|
transition: color 0.2s;
|
|
background: rgba(15,15,15,0.7);
|
|
padding: 0.4rem 0.8rem;
|
|
border-radius: 6px;
|
|
border: 1px solid #333;
|
|
}
|
|
|
|
.back-btn:hover { color: #fff; border-color: #555; }
|
|
|
|
.timer-btns {
|
|
display: flex;
|
|
gap: 4px;
|
|
}
|
|
|
|
.timer-btn {
|
|
padding: 0.4rem 0.8rem;
|
|
background: rgba(15,15,15,0.7);
|
|
color: #666;
|
|
border: 1px solid #333;
|
|
border-radius: 6px;
|
|
font-family: 'Inter', sans-serif;
|
|
font-weight: 700;
|
|
font-size: 0.75rem;
|
|
cursor: pointer;
|
|
transition: all 0.25s;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
.timer-btn:hover { color: #ccc; border-color: #555; background: rgba(255,255,255,0.03); }
|
|
.timer-btn.active { color: #fff; border-color: #4a4a8a; background: #1a1a2e; }
|
|
|
|
#clickArea {
|
|
width: 100vw;
|
|
height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.cps-display {
|
|
font-size: 5rem;
|
|
font-weight: 900;
|
|
color: #fff;
|
|
letter-spacing: 2px;
|
|
}
|
|
|
|
.cps-label {
|
|
color: #666;
|
|
font-size: 0.65rem;
|
|
font-weight: 600;
|
|
letter-spacing: 1.5px;
|
|
text-transform: uppercase;
|
|
margin-top: 0.25rem;
|
|
}
|
|
|
|
.timer-display {
|
|
color: #4a4a8a;
|
|
font-size: 1.2rem;
|
|
font-weight: 800;
|
|
margin-top: 0.5rem;
|
|
letter-spacing: 1px;
|
|
}
|
|
|
|
.stats {
|
|
display: flex;
|
|
gap: 2.5rem;
|
|
margin-top: 1.5rem;
|
|
}
|
|
|
|
.stat-box {
|
|
text-align: center;
|
|
}
|
|
|
|
.stat-box .value {
|
|
color: #ccc;
|
|
font-size: 1.4rem;
|
|
font-weight: 800;
|
|
}
|
|
|
|
.stat-box .label {
|
|
color: #555;
|
|
font-size: 0.55rem;
|
|
font-weight: 600;
|
|
letter-spacing: 1px;
|
|
text-transform: uppercase;
|
|
margin-top: 0.15rem;
|
|
}
|
|
|
|
#statusMsg {
|
|
margin-top: 2rem;
|
|
color: #888;
|
|
font-size: 0.85rem;
|
|
font-weight: 700;
|
|
letter-spacing: 0.5px;
|
|
text-transform: uppercase;
|
|
transition: opacity 0.2s;
|
|
}
|
|
|
|
#statusMsg.subtle {
|
|
color: #555;
|
|
font-size: 0.7rem;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="top-bar">
|
|
<a class="back-btn" href="index.html">← Back</a>
|
|
<div class="timer-btns">
|
|
<button class="timer-btn active" data-time="5">5s</button>
|
|
<button class="timer-btn" data-time="30">30s</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="clickArea">
|
|
<div class="cps-display" id="cpsDisplay">0.0</div>
|
|
<div class="cps-label">Clicks per second</div>
|
|
<div class="timer-display" id="timerDisplay">5s</div>
|
|
<div class="stats">
|
|
<div class="stat-box">
|
|
<div class="value" id="clickCount">0</div>
|
|
<div class="label">Clicks</div>
|
|
</div>
|
|
<div class="stat-box">
|
|
<div class="value" id="bestCps">0.0</div>
|
|
<div class="label">Best CPS</div>
|
|
</div>
|
|
</div>
|
|
<div id="statusMsg">Click to start</div>
|
|
</div>
|
|
|
|
<script>
|
|
const clickArea = document.getElementById('clickArea');
|
|
const cpsDisplay = document.getElementById('cpsDisplay');
|
|
const timerDisplay = document.getElementById('timerDisplay');
|
|
const clickCountEl = document.getElementById('clickCount');
|
|
const bestCpsEl = document.getElementById('bestCps');
|
|
const statusMsg = document.getElementById('statusMsg');
|
|
const timerBtns = document.querySelectorAll('.timer-btn');
|
|
|
|
let testDuration = 5;
|
|
let state = 'idle';
|
|
let clicks = 0;
|
|
let bestCps = 0;
|
|
let timerId = null;
|
|
let startTime = 0;
|
|
let animFrameId = null;
|
|
|
|
function formatCps(val) {
|
|
return val.toFixed(1);
|
|
}
|
|
|
|
function updateTimerDisplay(remaining) {
|
|
timerDisplay.textContent = remaining.toFixed(1) + 's';
|
|
}
|
|
|
|
function updateLiveCps() {
|
|
if (state !== 'running') return;
|
|
const elapsed = (performance.now() - startTime) / 1000;
|
|
if (elapsed <= 0) { cpsDisplay.textContent = '0.0'; return; }
|
|
const cps = clicks / elapsed;
|
|
cpsDisplay.textContent = formatCps(cps);
|
|
const remaining = Math.max(0, testDuration - elapsed);
|
|
updateTimerDisplay(remaining);
|
|
if (remaining <= 0) {
|
|
endTest();
|
|
return;
|
|
}
|
|
animFrameId = requestAnimationFrame(updateLiveCps);
|
|
}
|
|
|
|
function startTest() {
|
|
state = 'running';
|
|
clicks = 0;
|
|
clickCountEl.textContent = '0';
|
|
startTime = performance.now();
|
|
statusMsg.textContent = 'Click as fast as you can!';
|
|
statusMsg.className = '';
|
|
updateTimerDisplay(testDuration);
|
|
animFrameId = requestAnimationFrame(updateLiveCps);
|
|
}
|
|
|
|
function endTest() {
|
|
state = 'done';
|
|
if (animFrameId) { cancelAnimationFrame(animFrameId); animFrameId = null; }
|
|
if (timerId) { clearInterval(timerId); timerId = null; }
|
|
const elapsed = testDuration;
|
|
const cps = clicks / elapsed;
|
|
cpsDisplay.textContent = formatCps(cps);
|
|
if (cps > bestCps) {
|
|
bestCps = cps;
|
|
bestCpsEl.textContent = formatCps(cps);
|
|
}
|
|
statusMsg.textContent = 'Click to try again';
|
|
statusMsg.className = 'subtle';
|
|
timerDisplay.textContent = '0.0s';
|
|
}
|
|
|
|
function handleClick() {
|
|
if (state === 'idle') {
|
|
startTest();
|
|
clicks++;
|
|
clickCountEl.textContent = clicks;
|
|
return;
|
|
}
|
|
if (state === 'running') {
|
|
clicks++;
|
|
clickCountEl.textContent = clicks;
|
|
return;
|
|
}
|
|
if (state === 'done') {
|
|
state = 'idle';
|
|
cpsDisplay.textContent = '0.0';
|
|
statusMsg.textContent = 'Click to start';
|
|
statusMsg.className = '';
|
|
timerDisplay.textContent = testDuration + 's';
|
|
clickCountEl.textContent = '0';
|
|
return;
|
|
}
|
|
}
|
|
|
|
function setDuration(seconds) {
|
|
if (state === 'running') {
|
|
endTest();
|
|
}
|
|
testDuration = seconds;
|
|
timerBtns.forEach(btn => {
|
|
btn.classList.toggle('active', parseInt(btn.dataset.time) === seconds);
|
|
});
|
|
timerDisplay.textContent = seconds + 's';
|
|
state = 'idle';
|
|
cpsDisplay.textContent = '0.0';
|
|
statusMsg.textContent = 'Click to start';
|
|
statusMsg.className = '';
|
|
clickCountEl.textContent = '0';
|
|
}
|
|
|
|
timerBtns.forEach(btn => {
|
|
btn.addEventListener('click', () => {
|
|
setDuration(parseInt(btn.dataset.time));
|
|
});
|
|
});
|
|
|
|
clickArea.addEventListener('click', handleClick);
|
|
|
|
document.addEventListener('keydown', (e) => {
|
|
if (e.key === 'Escape') window.location.href = 'index.html';
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|