Skip to content

Commit

Permalink
Coverage (#90)
Browse files Browse the repository at this point in the history
* git ignoring coverage output

* refactoring embedded script
  • Loading branch information
eebbesen authored Oct 9, 2024
1 parent 5b34d87 commit aca2d35
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
coverage
mochawesome-report

11 changes: 4 additions & 7 deletions public/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ export function formatGeoInfo(loc) {
return str;
}

export function showLocations(html) {
document.querySelector('#results').innerHTML = html;
}

export function locationError(err) {
console.log('Error getting location', err);
let message = `
Expand All @@ -47,15 +43,15 @@ export function locationError(err) {
return `${message}</div>`;
}

export function populateResults(c) {
export function populateResults() {
navigator.geolocation.getCurrentPosition(
function (location) {
const xhr = new XMLHttpRequest();
xhr.onload = function () {
const json = JSON.parse(xhr.response);
const html = formatResults(json);

return showLocations(html);
return (document.querySelector('#results').innerHTML = html);
};
xhr.open(
'GET',
Expand All @@ -68,7 +64,8 @@ export function populateResults(c) {
xhr.send();
},
function (err) {
return showLocations(locationError(err));
return (document.querySelector('#results').innerHTML =
locationError(err));
},
);
}
Expand Down
11 changes: 4 additions & 7 deletions src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ export function formatGeoInfo(loc) {
return str;
}

export function showLocations(html) {
document.querySelector('#results').innerHTML = html;
}

export function locationError(err) {
console.log('Error getting location', err);
let message = `
Expand All @@ -47,15 +43,15 @@ export function locationError(err) {
return `${message}</div>`;
}

export function populateResults(c) {
export function populateResults() {
navigator.geolocation.getCurrentPosition(
function (location) {
const xhr = new XMLHttpRequest();
xhr.onload = function () {
const json = JSON.parse(xhr.response);
const html = formatResults(json);

return showLocations(html);
return (document.querySelector('#results').innerHTML = html);
};
xhr.open(
'GET',
Expand All @@ -68,7 +64,8 @@ export function populateResults(c) {
xhr.send();
},
function (err) {
return showLocations(locationError(err));
return (document.querySelector('#results').innerHTML =
locationError(err));
},
);
}
Expand Down

0 comments on commit aca2d35

Please sign in to comment.