mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Make the cryptolive using the global config reference.
Signed-off-by: Eugene Dzhurinsky <jdevelop@gmail.com>
This commit is contained in:
@@ -7,12 +7,9 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/olebedev/config"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
// Config is a pointer to the global config object
|
||||
var Config *config.Config
|
||||
|
||||
var baseURL = "https://min-api.cryptocompare.com/data/price"
|
||||
var ok = true
|
||||
|
||||
@@ -35,12 +32,12 @@ func NewWidget() *Widget {
|
||||
}
|
||||
|
||||
func (widget *Widget) setList() {
|
||||
currenciesMap, _ := Config.Map("wtf.mods.cryptolive.currencies")
|
||||
currenciesMap, _ := wtf.Config.Map("wtf.mods.cryptolive.currencies")
|
||||
|
||||
widget.list = &list{}
|
||||
|
||||
for currency := range currenciesMap {
|
||||
displayName, _ := Config.String("wtf.mods.cryptolive.currencies." + currency + ".displayName")
|
||||
displayName, _ := wtf.Config.String("wtf.mods.cryptolive.currencies." + currency + ".displayName")
|
||||
toList := getToList(currency)
|
||||
widget.list.addItem(currency, displayName, toList)
|
||||
}
|
||||
@@ -70,10 +67,10 @@ func (widget *Widget) Refresh(wg *sync.WaitGroup) {
|
||||
func (widget *Widget) display() {
|
||||
str := ""
|
||||
var (
|
||||
fromNameColor = Config.UString("wtf.mods.cryptolive.colors.from.name", "coral")
|
||||
fromDisplayNameColor = Config.UString("wtf.mods.cryptolive.colors.from.displayName", "grey")
|
||||
toNameColor = Config.UString("wtf.mods.cryptolive.colors.to.name", "white")
|
||||
toPriceColor = Config.UString("wtf.mods.cryptolive.colors.to.price", "green")
|
||||
fromNameColor = wtf.Config.UString("wtf.mods.cryptolive.colors.from.name", "coral")
|
||||
fromDisplayNameColor = wtf.Config.UString("wtf.mods.cryptolive.colors.from.displayName", "grey")
|
||||
toNameColor = wtf.Config.UString("wtf.mods.cryptolive.colors.to.name", "white")
|
||||
toPriceColor = wtf.Config.UString("wtf.mods.cryptolive.colors.to.price", "green")
|
||||
)
|
||||
for _, item := range widget.list.items {
|
||||
str += fmt.Sprintf(" [%s]%s[%s] (%s)\n", fromNameColor, item.displayName, fromDisplayNameColor, item.name)
|
||||
@@ -87,7 +84,7 @@ func (widget *Widget) display() {
|
||||
}
|
||||
|
||||
func getToList(fromName string) []*toCurrency {
|
||||
toNames, _ := Config.List("wtf.mods.cryptolive.currencies." + fromName + ".to")
|
||||
toNames, _ := wtf.Config.List("wtf.mods.cryptolive.currencies." + fromName + ".to")
|
||||
|
||||
var toList []*toCurrency
|
||||
|
||||
|
||||
Reference in New Issue
Block a user