|
|
|
@@ -2,13 +2,12 @@ document.addEventListener("DOMContentLoaded", function () { |
|
|
|
|
|
|
|
let groupSelectElement = document.getElementById("election-group"), |
|
|
|
areaSelectElement = document.getElementById("election-area"), |
|
|
|
formContainer = document.querySelector(".election-form--form"), |
|
|
|
electionDetail = document.querySelector(".election-detail"); |
|
|
|
formContainer = document.querySelector(".election-form--form"); |
|
|
|
|
|
|
|
// STEP 1: LOAD SEARCH ITEMS |
|
|
|
|
|
|
|
// Load all groups and areas |
|
|
|
if(formContainer) { |
|
|
|
if (formContainer) { |
|
|
|
fetch("https://ihk-wahl.info/selects?ihk_id=M6uOiDGzTD7SlhF1") |
|
|
|
.then(response => { |
|
|
|
if (!response.ok) { |
|
|
|
@@ -99,6 +98,7 @@ document.addEventListener("DOMContentLoaded", function () { |
|
|
|
}); |
|
|
|
|
|
|
|
document.addEventListener("click", function (event) { |
|
|
|
// click one of the search again links |
|
|
|
if (event.target && (event.target.getAttribute("data-search") === "group" || event.target.getAttribute("data-search") === "area")) { |
|
|
|
let id = event.target.getAttribute("data-id"); |
|
|
|
document.getElementById("election-searchstring").value = ""; |
|
|
|
@@ -111,199 +111,26 @@ document.addEventListener("DOMContentLoaded", function () { |
|
|
|
} |
|
|
|
submitForm(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// STEP 3: LOAD DETAIL PAGE |
|
|
|
|
|
|
|
// Get the URL query string parameters |
|
|
|
const queryParams = new URLSearchParams(window.location.search); |
|
|
|
|
|
|
|
if (electionDetail && queryParams.has('ihk_id') && queryParams.has('c')) { |
|
|
|
// Get the values of the 'c' and 'a' parameters |
|
|
|
const ihkIdValue = queryParams.get('ihk_id'); |
|
|
|
const cValue = queryParams.get('c'); |
|
|
|
|
|
|
|
console.log('Value of "c":', ihkIdValue); |
|
|
|
console.log('Value of "a":', cValue); |
|
|
|
|
|
|
|
let electionDetailText = electionDetail.querySelector('.election-detail--text'), |
|
|
|
electionDetailVideo = electionDetail.querySelector('.election-detail--video'), |
|
|
|
electionDetailInfo = electionDetail.querySelector('.election-detail--info'), |
|
|
|
htmlText = '', |
|
|
|
htmlVideo = '', |
|
|
|
htmlInfo = ''; |
|
|
|
|
|
|
|
fetch("https://ihk-wahl.info/candidate?ihk_id=" + ihkIdValue + "&candidate=" + cValue) |
|
|
|
.then(response => { |
|
|
|
if (!response.ok) { |
|
|
|
throw new Error('Network response was not ok'); |
|
|
|
} |
|
|
|
return response.json(); |
|
|
|
}) |
|
|
|
.then(data => { |
|
|
|
console.log(data); |
|
|
|
// Build the detail page for the candidate |
|
|
|
|
|
|
|
htmlText += data.img_path ? ` |
|
|
|
<img src="${data.img_path}" loading="lazy" class="loading" width="545" height="526"> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += '<div class="text-box">'; |
|
|
|
|
|
|
|
htmlText += (data.first_name && data.last_name) ? ` |
|
|
|
<h1>${data.first_name} ${data.last_name}</h1> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += data.position ? ` |
|
|
|
<p class="subheadline">${data.position}</p> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += data.election_statement ? ` |
|
|
|
<h2>Was möchten Sie bewegen?</h2> |
|
|
|
<p>${data.election_statement}</p> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
if (data.twitter_link || data.facebook_link || data.xing_link || |
|
|
|
data.whatsapp_link || data.linkedin_link || data.threema_link || |
|
|
|
data.telegram_link) { |
|
|
|
htmlText += ` |
|
|
|
<div class="social-media"> |
|
|
|
<p>Meine Kanäle</p> |
|
|
|
<ul class="social-icons"> |
|
|
|
`; |
|
|
|
} |
|
|
|
|
|
|
|
htmlText += data.twitter_link ? ` |
|
|
|
<li><a class="social-share twitter" href="${data.twitter_link}"></a></li> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += data.facebook_link ? ` |
|
|
|
<li><a class="social-share facebook" href="${data.facebook_link}"></a></li> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += data.xing_link ? ` |
|
|
|
<li><a class="social-share xing" href="${data.xing_link}"></a></li> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += data.whatsapp_link ? ` |
|
|
|
<li><a class="social-share whatsapp" href="${data.whatsapp_link}"></a></li> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += data.linkedin_link ? ` |
|
|
|
<li><a class="social-share linkedin" href="${data.linkedin_link}"></a></li> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += data.threema_link ? ` |
|
|
|
<li><a class="social-share threema" href="${data.threema_link}"></a></li> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += data.telegram_link ? ` |
|
|
|
<li><a class="social-share telegram" href="${data.telegram_link}"></a></li> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
if (data.twitter_link || data.facebook_link || data.xing_link || |
|
|
|
data.whatsapp_link || data.linkedin_link || data.threema_link || |
|
|
|
data.telegram_link) { |
|
|
|
htmlText += ` |
|
|
|
</ul> |
|
|
|
</div> |
|
|
|
`; |
|
|
|
} |
|
|
|
|
|
|
|
htmlText += '</div>'; |
|
|
|
|
|
|
|
electionDetailText.innerHTML = htmlText; |
|
|
|
|
|
|
|
htmlVideo += data.video_path ? ` |
|
|
|
<div className="video-container"> |
|
|
|
<figure className="video"> |
|
|
|
<div className="video-box"> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
if (data.video_path && data.video_img_path) { |
|
|
|
htmlVideo += ` |
|
|
|
<video src="${data.video_path}" controls="" poster="${data.video_img_path}"></video> |
|
|
|
`; |
|
|
|
} else if (data.video_path) { |
|
|
|
htmlVideo += ` |
|
|
|
<video src="${data.video_path}" controls=""></video> |
|
|
|
`; |
|
|
|
} |
|
|
|
|
|
|
|
htmlVideo += data.video_path ? ` |
|
|
|
</div> |
|
|
|
</figure> |
|
|
|
</div> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
electionDetailVideo.innerHTML = htmlVideo; |
|
|
|
|
|
|
|
htmlInfo += (data.candidate_election_group_id && data.candidate_election_group_name) ? ` |
|
|
|
<div class="info-box info-box-01"> |
|
|
|
<p class="info-headline">Wahlgruppe 02</p> |
|
|
|
<p class="info-box--content info-box--text"> |
|
|
|
<a href="${data.candidate_election_group_id}">${data.candidate_election_group_name}</a> |
|
|
|
</p> |
|
|
|
</div> |
|
|
|
` : ''; |
|
|
|
htmlInfo += (data.candidate_election_district_id && data.candidate_election_district_name) ? ` |
|
|
|
<div class="info-box info-box-02"> |
|
|
|
<p class="info-headline">Wahlbezirk 05</p> |
|
|
|
<p class="info-box--content info-box--text"> |
|
|
|
<a href="${data.candidate_election_district_id}">${data.candidate_election_district_name}</a> |
|
|
|
</p> |
|
|
|
</div> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlInfo += '<div class="info-box info-box-03">'; |
|
|
|
|
|
|
|
htmlInfo += data.company ? ` |
|
|
|
<p class="info-headline">Unternehmen</p> |
|
|
|
<div class="info-box--content"> |
|
|
|
<p class="headline">${data.company}</p> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlInfo += data.company_address ? ` |
|
|
|
<p className="address">${data.company_address}</p> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlInfo += data.website ? ` |
|
|
|
<p> |
|
|
|
<a href="${data.website}" target="_blank">Unternehmenswebseite</a> |
|
|
|
</p> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlInfo += data.email ? ` |
|
|
|
<p> |
|
|
|
<a href="mailto:${data.email}">E-Mail</a> |
|
|
|
</p> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
if (data.phone) { |
|
|
|
|
|
|
|
htmlInfo += ` |
|
|
|
<p> |
|
|
|
<a href="tel:${formatNumberLink(data.phone)}">${formatNumberOutput(data.phone)}</a> |
|
|
|
</p> |
|
|
|
`; |
|
|
|
} |
|
|
|
// click the detail page link |
|
|
|
const topBoxElement = event.target.closest(".top-box"); |
|
|
|
if (topBoxElement) { |
|
|
|
let ihkId = topBoxElement.getAttribute("data-ihk_id"), |
|
|
|
candidate = topBoxElement.getAttribute("data-c"); |
|
|
|
showDetailPage(event, ihkId, candidate); |
|
|
|
} |
|
|
|
|
|
|
|
htmlInfo += data.company ? ` |
|
|
|
</div> |
|
|
|
` : ''; |
|
|
|
// click the back button |
|
|
|
if (event.target.closest(".election-detail--back a")) { |
|
|
|
event.preventDefault(); |
|
|
|
hideDetailPage(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
htmlInfo += '</div>'; |
|
|
|
// STEP 3 NEW: SET LINK AND LOAD DETAIL PAGE |
|
|
|
|
|
|
|
electionDetailInfo.innerHTML = htmlInfo; |
|
|
|
|
|
|
|
}) |
|
|
|
.catch(error => { |
|
|
|
// Handle errors here |
|
|
|
console.error('Fetch error:', error); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
function submitForm(e) { |
|
|
|
@@ -402,12 +229,12 @@ function submitForm(e) { |
|
|
|
sortedCandidates.forEach(function (candidate) { |
|
|
|
let html = ` |
|
|
|
<div class="election-result-list-item"> |
|
|
|
<a class="top-box" href="index2.html?ihk_id=${data.ihk_id}&c=${candidate.candidate_id}"> |
|
|
|
<span class="top-box" data-ihk_id="${data.ihk_id}" data-c="${candidate.candidate_id}"> |
|
|
|
<div class="image-box"> |
|
|
|
<img src="${candidate.img_path}" loading="lazy" class="loading" width="310" height="310"> |
|
|
|
</div> |
|
|
|
<h3>${candidate.first_name} ${candidate.last_name}</h3> |
|
|
|
</a> |
|
|
|
</span> |
|
|
|
<div class="text-box"> |
|
|
|
<div class="job-box"> |
|
|
|
<span class="icon-small-election-group" data-search="group" data-id="${candidate.candidate_election_group_id}">${candidate.candidate_election_group_name}</span> |
|
|
|
@@ -434,54 +261,60 @@ function submitForm(e) { |
|
|
|
// Return phone number to call |
|
|
|
function formatNumberLink(phoneNo) { |
|
|
|
const phoneNoStripped = phoneNo.replace(/\D/g, ''); |
|
|
|
|
|
|
|
let formatedNo = phoneNoStripped; |
|
|
|
if (phoneNoStripped.startsWith('49')) { |
|
|
|
// has leading 49 - countrycode |
|
|
|
formatedNo = `00${phoneNoStripped}`; |
|
|
|
} else if (phoneNoStripped.startsWith('0')) { |
|
|
|
if (phoneNoStripped.startsWith('000')) { |
|
|
|
// has three leading zeros - countrycode with error? |
|
|
|
formatedNo = phoneNoStripped.substr(1); |
|
|
|
} else if (phoneNoStripped.startsWith('00')) { |
|
|
|
// has two leading zeros - countrycode |
|
|
|
// Do nothing |
|
|
|
} else { |
|
|
|
// has leading zero |
|
|
|
formatedNo = `0049${phoneNoStripped.substr(1)}`; |
|
|
|
if (phoneNoStripped !== "") { |
|
|
|
let formatedNo = phoneNoStripped; |
|
|
|
if (phoneNoStripped.startsWith('49')) { |
|
|
|
// has leading 49 - countrycode |
|
|
|
formatedNo = `00${phoneNoStripped}`; |
|
|
|
} else if (phoneNoStripped.startsWith('0')) { |
|
|
|
if (phoneNoStripped.startsWith('000')) { |
|
|
|
// has three leading zeros - countrycode with error? |
|
|
|
formatedNo = phoneNoStripped.substr(1); |
|
|
|
} else if (phoneNoStripped.startsWith('00')) { |
|
|
|
// has two leading zeros - countrycode |
|
|
|
// Do nothing |
|
|
|
} else { |
|
|
|
// has leading zero |
|
|
|
formatedNo = `0049${phoneNoStripped.substr(1)}`; |
|
|
|
} |
|
|
|
} |
|
|
|
return formatedNo; |
|
|
|
} |
|
|
|
return formatedNo; |
|
|
|
return phoneNo; |
|
|
|
} |
|
|
|
|
|
|
|
// Return phone number to show on website |
|
|
|
function formatNumberOutput(phoneNo) { |
|
|
|
const allowedChars = /[0-9\-\/\s]/g; |
|
|
|
const phoneNoStripped = phoneNo.match(allowedChars).join(''); |
|
|
|
let formatedNo = phoneNoStripped; |
|
|
|
|
|
|
|
if (phoneNoStripped.startsWith('49')) { |
|
|
|
// has leading 49 - countrycode |
|
|
|
formatedNo = `+${phoneNoStripped}`; |
|
|
|
} else if (phoneNoStripped.startsWith('0')) { |
|
|
|
if (phoneNoStripped.startsWith('000')) { |
|
|
|
// has three leading zeros - countrycode with error? |
|
|
|
formatedNo = `+${phoneNoStripped.substr(3)}`; |
|
|
|
} else if (phoneNoStripped.startsWith('00')) { |
|
|
|
// has two leading zeros - countrycode |
|
|
|
formatedNo = `+${phoneNoStripped.substr(2)}`; |
|
|
|
} else { |
|
|
|
// has leading zero |
|
|
|
formatedNo = `+49 ${phoneNoStripped.substr(1)}`; |
|
|
|
if (phoneNo.match(allowedChars) !== null) { |
|
|
|
const phoneNoStripped = phoneNo.match(allowedChars).join(''); |
|
|
|
let formatedNo = phoneNoStripped; |
|
|
|
|
|
|
|
if (phoneNoStripped.startsWith('49')) { |
|
|
|
// has leading 49 - countrycode |
|
|
|
formatedNo = `+${phoneNoStripped}`; |
|
|
|
} else if (phoneNoStripped.startsWith('0')) { |
|
|
|
if (phoneNoStripped.startsWith('000')) { |
|
|
|
// has three leading zeros - countrycode with error? |
|
|
|
formatedNo = `+${phoneNoStripped.substr(3)}`; |
|
|
|
} else if (phoneNoStripped.startsWith('00')) { |
|
|
|
// has two leading zeros - countrycode |
|
|
|
formatedNo = `+${phoneNoStripped.substr(2, 2)} ${phoneNoStripped.substr(4)}`; |
|
|
|
|
|
|
|
} else { |
|
|
|
// has leading zero |
|
|
|
formatedNo = `+49 ${phoneNoStripped.substr(1)}`; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Überprüfe, ob nach "+49" ein Leerzeichen folgt, falls nicht, füge es hinzu |
|
|
|
if (formatedNo.startsWith('+49') && !formatedNo.includes(' ', 3)) { |
|
|
|
formatedNo = `${formatedNo.slice(0, 3)} ${formatedNo.slice(3)}`; |
|
|
|
} |
|
|
|
// Überprüfe, ob nach "+49" ein Leerzeichen folgt, falls nicht, füge es hinzu |
|
|
|
if (formatedNo.startsWith('+49') && !formatedNo.includes(' ', 3)) { |
|
|
|
formatedNo = `${formatedNo.slice(0, 3)} ${formatedNo.slice(3)}`; |
|
|
|
} |
|
|
|
|
|
|
|
return formatedNo; |
|
|
|
return formatedNo; |
|
|
|
} |
|
|
|
return phoneNo; |
|
|
|
} |
|
|
|
|
|
|
|
// STEP 2B: CLICK BADGE (RELOAD SEARCH) |
|
|
|
@@ -500,4 +333,220 @@ function badgeClick(e) { |
|
|
|
searchElement.value = ""; |
|
|
|
} |
|
|
|
submitForm(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// STEP 3: LOAD DETAIL PAGE |
|
|
|
function showDetailPage(e, ihkIdValue, cValue) { |
|
|
|
let electionDetail = document.querySelector(".election-detail"), |
|
|
|
electionDetailText = electionDetail.querySelector('.election-detail--text'), |
|
|
|
electionDetailVideo = electionDetail.querySelector('.election-detail--video'), |
|
|
|
electionDetailInfo = electionDetail.querySelector('.election-detail--info'), |
|
|
|
htmlText = '', |
|
|
|
htmlVideo = '', |
|
|
|
htmlInfo = '', |
|
|
|
staticElectionOverviewElement = document.getElementById("static-election-overview"), |
|
|
|
staticElectionDetailElement = document.getElementById("static-election-detail"); |
|
|
|
|
|
|
|
fetch("https://ihk-wahl.info/candidate?ihk_id=" + ihkIdValue + "&candidate=" + cValue) |
|
|
|
.then(response => { |
|
|
|
if (!response.ok) { |
|
|
|
throw new Error('Network response was not ok'); |
|
|
|
} |
|
|
|
return response.json(); |
|
|
|
}) |
|
|
|
.then(data => { |
|
|
|
console.log(data); |
|
|
|
// Build the detail page for the candidate |
|
|
|
|
|
|
|
htmlText += data.img_path ? ` |
|
|
|
<img src="${data.img_path}" loading="lazy" class="loading" width="545" height="526"> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += '<div class="text-box">'; |
|
|
|
|
|
|
|
htmlText += (data.first_name && data.last_name) ? ` |
|
|
|
<h1>${data.first_name} ${data.last_name}</h1> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += data.position ? ` |
|
|
|
<p class="subheadline">${data.position}</p> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += data.election_statement ? ` |
|
|
|
<h2>Was möchten Sie bewegen?</h2> |
|
|
|
<p>${data.election_statement}</p> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
if (data.twitter_link || data.facebook_link || data.xing_link || |
|
|
|
data.whatsapp_link || data.linkedin_link || data.threema_link || |
|
|
|
data.telegram_link) { |
|
|
|
htmlText += ` |
|
|
|
<div class="social-media"> |
|
|
|
<p>Meine Kanäle</p> |
|
|
|
<ul class="social-icons"> |
|
|
|
`; |
|
|
|
} |
|
|
|
|
|
|
|
htmlText += data.twitter_link ? ` |
|
|
|
<li><a class="social-share twitter" href="${data.twitter_link}"></a></li> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += data.facebook_link ? ` |
|
|
|
<li><a class="social-share facebook" href="${data.facebook_link}"></a></li> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += data.xing_link ? ` |
|
|
|
<li><a class="social-share xing" href="${data.xing_link}"></a></li> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += data.whatsapp_link ? ` |
|
|
|
<li><a class="social-share whatsapp" href="${data.whatsapp_link}"></a></li> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += data.linkedin_link ? ` |
|
|
|
<li><a class="social-share linkedin" href="${data.linkedin_link}"></a></li> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += data.threema_link ? ` |
|
|
|
<li><a class="social-share threema" href="${data.threema_link}"></a></li> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlText += data.telegram_link ? ` |
|
|
|
<li><a class="social-share telegram" href="${data.telegram_link}"></a></li> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
if (data.twitter_link || data.facebook_link || data.xing_link || |
|
|
|
data.whatsapp_link || data.linkedin_link || data.threema_link || |
|
|
|
data.telegram_link) { |
|
|
|
htmlText += ` |
|
|
|
</ul> |
|
|
|
</div> |
|
|
|
`; |
|
|
|
} |
|
|
|
|
|
|
|
htmlText += '</div>'; |
|
|
|
|
|
|
|
electionDetailText.innerHTML = htmlText; |
|
|
|
|
|
|
|
htmlVideo += data.video_path ? ` |
|
|
|
<div className="video-container"> |
|
|
|
<figure className="video"> |
|
|
|
<div className="video-box"> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
if (data.video_path && data.video_img_path) { |
|
|
|
htmlVideo += ` |
|
|
|
<video src="${data.video_path}" controls="" poster="${data.video_img_path}"></video> |
|
|
|
`; |
|
|
|
} else if (data.video_path) { |
|
|
|
htmlVideo += ` |
|
|
|
<video src="${data.video_path}" controls=""></video> |
|
|
|
`; |
|
|
|
} |
|
|
|
|
|
|
|
htmlVideo += data.video_path ? ` |
|
|
|
</div> |
|
|
|
</figure> |
|
|
|
</div> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
electionDetailVideo.innerHTML = htmlVideo; |
|
|
|
|
|
|
|
htmlInfo += (data.candidate_election_group_id && data.candidate_election_group_name) ? ` |
|
|
|
<div class="info-box info-box-01"> |
|
|
|
<p class="info-headline">Wahlgruppe 02</p> |
|
|
|
<p class="info-box--content info-box--text"> |
|
|
|
<a href="${data.candidate_election_group_id}">${data.candidate_election_group_name}</a> |
|
|
|
</p> |
|
|
|
</div> |
|
|
|
` : ''; |
|
|
|
htmlInfo += (data.candidate_election_district_id && data.candidate_election_district_name) ? ` |
|
|
|
<div class="info-box info-box-02"> |
|
|
|
<p class="info-headline">Wahlbezirk 05</p> |
|
|
|
<p class="info-box--content info-box--text"> |
|
|
|
<a href="${data.candidate_election_district_id}">${data.candidate_election_district_name}</a> |
|
|
|
</p> |
|
|
|
</div> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlInfo += '<div class="info-box info-box-03">'; |
|
|
|
|
|
|
|
htmlInfo += data.company ? ` |
|
|
|
<p class="info-headline">Unternehmen</p> |
|
|
|
<div class="info-box--content"> |
|
|
|
<p class="headline">${data.company}</p> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlInfo += data.company_address ? ` |
|
|
|
<p className="address">${data.company_address}</p> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlInfo += data.website ? ` |
|
|
|
<p> |
|
|
|
<a href="${data.website}" target="_blank">Unternehmenswebseite</a> |
|
|
|
</p> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlInfo += data.email ? ` |
|
|
|
<p> |
|
|
|
<a href="mailto:${data.email}">E-Mail</a> |
|
|
|
</p> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
if (data.phone) { |
|
|
|
|
|
|
|
htmlInfo += ` |
|
|
|
<p> |
|
|
|
<a href="tel:${formatNumberLink(data.phone)}">${formatNumberOutput(data.phone)}</a> |
|
|
|
</p> |
|
|
|
`; |
|
|
|
console.log(data); |
|
|
|
} |
|
|
|
|
|
|
|
if (data.phone2) { |
|
|
|
|
|
|
|
htmlInfo += ` |
|
|
|
<p> |
|
|
|
<a href="tel:${formatNumberLink(data.phone2)}">${formatNumberOutput(data.phone2)}</a> |
|
|
|
</p> |
|
|
|
`; |
|
|
|
} |
|
|
|
|
|
|
|
htmlInfo += data.company ? ` |
|
|
|
</div> |
|
|
|
` : ''; |
|
|
|
|
|
|
|
htmlInfo += '</div>'; |
|
|
|
|
|
|
|
electionDetailInfo.innerHTML = htmlInfo; |
|
|
|
|
|
|
|
staticElectionOverviewElement.style.display = "none"; |
|
|
|
staticElectionDetailElement.style.display = "block"; |
|
|
|
|
|
|
|
if (staticElectionDetailElement) { |
|
|
|
staticElectionDetailElement.scrollIntoView({ |
|
|
|
behavior: "smooth", |
|
|
|
block: "start", |
|
|
|
}); |
|
|
|
} |
|
|
|
}) |
|
|
|
.catch(error => { |
|
|
|
// Handle errors here |
|
|
|
console.error('Fetch error:', error); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function hideDetailPage(e) { |
|
|
|
let staticElectionOverviewElement = document.getElementById("static-election-overview"), |
|
|
|
staticElectionDetailElement = document.getElementById("static-election-detail"); |
|
|
|
|
|
|
|
staticElectionOverviewElement.style.display = "block"; |
|
|
|
staticElectionDetailElement.style.display = "none"; |
|
|
|
|
|
|
|
if (staticElectionOverviewElement) { |
|
|
|
staticElectionOverviewElement.scrollIntoView({ |
|
|
|
behavior: "smooth", |
|
|
|
block: "start", |
|
|
|
}); |
|
|
|
} |
|
|
|
} |