-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
345 lines (328 loc) · 15.6 KB
/
index.html
File metadata and controls
345 lines (328 loc) · 15.6 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
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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title id="page-title">VCMail Email</title>
<script>
// VCMail configuration will be injected here during deployment
// This is populated from vcmail.config.json by the setup process
window.VCMAIL_CONFIG = window.VCMAIL_CONFIG || {
domain: "example.com",
webmailDomain: "mail.example.com",
apiEndpoint: "https://api.example.com",
storageCacheKey: "vcmail_email_cache",
googleOAuthClientId: "",
firebase: {
apiKey: "your-api-key",
authDomain: "your-project.firebaseapp.com",
databaseURL: "https://your-project.firebaseio.com",
projectId: "your-project-id",
storageBucket: "your-project.appspot.com",
messagingSenderId: "123456789",
appId: "your-app-id"
}
};
// Update page title based on domain
function updatePageTitle() {
const emailDomain = window.VCMAIL_CONFIG?.domain || 'example.com';
const titleElement = document.getElementById('page-title');
if (titleElement) {
titleElement.textContent = `${emailDomain} Email`;
}
// Also update document.title for immediate effect
document.title = `${emailDomain} Email`;
}
// Run immediately if config is available, otherwise wait for DOMContentLoaded
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', updatePageTitle);
} else {
updatePageTitle();
}
// Also run when config might become available later
document.addEventListener('DOMContentLoaded', updatePageTitle);
</script>
<link rel="icon" type="image/x-icon" href="/favicon.ico">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inter:400,600&display=swap">
<link rel="stylesheet" href="/src/styles.css">
<script src="https://cdn.jsdelivr.net/npm/dompurify@3.0.8/dist/purify.min.js"></script>
</head>
<body>
<div id="app">
<!-- Sign In Section -->
<section id="signin-section" class="hidden">
<h1 class="center" id="signin-heading">VCMail Email</h1>
<script>
// Update signin heading based on domain
function updateSigninHeading() {
const emailDomain = window.VCMAIL_CONFIG?.domain || 'example.com';
const heading = document.getElementById('signin-heading');
if (heading) {
heading.textContent = `${emailDomain} Email`;
}
}
// Run immediately if config is available, otherwise wait for DOMContentLoaded
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', updateSigninHeading);
} else {
updateSigninHeading();
}
// Also run when config might become available later
document.addEventListener('DOMContentLoaded', updateSigninHeading);
</script>
<div class="auth-container">
<!-- Email/Password Form -->
<form id="auth-form" class="auth-form">
<div class="auth-toggle">
<button type="button" class="toggle-btn active" id="signin-toggle">Sign In</button>
<button type="button" class="toggle-btn" id="signup-toggle">Sign Up</button>
</div>
<div class="form-group">
<label for="auth-email">Email:</label>
<input type="email" id="auth-email" class="input" required placeholder="your@email.com" />
</div>
<div class="form-group">
<label for="auth-password">Password:</label>
<input type="password" id="auth-password" class="input" required placeholder="Password" />
</div>
<div class="form-group" id="confirm-password-group" style="display: none;">
<label for="auth-confirm-password">Confirm Password:</label>
<input type="password" id="auth-confirm-password" class="input" placeholder="Confirm Password" />
</div>
<div class="auth-error" id="auth-error"></div>
<button type="submit" class="btn" id="auth-submit-btn">Sign In</button>
</form>
<div class="auth-divider">
<span>or</span>
</div>
<!-- Google Sign In -->
<button class="btn btn-google" id="google-signin-btn">
<svg width="20" height="20" viewBox="0 0 24 24">
<path fill="#4285F4" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"/>
<path fill="#34A853" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"/>
<path fill="#FBBC05" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"/>
<path fill="#EA4335" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"/>
</svg>
Sign in with Google
</button>
</div>
</section>
<!-- Setup Section -->
<section id="setup-section" class="hidden">
<h1 id="setup-heading">Set up your Email</h1>
<form id="setup-form">
<label>Choose your username (for <b id="email-domain-display">@example.com</b>):</label>
<script>
// Update email domain display and heading
function updateEmailDomainDisplay() {
const emailDomain = window.VCMAIL_CONFIG?.domain || 'example.com';
const display = document.getElementById('email-domain-display');
const heading = document.getElementById('setup-heading');
if (display) {
display.textContent = `@${emailDomain}`;
}
if (heading) {
heading.textContent = `Set up your ${emailDomain} Email`;
}
}
// Run immediately if config is available, otherwise wait for DOMContentLoaded
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', updateEmailDomainDisplay);
} else {
updateEmailDomainDisplay();
}
// Also run when config might become available later
document.addEventListener('DOMContentLoaded', updateEmailDomainDisplay);
</script>
<input class="input" id="username-input" required maxlength="32" placeholder="yourname" />
<button class="btn" type="submit">Set Username</button>
</form>
</section>
<!-- Inbox Section -->
<section id="inbox-section" class="hidden">
<div class="toolbar">
<div class="toolbar-left">
<button class="btn" id="compose-btn">Compose</button>
</div>
<div class="toolbar-center">
<a href="/" class="logo-link">
<img src="/images/logo_transparent.webp" alt="VCMail" class="logo">
</a>
</div>
<div class="toolbar-right">
<button class="btn btn-secondary" id="settings-btn">Settings</button>
</div>
</div>
<div class="user-email-mobile" id="user-email-display"></div>
<div class="folder-tabs">
<button class="folder-tab active" id="inbox-tab">Inbox</button>
<button class="folder-tab" id="sent-tab">Sent</button>
</div>
<ul class="inbox-list" id="inbox-list"></ul>
<div class="load-more-container">
<button class="btn btn-secondary hidden" id="load-more-btn">Load More</button>
</div>
<div class="footer" id="footer">
<span id="message-count">0 messages</span>
</div>
</section>
<!-- Email View Section -->
<section id="email-view-section" class="hidden">
<div class="topbar">
<button class="btn" id="back-to-inbox-btn">← Inbox</button>
<div class="email-actions">
<button class="btn" id="reply-btn">Reply</button>
<button class="btn btn-danger" id="delete-email-btn">Delete</button>
</div>
</div>
<div class="email-header">
<h2 id="email-subject"></h2>
</div>
<div class="email-details">
<div class="email-detail">
<span class="email-detail-label">From:</span>
<span id="email-from"></span>
</div>
<div class="email-detail">
<span class="email-detail-label">To:</span>
<span id="email-to"></span>
</div>
<div class="email-detail">
<span class="email-detail-label">Date:</span>
<span id="email-date"></span>
</div>
</div>
<div class="email-attachments-header" id="email-attachments-header"></div>
<div class="email-content" id="email-content"></div>
</section>
<!-- Compose Section -->
<section id="compose-section" class="hidden">
<div class="topbar">
<button class="btn" id="back-to-inbox-compose-btn">← Inbox</button>
<span></span>
</div>
<h2>Compose Email</h2>
<form id="compose-form">
<label>To:</label>
<input class="input" id="to-input" required placeholder="recipient@example.com" />
<script>
// Update placeholder
document.addEventListener('DOMContentLoaded', function() {
const emailDomain = window.VCMAIL_CONFIG?.domain || 'example.com';
const toInput = document.getElementById('to-input');
if (toInput) {
toInput.placeholder = `recipient@${emailDomain}`;
}
});
</script>
<label>Subject:</label>
<input class="input" id="subject-input" placeholder="Subject" />
<label>Message:</label>
<textarea class="input" id="body-input" rows="8" required placeholder="Type your message here..."></textarea>
<div class="actions">
<button class="btn" type="submit" id="send-btn">Send</button>
<button class="btn btn-secondary" type="button" id="cancel-compose-btn">Cancel</button>
</div>
</form>
</section>
<!-- Settings Section -->
<section id="settings-section" class="hidden">
<div class="topbar">
<button class="btn" id="back-to-inbox-settings-btn">← Inbox</button>
<h2>Settings</h2>
<button class="btn btn-secondary" id="logout-btn">Logout</button>
</div>
<div class="settings-container">
<div class="settings-section">
<h3>Account Information</h3>
<div class="account-info">
<div class="info-item">
<span class="info-label">Email Address:</span>
<span class="info-value" id="account-email">Loading...</span>
</div>
<div class="info-item">
<span class="info-label">User ID:</span>
<span class="info-value" id="account-uid">Loading...</span>
</div>
</div>
</div>
<div class="settings-section" id="calendar-settings-section">
<h3>Google Calendar</h3>
<div id="calendar-settings-disabled" class="hidden">
<p class="settings-description">
<strong>Firebase “Sign in with Google” is separate from Calendar here.</strong> This page only enables Calendar after
<code>googleOAuthClientId</code> is set in <code>vcmail.config.json</code> and the webmail app is redeployed so
<code>window.VCMAIL_CONFIG.googleOAuthClientId</code> is non-empty (check in DevTools).
Use a <strong>Google Cloud OAuth 2.0 Client ID</strong> of type <em>Web application</em>; enable the Calendar API on that project.
Under <strong>APIs & Credentials → that OAuth client → Authorized JavaScript origins</strong>, add this site’s origin
(e.g. <code>https://mail.yourdomain.com</code>). Firebase’s “Authorized domains” list does not replace that step for the token client.
You may reuse the same Web client ID Firebase uses if you add the webmail origin there.
</p>
</div>
<div id="calendar-settings-active" class="hidden">
<p id="calendar-google-signin-hint" class="settings-description hidden">
You signed in with Google. Use <strong>Connect Google Calendar</strong> below with the same Google account so invitations can be added to the calendar you choose.
</p>
<p class="settings-description">
Connect once on this device to add <code>.ics</code> invitations from email into a calendar you select. Duplicate detection compares the invitation to events on the same day (by UID and start time). Access tokens stay in this browser only. After an upgrade, use <strong>Disconnect</strong> then connect again if your calendar list does not load (OAuth scopes may have changed).
</p>
<div class="cache-actions">
<button type="button" class="btn" id="calendar-connect-btn">Connect Google Calendar</button>
<button type="button" class="btn btn-secondary hidden" id="calendar-disconnect-btn">Disconnect</button>
</div>
<div class="storage-info" style="margin-top: 12px;">
<div class="info-item">
<span class="info-label">Status</span>
<span class="info-value" id="calendar-connection-status">Not connected</span>
</div>
</div>
<div id="gcal-target-calendar-wrap" class="hidden" style="margin-top: 16px;">
<label for="gcal-target-calendar-select" class="settings-field-label">Add invitations to this calendar</label>
<select id="gcal-target-calendar-select" class="input settings-select" aria-label="Target Google calendar for ICS imports"></select>
<p class="settings-description" style="margin-top: 8px;">
Shown after you connect. Imports and duplicate checks use this calendar.
</p>
</div>
</div>
</div>
<div class="settings-section">
<h3>Storage Information</h3>
<div class="storage-info" id="storage-info">
<div class="info-item">
<span class="info-label">Browser Storage Quota:</span>
<span class="info-value" id="quota-info">Loading...</span>
</div>
<div class="info-item">
<span class="info-label">Storage Usage:</span>
<span class="info-value" id="usage-info">Loading...</span>
</div>
<div class="info-item">
<span class="info-label">Available Space:</span>
<span class="info-value" id="available-info">Loading...</span>
</div>
<div class="info-item">
<span class="info-label">localStorage Usage:</span>
<span class="info-value" id="localstorage-info">Loading...</span>
</div>
<div class="info-item">
<span class="info-label">Email Cache:</span>
<span class="info-value" id="cache-info">Loading...</span>
</div>
</div>
</div>
<div class="settings-section">
<h3>Cache Management</h3>
<div class="cache-actions">
<button class="btn btn-secondary" id="clear-cache-btn">Clear Email Cache</button>
<button class="btn btn-secondary" id="refresh-storage-btn">Refresh Storage Info</button>
</div>
<p class="settings-description">
Clearing the cache will remove all locally stored emails. They will be reloaded from the server when needed.
</p>
</div>
</div>
</section>
</div>
<script type="module" src="/src/email.js"></script>
</body>
</html>