From 7762ceaa7e2bb34f8758e17a4c8f512fa6a81b9e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 15 Jan 2017 18:24:09 -0800 Subject: Initial Vueification --- static/js/register.js | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 static/js/register.js (limited to 'static/js/register.js') diff --git a/static/js/register.js b/static/js/register.js new file mode 100644 index 00000000..6e623ae4 --- /dev/null +++ b/static/js/register.js @@ -0,0 +1,60 @@ +(function() { + var g; + + g = this; + + $(function() { + $('#username').focus(); + $('#username').blur(function() { + $(this).parent().next('.alert').remove(); + if (/^[a-z]+$/.test($(this).val())) { + return $(this).parent().removeClass('has-error'); + } else { + $(this).parent().addClass('has-error'); + return $(this).parent().after('
Username must be lowercase
'); + } + }); + $('#password').blur(function() { + $('#confirm').blur(); + return $(this).parent().next('.alert').remove(); + }); + $('#confirm').blur(function() { + if ($(this).val() === '') { + return; + } + $(this).parent().next('.alert').remove(); + if ($('#password').val() === $('#confirm').val()) { + return $('#confirm').parent().removeClass('has-error'); + } else { + $('#confirm').parent().addClass('has-error'); + return $('#confirm').parent().after('
Passwords don\'t match
'); + } + }); + $('#email').blur(function() { + if ($(this).val() === '') { + return; + } + $(this).parent().next('.alert').remove(); + if (validateEmail($(this).val())) { + return $(this).parent().removeClass('has-error'); + } else { + $(this).parent().addClass('has-error'); + return $(this).parent().after('
Invalid email
'); + } + }); + return $('#register').submit(function() { + var key, mnemonic; + $('.form-control').blur(); + if ($('.has-error').length > 0) { + $('.has-error').effect('shake', 500); + return false; + } else { + mnemonic = bip39.generateMnemonic(); + key = bitcoin.HDNode.fromSeedBuffer(bip39.mnemonicToSeed(mnemonic)).deriveHardened(44).deriveHardened(0); + $('#pubkey').val(key.neutered().toString()); + return $('#privkey').val(CryptoJS.AES.encrypt(key.toString(), $('#password').val()).toString()); + } + }); + }); + +}).call(this); -- cgit v1.2.3