This repository was archived by the owner on Mar 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathapp.js
More file actions
95 lines (85 loc) · 2.63 KB
/
Copy pathapp.js
File metadata and controls
95 lines (85 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
var $ = require('jquery');
var {Login} = require("graphenejs-lib");
var $result = $('.result').hide();
var $pwdlengthwarning = $("#pwdlengthwarning").hide();
var $pwdmismatchWarning = $("#pwdmismatchhwarning").hide();
var prefix = "STM";
import QRCode from 'qrcode';
let qrcodedraw = new QRCode.QRCodeDraw();
function verifyPasswordLength(w) {
if (w.length >= 16) {
$pwdlengthwarning.hide();
return true;
} else if (w.length > 0){
$pwdlengthwarning.show();
$result.hide();
return false;
}
}
window.$ = $;
function verifyPasswordMatch(password, passwordConfirm) {
if (password != passwordConfirm) {
$pwdmismatchWarning.show();
$result.hide();
return false;
} else {
$pwdmismatchWarning.hide();
return true;
}
}
function processKey(p, type) {
$('#' + type + '_key').text(p["pubKeys"][type]);
$('#' + type + '_pkey').text(p["privKeys"][type].toWif());
qrcodedraw.draw(document.getElementById(type + "_pub"), p["pubKeys"][type], function(error,canvas){
if(error){ return console.log('Error =( ', error); }
});
qrcodedraw.draw(document.getElementById(type + "_wif"), p["privKeys"][type].toWif(), function(error,canvas){
if(error){ return console.log('Error =( ', error); }
});
}
function processKeyPress() {
var name = $('input[name=name]').val();
var password = $('input[name=password]').val();
var passwordConfirm = $('input[name=passwordConfirm]').val();
$('#printplainpassword').text(password);
$('#printplainusername').text("account: " + name);
if (!verifyPasswordLength(password) || !name) {
return;
}
if (!verifyPasswordMatch(password, passwordConfirm)) {
return;
}
$result.hide();
var p = Login.generateKeys(name, password, ["owner", "active", "posting", "memo"], prefix);
processKey(p, "owner");
processKey(p, "active");
processKey(p, "posting");
processKey(p, "memo");
$result.show();
}
$('input[name=name]').keyup(processKeyPress);
$('input[name=password]').keyup(processKeyPress);
$('input[name=passwordConfirm]').keyup(processKeyPress);
$(".showpwdicon").click(function(){
if ($(this).prev().attr('type') == "text") {
$(this).prev().attr('type','password');
$(this).addClass('glyphicon-eye-open')
$(this).removeClass('glyphicon-eye-close')
} else {
$(this).prev().attr('type','text');
$(this).addClass('glyphicon-eye-close')
$(this).removeClass('glyphicon-eye-open')
}
});
$("#printBtn").click(function() {
$("#printpassword").hide();
$("#printpassword").removeClass("visible-print-block");
javascript:window.print();
return false;
});
$("#printWithPWdBtn").click(function() {
$("#printpassword").show();
$("#printpassword").addClass("visible-print-block");
window.print();
return false;
});