$(document).ready(function() {
// Title Sliding auf Terminseiten
$('.bezSliding').inewsticker({
speed : 3000,
effect : 'fade',
delay_after : 1000,
});
// Interaktive Wahllokalsuche
$('#suchfeld').val(getUrlVar('str'));
validiereSuche($('#suchfeld').val());
$('#suchfeld').keyup(function() {
validiereSuche(this.value)
});
});
var req = null;
function validiereSuche(val) {
val = $.trim(val);
if (val.length >= 3) {
suche(val);
} else {
$("#ergebnis").html("
");
$("#suchInfo")
.html(
'Bitte geben Sie mindestens 3 Zeichen ein!');
}
}
function getUrlVar(key) {
var result = new RegExp(key + "=([^&]*)", "i").exec(window.location.search);
return result && decodeURIComponent(result[1]).split("+").join(" ") || "";
}
function suche(value) {
if (req != null)
req.abort();
req = $
.ajax({
url : "html5strassen.xml",
dataType : "xml",
success : function(xml) {
$("#ergebnis").html("");
var ergebnismenge = 0;
$(xml).find("str").filter(
function() {
// suche
return $(this).find("name").text()
.toLowerCase().indexOf(
value.toLowerCase()) >= 0;
}).each(
function() {
$("#ergebnis").append(
""
+ $(this).find("name").text()
+ " "
+ $(this).find("hnr").text()
+ "");
ergebnismenge++;
});
if (ergebnismenge == 0) {
$("#ergebnis")
.append(
"Es wurden keine passenden Straßen gefunden!
");
} else {
$("#suchInfo").html(
'Es wurden '
+ ergebnismenge
+ ' Einträge gefunden:');
}
},
error : function(xml) {
$("#suchInfo")
.html(
'Fehler: Das Straßenverzeichnis konnte nicht geladen werden!');
}
});
}
function fuelleTabelle(character) {
btnArr = [ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"0-9" ];
$
.ajax({
url : "html5strassen.xml",
dataType : "xml",
type : "POST",
success : function(response) {
var table = $(document.createElement("table"));
table.addClass("table table-striped");
table
.append("Name | Hausnummer | Stimmbezirk |
");
var tBody = $(document.createElement("tbody"));
var $events = $(response).find("strassen");
$events
.each(function(index, event) {
var $event = $(event);
$event
.children()
.each(
function(i, child) {
var $child = $(child);
name = $(child)
.find("name")
.text();
printZeile = name
.toLowerCase()
.indexOf(
btnArr[character]
.toLowerCase()) == 0;
if ((character + 1) == btnArr.length) {
printZeile = false;
$
.each(
btnArr,
function(
index,
value) {
printZeile = printZeile
|| name
.toLowerCase()
.indexOf(
value
.toLowerCase()) == 0;
});
printZeile = !printZeile;
}
if (printZeile) {
spalte1 = "" + name
+ "";
spalte2 = $(child)
.find("hnr")
.text();
spalte3 = $(child)
.find(
"stbz_bez")
.text();
tBody.append(""
+ spalte1
+ " | "
+ spalte2
+ " | "
+ spalte3
+ " |
");
}
});
});
table.append(tBody);
var btnListe = $(document.createElement("ul"));
btnListe.addClass("pagination justify-content-center m-2");
$
.each(
btnArr,
function(index, value) {
btnListe
.append(""
+ value
+ "");
});
var btnListeContainer = $(document.createElement("div"));
btnListeContainer.html(btnListe);
btnListeContainer.css("text-align", "center");
btnListeContainer.css("border-bottom", "solid 1px #efefef");
var container = $('#tabelle');
container.html(btnListeContainer);
var fixedHeight = $(document.createElement("div"));
fixedHeight.html(table);
fixedHeight.css("max-height", "250px");
fixedHeight.css("overflow", "auto");
container.append(fixedHeight);
}
});
}