-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
104 lines (94 loc) · 4.17 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- Make website responsive -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="color-scheme" content="dark light">
<meta description="A website built to allow users to send a pre-defined email (which they can preview) to multiple, pre-defined recipients (which they can preview in their email app).">
<title>Email Sender</title>
<link href="./styles.css" rel="stylesheet"/>
<script>
let emailMessageBody = `Email message body
`;
let subjectLine = `Subject Line`;
function normaliseString(str) {
// Define a mapping of accented letters to their non-accented equivalents
const charMap = {
'à': 'a',
'á': 'a',
'ä': 'a',
'é': 'e',
'è': 'e',
'ê': 'e',
'ë': 'e',
'í': 'i',
'î': 'i',
'ï': 'i',
'ì': 'i',
'ó': 'o',
'ô': 'o',
'ö': 'o',
'ú': 'u',
'û': 'u',
'ü': 'u',
'ū': 'u',
'ç': 'c',
'À': 'A',
'Á': 'A',
'Ä': 'A',
'É': 'E',
'È': 'E',
'Ê': 'E',
'Ë': 'E',
'Í': 'I',
'Ì': 'I',
'Î': 'I',
'Ï': 'I',
'Ó': 'O',
'Ô': 'O',
'Ö': 'O',
'Ú': 'U',
'Û': 'U',
'Ü': 'U',
'Ū': 'U',
'Ç': 'C',
// Add more mappings as needed
// **********TODO also move to Javascript file**********
};
// Use a regular expression to replace special characters
return str.replace(/[àáäéèêëíîìïóôöúûüūçÀÁÄÉÈÊËÍÌÎÏÓÔÖÚÛÜŪÇ]/g, match => charMap[match] || match);
}
function sendEmail() {
// Get user's signature from text area
let signature = document.getElementById("signature").value;
// Replace spaces with space characters
signature = signature.replace(/ /g, " ");
// Normalise signature by replacing special characters
let normalisedSignature = normaliseString(signature);
// Encode signature for use in mail-to link
let encodedSignature = encodeURIComponent(normalisedSignature).replace(/%20/g, " ");
// Create mail-to link
let mailToLink = `mailto:exampleEmail1@email.com,exampleEmail2@email.com?subject=${subjectLine}&&body=${encodeURIComponent(emailMessageBody + encodedSignature)}`;
console.log(encodedSignature)
// Open email client with pre-filled email
window.location.href = mailToLink;
}
</script>
</head>
<body>
<div>
<p>Please sign your name and we will write and sign the below email on your behalf.</p>
<textarea class="signature-box" id="signature" name="signature" placeholder="Type your full name here"></textarea>
<input class="send-email-button" type="button" value="Send Email" onclick="sendEmail()">
<h3><script>document.write(subjectLine)</script></h3>
<p><script>document.write(emailMessageBody)</script></p>
</div>
<footer>
<h4>Made by Sarah Caulfield</h4>
<a href="https://www.linkedin.com/in/scaulfield7/">LinkedIn</a> |
<a href="https://github.com/scaulfield7">GitHub</a> |
<a href="https://ko-fi.com/scaulfield7">Ko-fi</a>
</footer>
</body>
</html>