Skip to content

Commit

Permalink
refactor: Ditch JQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
TAEMBO committed Jun 6, 2024
1 parent 43cc0a2 commit 2d02405
Showing 2 changed files with 19 additions and 35 deletions.
18 changes: 3 additions & 15 deletions src/app.html
Original file line number Diff line number Diff line change
@@ -34,22 +34,10 @@
%sveltekit.body%
<script type="text/javascript"></script>

<!-- Bootstrap Core JavaScript -->
<script
src="https://unpkg.com/[email protected]/dist/jquery.min.js"
integrity="sha512-3gJwYpMe3QewGELv8k/BX9vcqhryRdzRMxVfq6ngyWXwo03GFEzjsUm8Q7RZcHPHksttq7/GFoxjCVUjkjvPdw=="
crossorigin="anonymous"
></script>

<!-- Bootstrap -->
<script
src="https://unpkg.com/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4"
crossorigin="anonymous"
></script>

<!-- Custom Scripts -->
<!-- Leaflet map -->
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>

<!-- Custom script -->
<script src="%sveltekit.assets%/script.js"></script>
</body>
</html>
36 changes: 16 additions & 20 deletions static/script.js
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ function toggleDarkMode() {
}
}

$(document).ready(() => {
document.addEventListener('DOMContentLoaded', () => {
if (localStorage.getItem('isDark')) {
document.body.classList.toggle('dark-mode');
queryAllSet('.card', '.list-group', '.list-group-item > a');
@@ -63,25 +63,21 @@ $(document).ready(() => {

map.on('drag', () => map.panInsideBounds([[-749, -749], [749, 749]], { animate: false }));

$.ajax({
type: "GET",
url: `/api/geojson/${serverAcro}`,
dataType: "json",
success: (geojson) => {
new L.GeoJSON(geojson, {
onEachFeature: (_, layer) => {
if (!(layer instanceof L.Marker)) return;

layer.bindPopup(layer.feature.properties.popup);
fetch(`/api/geojson/${serverAcro}`).then(x => x.json()).then(data => {
new L.GeoJSON(data, {
onEachFeature: (_, layer) => {
if (!(layer instanceof L.Marker)) return;

layer.setIcon(L.icon({
iconUrl: '/icons/' + layer.feature.properties.icon.icon,
iconSize: [layer.feature.properties.icon.dimension, layer.feature.properties.icon.dimension],
iconAnchor: [(layer.feature.properties.icon.dimension / 2), (layer.feature.properties.icon.dimension / 2)],
popupAnchor: [0, -10]
}));
}
}).addTo(map);
}
layer.bindPopup(layer.feature.properties.popup);

layer.setIcon(L.icon({
iconUrl: '/icons/' + layer.feature.properties.icon.icon,
iconSize: [layer.feature.properties.icon.dimension, layer.feature.properties.icon.dimension],
iconAnchor: [(layer.feature.properties.icon.dimension / 2), (layer.feature.properties.icon.dimension / 2)],
popupAnchor: [0, -10]
}));
}
}).addTo(map);
});
});
}, false);

0 comments on commit 2d02405

Please sign in to comment.