SortBy_newIII

by mtenschert

JavaScript

// pay attention, dont show this function for /ski school/ !!!
// pay attention, the feature doenst run in jsfddle, because of missing lang_path

// timeout for optimize360 asynchronous loading

$(document).ready(function() {

  setTimeout(function() {

    // timeout for optimize360 asynchronous loading
    var totalPath = window.location.pathname;  // "/nl/skiverleih/austria/tirol/nauders"; window.location.pathname;
    var paths = totalPath.split("/"); // string to [en, ski-rental, france, ...]
    var lang = paths[1]; // extract language string, example: en
    var townNameSortBy = paths[5]; // extract language string, example: en
    var target_country = paths[3]; // extract language string, for exaple: france, frankreich, francia, frankrijk

    // Target_Countries Arrays from URL path
    var fr_target_country = ["france", "frankreich", "francia", "frankrijk"];
    var at_target_country = ["austria", "oesterreich", "autriche", "oostenrijk"];
    var ch_target_country = ["switzerland", "svizzera", "schweiz", "zwitserland", "suisse"];
    var ad_target_country = ["andorre", "andorra"];
    var de_target_country = ["duitsland", "deutschland", "allemagne", "germania", "germany"];
    var bg_target_country = ["bulgaria", "bulgarien", "bulgarie", "bulgaria", "bulgarije"];
    var it_target_country = ["italie", "italia", "italy", "italien"];
    var si_target_country = ["slovenien", "slovenia", "slovenie", "slovenia"]; // slovenia
    var sk_target_country = ["slovakia", "slowakei", "slovaquie", "slovacchi", "slowakije"]; // slovakia
    var es_target_country = ["spanje", "spanien", "spain", "espagne", "spagna"];

    var empty_countries = [] // empty arrray for .concat, for a better overview only
    var all_target_countries = empty_countries.concat( // all countries into one array
      fr_target_country, // FR show, avoid the "," after the last one
      // at_target_country, // AT hide, avoid the "," after the last one
      ch_target_country, // CH show,...