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
/**
* This application creates a client-side data URI generator with the following features:
* - File upload through input and drag-and-drop
* - Automatic MIME type detection
* - Preview of the uploaded file (image, video, audio, or text)
* - Copy button to easily copy the generated data URI
*
* We'll use the FileReader API for file handling and data URI generation.
* The application will be built using HTML, CSS, and JavaScript, served by a Hono app.
*/
import { serve } from 'https://esm.town/v/g/serveUtils';
import { Hono } from 'npm:hono';
function html() {
/*
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Data URI Generator</title>
<link rel="stylesheet" href="/styles.css">
<script type="module" src="/main.js" defer></script>
</head>
<body>
<div class="container">
<h1>Data URI Generator</h1>
<div id="drop-zone" class="drop-zone">
<p>Drag & Drop file here or</p>
<input type="file" id="file-input">
<label for="file-input" class="file-input-label">Choose a file</label>
</div>
<div id="preview" class="preview"></div>
<textarea id="output" readonly></textarea>
<button id="copy-btn" disabled>Copy Data URI</button>
</div>
</body>
</html>
*/
}
function css() {
/*
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 0;
padding: 20px;
background-color: #f4f4f4;
}
.container {
max-width: 800px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
color: #333;
}
.drop-zone {
border: 2px dashed #ccc;
border-radius: 5px;
padding: 20px;
text-align: center;
margin-bottom: 20px;
transition: background-color 0.3s;
}
.drop-zone.dragover {
background-color: #e9e9e9;
}
.file-input-label {
background-color: #4CAF50;
color: white;
padding: 10px 15px;
border-radius: 5px;
cursor: pointer;
}
#file-input {
display: none;
}
.preview {
margin-bottom: 20px;
text-align: center;
}
.preview img, .preview video {
max-width: 100%;
max-height: 300px;
}
g-dataurigenapp.web.val.run
August 30, 2024