Skip to content

Commit 779516f

Browse files
committed
add actual mailto-generator
1 parent d453f69 commit 779516f

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php get_header(); ?>
2+
3+
<div id="site-container">
4+
<main>
5+
<?php if (have_posts()): ?>
6+
<?php while (have_posts()): the_post(); ?>
7+
<?php get_template_part('partials/content', 'title'); ?>
8+
9+
<div id="mailtogenerator" class="container-fluid xml-stripper">
10+
<div class="columns is-gapless">
11+
12+
<div class="column">
13+
<div class="px-4 py-4">
14+
<p class="has-text-grey is-uppercase is-size-7">Input</p>
15+
16+
<?= fractalFormText(array(
17+
'label' => array( 'string' => 'Mail', 'required' => true),
18+
'name' => 'mail',
19+
'placeholder' => '[email protected]'
20+
)) ?>
21+
</div>
22+
</div> <!-- // column -->
23+
24+
<div class="column has-background-light">
25+
<div class="px-4 py-4">
26+
<p class="has-text-grey is-uppercase is-size-7">Output</p>
27+
<textarea class="textarea is-family-code" name="" id="output" cols="30" rows="10" readonly=""></textarea>
28+
</div>
29+
</div>
30+
31+
</div> <!-- // columns -->
32+
</div> <!-- application -->
33+
34+
<script>
35+
const input = document.getElementById('mail')
36+
const output = document.getElementById('output')
37+
38+
input.addEventListener('input', function() {
39+
const addressInput = input.value;
40+
let addressOutput = ''
41+
42+
for (let character of addressInput) {
43+
addressOutput += character.charCodeAt() + ';'
44+
}
45+
addressOutput = addressOutput.slice(0, -1);
46+
47+
output.value = `\<script\>
48+
function UnCryptMailto(s) {
49+
var myS = ''; var arrS = s.split(';'); var i = 0;
50+
for (i = 0; i < arrS.length; i++) {
51+
myS += String.fromCharCode(parseInt(arrS[i]));
52+
}
53+
return myS;
54+
}
55+
document.write('<a href="mailto:' + UnCryptMailto('${addressOutput}') + '">' + UnCryptMailto('${addressOutput}') + '</a>')
56+
\<\/script\>`
57+
});
58+
</script>
59+
60+
<?php endwhile; ?>
61+
<?php endif; ?>
62+
</main>
63+
64+
<?php get_footer(); ?>

0 commit comments

Comments
 (0)