Coming from C#, I have some problems using a variable from another function:
// Define colors
albumart.addEventListener('load', function () {
var vibrant = new Vibrant(albumart);
var swatches = vibrant.swatches()
for (var swatch in swatches)
if (swatches.hasOwnProperty(swatch) && swatches[swatch]) {
var darkvibrant = swatches.DarkVibrant;
}
})
// Toggle styles
function mainUpdate(type) {
if (type == "music") {
isplaying ? albumart.src = "/var/mobile/Documents/Artwork.jpg?" + milli : albumart.src = "images/No-album-art.png";
isplaying ? icons.style.color = darkvibrant : icons.style.color = "#202727";
}
}
I am trying to use darkvibrant
in the second function, I tried this:
var darkvibrant = {};
darkvibrant.color = swatches.DarkVibrant;
isplaying ? icons.style.color = darkvibrant : icons.style.color = "#202727";
I would appreciate any help.