fix: update scraper settings and modify scrape form to use POST method
Some checks failed
CI/CD Pipeline / test (push) Successful in 1m32s
CI/CD Pipeline / build-image (push) Failing after 1m41s

This commit is contained in:
2026-01-07 16:25:35 +01:00
parent f8a5b1b5ef
commit 54ed111078
5 changed files with 60 additions and 25 deletions

View File

@@ -29,9 +29,12 @@ function fetchJobs() {
.catch((error) => console.error("Error fetching jobs:", error));
}
const scrapeForm = document.getElementById("scrape-form");
scrapeForm.addEventListener("submit", scrape);
// scrape form submission
function updateScrapeInfo(message, color) {
let scrapingInfo = document.getElementById("scrape-info");
const scrapingInfo = document.getElementById("scrape-info");
scrapingInfo.style.display = "inline-block"; // Show the scraping info
scrapingInfo.innerText = message;
scrapingInfo.style.color = color;
@@ -40,7 +43,8 @@ function updateScrapeInfo(message, color) {
function scrape(event) {
event.preventDefault(); // Prevent the default form submission
updateScrapeInfo("Scraping in progress...", "blue");
fetch("/scrape")
// Send POST request to /scrape endpoint
fetch(scrapeForm.action, { method: "POST" })
// expect HTML response containing "Scraping completed successfully!"
.then((response) => response.text())
.then((data) => {
@@ -82,6 +86,32 @@ function keywordClick(event) {
updateJobsFiltered();
}
function favoriteClick(event) {
event.preventDefault();
const button = event.target;
const username = button.getAttribute("data-username");
const jobId = button.getAttribute("data-job-id");
fetch(`/jobs/${jobId}/favorite`, { method: "POST" })
.then((response) => response.json())
.then((data) => {
if (data.status === "success") {
// Toggle favorite state in the button
if (data.is_favorite) {
button.innerText = "★";
} else {
button.innerText = "☆";
}
} else {
console.error("Error updating favorite:", data.message);
}
})
.catch((error) => console.error("Error:", error));
}
document.querySelectorAll(".favorite-button").forEach((element) => {
element.addEventListener("click", favoriteClick);
});
document.querySelectorAll(".job-keyword").forEach((element) => {
element.addEventListener("click", keywordClick);
});
@@ -89,7 +119,6 @@ document.querySelectorAll(".job-region").forEach((element) => {
element.addEventListener("click", regionClick);
});
document.getElementById("scrape-form").addEventListener("submit", scrape);
document
.getElementById("region")
.addEventListener("change", updateJobsFiltered);