🚧 last try for AI
parent
917e2908f2
commit
93fc758c5e
|
|
@ -2,23 +2,26 @@
|
||||||
(function() {
|
(function() {
|
||||||
// Reads and validates settings from storage.
|
// Reads and validates settings from storage.
|
||||||
function readSettings() {
|
function readSettings() {
|
||||||
var storage = require("Storage");
|
const storage = require("Storage");
|
||||||
var settings = storage.readJSON("coin_info.settings.json", 1) || {};
|
let settings = storage.readJSON("coin_info.settings.json", 1) || {};
|
||||||
if (!(settings.tokenSelected instanceof Array)) {
|
if (!(settings.tokenSelected instanceof Array)) {
|
||||||
settings.tokenSelected = [];
|
settings.tokenSelected = [];
|
||||||
}
|
}
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the display info (text and image) for a given token.
|
// Returns the display content for a given token.
|
||||||
function getCoinInfo(token) {
|
function getCoinInfo(token) {
|
||||||
return {
|
return {
|
||||||
text: token,
|
text: token,
|
||||||
|
// Decodes the base-64 image that will be shown.
|
||||||
img: 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==")
|
img: 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==")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Starts the redraw timer so the info gets updated at the start of each minute.
|
// Starts the redraw timer for a clock info item.
|
||||||
|
// The timer is set so that the first redraw happens at the beginning of the next minute,
|
||||||
|
// and then continues with an interval of 60,000ms (1 minute).
|
||||||
function showCoinInfo() {
|
function showCoinInfo() {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.interval = setTimeout(function timerTimeout() {
|
self.interval = setTimeout(function timerTimeout() {
|
||||||
|
|
@ -37,7 +40,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a single clock_info item for a given token.
|
// Creates a single clock info item for a given token.
|
||||||
function createCoinInfoItem(token) {
|
function createCoinInfoItem(token) {
|
||||||
return {
|
return {
|
||||||
name: token,
|
name: token,
|
||||||
|
|
@ -46,17 +49,22 @@
|
||||||
},
|
},
|
||||||
show: showCoinInfo,
|
show: showCoinInfo,
|
||||||
hide: hideCoinInfo,
|
hide: hideCoinInfo,
|
||||||
hasRange: false
|
hasRange: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read settings and create items.
|
// Reads the stored tokens and creates clock info items for them.
|
||||||
var settings = readSettings();
|
function createCoinInfoModule() {
|
||||||
var items = settings.tokenSelected.map(createCoinInfoItem);
|
const settings = readSettings();
|
||||||
|
const items = settings.tokenSelected.map(createCoinInfoItem);
|
||||||
// Return the module object, exactly as the clock_info app expects.
|
|
||||||
return {
|
return {
|
||||||
name: "CoinInfo",
|
name: "CoinInfo",
|
||||||
items: items
|
items: items,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the exported object (the module) from the IIFE.
|
||||||
|
// Using this pattern ensures compatibility with the Espruino environment
|
||||||
|
// on Bangle.js instead of Node.js-style module.exports.
|
||||||
|
return createCoinInfoModule();
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -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.23",
|
"version": "0.03.24",
|
||||||
"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",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue