Basic interaction implemented
This commit is contained in:
parent
f70f23335b
commit
cc442b3a2e
|
@ -71,9 +71,26 @@ function address_to_url(address: BlockchainAddress): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
function ui_show_route() {
|
function ui_show_route() {
|
||||||
|
if (CURRENT_ROUTE.from == null || CURRENT_ROUTE.to == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const infoFrom = TOKENS[CURRENT_ROUTE.from.asString()];
|
||||||
|
const infoTo = TOKENS[CURRENT_ROUTE.to.asString()];
|
||||||
|
|
||||||
|
const symbolFrom = infoFrom.latest_state == null ? "???" : infoFrom.latest_state.symbol;
|
||||||
|
const symbolTo = infoTo.latest_state == null ? "???" : infoTo.latest_state.symbol;
|
||||||
|
|
||||||
|
for (const a of document.querySelectorAll("[data-input-token]")) {
|
||||||
|
(<HTMLElement>a).innerText = symbolFrom;
|
||||||
|
}
|
||||||
|
for (const a of document.querySelectorAll("[data-output-token]")) {
|
||||||
|
(<HTMLElement>a).innerText = symbolTo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function reroute() {
|
function reroute() {
|
||||||
|
console.log("Rerouting", CURRENT_ROUTE);
|
||||||
|
|
||||||
// Do not route if from or to are not assigned yet.
|
// Do not route if from or to are not assigned yet.
|
||||||
if (CURRENT_ROUTE.from == null || CURRENT_ROUTE.to == null) {
|
if (CURRENT_ROUTE.from == null || CURRENT_ROUTE.to == null) {
|
||||||
|
@ -82,6 +99,8 @@ function reroute() {
|
||||||
|
|
||||||
// Perform routing.
|
// Perform routing.
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
ui_show_route();
|
||||||
}
|
}
|
||||||
|
|
||||||
function routeFrom(address: BlockchainAddress) {
|
function routeFrom(address: BlockchainAddress) {
|
||||||
|
@ -114,7 +133,7 @@ function ui_add_token(tokenState: TokenStateV1 | TokenStateV2, address: Blockcha
|
||||||
value="To" />
|
value="To" />
|
||||||
</form>
|
</form>
|
||||||
`;
|
`;
|
||||||
spanFrom.addEventListener("click", () => routeTo(address));
|
spanTo.addEventListener("click", () => routeTo(address));
|
||||||
const spanSymbol= document.createElement("a");
|
const spanSymbol= document.createElement("a");
|
||||||
spanSymbol.innerText = tokenState.symbol;
|
spanSymbol.innerText = tokenState.symbol;
|
||||||
spanSymbol.title = tokenState.name;
|
spanSymbol.title = tokenState.name;
|
||||||
|
|
|
@ -12,6 +12,6 @@
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"lib": ["dom", "es2015", "es2016", "es2017", "esnext"]
|
"lib": ["dom", "es2015", "es2016", "es2017", "esnext", "dom.iterable"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user