Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cardwallet #256

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added business_cards/bitcoin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 54 additions & 42 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9456,6 +9456,7 @@
#coinLogoImg { width: 100%; height: 100%; }

.coinIcoin { width: 64px; height: 64px; padding: 10px; position: absolute; top: 272px; left: 48px; }
.cardCoinIcoin { width: 61px; height: 61px; padding: 10px; position: absolute; top: 43px; right: 8px; }
#coinImg { width: 100%; height: 100%; }

#main { position: relative; text-align: center; margin: 0px auto; width: 1005px; }
Expand Down Expand Up @@ -9509,6 +9510,30 @@
#suppliedPrivateKey { width: 420px; }
#papergenerate { margin-left: 10px; margin-right: 0px;}

#cardarea .artcard { position: relative; width: 332px; height: 209px; display: inline-block; }

#cardarea .artcard .cardsvg { width: 332px; height: 209px; }

#cardarea .artcard .card_qrcode_public { top: 28px; left: 34px; z-index: 100; margin: 0; float: none; display: block; position: absolute; background-color: #FFFFFF;
padding: 5px 5px 2px 5px; }

#cardarea .artcard .card_btcaddress
{
position: absolute; bottom: 110px; left: 122px; z-index: 100; font-size: 14px; background-color: transparent;
font-weight: 100; color: #000000; margin: 0; width: 108px; height: 32px; text-align: center;
word-wrap: break-word; font-family: Courier, monospace;
-ms-transform: rotate(-90deg); /* IE 9 */
-webkit-transform: rotate(-90deg); /* Chrome, Safari, Opera */
transform: rotate(-90deg);
}

#cardarea .artcard .card_custom_text
{
position: absolute; bottom: 10px; left: 18px; z-index: 100; font-size: 14px; background-color: transparent;
font-weight: 100; color: white; margin: 0; width: 294px; height: 34px; text-align: left;
word-wrap: break-word;
}

.displayNone { displa: none; }
.redColor { color: red; }
.1percentwidth { width: 1%; }
Expand Down Expand Up @@ -9885,9 +9910,12 @@ <h3 class="faqQuestion"><a class="faqLink" onclick="ninja.toggleFaqQuestion('faq
<div id="cardarea" class="walletarea">
<div class="commands">
<div id="papercommands" class="row">
<input placeholder="Enter your public address" id="suppliedPublicAddress" name="suppliedPublicAddress" spellcheck="false" />&nbsp;
<span><label id="cardFillInfo" for="suppliedPublicAddress" class="i18n">Enter your public address:</label>
<input placeholder="Public address" id="suppliedPublicAddress" name="suppliedPublicAddress" spellcheck="false" />&nbsp;
<label id="cardCustomText" for="suppliedCustomText" class="i18n">Insert text you want to see on cards:</label>
<input placeholder="Custom text" id="suppliedCustomText" name="suppliedCustomText" spellcheck="false" />&nbsp;
<input type="button" id="cardgenerate" value="Apply &raquo;" onClick="ninja.wallets.cardwallet.generate();" />
</span>

<span class="print"><input type="button" name="print" value="Print" id="cardprint" onclick="window.print();" /></span>
</div>
Expand Down Expand Up @@ -11390,57 +11418,41 @@ <h3>Release notes</h3>

