mirror of
https://github.com/Brandon-Rozek/website-theme.git
synced 2024-11-21 15:56:29 -05:00
Redid PGP form
This commit is contained in:
parent
5e60c49e0b
commit
064884cccb
2 changed files with 22 additions and 11 deletions
|
@ -433,3 +433,13 @@ main .e-content .toot-photos img {
|
||||||
#webmentions img { max-height: 1.2em; margin-right: -1ex; }
|
#webmentions img { max-height: 1.2em; margin-right: -1ex; }
|
||||||
|
|
||||||
.date-updated { margin-top: -18px; }
|
.date-updated { margin-top: -18px; }
|
||||||
|
|
||||||
|
.pgpform {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 10rem;
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pgpbutton {
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
|
@ -1,9 +1,14 @@
|
||||||
{{- $openPGP := resources.Get "js/openpgp.min.js" -}}
|
{{- $openPGP := resources.Get "js/openpgp.min.js" -}}
|
||||||
<script src="{{ $openPGP.Permalink }}"></script>
|
<script src="{{ $openPGP.Permalink }}"></script>
|
||||||
<textarea id="pgpform" style="width: 100%; min-height: 10rem;"></textarea>
|
<textarea id="pgpcleartext" class="pgpform" style="width: 100%; min-height: 10rem;"></textarea>
|
||||||
|
<button class="pgpbutton" onclick="encrypt()">Encrypt</button>
|
||||||
|
<br/>
|
||||||
|
Encrypted Result:
|
||||||
|
<pre id="pgpresult" class="pgpform"></pre>
|
||||||
<script>
|
<script>
|
||||||
function encrypt() {
|
function encrypt() {
|
||||||
let textarea = document.querySelector("#pgpform");
|
let textarea = document.querySelector("#pgpcleartext");
|
||||||
|
let resultarea = document.querySelector('#pgpresult');
|
||||||
let pubKeyURL = "{{ .Get 0 }}"
|
let pubKeyURL = "{{ .Get 0 }}"
|
||||||
fetch(pubKeyURL).then(function(response) {
|
fetch(pubKeyURL).then(function(response) {
|
||||||
return response.text().then(function(text) {
|
return response.text().then(function(text) {
|
||||||
|
@ -15,24 +20,20 @@ function encrypt() {
|
||||||
encryptionKeys: mp[1]
|
encryptionKeys: mp[1]
|
||||||
}
|
}
|
||||||
return openpgp.encrypt(encryptionParameters).then(function(encryptedMessage) {
|
return openpgp.encrypt(encryptionParameters).then(function(encryptedMessage) {
|
||||||
textarea.value = encryptedMessage
|
pgpresult.textContent = encryptedMessage
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function copyToClipboard() {
|
|
||||||
let textarea = document.querySelector("#pgpform");
|
|
||||||
textarea.select();
|
|
||||||
let successful = document.execCommand('copy');
|
|
||||||
}
|
|
||||||
function genEmail() {
|
function genEmail() {
|
||||||
let textarea = document.querySelector("#pgpform");
|
let resultarea = document.querySelector('#pgpresult');
|
||||||
let contents = textarea.value;
|
let contents = resultarea.textContent;
|
||||||
let encodedContents = encodeURIComponent(contents);
|
let encodedContents = encodeURIComponent(contents);
|
||||||
let encodedSubject = encodeURIComponent("Contact Form")
|
let encodedSubject = encodeURIComponent("Contact Form")
|
||||||
window.location.href = "mailto:{{ .Site.Params.email }}?subject=" +
|
window.location.href = "mailto:{{ .Site.Params.email }}?subject=" +
|
||||||
encodedSubject + "&body=" + encodedContents;
|
encodedSubject + "&body=" + encodedContents;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<button onclick="encrypt()">Encrypt</button><button onclick="copyToClipboard()">Copy</button><button onclick="genEmail()">Generate Email</button>
|
<button class="pgpbutton" onclick="genEmail()">Generate Email</button>
|
||||||
|
|
Loading…
Reference in a new issue