aboutsummaryrefslogtreecommitdiffhomepage
path: root/public/scripts/input_pin.js
diff options
context:
space:
mode:
authorMarvin Borner2019-02-13 17:14:47 +0100
committerMarvin Borner2019-02-13 17:14:47 +0100
commit6a967887df29c0051a22df96463aed63b7ece729 (patch)
tree15b91fccb40990ebc2e0c822b843582e672f0465 /public/scripts/input_pin.js
parent8cad9c810741088a1874b58e80245ce83909b582 (diff)
Code cleanup
Diffstat (limited to 'public/scripts/input_pin.js')
-rw-r--r--public/scripts/input_pin.js74
1 files changed, 50 insertions, 24 deletions
diff --git a/public/scripts/input_pin.js b/public/scripts/input_pin.js
index c28d6e9..69b068b 100644
--- a/public/scripts/input_pin.js
+++ b/public/scripts/input_pin.js
@@ -6,6 +6,7 @@
*/
const $ = require('jquery');
+
let pin = [];
/**
@@ -13,31 +14,50 @@ let pin = [];
* @param callback
*/
function init(callback) {
- let tryCount = 0;
+ let tryCount = 0;
- $('#1').focus().on('input', (el) => {
- pin.push($(el.target).val());
- $(el.target).val('*');
- $('#' + (parseInt($(el.target).attr('id')) + 1).toString()).focus();
+ $('#1')
+ .focus()
+ .on('input', (el) => {
+ pin.push($(el.target)
+ .val());
+ $(el.target)
+ .val('*');
+ $(`#${(parseInt($(el.target)
+ .attr('id')) + 1).toString()}`)
+ .focus();
});
- $('#2').on('input', (el) => {
- pin.push($(el.target).val());
- $(el.target).val('*');
- $('#' + (parseInt($(el.target).attr('id')) + 1).toString()).focus();
+ $('#2')
+ .on('input', (el) => {
+ pin.push($(el.target)
+ .val());
+ $(el.target)
+ .val('*');
+ $(`#${(parseInt($(el.target)
+ .attr('id')) + 1).toString()}`)
+ .focus();
});
- $('#3').on('input', (el) => {
- pin.push($(el.target).val());
- $(el.target).val('*');
- $('#' + (parseInt($(el.target).attr('id')) + 1).toString()).focus();
+ $('#3')
+ .on('input', (el) => {
+ pin.push($(el.target)
+ .val());
+ $(el.target)
+ .val('*');
+ $(`#${(parseInt($(el.target)
+ .attr('id')) + 1).toString()}`)
+ .focus();
});
- $('#4').on('input', (el) => {
- pin.push($(el.target).val());
- $(el.target).val('*');
- tryCount++;
- callback(pin.join(''), tryCount)
+ $('#4')
+ .on('input', (el) => {
+ pin.push($(el.target)
+ .val());
+ $(el.target)
+ .val('*');
+ tryCount++;
+ callback(pin.join(''), tryCount);
});
}
@@ -45,18 +65,24 @@ function init(callback) {
* Displays error message and clears input
*/
function isWrong(message) {
- $('#pin_message').text(message);
- for (let i = 1; i < 5; i++) $(`#${i}`).val('');
- $('#1').focus();
- pin = [];
+ $('#pin_message')
+ .text(message);
+ for (let i = 1; i < 5; i++) {
+ $(`#${i}`)
+ .val('');
+ }
+ $('#1')
+ .focus();
+ pin = [];
}
/**
* Display generation message
*/
function needsGeneration() {
- // TODO: Add loading animation
- $('#pin_message').text('Generating keys...');
+ // TODO: Add loading animation
+ $('#pin_message')
+ .text('Generating keys...');
}
exports.init = init;