// Verify that a self-entered key is valid, and compute the corresponding
// public address, render the wallet.
testAndApplyVanityKey: function () {
var suppliedKey = document.getElementById('suppliedPrivateKey').value;
generate: function () {
var suppliedKey = document.getElementById('suppliedPublicAddress').value;
suppliedKey = suppliedKey.trim(); // in case any spaces or whitespace got pasted in
document.getElementById('suppliedPrivateKey').value = suppliedKey;
if (!ninja.privateKey.isPrivateKey(suppliedKey)) {
alert(ninja.translator.get("detailalertnotvalidprivatekey"));
} else {
var computedPublicAddress = new Bitcoin.ECKey(suppliedKey).getBitcoinAddress();
if (ninja.wallets.paperwallet.encrypt) {
document.getElementById("busyblock").className = "busy";
ninja.privateKey.BIP38PrivateKeyToEncryptedKeyAsync(suppliedKey,
document.getElementById('paperpassphrase').value, false, function(encodedKey) {
document.getElementById("busyblock").className = "";
ninja.wallets.paperwallet.showArtisticWallet(1, computedPublicAddress, encodedKey);
});
}
else {
ninja.wallets.paperwallet.showArtisticWallet(1, computedPublicAddress, suppliedKey);
}
document.getElementById('suppliedPublicAddress').value = suppliedKey;

var suppliedCustomText = document.getElementById('suppliedCustomText').value;
document.getElementById('cardkeyarea').innerHTML = "";

var keyValuePair = {};

var i = 0;
for(i=0;i<9;i++)
{
document.getElementById('cardkeyarea').innerHTML += ninja.wallets.cardwallet.templateArtisticHtml(i, suppliedCustomText);
document.getElementById("card_btcaddress" + i).innerHTML = suppliedKey;
keyValuePair["card_qrcode_public" + i] = suppliedKey;
}

ninja.qrCode.showQrCode(keyValuePair, 3.2);
},

templateArtisticHtml: function (i) {
var keyelement = 'btcprivwif';
templateArtisticHtml: function (i, customText) {
var keyelement = 'card_btcprivwif';
var coinImgUrl = "logos/" + janin.selectedCurrency.name.toLowerCase() + ".png";
var walletBackgroundUrl = "wallets/" + janin.selectedCurrency.name.toLowerCase() + ".png";
var walletBackgroundUrl = "business_cards/" + janin.selectedCurrency.name.toLowerCase() + ".png";

var walletHtml =
"<div class='coinIcoin'> <img id='coinImg' src='" + coinImgUrl + "' alt='currency_logo' /></div><div class='artwallet' id='artwallet" + i + "'>" +
"<img id='papersvg" + i + "' class='papersvg' src='" + walletBackgroundUrl + "' />" +
"<div id='qrcode_public" + i + "' class='qrcode_public'></div>" +
"<div id='qrcode_private" + i + "' class='qrcode_private'></div>" +
"<div class='btcaddress' id='btcaddress" + i + "'></div>" +
"<div class='" + keyelement + "' id='" + keyelement + i + "'></div>" +
"<div class='paperWalletText'><img class='backLogo' src='" + coinImgUrl + "' alt='currency_logo' />" + ninja.translator.get("paperwalletback") + "</div>" +
"<div class='artcard' id='artcard" + i + "'><div class='cardCoinIcoin'> <img id='coinImg' src='" + coinImgUrl + "' alt='currency_logo' /></div>" +
"<img id='cardsvg" + i + "' class='cardsvg' src='" + walletBackgroundUrl + "' />" +
"<div id='card_qrcode_public" + i + "' class='card_qrcode_public'></div>" +
"<div class='card_btcaddress' id='card_btcaddress" + i + "'></div>" +
"<div class='card_custom_text' id='card_custom_text" + i + "'><span>" + customText + "</span></div>" +
"</div>";
return walletHtml;
},

showArtisticWallet: function (idPostFix, bitcoinAddress, privateKey) {
var keyValuePair = {};
keyValuePair["qrcode_public" + idPostFix] = bitcoinAddress;
ninja.qrCode.showQrCode(keyValuePair, 3.5);

var keyValuePair = {};
keyValuePair["qrcode_private" + idPostFix] = privateKey;
ninja.qrCode.showQrCode(keyValuePair, 2.8);

document.getElementById("btcaddress" + idPostFix).innerHTML = bitcoinAddress;
document.getElementById("btcprivwif" + idPostFix).innerHTML = privateKey;
},
};

</script>
Expand Down
5 changes: 4 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,12 @@ <h3 class="faqQuestion"><a class="faqLink" onclick="ninja.toggleFaqQuestion('faq
<div id="cardarea" class="walletarea">
<div class="commands">
<div id="papercommands" class="row">
<input placeholder="Enter your public address" id="suppliedPublicAddress" name="suppliedPublicAddress" spellcheck="false" />&nbsp;
<span><label id="cardFillInfo" for="suppliedPublicAddress" class="i18n">Enter your public address:</label>
<input placeholder="Public address" id="suppliedPublicAddress" name="suppliedPublicAddress" spellcheck="false" />&nbsp;
<label id="cardCustomText" for="suppliedCustomText" class="i18n">Insert text you want to see on cards:</label>
<input placeholder="Custom text" id="suppliedCustomText" name="suppliedCustomText" spellcheck="false" />&nbsp;
<input type="button" id="cardgenerate" value="Apply &raquo;" onClick="ninja.wallets.cardwallet.generate();" />
</span>

<span class="print"><input type="button" name="print" value="Print" id="cardprint" onclick="window.print();" /></span>
</div>
Expand Down
25 changes: 25 additions & 0 deletions src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ h1 { margin: 0px; height: 91px; }
#coinLogoImg { width: 100%; height: 100%; }

.coinIcoin { width: 64px; height: 64px; padding: 10px; position: absolute; top: 272px; left: 48px; }
.cardCoinIcoin { width: 61px; height: 61px; padding: 10px; position: absolute; top: 43px; right: 8px; }
#coinImg { width: 100%; height: 100%; }

#main { position: relative; text-align: center; margin: 0px auto; width: 1005px; }
Expand Down Expand Up @@ -204,6 +205,30 @@ h1 { margin: 0px; height: 91px; }
#suppliedPrivateKey { width: 420px; }
#papergenerate { margin-left: 10px; margin-right: 0px;}

#cardarea .artcard { position: relative; width: 332px; height: 209px; display: inline-block; }

#cardarea .artcard .cardsvg { width: 332px; height: 209px; }

#cardarea .artcard .card_qrcode_public { top: 28px; left: 34px; z-index: 100; margin: 0; float: none; display: block; position: absolute; background-color: #FFFFFF;
padding: 5px 5px 2px 5px; }

#cardarea .artcard .card_btcaddress
{
position: absolute; bottom: 110px; left: 122px; z-index: 100; font-size: 14px; background-color: transparent;
font-weight: 100; color: #000000; margin: 0; width: 108px; height: 32px; text-align: center;
word-wrap: break-word; font-family: Courier, monospace;
-ms-transform: rotate(-90deg); /* IE 9 */
-webkit-transform: rotate(-90deg); /* Chrome, Safari, Opera */
transform: rotate(-90deg);
}

#cardarea .artcard .card_custom_text
{
position: absolute; bottom: 10px; left: 18px; z-index: 100; font-size: 14px; background-color: transparent;
font-weight: 100; color: white; margin: 0; width: 294px; height: 34px; text-align: left;
word-wrap: break-word;
}

.displayNone { displa: none; }
.redColor { color: red; }
.1percentwidth { width: 1%; }
Expand Down
66 changes: 25 additions & 41 deletions src/ninja.cardwallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,39 @@ ninja.wallets.cardwallet = {

// Verify that a self-entered key is valid, and compute the corresponding
// public address, render the wallet.
testAndApplyVanityKey: function () {
var suppliedKey = document.getElementById('suppliedPrivateKey').value;
generate: function () {
var suppliedKey = document.getElementById('suppliedPublicAddress').value;
suppliedKey = suppliedKey.trim(); // in case any spaces or whitespace got pasted in
document.getElementById('suppliedPrivateKey').value = suppliedKey;
if (!ninja.privateKey.isPrivateKey(suppliedKey)) {
alert(ninja.translator.get("detailalertnotvalidprivatekey"));
} else {
var computedPublicAddress = new Bitcoin.ECKey(suppliedKey).getBitcoinAddress();
if (ninja.wallets.paperwallet.encrypt) {
document.getElementById("busyblock").className = "busy";
ninja.privateKey.BIP38PrivateKeyToEncryptedKeyAsync(suppliedKey,
document.getElementById('paperpassphrase').value, false, function(encodedKey) {
document.getElementById("busyblock").className = "";
ninja.wallets.paperwallet.showArtisticWallet(1, computedPublicAddress, encodedKey);
});
}
else {
ninja.wallets.paperwallet.showArtisticWallet(1, computedPublicAddress, suppliedKey);
}
document.getElementById('suppliedPublicAddress').value = suppliedKey;

var suppliedCustomText = document.getElementById('suppliedCustomText').value;
document.getElementById('cardkeyarea').innerHTML = "";

var keyValuePair = {};

var i = 0;
for(i=0;i<9;i++)
{
document.getElementById('cardkeyarea').innerHTML += ninja.wallets.cardwallet.templateArtisticHtml(i, suppliedCustomText);
document.getElementById("card_btcaddress" + i).innerHTML = suppliedKey;
keyValuePair["card_qrcode_public" + i] = suppliedKey;
}

ninja.qrCode.showQrCode(keyValuePair, 3.2);
},

templateArtisticHtml: function (i) {
var keyelement = 'btcprivwif';
templateArtisticHtml: function (i, customText) {
var keyelement = 'card_btcprivwif';
var coinImgUrl = "logos/" + janin.selectedCurrency.name.toLowerCase() + ".png";
var walletBackgroundUrl = "wallets/" + janin.selectedCurrency.name.toLowerCase() + ".png";
var walletBackgroundUrl = "business_cards/" + janin.selectedCurrency.name.toLowerCase() + ".png";

var walletHtml =
"<div class='coinIcoin'> <img id='coinImg' src='" + coinImgUrl + "' alt='currency_logo' /></div><div class='artwallet' id='artwallet" + i + "'>" +
"<img id='papersvg" + i + "' class='papersvg' src='" + walletBackgroundUrl + "' />" +
"<div id='qrcode_public" + i + "' class='qrcode_public'></div>" +
"<div id='qrcode_private" + i + "' class='qrcode_private'></div>" +
"<div class='btcaddress' id='btcaddress" + i + "'></div>" +
"<div class='" + keyelement + "' id='" + keyelement + i + "'></div>" +
"<div class='paperWalletText'><img class='backLogo' src='" + coinImgUrl + "' alt='currency_logo' />" + ninja.translator.get("paperwalletback") + "</div>" +
"<div class='artcard' id='artcard" + i + "'><div class='cardCoinIcoin'> <img id='coinImg' src='" + coinImgUrl + "' alt='currency_logo' /></div>" +
"<img id='cardsvg" + i + "' class='cardsvg' src='" + walletBackgroundUrl + "' />" +
"<div id='card_qrcode_public" + i + "' class='card_qrcode_public'></div>" +
"<div class='card_btcaddress' id='card_btcaddress" + i + "'></div>" +
"<div class='card_custom_text' id='card_custom_text" + i + "'><span>" + customText + "</span></div>" +
"</div>";
return walletHtml;
},

showArtisticWallet: function (idPostFix, bitcoinAddress, privateKey) {
var keyValuePair = {};
keyValuePair["qrcode_public" + idPostFix] = bitcoinAddress;
ninja.qrCode.showQrCode(keyValuePair, 3.5);

var keyValuePair = {};
keyValuePair["qrcode_private" + idPostFix] = privateKey;
ninja.qrCode.showQrCode(keyValuePair, 2.8);

document.getElementById("btcaddress" + idPostFix).innerHTML = bitcoinAddress;
document.getElementById("btcprivwif" + idPostFix).innerHTML = privateKey;
},
};