Skip to content

Commit

Permalink
Merge pull request #23 from unboxed/jquery
Browse files Browse the repository at this point in the history
Replace some jquery with standard javascript
  • Loading branch information
HonTastic2 committed Jul 25, 2024
2 parents e4de299 + 25ad80a commit b3f4716
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
6 changes: 0 additions & 6 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"axios": "^1.7.2",
"govuk-frontend": "^5.4.0",
"govuk-react": "^0.10.7",
"jquery": "^3.7.1",
"leaflet": "^1.9.4",
"nth-check": ">=2.0.1",
"react": "^18.3.1",
Expand Down
16 changes: 12 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import './App.css';
import './govuk-styles.scss';
import axios from 'axios';
import LocationMarker from './LocationMarker';
import $ from 'jquery';
// import data from './london-spots.json';
let pageSize = 50;
let zoomSize = 16;
Expand Down Expand Up @@ -55,6 +54,15 @@ const fetchPostCode = async(postcode) => {
}
}

// https://youmightnotneedjquery.com/#ready
function ready(fn) {
if (document.readyState !== 'loading') {
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}

// const fetchApplicationDocs = async(ref) => {
// try {
// const response = await axios.get(apiUrl + ref + "/documents");
Expand Down Expand Up @@ -163,7 +171,7 @@ function App () {
let loaded = false;
loaded = await(!loading);
if (loaded) {
$("#applicationTableBody").empty();
document.querySelector("#applicationTableBody").replaceChildren();

if (data === null) {return;}

Expand All @@ -183,7 +191,7 @@ function App () {
featureHTML += `<td class='govuk-table__cell'><a class='govuk-link' href='${feature.publicUrl}' target='_blank'>More info</a></td></tr>`;
}

$("#applicationTable").find('tbody').append(featureHTML);
document.querySelector("#applicationTable").querySelector('tbody').append(featureHTML);
}
}
}
Expand Down Expand Up @@ -378,7 +386,7 @@ function App () {

if (loading) {return (<div>Loading...</div>);}

$(document).ready(async() => {
ready(async() => {
populateTable(geojson);
});

Expand Down

0 comments on commit b3f4716

Please sign in to comment.