Retrieve real data for graph
parent
207767344e
commit
c1edfede23
|
|
@ -4,7 +4,7 @@ const csTokens = db.csTokens.split(',');
|
||||||
var ticker = 0;
|
var ticker = 0;
|
||||||
var currLoadMsg = "...";
|
var currLoadMsg = "...";
|
||||||
var timePeriod = "24h";
|
var timePeriod = "24h";
|
||||||
var tknChrtData = [0,1,3,8,10,12,12,10,8,3,1,0];
|
var tknChrtData = [5,6,5,6,5,6,5,6,5,6,5,6,5,6,];
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -21,7 +21,7 @@ var layout = new Layout({
|
||||||
{type:"h", valign:-1,
|
{type:"h", valign:-1,
|
||||||
c: [
|
c: [
|
||||||
{type:"txt", id:"tknName", font:"6x8:2", label:"", halign:-1, fillx:1},
|
{type:"txt", id:"tknName", font:"6x8:2", label:"", halign:-1, fillx:1},
|
||||||
{type:"btn", label:"...", halign:1, cb: d=>setLoadMsg("details")}
|
{type:"btn", label:"...", halign:1, cb: d=>showDetails()}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{type:"txt", id:"loadMsg", font:"6x8", label:"", fillx:1 },
|
{type:"txt", id:"loadMsg", font:"6x8", label:"", fillx:1 },
|
||||||
|
|
@ -41,20 +41,30 @@ layout.update();
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// function makeHttpRequest() {
|
function repeatingRequest(repeatable) {
|
||||||
// // Ensure Internet Access is enabled in Gadgetbridge settings
|
const url = `https://openapiv1.coinstats.app/coins/bitcoin/charts?period=${timePeriod}`;
|
||||||
// Bangle.http("https://example.com/your_api_endpoint")
|
Bangle
|
||||||
// .then(data => {
|
.http(url, {
|
||||||
// console.log("Got HTTP response:", data);
|
method: 'GET',
|
||||||
// // Handle the response here
|
headers: {
|
||||||
// })
|
'X-API-KEY': db.csApiKey
|
||||||
// .catch(err => {
|
}
|
||||||
// console.error("HTTP request failed:", err);
|
})
|
||||||
// });
|
.then(data => {
|
||||||
//
|
// console.log("Got HTTP response:", data);
|
||||||
// if (httpTimeout) clearTimeout(httpTimeout);
|
// Handle the response here
|
||||||
// httpTimeout = setTimeout(makeHttpRequest, 300000); // Make HTTP request every 5 minutes
|
const apiData = JSON.parse(data.resp);
|
||||||
// }
|
tknChrtData = apiData.map(innerArray => innerArray[1]);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error("HTTP request failed:", err);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (repeatable == true) {
|
||||||
|
if (httpTimeout) clearTimeout(httpTimeout);
|
||||||
|
httpTimeout = setTimeout(repeatingRequest, 300000); // Make HTTP request every 5 minutes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
function swipeHandler(lr, ud) {
|
function swipeHandler(lr, ud) {
|
||||||
|
|
@ -71,6 +81,10 @@ function swipeHandler(lr, ud) {
|
||||||
//
|
//
|
||||||
function setLoadMsg(x) {
|
function setLoadMsg(x) {
|
||||||
currLoadMsg = `Load... ${x}`;
|
currLoadMsg = `Load... ${x}`;
|
||||||
|
timePeriod = x;
|
||||||
|
}
|
||||||
|
function showDetails() {
|
||||||
|
currLoadMsg = `Details for ${(csTokens[ticker]).toUpperCase()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// timeout used to update every minute
|
// timeout used to update every minute
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{ "id": "coin_info",
|
{ "id": "coin_info",
|
||||||
"name": "Crypto-Coins Info",
|
"name": "Crypto-Coins Info",
|
||||||
"shortName":"Coins Info",
|
"shortName":"Coins Info",
|
||||||
"version": "0.06.26",
|
"version": "0.06.30",
|
||||||
"description": "Crypto-Coins Infos with the help of the Binance API",
|
"description": "Crypto-Coins Infos with the help of the Binance API",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"tags": "clkinfo",
|
"tags": "clkinfo",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue