🚧 anonymous functions it is
parent
93fc758c5e
commit
0c12c65522
|
|
@ -1,36 +0,0 @@
|
||||||
(function() {
|
|
||||||
const settings = require("Storage").readJSON("coin_info.settings.json",1)||{};
|
|
||||||
if (!(settings.tokenSelected instanceof Array))
|
|
||||||
settings.tokenSelected = [];
|
|
||||||
return {
|
|
||||||
name: "CoinInfo",
|
|
||||||
items: settings.tokenSelected.map(token => {
|
|
||||||
return { name : token,
|
|
||||||
get : function()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
text : token,
|
|
||||||
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==")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
@ -1,70 +1,36 @@
|
||||||
/* coin_info.js */
|
|
||||||
(function() {
|
(function() {
|
||||||
// Reads and validates settings from storage.
|
const settings = require("Storage").readJSON("coin_info.settings.json",1)||{};
|
||||||
function readSettings() {
|
if (!(settings.tokenSelected instanceof Array))
|
||||||
const storage = require("Storage");
|
settings.tokenSelected = [];
|
||||||
let settings = storage.readJSON("coin_info.settings.json", 1) || {};
|
return {
|
||||||
if (!(settings.tokenSelected instanceof Array)) {
|
name: "CoinInfo",
|
||||||
settings.tokenSelected = [];
|
items: settings.tokenSelected.map(token => {
|
||||||
}
|
return { name : token,
|
||||||
return settings;
|
get : function()
|
||||||
}
|
{
|
||||||
|
return {
|
||||||
// Returns the display content for a given token.
|
text : token,
|
||||||
function getCoinInfo(token) {
|
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==")
|
||||||
return {
|
}
|
||||||
text: token,
|
},
|
||||||
// Decodes the base-64 image that will be shown.
|
show : function() {
|
||||||
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==")
|
var self = this;
|
||||||
};
|
// Set timeout to align to the next minute
|
||||||
}
|
self.interval = setTimeout(function timerTimeout() {
|
||||||
|
self.emit("redraw");
|
||||||
// Starts the redraw timer for a clock info item.
|
// Continue updating every minute
|
||||||
// The timer is set so that the first redraw happens at the beginning of the next minute,
|
self.interval = setInterval(function intervalCallback() {
|
||||||
// and then continues with an interval of 60,000ms (1 minute).
|
self.emit("redraw");
|
||||||
function showCoinInfo() {
|
}, 60000);
|
||||||
var self = this;
|
}, 60000 - (Date.now() % 60000));
|
||||||
self.interval = setTimeout(function timerTimeout() {
|
},
|
||||||
self.emit("redraw");
|
hide : function() {
|
||||||
self.interval = setInterval(function intervalCallback() {
|
if (this.interval) {
|
||||||
self.emit("redraw");
|
clearInterval(this.interval);
|
||||||
}, 60000);
|
this.interval = null;
|
||||||
}, 60000 - (Date.now() % 60000));
|
}
|
||||||
}
|
},
|
||||||
|
}
|
||||||
// Stops the redraw timer.
|
})
|
||||||
function hideCoinInfo() {
|
};
|
||||||
if (this.interval) {
|
})
|
||||||
clearInterval(this.interval);
|
|
||||||
this.interval = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creates a single clock info item for a given token.
|
|
||||||
function createCoinInfoItem(token) {
|
|
||||||
return {
|
|
||||||
name: token,
|
|
||||||
get: function() {
|
|
||||||
return getCoinInfo(token);
|
|
||||||
},
|
|
||||||
show: showCoinInfo,
|
|
||||||
hide: hideCoinInfo,
|
|
||||||
hasRange: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reads the stored tokens and creates clock info items for them.
|
|
||||||
function createCoinInfoModule() {
|
|
||||||
const settings = readSettings();
|
|
||||||
const items = settings.tokenSelected.map(createCoinInfoItem);
|
|
||||||
return {
|
|
||||||
name: "CoinInfo",
|
|
||||||
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.24",
|
"version": "0.03.25",
|
||||||
"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