Skip to content

Commit

Permalink
fix bug and add flag and long name
Browse files Browse the repository at this point in the history
  • Loading branch information
nimrod-cohen committed Nov 19, 2024
1 parent edab8b7 commit 8ca330f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
6 changes: 6 additions & 0 deletions assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
color: red;
}

#test-ip img.flag {
width: 16px;
height: 11px;
margin-right: 5px;
}

.fv-country-list {
max-height: 400px;
overflow-y: scroll;
Expand Down
2 changes: 1 addition & 1 deletion assets/css/admin.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions assets/css/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
color: red;
}

#test-ip {
img.flag {
width: 16px;
height: 11px;
margin-right: 5px;
}
}

.fv-country-list {
max-height: 400px;
overflow-y: scroll;
Expand Down
15 changes: 13 additions & 2 deletions assets/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,23 @@ document.addEventListener('DOMContentLoaded', () => {
})
});

const capitalize = s =>
s
.split(' ')
.map(w => w.charAt(0).toUpperCase() + w.slice(1))
.join(' ');

const data = await response.json();
const result = document.querySelector('.test-ip-result');
result.innerHTML = '';
if (data.success) {
result.textContent = data.country;
const country = document.querySelector(`label.country-item[data-code='${data.data.toLowerCase()}']`);
const img = country.querySelector('img');
const clone = img.cloneNode(true);
result.innerHTML = `<span>${capitalize(country.dataset.longName)}</span>`;
result.insertBefore(clone, result.firstChild);
} else {
result.textContent = data.data;
result.textContent = `Failed: ${data.data}`;
}
} finally {
e.target.disabled = false;
Expand Down
2 changes: 1 addition & 1 deletion fv-country-blocker.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: FV Country Blocker
* Plugin URI: https://github.com/nimrod-cohen/fv-country-blocker
* Description: Block visitors from specific countries using MaxMind GeoIP database.
* Version: 1.1.0
* Version: 1.1.1
* Author: nimrod-cohen
* Author URI: https://github.com/nimrod-cohen/fv-country-blocker
* License: GPL-2.0+
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: country blocker, IP blocker, geo-blocking, security
Requires at least: 5.0
Tested up to: 6.0
Requires PHP: 7.0
Stable tag: 1.1.0
Stable tag: 1.1.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down

0 comments on commit 8ca330f

Please sign in to comment.