-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
314 lines (273 loc) · 10.3 KB
/
index.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
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Newsletter Preview Analyzer</title>
<style>
:root {
--bg-primary: #1a1a1a;
--bg-secondary: #242424;
--bg-tertiary: #2d2d2d;
--text-primary: #ffffff;
--text-secondary: #b3b3b3;
--border-color: #333333;
--accent-color: #4a9eff;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background: var(--bg-primary);
color: var(--text-primary);
}
h1 {
color: var(--text-primary);
margin-bottom: 24px;
}
.container {
display: grid;
gap: 20px;
}
.input-group {
margin-bottom: 20px;
}
.input-label {
display: block;
margin-bottom: 8px;
color: var(--accent-color);
font-weight: bold;
}
input[type="text"], textarea {
width: 100%;
padding: 12px;
border: 1px solid var(--border-color);
border-radius: 4px;
background: var(--bg-secondary);
color: var(--text-primary);
font-family: inherit;
margin-bottom: 16px;
}
textarea {
height: 200px;
resize: vertical;
font-family: monospace;
}
.preview-card {
background: var(--bg-secondary);
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
.preview-section {
margin-bottom: 24px;
}
.label {
font-weight: bold;
color: var(--accent-color);
margin-bottom: 8px;
}
.preview-box {
padding: 12px;
background: var(--bg-tertiary);
border: 1px solid var(--border-color);
border-radius: 4px;
color: var(--text-primary);
}
.preview-stack {
display: flex;
flex-direction: column;
gap: 20px;
margin-top: 20px;
}
.desktop-preview {
background: var(--bg-tertiary);
border: 12px solid var(--border-color);
border-radius: 8px;
padding: 16px;
}
.desktop-preview .email-header {
display: grid;
grid-template-columns: 200px 1fr 100px;
gap: 12px;
padding: 12px;
border-bottom: 1px solid var(--border-color);
}
.mobile-preview {
max-width: 350px;
background: var(--bg-tertiary);
border: 12px solid var(--border-color);
border-radius: 24px;
padding: 16px;
margin: 0 auto;
}
.email-row {
display: flex;
gap: 12px;
padding: 8px 0;
border-bottom: 1px solid var(--border-color);
}
.sender-avatar {
width: 48px;
height: 48px;
background: var(--bg-primary);
border-radius: 50%;
}
.email-content {
flex: 1;
}
.subject {
font-weight: 600;
color: var(--text-primary);
margin-bottom: 4px;
}
.preview-text {
color: var(--text-secondary);
font-size: 0.9em;
}
.folder {
color: var(--text-secondary);
font-size: 0.9em;
}
.timestamp {
color: var(--text-secondary);
font-size: 0.9em;
text-align: right;
}
.desktop-toolbar {
display: flex;
gap: 8px;
padding: 8px;
background: var(--bg-secondary);
border-bottom: 1px solid var(--border-color);
}
.toolbar-button {
width: 12px;
height: 12px;
border-radius: 50%;
border: none;
}
.close { background: #ff5f57; }
.minimize { background: #febc2e; }
.maximize { background: #28c840; }
.preview-label {
font-size: 0.9em;
color: var(--text-secondary);
margin-bottom: 8px;
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<h1>Newsletter Preview Analyzer</h1>
<div class="input-group">
<label class="input-label" for="subjectInput">Subject Line</label>
<input type="text" id="subjectInput" placeholder="Enter subject line...">
</div>
<div class="input-group">
<label class="input-label" for="htmlInput">Newsletter HTML</label>
<textarea id="htmlInput" placeholder="Paste your newsletter HTML here..."></textarea>
</div>
<div class="preview-card">
<div class="preview-section">
<div class="label">Preview Text</div>
<div id="previewTextContent" class="preview-box">Preview text will appear here</div>
</div>
<div class="preview-section">
<div class="label">Preview Displays</div>
<div class="preview-stack">
<!-- Desktop Preview -->
<div>
<div class="preview-label">Desktop View</div>
<div class="desktop-preview">
<div class="desktop-toolbar">
<div class="toolbar-button close"></div>
<div class="toolbar-button minimize"></div>
<div class="toolbar-button maximize"></div>
</div>
<div class="email-header">
<div class="folder">Inbox</div>
<div class="subject" id="desktopSubject">Subject line</div>
<div class="timestamp">9:41 AM</div>
</div>
<div class="email-row">
<div class="sender-avatar"></div>
<div class="email-content">
<div class="preview-text" id="desktopPreview">Preview text will appear here...</div>
</div>
</div>
</div>
</div>
<!-- Mobile Preview -->
<div>
<div class="preview-label">Mobile View</div>
<div class="mobile-preview">
<div class="email-row">
<div class="sender-avatar"></div>
<div class="email-content">
<div id="mobileSubject" class="subject">Subject line</div>
<div id="mobilePreview" class="preview-text">Preview text will appear here...</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
const htmlInput = document.getElementById('htmlInput');
const subjectInput = document.getElementById('subjectInput');
const previewTextContent = document.getElementById('previewTextContent');
const mobileSubject = document.getElementById('mobileSubject');
const mobilePreview = document.getElementById('mobilePreview');
const desktopSubject = document.getElementById('desktopSubject');
const desktopPreview = document.getElementById('desktopPreview');
// Listen for both HTML and subject input changes
htmlInput.addEventListener('input', updatePreviews);
subjectInput.addEventListener('input', updatePreviews);
function updatePreviews() {
const html = htmlInput.value;
const manualSubject = subjectInput.value;
// Create a temporary DOM element to parse the HTML
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
// Use manual subject if provided, otherwise try to extract from HTML
let subject = manualSubject;
if (!subject) {
const subjectMeta = doc.querySelector('meta[name="subject"], meta[name="og:title"]');
const titleElement = doc.querySelector('title');
if (subjectMeta) {
subject = subjectMeta.getAttribute('content');
} else if (titleElement) {
subject = titleElement.textContent;
}
}
// Extract preview text (common patterns)
let previewText = '';
const previewMeta = doc.querySelector('meta[name="description"], meta[name="preview"], div[data-preview-text]');
if (previewMeta) {
previewText = previewMeta.getAttribute('content') || previewMeta.textContent;
} else {
// Fallback: Get first text content
const firstParagraph = doc.querySelector('p, div');
if (firstParagraph) {
previewText = firstParagraph.textContent.trim().substring(0, 200) + '...';
}
}
// Update all preview elements
previewTextContent.textContent = previewText || 'No preview text found';
mobileSubject.textContent = subject || 'No subject found';
mobilePreview.textContent = previewText || 'No preview text found';
desktopSubject.textContent = subject || 'No subject found';
desktopPreview.textContent = previewText || 'No preview text found';
// Update subject input if it's empty and we found a subject in the HTML
if (!manualSubject && subject) {
subjectInput.value = subject;
}
}
</script>
</body>
</html>