//Global Variables var displayAddress = "oKv51tWdZWJyMJfVCtQoTo2FxrPicPtWbe"; //reading floData from transactions made to this address var id_contents_map = new Map(); //to store contents of bus route with repsect to its service type number var jsonParam = ['SNo.','Bus Operator','Source','Destination','Dept Location','Bus Type','Dept Time','Fare Seat','Via']; function convertStringToInt(string){ return parseInt(string,10); } function convertStringToFloat(string){ return parseFloat(string); } function compareVersion(newVer,oldVer){ if(newVer > oldVer) return true; return false; } let ajax = function (uri, params, req_type, callback) { let url = `https://livenet.flocha.in/${uri}`; //console.log(url); let response = {}; var http = new XMLHttpRequest(); http.open(req_type, url, true); http.onreadystatechange = function () { //Call a function when the state changes. if (http.readyState == 4 && http.status == 200) { response.success = true; response.data = http.responseText; callback(response.data); } else { //response.data = http.responseText; response.success = false; } } http.send(params); } function getTotalPages(address){ //Getting an array of transactions var uri = "api/txs/?address="+address; try { let res = ajax(uri, null, 'GET', function (response) { try { let data = JSON.parse(response); //console.log(data["txs"]); getTransactionsByPage(address,convertStringToInt(data["pagesTotal"]+'')); } catch (error) { console.log(error); } }); } catch (error) { console.error(error); } } function getTransactionsByPage(address,totalPages){ var cnt = 0; for(var i=0;i"; } var rowNum = 1; for(var i=1;i>=1;i++){ if(id_contents_map.get(i) === undefined) break; //var tableElement = document.getElementById("busTable"); var row = tableElement.insertRow(rowNum); for(var j=1;j<10;j++){ var cell = row.insertCell(j-1); cell.innerHTML = "
"+id_contents_map.get(i)[j]+"
"; } rowNum++; } document.getElementById('Loading').remove(); } getTotalPages(displayAddress);