Test Commit

This commit is contained in:
schrom01 2023-08-16 21:15:28 +02:00
parent 43b4d07340
commit 5176edcc51
3 changed files with 3671 additions and 0 deletions

3487
gemeinden.csv Normal file

File diff suppressed because it is too large Load Diff

4
gemeinden.php Normal file
View File

@ -0,0 +1,4 @@
<?php
echo "csvData = `". file_get_contents('gemeinden.csv') ."`;";
?>

180
index.php
View File

@ -7,6 +7,45 @@
<link rel="stylesheet" href="css/bootstrap.css">
<title>Silias Zefix Suche</title>
<style>
#myInput {
box-sizing: border-box;
background-position: 14px 12px;
background-repeat: no-repeat;
font-size: 16px;
padding: 14px 20px 12px 45px;
border: none;
border-bottom: 1px solid #ddd;
}
#myInput:focus {outline: 3px solid #ddd;}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
position: absolute;
background-color: #f6f6f6;
min-width: 230px;
overflow: auto;
border: 1px solid #ddd;
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown a:hover {background-color: #ddd;}
.show {display: block;}
</style>
</head>
<body>
@ -20,8 +59,149 @@
<p>Diese Webseite wird gerade neu entwickelt und steht demnächst zur Verfügung.</p>
</div>
<div class="container">
<form action="submit.php" method="post">
<label for="firmenname">Firmenname:</label>
<input type="text" id="firmenname" name="firmenname" required><br><br>
<label for="kanton">Kanton:</label>
<select id="kanton" name="kanton">
<!-- Hier kannst du die Optionen für die Kantone einfügen -->
</select><br><br>
<label for="sitz">Sitz (Postleitzahl / Gemeinde):</label>
<div class="dropdown">
<div id="myDropdown" class="dropdown-content">
<input type="text" placeholder="Postleitzahl / Ort" id="myInput" onkeyup="filterFunction()" name="sitz">
<div id="results">
</div>
</div>
</div><br><br>
<label for="rechtsform">Rechtsform:</label>
<select id="rechtsform" name="rechtsform">
<!-- Hier kannst du die Optionen für die Rechtsformen einfügen -->
</select><br><br>
<input type="checkbox" id="exakteSuche" name="exakteSuche">
<label for="exakteSuche">Exakte Suche</label><br>
<input type="checkbox" id="geloeschteRechtseinheiten" name="geloeschteRechtseinheiten">
<label for="geloeschteRechtseinheiten">Gelöschte Rechtseinheiten suchen</label><br>
<input type="checkbox" id="inBisherigenFirmen" name="inBisherigenFirmen">
<label for="inBisherigenFirmen">In bisherigen Firmen/Namen suchen</label><br>
<input type="checkbox" id="phonetischeSuche" name="phonetischeSuche">
<label for="phonetischeSuche">Phonetische Suche</label><br><br>
<input type="submit" value="Formular absenden">
</form>
<script>
const kantonDropdown = document.getElementById('kanton');
const sitzInput = document.getElementById('sitz');
// Parse CSV-Daten und fülle das Dropdown-Feld
let csvData;
<?php
include 'gemeinden.php';
?>
csvData = csvData.slice(1);
// csvData = "PLZ,ORTBEZ,KANTON
// 1000,Lausanne Dépôt,VD
// 1001,Lausanne,VD
// 1002,Lausanne,VD"
const lines = csvData.trim().split('\n');
const headers = lines[0].split(',');
const gemeindeNameIndex = headers.indexOf('Gemeindename');
const plzIndex = headers.indexOf('PLZ');
const kantonIndex = headers.indexOf('Kanton');
const sitze = [];
for (let i = 1; i < lines.length; i++) {
const cells = lines[i].split(',');
const plz = cells[plzIndex].trim();
const gemeindeName = cells[gemeindeNameIndex].trim();
const kanton = cells[kantonIndex].trim();
// Falls Kanton noch nicht vorhanden -> hinzufügen
if (!kantonDropdown.querySelector(`[value="${kanton}"]`)) {
const option = document.createElement('option');
option.value = kanton;
option.textContent = kanton;
kantonDropdown.appendChild(option);
}
// Sitz hinzufügen
const sitzString = plz + " " + gemeindeName
sitze.push(sitzString)
const anchorElement = document.createElement('a');
anchorElement.textContent = sitzString
anchorElement.href="#"
anchorElement.classList.add("result")
anchorElement.addEventListener('click', function(event) {
const index = i - 1; // Make sure 'i' is defined before using it here
chooseResult(index.toString());
});
document.getElementById("results").appendChild(anchorElement)
}
function filterFunction() {
var input, filter, ul, li, a, i;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
div = document.getElementById("myDropdown");
a = div.getElementsByTagName("a");
for (i = 0; i < a.length; i++) {
txtValue = a[i].textContent || a[i].innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
a[i].style.display = "";
} else {
a[i].style.display = "none";
}
}
}
function chooseResult(index) {
document.getElementById("myInput").value = sitze[index]
console.log("Choosen" + index)
}
const myInput = document.getElementById('myInput');
const results = document.getElementById('results');
results.style.display = 'none';
myInput.addEventListener('focus', () => {
results.style.display = 'block';
});
myInput.addEventListener('blur', () => {
setTimeout(() => {
results.style.display = 'none';
}, 100); // 1000 milliseconds = 1 second
});
</script>
</div>
</section>
</div>
<?php
include 'env_vars.php';
//echo "My API Key is:" . $_ENV["APIKEY"];