Skip to content
This repository has been archived by the owner on Mar 23, 2020. It is now read-only.

Commit

Permalink
Simplication of code and nicer layout/design
Browse files Browse the repository at this point in the history
  • Loading branch information
xeroc committed Jul 14, 2016
1 parent e434c5b commit 146f20a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 58 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
main.js*
node_modules
bundle.*
51 changes: 15 additions & 36 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import QRCode from 'qrcode';
let qrcodedraw = new QRCode.QRCodeDraw();

function verifyPasswordLength(w) {
console.log(w);
console.log(w.length);
if (w.length >= 16) {
$pwdlengthwarning.hide();
return true;
Expand All @@ -20,6 +18,17 @@ function verifyPasswordLength(w) {
}
}

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); }
});
}

$('input[name=password]').keypress(function() {
var name = $('input[name=name]').val();
var passwod = $('input[name=password]').val();
Expand All @@ -28,39 +37,9 @@ $('input[name=password]').keypress(function() {
}
$result.hide();
var p = Login.generateKeys(name, passwod, ["owner", "active", "posting", "memo"], prefix);
$('#owner_key').text(p["pubKeys"]["owner"]);
$('#active_key').text(p["pubKeys"]["active"]);
$('#posting_key').text(p["pubKeys"]["posting"]);
$('#memo_key').text(p["pubKeys"]["memo"]);
qrcodedraw.draw(document.getElementById("owner_pub"), p["pubKeys"]["owner"], function(error,canvas){
if(error){ return console.log('Error =( ', error); }
});
qrcodedraw.draw(document.getElementById("active_pub"), p["pubKeys"]["active"], function(error,canvas){
if(error){ return console.log('Error =( ', error); }
});
qrcodedraw.draw(document.getElementById("posting_pub"), p["pubKeys"]["posting"], function(error,canvas){
if(error){ return console.log('Error =( ', error); }
});
qrcodedraw.draw(document.getElementById("memo_pub"), p["pubKeys"]["memo"], function(error,canvas){
if(error){ return console.log('Error =( ', error); }
});

$('#owner_pkey').text(p["privKeys"]["owner"].toWif());
$('#active_pkey').text(p["privKeys"]["active"].toWif());
$('#posting_pkey').text(p["privKeys"]["posting"].toWif());
$('#memo_pkey').text(p["privKeys"]["memo"].toWif());
qrcodedraw.draw(document.getElementById("owner_wif"), p["privKeys"]["owner"].toWif(), function(error,canvas){
if(error){ return console.log('Error =( ', error); }
});
qrcodedraw.draw(document.getElementById("active_wif"), p["privKeys"]["active"].toWif(), function(error,canvas){
if(error){ return console.log('Error =( ', error); }
});
qrcodedraw.draw(document.getElementById("posting_wif"), p["privKeys"]["posting"].toWif(), function(error,canvas){
if(error){ return console.log('Error =( ', error); }
});
qrcodedraw.draw(document.getElementById("memo_wif"), p["privKeys"]["memo"].toWif(), function(error,canvas){
if(error){ return console.log('Error =( ', error); }
});

processKey(p, "owner")
processKey(p, "active")
processKey(p, "posting")
processKey(p, "memo")
$result.show();
});
52 changes: 30 additions & 22 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link href='https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css' rel='stylesheet'>
<style>
.key {
font-family: monospace;
border: 1px solid #999;
background: #eee;
padding:.2em;
}
.key {
font-family: monospace;
border: 1px solid #999;
background: #eee;
padding:.2em;
}
.pkey {
font-family: monospace;
border: 1px solid #999;
Expand All @@ -19,23 +19,31 @@
.headline {
background: #eee;
}

@media print {

}
</style>
</head>
<body>
<div class="container">
<div class="container-fluid">
<h2>Steem Permission Keys</h2>
<form>
<div class="form-group">
<label>Account Name</label>
<input class="form-control" type=text name="name" />
</div>
<div class="form-group">
<label>Password</label>
<input class="form-control" class="form-control" type=password name="password" />
</div>
</form>
<div class="hidden-print">
<form>
<div class="form-group">
<label><i class="fa fa-user"></i> Account Name</label>
<input class="form-control" type=text name="name" />
</div>
<div class="form-group">
<label><i class="fa fa-key"></i> Password</label>
<input class="form-control" class="form-control" type=password name="password" />
</div>
</form>
</div>
<span id="pwdlengthwarning" style="color:red;">Keep typing, your password is still too short</span>
<div class="result">
<div id="result">
<button class="btn btn-primary" onClick="window.print();"><i class="fa fa-print"></i> Print</button>
<small>The provided password will <b>NOT</b> be shown on the print</small>
<table class="table">
<thead>
<tr>
Expand All @@ -51,7 +59,7 @@ <h2>Steem Permission Keys</h2>
<tr>
<td><canvas id="owner_pub"></canvas></td>
<td><p><span id="owner_key" class="key"></span></p>
<p><span id="owner_pkey" class="pkey"></span></p>
<p><span id="owner_pkey" class="pkey"></span></p>
</td>
<td><canvas id="owner_wif"></canvas></td>
</tr>
Expand All @@ -61,7 +69,7 @@ <h2>Steem Permission Keys</h2>
<tr>
<td><canvas id="active_pub"></canvas></td>
<td><p><span id="active_key" class="key"></span></p>
<p><span id="active_pkey" class="pkey"></span></p>
<p><span id="active_pkey" class="pkey"></span></p>
</td>
<td><canvas id="active_wif"></canvas></td>
</tr>
Expand All @@ -71,7 +79,7 @@ <h2>Steem Permission Keys</h2>
<tr>
<td><canvas id="posting_pub"></canvas></td>
<td><p><span id="posting_key" class="key"></span></p>
<p><span id="posting_pkey" class="pkey"></span></p>
<p><span id="posting_pkey" class="pkey"></span></p>
</td>
<td><canvas id="posting_wif"></canvas></td>
</tr>
Expand All @@ -81,7 +89,7 @@ <h2>Steem Permission Keys</h2>
<tr>
<td><canvas id="memo_pub"></canvas></td>
<td><p><span id="memo_key" class="key"></span></p>
<p><span id="memo_pkey" class="pkey"></span></p>
<p><span id="memo_pkey" class="pkey"></span></p>
</td>
<td><canvas id="memo_wif"></canvas></td>
</tr>
Expand Down

0 comments on commit 146f20a

Please sign in to comment.