Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Commit

Permalink
url fixed, added autofill and added qr to offline tx
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Apr 18, 2016
1 parent 67fc930 commit 0d579f5
Show file tree
Hide file tree
Showing 12 changed files with 377 additions and 81 deletions.
7 changes: 7 additions & 0 deletions app/scripts/controllers/offlineTxCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';
var offlineTxCtrl = function($scope, $sce, walletService) {
//new Modal(document.getElementById('sendTransaction'));
walletService.wallet = null;
walletService.password = '';
};
module.exports = offlineTxCtrl;
8 changes: 4 additions & 4 deletions app/scripts/controllers/sendTxCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ var sendTxCtrl = function($scope, $sce, walletService) {
$scope.showAdvance = false;
$scope.showRaw = false;
$scope.tx = {
gasLimit: globalFuncs.defaultTxGasLimit,
data: "",
to: "",
gasLimit: globalFuncs.urlGet('gaslimit') == null ? globalFuncs.defaultTxGasLimit : globalFuncs.urlGet('gaslimit'),
data: globalFuncs.urlGet('data') == null ? "" : globalFuncs.urlGet('data'),
to: globalFuncs.urlGet('to') == null ? "" : globalFuncs.urlGet('to'),
unit: "ether",
value: '',
value: globalFuncs.urlGet('value') == null ? "" : globalFuncs.urlGet('value'),
nonce: null,
gasPrice: null,
donate: false
Expand Down
18 changes: 17 additions & 1 deletion app/scripts/controllers/tabsCtrl.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
'use strict';
var tabsCtrl = function($scope, globalService) {
$scope.tabNames = globalService.tabs;
$scope.activeTab = globalService.currentTab;
var hval = window.location.hash;
if(hval!=""){
hval = hval.replace("#",'');
for (var key in $scope.tabNames) {
if($scope.tabNames[key].url == hval){
$scope.activeTab = globalService.currentTab = $scope.tabNames[key].id;
break;
}
$scope.activeTab = globalService.currentTab;
}
} else {
$scope.activeTab = globalService.currentTab;
}
$scope.tabClick = function(id) {
$scope.activeTab = globalService.currentTab = id;
for (var key in $scope.tabNames) {
if($scope.tabNames[key].id == id)
location.hash = $scope.tabNames[key].url;
}
}
};
module.exports = tabsCtrl;
14 changes: 12 additions & 2 deletions app/scripts/globalFuncs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ globalFuncs.getBlockie = function(address) {
}).toDataURL();
}
globalFuncs.printPaperWallets = function(strJson) {
console.log(strJson);
var win = window.open("about:blank", "_blank");
var data = "<html><head><link rel=\"stylesheet\" href=\"css\/etherwallet-master.min.css\"\/><script type=\"text\/javascript\" src=\"js\/jquery-1.11.3.min.js\"><\/script><script type=\"text\/javascript\" src=\"js\/etherwallet-static.min.js\"><\/script><script type=\"text\/javascript\">function generateWallets(){ var json = JSON.parse($(\"#printwalletjson\").html()); for(var i=0;i<json.length;i++){ var walletTemplate = $(\'<div\/>\').append($(\"#print-container\").clone()); new QRCode($(walletTemplate).find(\"#paperwalletaddqr\")[0], {\t\t text: json[i][\'address\'],\t\t colorDark: \"#000000\",\t\t colorLight: \"#ffffff\",\t\tcorrectLevel: QRCode.CorrectLevel.H\t }); new QRCode($(walletTemplate).find(\"#paperwalletprivqr\")[0], {\t\t text: json[i][\'private\'],\t\t colorDark: \"#000000\",\t\t colorLight: \"#ffffff\",\t\tcorrectLevel: QRCode.CorrectLevel.H\t }); $(walletTemplate).find(\"#paperwalletadd\").html(json[i][\'address\']); $(walletTemplate).find(\"#paperwalletpriv\").html(json[i][\'private\']); walletTemplate = $(walletTemplate).find(\"#print-container\").show(); $(\"body\").append(walletTemplate); } setTimeout(function(){window.print();},2000);}<\/script><\/head><body><span id=\"printwalletjson\" style=\"display: none;\">{{WALLETJSON}}<\/span><div class=\"print-container\" style=\"display: none; margin-bottom: 28px;\" id=\"print-container\"> <img src=\"images\/logo-1.png\" class=\"ether-logo-1\" height=\"100%\" width=\"auto\"\/> <img src=\"images\/logo-2.png\" class=\"ether-logo-2\"\/> <img src=\"images\/ether-title.png\" height=\"100%\" width=\"auto\" class=\"print-title\"\/> <div class=\"print-qr-code-1\"> <div id=\"paperwalletaddqr\"><\/div> <p class=\"print-text\" style=\"padding-top: 25px;\">YOUR ADDRESS<\/p> <\/div> <div class=\"print-qr-code-2\"> <div id=\"paperwalletprivqr\"><\/div> <p class=\"print-text\" style=\"padding-top: 30px;\">YOUR PRIVATE KEY<\/p> <\/div> <div class=\"print-notes\"> <img src=\"images\/notes-bg.png\" width=\"90%;\" height=\"auto\" class=\"pull-left\" \/> <p class=\"print-text\">AMOUNT \/ NOTES<\/p> <\/div> <div class=\"print-address-container\"> <p> <strong>Your Address:<\/strong><br \/> <span id=\"paperwalletadd\"><\/span> <\/p> <p> <strong>Your Private Key:<\/strong><br \/> <span id=\"paperwalletpriv\"><\/span> <\/p> <\/div><\/div><\/body><\/html>";
var data = "<html><head><link rel=\"stylesheet\" href=\"css\/etherwallet-master.min.css\"\/><script type=\"text\/javascript\" src=\"js\/jquery-1.12.3.min.js\"><\/script><script type=\"text\/javascript\" src=\"js\/etherwallet-static.min.js\"><\/script><script type=\"text\/javascript\">function generateWallets(){ var json = JSON.parse($(\"#printwalletjson\").html()); for(var i=0;i<json.length;i++){ var walletTemplate = $(\'<div\/>\').append($(\"#print-container\").clone()); new QRCode($(walletTemplate).find(\"#paperwalletaddqr\")[0], {\t\t text: json[i][\'address\'],\t\t colorDark: \"#000000\",\t\t colorLight: \"#ffffff\",\t\tcorrectLevel: QRCode.CorrectLevel.H\t }); new QRCode($(walletTemplate).find(\"#paperwalletprivqr\")[0], {\t\t text: json[i][\'private\'],\t\t colorDark: \"#000000\",\t\t colorLight: \"#ffffff\",\t\tcorrectLevel: QRCode.CorrectLevel.H\t }); $(walletTemplate).find(\"#paperwalletadd\").html(json[i][\'address\']); $(walletTemplate).find(\"#paperwalletpriv\").html(json[i][\'private\']); walletTemplate = $(walletTemplate).find(\"#print-container\").show(); $(\"body\").append(walletTemplate); } setTimeout(function(){window.print();},2000);}<\/script><\/head><body><span id=\"printwalletjson\" style=\"display: none;\">{{WALLETJSON}}<\/span><div class=\"print-container\" style=\"display: none; margin-bottom: 28px;\" id=\"print-container\"> <img src=\"images\/logo-1.png\" class=\"ether-logo-1\" height=\"100%\" width=\"auto\"\/> <img src=\"images\/logo-2.png\" class=\"ether-logo-2\"\/> <img src=\"images\/ether-title.png\" height=\"100%\" width=\"auto\" class=\"print-title\"\/> <div class=\"print-qr-code-1\"> <div id=\"paperwalletaddqr\"><\/div> <p class=\"print-text\" style=\"padding-top: 25px;\">YOUR ADDRESS<\/p> <\/div> <div class=\"print-qr-code-2\"> <div id=\"paperwalletprivqr\"><\/div> <p class=\"print-text\" style=\"padding-top: 30px;\">YOUR PRIVATE KEY<\/p> <\/div> <div class=\"print-notes\"> <img src=\"images\/notes-bg.png\" width=\"90%;\" height=\"auto\" class=\"pull-left\" \/> <p class=\"print-text\">AMOUNT \/ NOTES<\/p> <\/div> <div class=\"print-address-container\"> <p> <strong>Your Address:<\/strong><br \/> <span id=\"paperwalletadd\"><\/span> <\/p> <p> <strong>Your Private Key:<\/strong><br \/> <span id=\"paperwalletpriv\"><\/span> <\/p> <\/div><\/div><\/body><\/html>";
data = data.replace("{{WALLETJSON}}", strJson);
win.document.write(data);
win.document.write("<script>generateWallets();</script>");
Expand Down Expand Up @@ -54,4 +53,15 @@ globalFuncs.donateAddress = "0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8";
globalFuncs.isNumeric = function(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
globalFuncs.urlGet = function (name){
if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
return this.stripTags(decodeURIComponent(name[1]));
}
globalFuncs.stripTags = function(str){
var SCRIPT_REGEX = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;
while (SCRIPT_REGEX.test(str)) {
str = str.replace(SCRIPT_REGEX, "");
}
return str;
}
module.exports = globalFuncs;
21 changes: 14 additions & 7 deletions app/scripts/services/globalService.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,38 @@ var globalService = function($http, $httpParamSerializerJQLike) {
var tabs = {
generateWallet: {
id: 0,
name: "Generate Wallet"
name: "Generate Wallet",
url: "generate-wallet"
},
bulkGenerate: {
id: 1,
name: "Bulk Generate"
name: "Bulk Generate",
url: "bulk-generate"
},
viewWalletInfo: {
id: 2,
name: "View Wallet Details"
name: "View Wallet Details",
url: "view-wallet-info"
},
sendTransaction: {
id: 3,
name: "Send Transaction"
name: "Send Transaction",
url: "send-transaction"
},
offlineTransaction: {
id: 4,
name: "Advanced / Offline Transaction"
name: "Advanced / Offline Transaction",
url:"offline-transaction"
},
help: {
id: 5,
name: "Help"
name: "Help",
url: "help"
},
contact: {
id: 6,
name: "Contact"
name: "Contact",
url: "contact"
}
};
return {
Expand Down
187 changes: 187 additions & 0 deletions app/scripts/staticJS/collapse-native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
// Native Javascript for Bootstrap 3 | Collapse
// by dnp_theme

(function(factory){

// CommonJS/RequireJS and "native" compatibility
if(typeof module !== "undefined" && typeof exports == "object") {
// A commonJS/RequireJS environment
if(typeof window != "undefined") {
// Window and document exist, so return the factory's return value.
module.exports = factory();
} else {
// Let the user give the factory a Window and Document.
module.exports = factory;
}
} else {
// Assume a traditional browser.
window.Collapse = factory();
}

})(function(){

// COLLAPSE DEFINITION
// ===================
var Collapse = function( element, options ) {
options = options || {};
this.isIE = (new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})").exec(navigator.userAgent) != null) ? parseFloat( RegExp.$1 ) : false;
this.btn = typeof element === 'object' ? element : document.querySelector(element);
this.accordion = null;
this.collapse = null;
this.duration = 300; // default collapse transition duration
this.options = {};
this.options.duration = (this.isIE && this.isIE < 10) ? 0 : (options.duration || this.duration);
this.init();
};

// COLLAPSE METHODS
// ================
Collapse.prototype = {

init : function() {
this.actions();
this.addEvent();
},

actions : function() {
var self = this;
var getOuterHeight = function (el) {
var s = el && el.currentStyle || window.getComputedStyle(el), // the getComputedStyle polyfill would do this for us, but we want to make sure it does
btp = s.borderTopWidth || 0,
mtp = /px/.test(s.marginTop) ? Math.round(s.marginTop.replace('px','')) : 0,
mbp = /px/.test(s.marginBottom) ? Math.round(s.marginBottom.replace('px','')) : 0,
mte = /em/.test(s.marginTop) ? Math.round(s.marginTop.replace('em','') * parseInt(s.fontSize)) : 0,
mbe = /em/.test(s.marginBottom) ? Math.round(s.marginBottom.replace('em','') * parseInt(s.fontSize)) : 0;

return el.clientHeight + parseInt( btp ) + parseInt( mtp ) + parseInt( mbp ) + parseInt( mte ) + parseInt( mbe ); //we need an accurate margin value
};

this.toggle = function(e) {
self.btn = self.getTarget(e).btn;
self.collapse = self.getTarget(e).collapse;

if (!/in/.test(self.collapse.className)) {
self.open(e);
} else {
self.close(e);
}
},
this.close = function(e) {
e.preventDefault();
self.btn = self.getTarget(e).btn;
self.collapse = self.getTarget(e).collapse;
self._close(self.collapse);
self.removeClass(self.btn,'collapsed');
},
this.open = function(e) {
e.preventDefault();
self.btn = self.getTarget(e).btn;
self.collapse = self.getTarget(e).collapse;
self.accordion = self.btn.getAttribute('data-parent') && self.getClosest(self.btn, self.btn.getAttribute('data-parent'));

self._open(self.collapse);
self.addClass(self.btn,'collapsed');

if ( self.accordion !== null ) {
var active = self.accordion.querySelectorAll('.collapse.in'), al = active.length, i = 0;
for (i;i<al;i++) {
if ( active[i] !== self.collapse) self._close(active[i]);
}
}
},
this._open = function(c) {
self.removeEvent();
self.addClass(c,'in');
c.setAttribute('aria-expanded','true');
self.addClass(c,'collapsing');
setTimeout(function() {
var h = self.getMaxHeight(c);
c.style.height = h + 'px';
c.style.overflowY = 'hidden';
}, 0);
setTimeout(function() {
c.style.height = '';
c.style.overflowY = '';
self.removeClass(c,'collapsing');
self.addEvent();
}, self.options.duration);
},
this._close = function(c) {
self.removeEvent();
c.setAttribute('aria-expanded','false');
c.style.height = self.getMaxHeight(c) + 'px';
setTimeout(function() {
c.style.height = '0px';
c.style.overflowY = 'hidden';
self.addClass(c,'collapsing');
}, 0);

setTimeout(function() {
self.removeClass(c,'collapsing');
self.removeClass(c,'in');
c.style.overflowY = '';
c.style.height = '';
self.addEvent();
}, self.options.duration);
},
this.getMaxHeight = function(l) { // get collapse trueHeight and border
var h = 0;
for (var k = 0, ll = l.children.length; k < ll; k++) {
h += getOuterHeight(l.children[k]);
}
return h;
},
this.removeEvent = function() {
this.btn.removeEventListener('click', this.toggle, false);
},
this.addEvent = function() {
this.btn.addEventListener('click', this.toggle, false);
},
this.getTarget = function(e) {
var t = e.currentTarget || e.srcElement,
h = t.href && t.getAttribute('href').replace('#',''),
d = t.getAttribute('data-target') && ( t.getAttribute('data-target') ),
id = h || ( d && /#/.test(d)) && d.replace('#',''),
cl = (d && d.charAt(0) === '.') && d, //the navbar collapse trigger targets a class
c = id && document.getElementById(id) || cl && document.querySelector(cl);

return {
btn : t,
collapse : c
};
},

this.getClosest = function (el, s) { //el is the element and s the selector of the closest item to find
// source http://gomakethings.com/climbing-up-and-down-the-dom-tree-with-vanilla-javascript/
var f = s.charAt(0);
for ( ; el && el !== document; el = el.parentNode ) {// Get closest match
if ( f === '.' ) {// If selector is a class
if ( document.querySelector(s) !== undefined ) { return el; }
}
if ( f === '#' ) { // If selector is an ID
if ( el.id === s.substr(1) ) { return el; }
}
}
return false;
};
this.addClass = function(el,c) {
if (el.classList) { el.classList.add(c); } else { el.className += ' '+c; }
};
this.removeClass = function(el,c) {
if (el.classList) { el.classList.remove(c); } else { el.className = el.className.replace(c,'').replace(/^\s+|\s+$/g,''); }
};
}
};

// COLLAPSE DATA API
// =================
var Collapses = document.querySelectorAll('[data-toggle="collapse"]'), i = 0, cll = Collapses.length;
for (i;i<cll;i++) {
var item = Collapses[i], options = {};
options.duration = item.getAttribute('data-duration');
new Collapse(item,options);
}

return Collapse;

});
4 changes: 3 additions & 1 deletion app/views/offlinetransaction.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@
<label> Signed Transaction </label>
<textarea class="form-control" placeholder="" readonly="readonly" rows="3" ng-model="signedTx"></textarea>
</div>
<div class="col-sm-4 offline-qrcode"></div>
<div class="col-sm-4 offline-qrcode">
<div qr-code="{{signedTx}}" watch-var="signedTx" width="100%"></div>
</div>
</section>

</section>
Expand Down
4 changes: 3 additions & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,9 @@ <h4 class="col-xs-12"><span class="text-primary collapseButton"></span> Step 2:
<label> Signed Transaction </label>
<textarea class="form-control" placeholder="" readonly="readonly" rows="3" ng-model="signedTx"></textarea>
</div>
<div class="col-sm-4 offline-qrcode"></div>
<div class="col-sm-4 offline-qrcode">
<div qr-code="{{signedTx}}" watch-var="signedTx" width="100%"></div>
</div>
</section>

</section>
Expand Down
Loading

0 comments on commit 0d579f5

Please sign in to comment.