Skip to content

Commit

Permalink
Post a geoattempt
Browse files Browse the repository at this point in the history
  • Loading branch information
frasanz committed Sep 21, 2024
1 parent 74bc826 commit cbde2bd
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion frontend/templates/task2.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ <h3>Lost at night</h3>

$(document).ready(function () {

// Function to parse the coordinate string and convert to decimal degrees
// Function to parse the coordinate string and convert to decimal degrees
function parseCoordinates(coordString) {
const regex = /([0-9.]+)°\s*([NS]),\s*([0-9.]+)°\s*([EW])/;
const matches = coordString.match(regex);
Expand Down Expand Up @@ -184,6 +184,34 @@ <h3>Lost at night</h3>
stopContextMenu: true, // Disable the default context menu
selection: false // Disable object selection
});

// Add buttons behavior
$('#Test').on('click', function () {
if (iconList.length < 1) {
var myModal = new bootstrap.Modal(document.getElementById('exampleModal'), {
keyboard: true // Allows closing the modal with the Esc key
});
myModal.textContent = 'Few control points!'; // Set the modal content
$('.modal-body').html('Please add at least three control points.'); // Set the modal body content
myModal.show(); // Show the modal
return;
} else {
// Doing a post request to the backend
$.ajax({
url: 'http://127.0.0.1:8000/api/v1/post-geoattempt/',
type: 'POST',
dataType: 'json',
data: {
'image_name': image_name,
'iconList': JSON.stringify(iconList)
},
})
}
});
$('#Skip').on('click', function () {
// Reload page
location.reload();
});
const static_url = "{% static 'images/' %}";
const imageUrl = static_url + image_name + '.JPG'; // Image URL
console.log(response);
Expand Down

0 comments on commit cbde2bd

Please sign in to comment.