Skip to content

Commit

Permalink
console
Browse files Browse the repository at this point in the history
  • Loading branch information
SilentCicero committed Apr 15, 2019
1 parent dbab8ba commit a8afdfc
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .cache/0e/2be27f674cc4e2ef407dd574d475b7.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .cache/83/bc734f713200112f6b231c56770519.json

Large diffs are not rendered by default.

52 changes: 44 additions & 8 deletions dist/ethtoolbox.e31bb0bc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14651,9 +14651,19 @@ var _moment = _interopRequireDefault(require("moment"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _templateObject6() {
function _templateObject7() {
var data = _taggedTemplateLiteral(["\n margin-left: 20px;\n padding-bottom: 100px;\n"]);

_templateObject7 = function _templateObject7() {
return data;
};

return data;
}

function _templateObject6() {
var data = _taggedTemplateLiteral(["\n position: absolute;\n display: block;\n line-height: 15px;\n padding-top: 0px;\n bottom: 0px;\n height: 40px;\n margin-bottom: 10px;\n right: 35px;\n padding-right: 20px;\n padding-left: 23px;\n border: 0px;\n letter-spacing: .5px;\n font-size: 15px;\n width: 40%;\n outline: none;\n background: url(https://png.pngtree.com/svg/20160727/0bf24b248b.svg);\n background-position: 0px 10px;\n background-repeat: no-repeat;\n background-size: 20px 20px;\n\n &:focus {\n color: none;\n outline: none;\n }\n"]);

_templateObject6 = function _templateObject6() {
return data;
};
Expand All @@ -14662,7 +14672,7 @@ function _templateObject6() {
}

function _templateObject5() {
var data = _taggedTemplateLiteral(["\n margin-top: 30px;\n width: 40%;\n position: absolute;\n word-wrap: break-word;\n padding: 20px;\n bottom: 0px;\n top: 0px;\n height: 100%;\n right: 0px;\n overflow: scroll;\n"]);
var data = _taggedTemplateLiteral(["\n width: 40%;\n position: absolute;\n word-wrap: break-word;\n padding: 20px;\n bottom: 50px;\n top: 0px;\n right: 0px;\n overflow: scroll;\n overflow-x: hidden;\n"]);

_templateObject5 = function _templateObject5() {
return data;
Expand Down Expand Up @@ -14738,7 +14748,7 @@ var state = {
results: [(0, _hyperapp.h)("span", null, "Welcome to EthToolBox brought to you by Ethers.js, the Eth Community and Nick Dodson ", (0, _hyperapp.h)("a", {
href: "https://twitter.com/iamnickdodson",
target: "_blank"
}, "@IAmNickDodson"), " ;)"), 'Tip: you can access Ethers directly using Eval e.g. ethers.utils.bigNumberify("12").toHexString()'],
}, "@IAmNickDodson"), " ;)"), 'Tip: you can access Ethers directly using the console e.g. ethers.utils.bigNumberify("12").toHexString()'],
abi: {},
timestamp: Math.round(new Date().getTime() / 1000),
timestring: new Date().toLocaleString(undefined, {
Expand Down Expand Up @@ -14788,6 +14798,11 @@ var actions = {
actions.change({
results: state.results.concat([val])
});
var elm = document.getElementById('results'); // scroll to bottom

setTimeout(function (e) {
elm.scrollTop = elm.scrollHeight;
}, 50);
};
},
onAbi: function onAbi(val) {
Expand Down Expand Up @@ -14928,6 +14943,15 @@ var actions = {
}
};
},
console: function console(val) {
return function (state, actions) {
try {
actions.result("".concat(eval(val)));
} catch (error) {
actions.error(error);
}
};
},
time: function time(val) {
return function (state, actions) {
try {
Expand Down Expand Up @@ -15035,7 +15059,9 @@ var Button = _hyperappStyledComponents.default.button(_templateObject4());

var Results = _hyperappStyledComponents.default.div(_templateObject5());

var Column = _hyperappStyledComponents.default.div(_templateObject6());
var Console = _hyperappStyledComponents.default.input(_templateObject6());

var Column = _hyperappStyledComponents.default.div(_templateObject7());

var Code = function Code() {
return function (state, actions) {
Expand Down Expand Up @@ -15173,11 +15199,21 @@ var Code = function Code() {
}
}, "Hash"), (0, _hyperapp.h)("br", null), (0, _hyperapp.h)("br", null), (0, _hyperapp.h)("br", null), (0, _hyperapp.h)("h4", null, "Key Tools"), (0, _hyperapp.h)(Button, {
onclick: actions.generateKey
}, "Generate Key"))), (0, _hyperapp.h)(Results, null, state.results.concat(state.errors).reverse().map(function (v, i) {
}, "Generate Key"))), (0, _hyperapp.h)(Results, {
id: "results"
}, state.results.concat(state.errors).map(function (v, i) {
return (0, _hyperapp.h)("div", {
style: "margin-top: 10px;"
}, state.results.concat(state.errors).length - i, ") ", v);
})));
}, i + 1, ") ", v);
})), (0, _hyperapp.h)(Console, {
placeholder: "",
onkeyup: function onkeyup(e) {
if (e.keyCode === 13) {
e.preventDefault();
actions.console(e.target.value);
}
}
}));
};
}; // routes for app

Expand Down Expand Up @@ -15222,7 +15258,7 @@ var parent = module.bundle.parent;
if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
var hostname = "" || location.hostname;
var protocol = location.protocol === 'https:' ? 'wss' : 'ws';
var ws = new WebSocket(protocol + ':https://' + hostname + ':' + "38827" + '/');
var ws = new WebSocket(protocol + ':https://' + hostname + ':' + "42531" + '/');

ws.onmessage = function (event) {
var data = JSON.parse(event.data);
Expand Down
2 changes: 1 addition & 1 deletion dist/ethtoolbox.e31bb0bc.map

Large diffs are not rendered by default.

54 changes: 48 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const state = {
error: null,
results: [
(<span>Welcome to EthToolBox brought to you by Ethers.js, the Eth Community and Nick Dodson <a href="https://twitter.com/iamnickdodson" target="_blank">@IAmNickDodson</a> ;)</span>),
'Tip: you can access Ethers directly using Eval e.g. ethers.utils.bigNumberify("12").toHexString()',
'Tip: you can access Ethers directly using the console e.g. ethers.utils.bigNumberify("12").toHexString()',
],
abi: {},
timestamp: Math.round(new Date().getTime()/1000),
Expand Down Expand Up @@ -70,6 +70,10 @@ const actions = {
},
result: val => (state, actions) => {
actions.change({ results: state.results.concat([val]) });
const elm = document.getElementById('results');

// scroll to bottom
setTimeout(e => {(elm.scrollTop = elm.scrollHeight)}, 50);
},
onAbi: val => (state, actions) => {
try {
Expand Down Expand Up @@ -158,6 +162,11 @@ const actions = {
actions.result(`utf8("${state.inputA || ''}") => ${utils.toUtf8String(state.inputA || '')}`);
} catch (error) { actions.error(error); }
},
console: val => (state, actions) => {
try {
actions.result(`${eval(val)}`);
} catch (error) { actions.error(error); }
},
time: val => (state, actions) => {
try {
actions.change({ timestring: val, timestamp: moment(val).format('X'), });
Expand Down Expand Up @@ -262,16 +271,42 @@ const Button = styled.button`
`;

const Results = styled.div`
margin-top: 30px;
width: 40%;
position: absolute;
word-wrap: break-word;
padding: 20px;
bottom: 0px;
bottom: 50px;
top: 0px;
height: 100%;
right: 0px;
overflow: scroll;
overflow-x: hidden;
`;

const Console = styled.input`
position: absolute;
display: block;
line-height: 15px;
padding-top: 0px;
bottom: 0px;
height: 40px;
margin-bottom: 10px;
right: 35px;
padding-right: 20px;
padding-left: 23px;
border: 0px;
letter-spacing: .5px;
font-size: 15px;
width: 40%;
outline: none;
background: url(https://png.pngtree.com/svg/20160727/0bf24b248b.svg);
background-position: 0px 10px;
background-repeat: no-repeat;
background-size: 20px 20px;
&:focus {
color: none;
outline: none;
}
`;

const Column = styled.div`
Expand Down Expand Up @@ -373,8 +408,15 @@ const Code = () => (state, actions, v = console.log(state)) => (
</Column>
</Wrapper>

<Results>{state.results.concat(state.errors).reverse()
.map((v, i) => (<div style="margin-top: 10px;">{state.results.concat(state.errors).length - i}) {v}</div>))}</Results>
<Results id="results">{state.results.concat(state.errors)
.map((v, i) => (<div style="margin-top: 10px;">{i + 1}) {v}</div>))}</Results>

<Console placeholder="" onkeyup={e => {
if (e.keyCode === 13) {
e.preventDefault();
actions.console(e.target.value);
}
}}></Console>
</div>
);

Expand Down

0 comments on commit a8afdfc

Please sign in to comment.