Skip to content
Snippets Groups Projects
Verified Commit 473e0c9a authored by Jan Pavlinec's avatar Jan Pavlinec
Browse files

ludus: fix error with unknown country

parent 256a8ac4
No related merge requests found
......@@ -122,12 +122,13 @@ class LudusSysFunc(object):
ret = reader.get(ipv4)
name = None
iso_code = None
if "country" in ret:
iso_code = ret.get("country").get("iso_code")
name = ret.get("country").get("names").get("en")
elif "continent" in ret:
iso_code = ret.get("continent").get("code")
name = ret.get("continent").get("names").get("en")
if ret:
if "country" in ret:
iso_code = ret.get("country").get("iso_code")
name = ret.get("country").get("names").get("en")
elif "continent" in ret:
iso_code = ret.get("continent").get("code")
name = ret.get("continent").get("names").get("en")
reader.close()
return {"name": name, "iso_code": iso_code}
......
......@@ -259,6 +259,10 @@ function setBoxAttackers (data) {
function setTblAlerts (data) {
$('#top10_tbl').html('')
data.reverse().slice(0, 10).forEach(function (item) {
if(item.country_iso == null) {
item.country = "Unknown country"
item.country_iso = ""
}
$('#top10_tbl').append(
'<tr><td>' + '<span class="flag-icon flag-icon-' + item.country_iso.toLowerCase() + '"></span>&nbsp;' +
item.country + '</td>' +
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment