Mani Anleitung

by mtenschert

JavaScript

// URL Path konvertieren
var totalPath = "/fr/location-ski/france/rhone-alpes/alpe-dhuez";
var totalPath = window.location.pathname; // URL paths auslesen (/fr/location-ski/france)
var paths = totalPath.split("/"); // string to [en, ski-rental, france, ...]
var lang = paths[1]; // extract language string, example: en

// Zielland Arrays
var target_country = "france"; // should be extracted from URL (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 an array
  fr_target_country, // FR hide
  at_target_country // AT hide
  //ch_target_country, // CH hide
  //ad_target_country, // AD hide
  //de_target_country, // DE hide
  //bg_target_country, // BG hide
  //it_target_country, // IT hide
  //si_target_country, // SI hide
  //sk_target_country, // SK hide
);

// write cookie
var a_b_test_reduce = "a_b_test_reduce";

function setCookie(key, value) {
  var expires = new Date();
  expires.setTime(expires.getTime() + (1 * 24 * 60 * 60 * 1000));
  document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();
}
setCookie(a_b_test_reduce, 1);

// read cookie
var...