mirror of
https://github.com/aljazceru/twentyone-world.github.io.git
synced 2025-12-20 18:14:23 +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',
|
dataType: 'json',
|
||||||
success: function (countries) {
|
success: function (countries) {
|
||||||
|
|
||||||
var orangeCountries = countries.filter(function hasLink(c) {
|
var basedCountries = countries.filter(function hasLink(c) {
|
||||||
var hasLink = c.link ? true : false;
|
var hasLink = c.link ? true : false;
|
||||||
return hasLink;
|
return hasLink;
|
||||||
});
|
});
|
||||||
var orangeCountryCodes = orangeCountries.map(function(c) {
|
var basedCountryCodes = basedCountries.map(function(c) {
|
||||||
return c.alpha3;
|
return c.alpha3;
|
||||||
});
|
});
|
||||||
function isOrange(iso) {
|
function isBased(iso) {
|
||||||
return orangeCountryCodes.includes(iso);
|
return basedCountryCodes.includes(iso);
|
||||||
}
|
}
|
||||||
function getColor(iso) {
|
function getColor(iso) {
|
||||||
let country = countries.find(c => c.alpha3 == iso);
|
let country = countries.find(c => c.alpha3 == iso);
|
||||||
@@ -72,13 +72,13 @@ qtip: '/js/jquery.qtip.min.js'
|
|||||||
fill: cGray
|
fill: cGray
|
||||||
},
|
},
|
||||||
mouseenter: function (d, path) {
|
mouseenter: function (d, path) {
|
||||||
if (!isOrange(d.iso)) {
|
if (!isBased(d.iso)) {
|
||||||
path.attr('fill', Math.random() < 0.5 ? cDarkOrange : cDarkWhite );
|
path.attr('fill', Math.random() < 0.5 ? cDarkOrange : cDarkWhite );
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
mouseleave: function (d, path) {
|
mouseleave: function (d, path) {
|
||||||
if (!isOrange(d.iso)) {
|
if (!isBased(d.iso)) {
|
||||||
path.animate({ fill: getColor(d.iso) }, 1000);
|
path.animate({ fill: getColor(d.iso) }, 1000);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user