Ind.ie is now Small Technology Foundation.
Commit 5f226e62 authored by Aral Balkan's avatar Aral Balkan

Add progress indication

parent 311cd111
......@@ -22,6 +22,7 @@ function to_hex(input) {
// HTML elements.
const passphraseForm = document.getElementById('passphraseForm')
const indeterminateProgressIndicator = document.getElementById('indeterminateProgressIndicator')
const publicSigningKeyTextField = document.getElementById('publicSigningKey')
const privateSigningKeyTextArea = document.getElementById('privateSigningKey')
const publicEncryptionKeyTextField = document.getElementById('publicEncryptionKey')
......@@ -33,11 +34,32 @@ function generatePassphrase () {
generateKeys()
}
function showProgressIndicator() {
indeterminateProgressIndicator.style.opacity = 100
}
function hideProgressIndicator() {
indeterminateProgressIndicator.style.opacity = 0
}
function clearOutputForm() {
publicSigningKeyTextField.value = ''
privateSigningKeyTextArea.value = ''
publicEncryptionKeyTextField.value = ''
privateEncryptionKeyTextField.value = ''
}
function generateKeys() {
const passphrase = passphraseForm.elements.passphrase.value
const domain = passphraseForm.elements.domain.value
clearOutputForm()
showProgressIndicator()
session25519(domain, passphrase, (error, keys) => {
hideProgressIndicator()
if (error) { alert(error); return }
publicSigningKeyTextField.value = to_hex(keys.publicSignKey)
......@@ -50,6 +72,9 @@ function generateKeys() {
// Main
document.addEventListener('DOMContentLoaded', () => {
// Hide the progress indicator
indeterminateProgressIndicator.style.opacity = 0
// Generate a passphrase at start
generatePassphrase()
......
......@@ -22,6 +22,15 @@
</fieldset>
</form>
<!-- Courtesy: http://tobiasahlin.com/spinkit/ -->
<div id='indeterminateProgressIndicator' class="spinner">
<div class="rect1"></div>
<div class="rect2"></div>
<div class="rect3"></div>
<div class="rect4"></div>
<div class="rect5"></div>
</div>
<form id='outputForm'>
<label for='publicSigningKey'>Public signing key:</label>
<input type='text' id='publicSigningKey'>
......
......@@ -44,3 +44,56 @@ input, textarea {
color: black;
}
/* Spinkit CSS indeterminate progress indicator */
/* http://tobiasahlin.com/spinkit/ */
.spinner {
height: 40px;
text-align: center;
font-size: 10px;
}
.spinner > div {
background-color: #333;
height: 100%;
width: 6px;
display: inline-block;
-webkit-animation: sk-stretchdelay 1.2s infinite ease-in-out;
animation: sk-stretchdelay 1.2s infinite ease-in-out;
}
.spinner .rect2 {
-webkit-animation-delay: -1.1s;
animation-delay: -1.1s;
}
.spinner .rect3 {
-webkit-animation-delay: -1.0s;
animation-delay: -1.0s;
}
.spinner .rect4 {
-webkit-animation-delay: -0.9s;
animation-delay: -0.9s;
}
.spinner .rect5 {
-webkit-animation-delay: -0.8s;
animation-delay: -0.8s;
}
@-webkit-keyframes sk-stretchdelay {
0%, 40%, 100% { -webkit-transform: scaleY(0.4) }
20% { -webkit-transform: scaleY(1.0) }
}
@keyframes sk-stretchdelay {
0%, 40%, 100% {
transform: scaleY(0.4);
-webkit-transform: scaleY(0.4);
} 20% {
transform: scaleY(1.0);
-webkit-transform: scaleY(1.0);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment