Addition of address bar routing
This commit is contained in:
parent
9aae6b9f8c
commit
55ea4a4f2a
26
index.html
26
index.html
@ -786,7 +786,7 @@
|
|||||||
|
|
||||||
function renderTransactions() { }
|
function renderTransactions() { }
|
||||||
|
|
||||||
window.addEventListener("load", () => {
|
window.addEventListener("load", async() => {
|
||||||
|
|
||||||
var hashvalue = location.hash.slice(1);
|
var hashvalue = location.hash.slice(1);
|
||||||
if(hashvalue==''){
|
if(hashvalue==''){
|
||||||
@ -797,7 +797,7 @@
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
debugger;
|
debugger;
|
||||||
getAllSuggestions();
|
await getAllSuggestions();
|
||||||
categoriseText(hashvalue);
|
categoriseText(hashvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1546,36 +1546,33 @@
|
|||||||
return tempArray
|
return tempArray
|
||||||
}
|
}
|
||||||
|
|
||||||
function categoriseText(text, inputElement) {
|
function categoriseText(text) {
|
||||||
|
|
||||||
if (!isNaN(text) && isInt(Number(text))) {
|
if (!isNaN(text) && isInt(Number(text))) {
|
||||||
//console.log('this is a block number');
|
//console.log('this is a block number');
|
||||||
inputElement.value = '';
|
|
||||||
render("block_page", text);
|
render("block_page", text);
|
||||||
appState = {
|
appState = {
|
||||||
page: "block_page",
|
page: "block_page",
|
||||||
thisField: text,
|
thisField: text,
|
||||||
}
|
}
|
||||||
history.pushState(appState, null, null)
|
history.pushState(appState, null, `#${text}`)
|
||||||
} else if (typeof (text) == 'string') {
|
} else if (typeof (text) == 'string') {
|
||||||
if (text.length == 34 && text[0] == 'F') {
|
if (text.length == 34 && text[0] == 'F') {
|
||||||
//console.log('data entered is a FLO address');
|
//console.log('data entered is a FLO address');
|
||||||
inputElement.value = '';
|
|
||||||
render("address_page", text)
|
render("address_page", text)
|
||||||
appState = {
|
appState = {
|
||||||
page: "address_page",
|
page: "address_page",
|
||||||
thisField: text,
|
thisField: text,
|
||||||
}
|
}
|
||||||
history.pushState(appState, null, null)
|
history.pushState(appState, null, `#${text}`)
|
||||||
} else if (window.ranchimallflo.tokenlist.includes(text)) {
|
} else if (window.ranchimallflo.tokenlist.includes(text)) {
|
||||||
//console.log('data entered is a token name');
|
//console.log('data entered is a token name');
|
||||||
inputElement.value = '';
|
|
||||||
render("token_page", text)
|
render("token_page", text)
|
||||||
appState = {
|
appState = {
|
||||||
page: "token_page",
|
page: "token_page",
|
||||||
thisField: text,
|
thisField: text,
|
||||||
}
|
}
|
||||||
history.pushState(appState, null, null)
|
history.pushState(appState, null, `#${text}`)
|
||||||
} else if (window.ranchimallflo.smartcontractnamelist.includes(text)) {
|
} else if (window.ranchimallflo.smartcontractnamelist.includes(text)) {
|
||||||
//console.log('data entered is a smart contract name');
|
//console.log('data entered is a smart contract name');
|
||||||
for (var i = 0; i < window.ranchimallflo.smartcontractnameaddresslist.length; i++) {
|
for (var i = 0; i < window.ranchimallflo.smartcontractnameaddresslist.length; i++) {
|
||||||
@ -1583,7 +1580,6 @@
|
|||||||
var contractSplit = splitContractNameAddress(window.ranchimallflo.smartcontractnameaddresslist[i], window.ranchimallflo.smartcontractnameaddresslist[i].lastIndexOf('-'));
|
var contractSplit = splitContractNameAddress(window.ranchimallflo.smartcontractnameaddresslist[i], window.ranchimallflo.smartcontractnameaddresslist[i].lastIndexOf('-'));
|
||||||
|
|
||||||
if (window.ranchimallflo.smartcontractnamelist.includes(text)) {
|
if (window.ranchimallflo.smartcontractnamelist.includes(text)) {
|
||||||
inputElement.value = '';
|
|
||||||
render("contract_page", contract = {
|
render("contract_page", contract = {
|
||||||
name: '',
|
name: '',
|
||||||
address: ''
|
address: ''
|
||||||
@ -1592,7 +1588,7 @@
|
|||||||
page: "contract_page",
|
page: "contract_page",
|
||||||
thisField: text,
|
thisField: text,
|
||||||
}
|
}
|
||||||
history.pushState(appState, null, null)
|
history.pushState(appState, null, `#${text}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1606,22 +1602,20 @@
|
|||||||
.then(function (myJson) {
|
.then(function (myJson) {
|
||||||
if (myJson['type'] == 'transaction') {
|
if (myJson['type'] == 'transaction') {
|
||||||
//console.log('data entered is a transaction hash');
|
//console.log('data entered is a transaction hash');
|
||||||
inputElement.value = '';
|
|
||||||
render("transaction_page", text);
|
render("transaction_page", text);
|
||||||
appState = {
|
appState = {
|
||||||
page: "transaction_page",
|
page: "transaction_page",
|
||||||
thisField: text,
|
thisField: text,
|
||||||
}
|
}
|
||||||
history.pushState(appState, null, null)
|
history.pushState(appState, null, `#${text}`)
|
||||||
} else if (myJson['type'] == 'block') {
|
} else if (myJson['type'] == 'block') {
|
||||||
//console.log('data entered is a block hash');
|
//console.log('data entered is a block hash');
|
||||||
inputElement.value = '';
|
|
||||||
render("block_page", text)
|
render("block_page", text)
|
||||||
appState = {
|
appState = {
|
||||||
page: "block_page",
|
page: "block_page",
|
||||||
thisField: text,
|
thisField: text,
|
||||||
}
|
}
|
||||||
history.pushState(appState, null, null)
|
history.pushState(appState, null, `#${text}`)
|
||||||
} else {
|
} else {
|
||||||
//console.log('data entered is noise');
|
//console.log('data entered is noise');
|
||||||
}
|
}
|
||||||
@ -1643,11 +1637,11 @@
|
|||||||
|
|
||||||
async function getAllSuggestions() {
|
async function getAllSuggestions() {
|
||||||
window.data = [];
|
window.data = [];
|
||||||
|
window.ranchimallflo = {};
|
||||||
let response = await fetch(`${window.tokenapiUrl}/api/v1.0/getTokenSmartContractList`);
|
let response = await fetch(`${window.tokenapiUrl}/api/v1.0/getTokenSmartContractList`);
|
||||||
let myJson = await response.json();
|
let myJson = await response.json();
|
||||||
|
|
||||||
//console.log('first line of the fetch result');
|
//console.log('first line of the fetch result');
|
||||||
window.ranchimallflo = {};
|
|
||||||
ranchimallflo.tokenlist = myJson['tokens'];
|
ranchimallflo.tokenlist = myJson['tokens'];
|
||||||
ranchimallflo.smartcontractlist = myJson['smartContracts'];
|
ranchimallflo.smartcontractlist = myJson['smartContracts'];
|
||||||
ranchimallflo.smartcontractnamelist = [];
|
ranchimallflo.smartcontractnamelist = [];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user