use different api for country code/flag that support https
This commit is contained in:
parent
33a427bb8a
commit
8b06da5783
@ -23,7 +23,7 @@
|
||||
</div>
|
||||
<!-- Name/Level Column -->
|
||||
<div class="w-50 d-block d-lg-inline-flex flex-column flex-fill text-center text-lg-left pb-3 pb-lg-0 pt-3 pt-lg-0 pl-3 pr-3 ml-auto mr-auto" style="overflow-wrap: anywhere">
|
||||
<div class="mt-n2 d-block d-lg-inline-flex">
|
||||
<div class="mt-n2 d-block d-lg-inline-flex @(ViewBag.Authorized ? "" : "flex-fill")">
|
||||
<div id="profile_name" class="client-name h1 mb-0">
|
||||
<color-code value="@Model.Name" allow="@ViewBag.EnableColorCodes"></color-code>
|
||||
</div>
|
||||
@ -35,12 +35,9 @@
|
||||
|
||||
@if (ViewBag.Authorized)
|
||||
{
|
||||
<div class="d-flex flex-row justify-content-start flex-fill flex-column flex-md-row mr-2 mb-2 mb-md-0">
|
||||
<div class="ip-lookup-profile align-self-center mr-0 mr-md-2"
|
||||
data-ip="@Model.IPAddress"
|
||||
style="background-image: url('http://api.hostip.info/flag.php?ip=@Model.IPAddress'); height: 2.5rem; min-width: 3.0rem; background-size: contain; background-repeat: no-repeat; background-position: center;">
|
||||
</div>
|
||||
<div id="ip_lookup_country" class="h4 mb-0 align-self-center text-muted"></div>
|
||||
<div class="d-flex flex-row justify-content-start flex-fill flex-column flex-lg-row mr-lg-2 mb-2 mb-md-0">
|
||||
<div class="ip-lookup-profile align-self-center mr-0 mr-lg-2 ml-lg-n1" data-ip="@Model.IPAddress"></div>
|
||||
<div id="ip_lookup_country" class="h4 mb-2 mb-lg-0 align-self-center text-muted"></div>
|
||||
</div>
|
||||
|
||||
<div id="profile_aliases" class="text-muted pt-0 pt-lg-2 pb-2">
|
||||
|
@ -201,3 +201,11 @@
|
||||
background-color: $dark;
|
||||
color: $white !important;
|
||||
}
|
||||
|
||||
.ip-lookup-profile {
|
||||
height: 2.5rem;
|
||||
min-width: 3.0rem;
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
}
|
||||
|
@ -12,9 +12,22 @@
|
||||
|
||||
const ipAddresses = $('.ip-lookup-profile');
|
||||
$.each(ipAddresses, function (index, address) {
|
||||
$.get('http://ip-api.com/json/' + $(address).data('ip'), function (result) {
|
||||
const country = result['country'];
|
||||
$('#ip_lookup_country').text(country)
|
||||
let ip = $(address).data('ip');
|
||||
if (ip.length === 0) {
|
||||
return;
|
||||
}
|
||||
$.get('https://ip2c.org/' + ip, function (result) {
|
||||
const countryCode = result.split(';')[1].toLowerCase();
|
||||
const country = result.split(';')[3];
|
||||
|
||||
if (country === 'Unknown') {
|
||||
return;
|
||||
}
|
||||
|
||||
$('#ip_lookup_country').text(country);
|
||||
if (countryCode !== 'zz' && countryCode !== '') {
|
||||
$(address).css('background-image', `url(https://www.countryflags.io/${countryCode}/flat/64.png)`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user