-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.html
More file actions
212 lines (179 loc) · 5.65 KB
/
index.html
File metadata and controls
212 lines (179 loc) · 5.65 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Reform UK Exposed Tweets by Area</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="https://cdn.jsdelivr.net/npm/papaparse@5.4.1/papaparse.min.js"></script>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
padding: 0;
background: #f5f5f5;
color: #003b5c;
}
header {
background: #00aeef;
padding: 2rem 1rem 1rem;
text-align: center;
color: white;
position: relative;
}
header h1 {
margin: 0;
font-size: 2.5rem;
}
.subtext {
margin-top: 0.5rem;
font-size: 1rem;
color: white;
}
.subtext a {
color: white;
text-decoration: underline;
}
.hero-image {
width: 100%;
max-height: 300px;
object-fit: cover;
margin-top: 1rem;
border-bottom: 4px solid #003b5c;
}
.container {
max-width: 900px;
margin: 2rem auto;
padding: 0 1rem;
}
.filters {
margin-bottom: 1.5rem;
}
label {
font-weight: bold;
display: block;
margin-bottom: 0.5rem;
}
select, input[type="text"] {
width: 100%;
padding: 0.75rem;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1rem;
}
.tweet {
background: white;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
padding: 1rem;
margin-bottom: 1rem;
line-height: 1.5;
}
.tweet a {
display: inline-block;
margin-top: 0.5rem;
color: #00aeef;
text-decoration: none;
}
footer {
text-align: center;
color: #888;
font-size: 0.9rem;
margin-top: 3rem;
padding-bottom: 2rem;
}
@media (max-width: 700px) {
header h1 {
font-size: 2rem;
}
}
</style>
</head>
<body>
<header>
<h1>Reform UK Exposed Tweets</h1>
<div class="subtext">
Are you a local campaigner looking for information about your local Reform candidates? These are tweets from the brilliant <strong>Reform UK Exposed</strong> Twitter account, organised by geography.
<br />
Follow the original account <a href="https://twitter.com/ReformExposed" target="_blank">here</a>.
</div>
<img class="hero-image" src="https://samkriss.com/wp-content/uploads/2013/05/image_update_cdaea1042c69cad5_1364011137_9j-4aaqsk.jpeg" alt="Satirical image of Nigel Farage crying">
<!-- Replace with your preferred image URL or local image -->
</header>
<div class="container">
<div class="filters">
<label for="areaSelect">Filter by Area:</label>
<select id="areaSelect">
<option value="">All Areas</option>
</select>
</div>
<div style="margin-bottom: 1.5rem;">
<label for="searchInput">Search tweets:</label>
<input type="text" id="searchInput" placeholder="Enter keyword..." />
</div>
<div id="tweets"></div>
</div>
<footer>
Built by volunteers at Campaign Lab to uncover the truth behind Reform UK
</footer>
<script>
const sheetURL = 'https://docs.google.com/spreadsheets/d/e/2PACX-1vQyOqn4w0KNNgwXjXBam72jKvAmFwr3RUQEHjYEFhUq8gTwZqwuNSStbT-4SELNDNoT7taAgIXC66E2/pub?gid=0&single=true&output=csv';
let allData = [];
async function loadCSV(url) {
const res = await fetch(url);
const text = await res.text();
const parsed = Papa.parse(text, {
header: true,
skipEmptyLines: true
});
const cleaned = parsed.data.map(row => ({
area: row["Area"]?.trim(),
tweet: row["Tweet"]?.trim(),
url: row["URL"]?.trim()
})).filter(d => d.area && d.tweet);
return cleaned;
}
function populateDropdown(id, items) {
const select = document.getElementById(id);
items.sort().forEach(value => {
const option = document.createElement("option");
option.value = value;
option.textContent = value;
select.appendChild(option);
});
}
function applyFilters() {
const area = document.getElementById('areaSelect').value;
const searchTerm = document.getElementById('searchInput').value.toLowerCase();
const tweetsDiv = document.getElementById('tweets');
tweetsDiv.innerHTML = '';
const filtered = allData.filter(d => {
const matchesArea = area === '' || d.area === area;
const matchesSearch = searchTerm === '' || d.tweet.toLowerCase().includes(searchTerm);
return matchesArea && matchesSearch;
});
if (filtered.length === 0) {
tweetsDiv.innerHTML = "<p>No tweets match your filters.</p>";
return;
}
filtered.forEach(d => {
const div = document.createElement("div");
div.className = "tweet";
div.innerHTML = `
${d.tweet}
${d.url ? `<br><a href="${d.url}" target="_blank">View on Twitter</a>` : ''}
`;
tweetsDiv.appendChild(div);
});
}
async function init() {
allData = await loadCSV(sheetURL);
const uniqueAreas = [...new Set(allData.map(d => d.area).filter(Boolean))];
populateDropdown('areaSelect', uniqueAreas);
document.getElementById('areaSelect').addEventListener('change', applyFilters);
document.getElementById('searchInput').addEventListener('input', applyFilters);
applyFilters(); // initial render
}
init();
</script>
</body>
</html>