function getUrlVars() {
    let vars = [], hash;
    let href = window.location.href;
    let start = href.indexOf('?');
    let end = href.indexOf('#');
    if(end < 0) {
      end = href.length;
    }
    console.log(end);
    var hashes = href.slice(start + 1, end).split('&');
    for(let i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

let query_string = getUrlVars();
let hash_string = window.location.hash;

console.log(query_string);
console.log(hash_string);

let search = "";

if(query_string["contact"] != "" && query_string["contact"] != undefined) {
  search = query_string["contact"];
}

if("contact" in query_string) {
   document.getElementById('contact').scrollIntoView(true);
}

$(document).ready(function() {
    $('#contact-table').DataTable( {
        "order": [[0, "asc"]],
        "paging":   false,
        "ordering": false,
        "info":     false,
        "search": {
          "search": search
        },
        "language": {
          "decimal": "",
          "emptyTable": "Gibt nix zu zeigen",
          "info": "Zeige _START_ bis _END_ von _TOTAL_ Einträgen",
          "infoEmpty": "Zeige 0 bis 0 von 0 Einträgen",
          "infoFiltered": "(aus _MAX_ Einträgen)",
          "infoPostFix": "",
          "thousands": ",",
          "lengthMenu": "Zeige _MENU_ Einträge",
          "loadingRecords": "<i class=\"fas fa-spinner fa-pulse\"></i>",
          "processing": "<i class=\"fas fa-spinner fa-pulse\"></i>",
          "search": "Durchsuchen:",
          "zeroRecords": "Nix gefunden",
          "paginate": {
            "first": "<i class=\"fas fa-angle-double-left\"></i>",
            "last": "<i class=\"fas fa-angle-double-right\"></i>",
            "next": "<i class=\"fas fa-angle-right\"></i>",
            "previous": "<i class=\"fas fa-angle-left\"></i>"
          },
          "aria": {
            "sortAscending": ": activate to sort column ascending",
            "sortDescending": ": activate to sort column descending"
          }
        }
    } );
} );


