janpaul123-valle_tmp_59257570592856375817499399720445.web.val.run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// This val serves a HTML page that contains a Wordle game with custom CSS for a fun, colorful style
// Import dependencies
import { Hono } from "npm:hono";
const app = new Hono();
app.get("/", async (c) => {
const html = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wordle Clone</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
font-family: 'Comic Sans MS', 'Comic Sans', cursive;
background: linear-gradient(45deg, #ff00cc, #333399);
color: #fff;
text-align: center;
}
.title {
font-size: 2.5rem;
background: -webkit-linear-gradient(#eee, #333);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.grid {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 10px;
}
.cell {
width: 60px;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
font-size: 2rem;
background: #fff;
border: 2px solid #333;
transition: all 0.2s;
}
.cell.correct { background: #66ff66; }
.cell.present { background: #ffcc00; }
.cell.absent { background: #999999; }
.keyboard {
display: flex;
justify-content: center;
flex-wrap: wrap;
max-width: 500px;
}
.key {
padding: 10px 20px;
margin: 5px;
border: none;
background: #000;
color: #fff;
font-size: 1rem;
cursor: pointer;
transition: transform 0.1s;
}
.key:hover { transform: scale(1.1); }
.key:active { transform: scale(0.9); }
</style>
</head>
<body>
<h1 class="title">Wordle Clone</h1>
<div class="grid" id="grid"></div>
<div class="keyboard" id="keyboard"></div>
<script>
const WORD = "CRAFT";
let currentRow = 0;
let currentCol = 0;
const gridElement = document.getElementById('grid');
const keyboardElement = document.getElementById('keyboard');
const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
for (let i = 0; i < 30; i++) {
const cell = document.createElement('div');
cell.classList.add('cell');
gridElement.appendChild(cell);
}
letters.split('').forEach((letter) => {
const key = document.createElement('button');
key.classList.add('key');
key.textContent = letter;
key.addEventListener('click', () => handleKeyPress(letter));
keyboardElement.appendChild(key);
});
document.addEventListener('keydown', (e) => {
const letter = e.key.toUpperCase();
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
July 15, 2024