🚧 improve clk-info

master
Martin Zwigl 2025-02-28 01:04:47 +01:00
parent 1cda9a71a0
commit ced064c797
2 changed files with 18 additions and 14 deletions

View File

@ -1,10 +1,6 @@
(function() { (function() {
const SETTINGS_FILE = "coin_info.settings.json";
const settings = require("Storage").readJSON(SETTINGS_FILE,1) || {};
function retrieveClkInfo(token) { function retrieveClkInfo(token) {
// TODO: do something useful here -> http request to CMC
console.log("Retrieving:", token);
return { return {
text : token, text : token,
// color: "#f00", // color: "#f00",
@ -12,20 +8,26 @@
} }
} }
// function showClkInfo() {
// const self = this;
// this.interval = setTimeout(() => {
// self.emit("redraw");
// self.interval = setInterval(() => {
// console.log("Interval refresh");
// self.emit("redraw");
// }, 60000);
// }, 60000 - (Date.now() % 60000));
// }
function showClkInfo() { function showClkInfo() {
console.log("Show called"); this.interval = setTimeout(()=>{
const self = this; this.emit("redraw");
this.interval = setTimeout(() => { this.interval = setInterval(()=>{
self.emit("redraw"); this.emit("redraw");
self.interval = setInterval(() => {
console.log("Interval refresh");
self.emit("redraw");
}, 60000); }, 60000);
}, 60000 - (Date.now() % 60000)); }, 60000 - (Date.now() % 60000));
} }
function hideClkInfo() { function hideClkInfo() {
console.log("Hide called");
if (this.interval) { if (this.interval) {
clearInterval(this.interval); clearInterval(this.interval);
this.interval = null; this.interval = null;
@ -33,7 +35,9 @@
} }
function createClkInfoItems() { function createClkInfoItems() {
console.log("Creating items from:", settings.tokenSelected); const SETTINGS_FILE = "coin_info.settings.json";
const settings = require("Storage").readJSON(SETTINGS_FILE,1) || {};
return (settings.tokenSelected || []).map(token => ({ return (settings.tokenSelected || []).map(token => ({
name: token, name: token,
get: () => retrieveClkInfo(token), get: () => retrieveClkInfo(token),

View File

@ -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.03.14", "version": "0.03.15",
"description": "Crypto-Coins Infos with the help of the Coinmarketcap API", "description": "Crypto-Coins Infos with the help of the Coinmarketcap API",
"icon": "app.png", "icon": "app.png",
"tags": "clkinfo", "tags": "clkinfo",