зеркало из https://github.com/mozilla/kitsune.git
only do IP geolocation on step 3 of subscription-based AAQs
https://github.com/mozilla/sumo-project/issues/957
This commit is contained in:
Родитель
9fae4dc69a
Коммит
8882074746
|
@ -1,14 +1,18 @@
|
|||
window.addEventListener("DOMContentLoaded", (event) => {
|
||||
const geoIPUrl = 'https://location.services.mozilla.com/v1/country?key=fa6d7fc9-e091-4be1-b6c1-5ada5815ae9d';
|
||||
fetch(geoIPUrl)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`Fetch failed, status ${response.status}`)
|
||||
}
|
||||
return response.json();
|
||||
const countryField = document.querySelector('input#id_country');
|
||||
|
||||
})
|
||||
.then(data => {
|
||||
document.getElementById("id_country").value = data.country_name;
|
||||
})
|
||||
});
|
||||
if (countryField) {
|
||||
fetch(geoIPUrl)
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`Fetch failed, status ${response.status}`)
|
||||
}
|
||||
return response.json();
|
||||
|
||||
})
|
||||
.then(data => {
|
||||
countryField.value = data.country_name;
|
||||
})
|
||||
}
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче