-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.html
99 lines (92 loc) · 2.86 KB
/
main.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My PWA</title>
<link rel="manifest" href="/manifest.json">
<link rel="icon" href="/favicon.ico">
<style>
body {
align-items:center;
font-family: Arial, sans-serif;
text-align: center;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0; /* Light gray background */
}
h1 {
font-size: 2rem; /* Base font size for desktop */
color: #333; /* Dark text color */
margin: 0;
}
/* Mobile styles */
@media (max-width: 600px) {
h1 {
font-size: 1.5rem; /* Smaller font size for mobile */
}
body {
padding: 20px; /* Add some padding on mobile */
}
}
/* Desktop styles */
@media (min-width: 601px) {
h1 {
font-size: 3rem; /* Larger font size for desktop */
}
}
</style>
</head>
<body><div>
<div> <h1>Welcome to My Progressive Web App!</h1>
</div>
<div class="example">
<div class="file-select">
<label for="avatar">Choose a profile picture:</label>
<input
type="file"
id="avatar"
name="avatar"
accept="image/png, image/jpeg" />
</div>
<img src="" class="preview" height="200" alt="Image preview" />
<div class="event-log">
<label for="eventLog">Event log:</label>
<textarea readonly class="event-log-contents" id="eventLog"></textarea>
</div>
</div></div>
<script src="app.js">
const fileInput = document.querySelector('input[type="file"]');
const preview = document.querySelector("img.preview");
const eventLog = document.querySelector(".event-log-contents");
const reader = new FileReader();
function handleEvent(event) {
eventLog.textContent += `${event.type}: ${event.loaded} bytes transferred\n`;
if (event.type === "load") {
preview.src = reader.result;
}
}
function addListeners(reader) {
reader.addEventListener("loadstart", handleEvent);
reader.addEventListener("load", handleEvent);
reader.addEventListener("loadend", handleEvent);
reader.addEventListener("progress", handleEvent);
reader.addEventListener("error", handleEvent);
reader.addEventListener("abort", handleEvent);
}
function handleSelected(e) {
eventLog.textContent = "";
const selectedFile = fileInput.files[0];
if (selectedFile) {
addListeners(reader);
var ck=reader.readAsDataURL(selectedFile);
console.log("")
}
}
fileInput.addEventListener("change", handleSelected);</script>
</body>
</html>