Revert "🚧✏️ really? a colon?"

This reverts commit e22cc297fe.
master
Martin Zwigl 2025-03-02 23:38:01 +01:00
parent 536aeb510d
commit 9a66a57c33
2 changed files with 50 additions and 28 deletions

View File

@ -1,32 +1,56 @@
(function() {
const COIN_ICON = atob("MDCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAAAA//8AAAAB///AAAAB8A/gAAAAgAH4AAAwAAB8AAB4AAA+AADwA4APAADgA4APAAHgA4AHgADAf/ADwAAAf/gBwAAAf/wB4AAAcB4A4AAAcA4A4AAAcA4A4AYAcA4AcA8AcB4AcB+Af/wDdj/Af/4D/n/Af/8D/n/AcAcB/A4AcAOA+A4AcAOAcAcAcAOAAAcAcAAAAAcAcAAAAAeAf/AAAAOAf/AAAAPAf/ADAAHgA4AHgADwA4AHAADwA4APAAB8AAA+AAA+AAB8AAAfgAH4AAAH8A/gAAAD///AAAAA//8AAAAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==");
const settings = require("Storage").readJSON("coin_info.settings.json",1)||{};
const apiKey = (require("Storage").readJSON("coin_info.cmc_key.json",1)||{}).apiKey||"";
const COIN_ICON = atob("MDCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAAAA//8AAAAB///AAAAB8A/gAAAAgAH4AAAwAAB8AAB4AAA+AADwA4APAADgA4APAAHgA4AHgADAf/ADwAAAf/gBwAAAf/wB4AAAcB4A4AAAcA4A4AAAcA4A4AYAcA4AcA8AcB4AcB+Af/wDdj/Af/4D/n/Af/8D/n/AcAcB/A4AcAOA+A4AcAOAcAcAcAOAAAcAcAAAAAcAcAAAAAeAf/AAAAOAf/AAAAPAf/ADAAHgA4AHgADwA4AHAADwA4APAAB8AAA+AAA+AAB8AAAfgAH4AAAH8A/gAAAD///AAAAA//8AAAAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="); // (full base64 string here)
const settings = require("Storage").readJSON("coin_info.settings.json",1)||{};
const db = require("Storage").readJSON("coin_info.cmc_key.json",1)||{};
if (!(settings.tokenSelected instanceof Array))
settings.tokenSelected = [];
return {
name: "CoinInfo",
items: (settings.tokenSelected||[]).map(token => {
let current = {text:"-", img:COIN_ICON};
let tmr;
return {
name: token,
get: () => current,
show: function() {
const update = () => Bangle.http(
`https://pro-api.coinmarketcap.com/v2/cryptocurrency/quotes/latest?slug=${token}`,
{headers: {'CMC_PRO_API_KEY': apiKey}}
).then(r => {
// current.text = `${r.data["1"].symbol} $${r.data["1"].quote.USD.price.toFixed(2)}`;
current.text = `${r.data["1"].symbol}`;
Bangle.drawWidgets();
}).catch(e => current.text = `Err:${e}`);
update();
tmr = setInterval(update, 3600000);
items: settings.tokenSelected.map(token => {
return { name : token,
get : function()
{
const url = `https://pro-api.coinmarketcap.com//v2/cryptocurrency/quotes/latest?slug=${token}`;
Bangle
.http(url, {
method: 'GET',
headers: {
'CMC_PRO_API_KEY': db.apiKey
}
})
.then((cmcResult) => {
return {
text : cmcResult.resp.data["1"].symbol,
img : COIN_ICON
}
})
.catch(err => {
return {
text : err,
img : COIN_ICON
}
});
},
hide: () => tmr && clearInterval(tmr)
};
show : function() {
var self = this;
// Set timeout to align to the next minute
self.interval = setTimeout(function timerTimeout() {
self.emit("redraw");
// Continue updating every minute
self.interval = setInterval(function intervalCallback() {
self.emit("redraw");
}, 60000);
}, 60000 - (Date.now() % 60000));
},
hide : function() {
if (this.interval) {
clearInterval(this.interval);
this.interval = null;
}
},
}
})
};
})();
})

View File

@ -1,12 +1,10 @@
{ "id": "coin_info",
"name": "Crypto-Coins Info",
"shortName":"Coins Info",
"version": "0.04.9",
"version": "0.04.10",
"description": "Crypto-Coins Infos with the help of the Coinmarketcap API",
"icon": "app.png",
"tags": "clkinfo",
"dependencies": {"clock_info":"module"},
"provides_modules": ["coin_info"],
"supports" : ["BANGLEJS2"],
"interface": "interface.html",
"readme": "README.md",