-
Notifications
You must be signed in to change notification settings - Fork 0
/
feedback.html
144 lines (129 loc) · 4.63 KB
/
feedback.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Feedback Page</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 20px;
}
button {
padding: 1em;
margin: 1em;
}
.container {
max-width: 600px;
margin: auto;
background: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.feedback-form {
display: flex;
flex-direction: column;
}
.feedback-form label {
margin-top: 10px;
}
.feedback-form input, .feedback-form textarea {
margin-top: 5px;
padding: 1em;
font-size: 16px;
margin-bottom:1em;
}
.rating {
display: flex;
gap: 5px;
font-size: 2em;
cursor: pointer;
}
.url-preview {
margin-top: 10px;
font-size: 16px;
color: #555;
}
</style>
<link rel="stylesheet" href="css/basic.css">
</head>
<body>
<main>
<div class="topnav">
<ul>
<li><a class="btn-h" href="home.html">Home</a>
<li><a class="btn-v" href="rss.html" alt="RSS Feed"> 📶 RSS</a></li>
</ul>
</div>
<h2 class="title" id="blog">Feedback</h2>
<div class="article">
<p>Disclaimer:
This page uses minimal JavaScript for strictly functional purposes.
</p>
<div id="url-preview" class="url-preview"></div>
<form class="feedback-form" onsubmit="submitForm(event)">
<label for="username">Username (optional):</label>
<input type="text" id="username" name="username">
<label>Rate this article:</label>
<div class="rating">
<span data-value="1">☆</span>
<span data-value="2">☆</span>
<span data-value="3">☆</span>
<span data-value="4">☆</span>
<span data-value="5">☆</span>
</div>
<input type="hidden" id="rating" name="rating" required>
<input type="hidden" id="url" name="url" required>
<label for="feedback">Leave a comment (optional):</label>
<textarea id="feedback" name="feedback" rows="4"></textarea>
</br></br>
<button class="btn-h" type="submit">Submit</button>
</form>
</div>
<script>
function getQueryParam(param) {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(param);
}
document.addEventListener('DOMContentLoaded', () => {
const urlField = document.getElementById('url');
const urlPreview = document.getElementById('url-preview');
const articleUrl = getQueryParam('url');
if (articleUrl) {
const decodedUrl = decodeURIComponent(articleUrl);
urlField.value = decodedUrl;
urlPreview.textContent = `Feedback for: ${decodedUrl}`;
}
const stars = document.querySelectorAll('.rating span');
const ratingInput = document.getElementById('rating');
stars.forEach(star => {
star.addEventListener('click', () => {
const ratingValue = star.getAttribute('data-value');
ratingInput.value = ratingValue;
stars.forEach(s => {
s.textContent = '☆';
});
for (let i = 0; i < ratingValue; i++) {
stars[i].textContent = '★';
}
});
});
});
function submitForm(event) {
event.preventDefault();
const form = event.target;
const formData = new FormData(form);
const username = formData.get('username') || 'Anonymous';
const url = formData.get('url');
const rating = formData.get('rating') || 'No rating';
const feedback = formData.get('feedback') || 'No comment';
const subject = `Feedback: ${rating} Stars`;
const body = `Username: ${username}\nURL: ${url}\nRating: ${rating} Stars\nComment: ${feedback}`;
window.location.href = `mailto:amosnimos0@gmail.com?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
}
</script>
</main>
</body>
</html>