Public
HTTP
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
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
import qrcode from 'https://esm.sh/qrcode-generator@1.4.4';
import { nanoid } from 'https://esm.sh/nanoid@4.0.2';
import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
const SCHEMA_VERSION = 2;
const KEY = new URL(import.meta.url).pathname.split("/").at(-1);
const TABLE_NAME = `${KEY}_razza_users_${SCHEMA_VERSION}`;
async function initDB() {
await sqlite.execute(`
CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
id TEXT PRIMARY KEY,
handle TEXT NOT NULL,
phone TEXT NOT NULL,
category TEXT NOT NULL,
details TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
`);
console.log(`Table ${TABLE_NAME} initialized`);
}
function generateQRCode(text: string): string {
const qr = qrcode(0, 'L');
qr.addData(text);
qr.make();
return qr.createSvgTag({ cellSize: 4, margin: 1 });
}
const css = `
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f0f0f0;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
h1, h2 {
text-align: center;
color: #333;
}
.content {
display: flex;
justify-content: space-between;
margin-top: 20px;
gap: 20px;
}
.left-side, .right-side {
width: 48%;
background-color: white;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
input, select, textarea, button {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
textarea {
height: 100px;
resize: vertical;
}
button {
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
#qrCodesContainer {
display: flex;
flex-direction: column;
gap: 15px;
margin-top: 20px;
}
.qr-code-item {
display: flex;
background-color: #f8f9fa;
border: 1px solid #dee2e6;
border-radius: 4px;
padding: 10px;
box-sizing: border-box;
}
.qr-code-item svg {
width: 120px;
height: 120px;
}
.qr-code-details {
margin-left: 15px;
font-size: 0.9em;
gio-razza.web.val.run
August 25, 2024