mirror of
https://github.com/aljazceru/twentyone-world.github.io.git
synced 2025-12-19 15:04:21 +01:00
refactor: isBased()
This commit is contained in:
12
index.html
12
index.html
@@ -47,15 +47,15 @@ qtip: '/js/jquery.qtip.min.js'
|
||||
dataType: 'json',
|
||||
success: function (countries) {
|
||||
|
||||
var orangeCountries = countries.filter(function hasLink(c) {
|
||||
var basedCountries = countries.filter(function hasLink(c) {
|
||||
var hasLink = c.link ? true : false;
|
||||
return hasLink;
|
||||
});
|
||||
var orangeCountryCodes = orangeCountries.map(function(c) {
|
||||
var basedCountryCodes = basedCountries.map(function(c) {
|
||||
return c.alpha3;
|
||||
});
|
||||
function isOrange(iso) {
|
||||
return orangeCountryCodes.includes(iso);
|
||||
function isBased(iso) {
|
||||
return basedCountryCodes.includes(iso);
|
||||
}
|
||||
function getColor(iso) {
|
||||
let country = countries.find(c => c.alpha3 == iso);
|
||||
@@ -72,13 +72,13 @@ qtip: '/js/jquery.qtip.min.js'
|
||||
fill: cGray
|
||||
},
|
||||
mouseenter: function (d, path) {
|
||||
if (!isOrange(d.iso)) {
|
||||
if (!isBased(d.iso)) {
|
||||
path.attr('fill', Math.random() < 0.5 ? cDarkOrange : cDarkWhite );
|
||||
}
|
||||
return;
|
||||
},
|
||||
mouseleave: function (d, path) {
|
||||
if (!isOrange(d.iso)) {
|
||||
if (!isBased(d.iso)) {
|
||||
path.animate({ fill: getColor(d.iso) }, 1000);
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user