Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
155 lines (136 loc) · 3.52 KB
/
Copy pathindex.html
File metadata and controls
155 lines (136 loc) · 3.52 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Submit and View Quotes</title>
<style>
body {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
color: #333;
}
.container {
max-width: 800px;
margin: 20px auto;
padding: 20px;
background: #fff;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
font-size: 2em;
margin-bottom: 20px;
color: #007bff;
}
h2 {
font-size: 1.5em;
margin-bottom: 15px;
color: #333;
}
form {
margin-bottom: 20px;
}
label {
display: block;
font-weight: bold;
margin-bottom: 5px;
}
input[type="text"],
textarea {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
textarea {
height: 100px;
resize: vertical;
}
button {
background-color: #007bff;
color: white;
border: none;
padding: 10px 20px;
font-size: 1em;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #0056b3;
}
.note {
margin: 20px 0;
padding: 10px;
background-color: #e7f0ff;
border-left: 5px solid #007bff;
border-radius: 4px;
color: #333;
}
.quote {
border: 1px solid #ddd;
padding: 10px;
margin-bottom: 10px;
border-radius: 4px;
background-color: #f9f9f9;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body>
<div class="container">
<h1>Submit and View Quotes</h1>
<div class="note">
Your message will be printed on my printer!
</div>
<form id="quoteForm">
<label for="username">Username:</label>
<input type="text" id="username" name="username" maxlength="20" required>
<label for="message">Message:</label>
<textarea id="message" name="message" maxlength="200" required></textarea>
<button type="submit">Submit</button>
</form>
<hr>
<h2>Quotes</h2>
<div id="quotesContainer"></div>
</div>
<script>
document.getElementById('quoteForm').addEventListener('submit', async (e) => {
e.preventDefault();
const username = document.getElementById('username').value;
const message = document.getElementById('message').value;
const response = await fetch('api.goes.here.com', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ username, message })
});
if (response.ok) {
alert('Message submitted successfully!');
fetchQuotes();
} else {
alert('Failed to submit message');
}
});
async function fetchQuotes() {
const response = await fetch('api.goes.here.com');
const quotes = await response.json();
const quotesContainer = document.getElementById('quotesContainer');
quotesContainer.innerHTML = '';
quotes.forEach(quote => {
const quoteElement = document.createElement('div');
quoteElement.className = 'quote';
quoteElement.innerHTML = `<strong>${quote.username}:</strong> ${quote.message}`;
quotesContainer.appendChild(quoteElement);
});
}
// Fetch quotes when the page loads
fetchQuotes();
</script>
</body>
</html>