templates/includes/blocks/jobs.html.twig line 1
{% set propertyName = propertyName|default('blocks') %}<style>.custom-job-listing {position: relative;width: 100%;padding-bottom: 1rem;}.job-list.job-list {list-style-type: none;padding: 0;margin-left: 0;}.job-list__item {margin-bottom: 5px;border-bottom: 1px solid #ddd;padding-bottom: 2px;font-size: 0.9em;display: flex;& h5, h6 {color: var(--color-primary);text-decoration: none;font-weight: 700;font-family: Roboto, sans-serif;font-style: normal;}& h5 {font-size: 29px;}& h6 {font-size: 18px;}}@media (max-width: 640px) {.job-list__item {flex-direction: column;}}.job-list__item__left {display: flex;flex-direction: column;flex-grow: 1;}.job-list__item__right {display: flex;flex-direction: column;}.job-list__link {}.job-list__link:hover {}.job-list__title {font-size: 1.1em;}.pagination {display: flex;justify-content: center;margin-top: 20px;}.pagination__button {padding: 5px 10px;margin: 0 5px;background-color: #007bff;color: white;border: none;border-radius: 4px;cursor: pointer;}.pagination__button:disabled {background-color: #ccc;cursor: default;}.pagination__page-number {font-size: larger;}.loading-overlay {display: none; /* Standardmäßig versteckt */position: absolute; /* Positionierung über dem gesamten Inhalt */top: 0;left: 0;width: 100%;height: 100%;background: rgba(255, 255, 255, 0.5); /* Leicht transparenter Hintergrund */backdrop-filter: blur(5px); /* Unscharfer Hintergrund-Effekt */justify-content: center;align-items: center;z-index: 1000; /* Stellt sicher, dass es über anderen Elementen liegt */}.loading-indicator {font-size: 1.5em;}.job-counter{font-size: small;}</style><div class="grid-container"><div class="grid-x grid-margin-x"><div class="custom-job-listing"><div class="loading-overlay"><div class="loading-indicator">Jobs werden geladen...</div></div><ul class="job-list"></ul><div class="job-counter"></div><div class="error-message" style="display: none"></div><div class="pagination"><button class="pagination__button pagination__button--prev">Zurück</button><span class="pagination__page-number">1</span><button class="pagination__button pagination__button--next">Weiter</button></div></div></div></div><script>document.addEventListener("DOMContentLoaded", function () {const jobManager = new JobManager();jobManager.init();});class JobManager {constructor() {this.currentPage = 1;this.pageSize = 10;this.searchText = "";this.searchZipCode = "";this.searchZipCodeRadius = 50;this.totalPages = 0;this.artemisUrl = "https://ndh.artemis.aveo-solutions.net/GetAktuelleStellenanzeigen";}init() {this.fetchJobs();this.setupEventListeners();}fetchJobs() {this.showLoadingIndicator(true);const url = `${this.artemisUrl}?perPage=${this.pageSize}&page=${this.currentPage}&suchText=${this.searchText}&suchOrt=${this.searchZipCode}&radius=${this.searchZipCodeRadius}`;fetch(url).then((response) => this.handleResponse(response)).then((data) => this.processJobData(data)).catch((error) => this.handleError(error)).finally(() => this.showLoadingIndicator(false));}handleResponse(response) {if (!response.ok) {throw new Error(`HTTP error! status: ${response.status}`);}return response.json();}processJobData(data) {this.updateJobCount(data.totalResults);this.displayJobs(data.results);this.updatePagination(data.totalResults);}updateJobCount(totalJobs) {this.totalJobs = totalJobs;this.updateJobRangeDisplay();}displayJobs(jobs) {const jobsList = document.querySelector(".job-list");jobsList.innerHTML = jobs.map((job) => this.jobTemplate(job)).join("");}jobTemplate(job) {console.log(job);return `<li class="job-list__item"><div class="job-list__item__left"><h6>${job.arbeitsort}</h6><a class="job-list__link" href="${job.bewerbenUrl}" target="_blank"><h5>${job.name}</h5></a></div><div class="job-list__item__right"><a class="button-wrapper pt-0" href="${job.bewerbenUrl}" target="_blank" rel="external"><span class="btn btn-primary">Details</span></a></div></li>`;}updatePagination(totalJobs) {this.totalPages = Math.ceil(totalJobs / this.pageSize);this.updatePaginationControls();}setupEventListeners() {document.querySelector(".pagination__button--prev").addEventListener("click", () => this.changePage(-1));document.querySelector(".pagination__button--next").addEventListener("click", () => this.changePage(1));}changePage(delta) {const newPage = this.currentPage + delta;if (newPage > 0 && newPage <= this.totalPages) {this.currentPage = newPage;this.fetchJobs();this.updatePaginationDisplay();this.updateJobRangeDisplay();}}updatePaginationDisplay() {document.querySelector(".pagination__page-number").textContent =this.currentPage;this.updatePaginationControls();}updatePaginationControls() {document.querySelector(".pagination__button--prev").disabled =this.currentPage <= 1;document.querySelector(".pagination__button--next").disabled =this.currentPage >= this.totalPages;document.querySelector(".pagination").style.display =this.totalPages <= 1 ? "none" : "";}updateJobRangeDisplay() {const startJobNumber = (this.currentPage - 1) * this.pageSize + 1;const endJobNumber = Math.min(this.currentPage * this.pageSize,this.totalJobs);const jobCountElement = document.querySelector(".job-counter");jobCountElement.textContent = `Jobs ${startJobNumber} bis ${endJobNumber} von ${this.totalJobs}`;}showLoadingIndicator(show) {const overlay = document.querySelector(".loading-overlay");overlay.style.display = show ? "flex" : "none";}handleError(error) {const errorContainer = document.querySelector(".error-message");errorContainer.textContent = `Error: ${error.message}`;errorContainer.style.display = "block";}}</script>