The SBB is considering a direct train from Basel to London. Although traveling to the British capital by train is fairly easy, direct is always better. This journey would take five hours. But how long do train journeys to European cities actually take? Try the quiz here:
const questionList = [
// DATA ['Zürich – Paris',4,'Direkt','/imgdb/c534/void;NR;JPEG/944954221619524', ''], ['Zürich – Bologna','6','Direkt','/imgdb/e3ad/void;NR;JPEG/6687623305555221', ''], ['Zürich – Venedig','6','Direkt','/imgdb/7b6c/void;NR;JPEG/6534595234550312', ''], ['Zürich – München','3.5','Direkt','/imgdb/bfed/void;NR;JPEG/6273465626672594', ''], ['Zürich – Hamburg','10.5','Direkt','/imgdb/4c35/void;NR;JPEG/2438276691951519', ''], ['Zürich – Wien','8','Direkt','/imgdb/b969/void;NR;JPEG/389498786177831', ''], ['Zürich – Budapest','11','Direkt','/imgdb/97dd/void;NR;JPEG/2885419203456159', ''], ['Basel – Berlin','7.5','Direkt','/imgdb/df8c/void;NR;JPEG/7499496540751431', ''], ['Basel – Amsterdam','7','Direkt','/imgdb/369d/void;NR;JPEG/4807971575063507', ''], ['Zürich – Brüssel','6','Via Paris','/imgdb/a162/void;NR;JPEG/7905416423394174', ''], ['Zürich – Bordeaux','7.5','Via Paris','/imgdb/d4c2/void;NR;JPEG/3361506495182054', ''], ['Zürich – Barcelona','12','Via Paris','/imgdb/66f8/void;NR;JPEG/6634477606462120', ''], ['Zürich – Rom','8.5','Via Mailand','/imgdb/7bb4/void;NR;JPEG/8785936352408615', ''], ['Zürich – Prag','10.5','Via Dresden','/imgdb/57c6/void;NR;JPEG/8334200306678027', ''], ['Zürich – Warschau','15.5','Via Berlin','/imgdb/d5df/void;NR;JPEG/671036966026701', ''], ['Zürich – Kopenhagen','13.5','Via Frankfurt und Hamburg','/imgdb/418a/void;NR;JPEG/5343091281185636', ''], ['Zürich – Palermo','21','Via Milano, Salerno und Messina','/imgdb/13d1/void;NR;JPEG/3429596502422263', ''], ['Basel – Madrid','12.5','Via Mulhouse, Montpellier und Barcelona','/imgdb/bb64/void;NR;JPEG/4396278906019967', ''], // DATA ];
// shuffle questionList (optional) // questionList.sort(() => Math.random() - 0.5);
const projectId = 1672; // Add in this list: https://docs.google.com/spreadsheets/d/1jJDX-UIVlUcK0OET2zjrmfqeqcRe3WUF38Q3FSiBHns/edit?usp=sharing const unit=" Stunden"; // What unit are the values in? const min = 0; // Minimum value const max = 24; // Maximum value
const lessLabel = min.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "'") + unit; // Labelling of the min value const moreLabel = max.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "'") + unit; // Labelling of the max value
// TABLE function createTable(questionListCopy) { // Referenz auf das div-Element mit der Klasse "result-table" var tableContainer = document.querySelector(".result-table");
// Erstellung der Tabellen-Elemente var table = document.createElement("table");
var tableHead = document.createElement("thead"); var tableBody = document.createElement("tbody");
// Erstellung der Tabellen-Kopfzeile var headerRow = document.createElement("tr"); var headerCell1 = document.createElement("th"); var headerCell2 = document.createElement("th"); var headerText1 = document.createTextNode("Ort"); var headerText2 = document.createTextNode("Schnitt");
headerCell1.appendChild(headerText1); headerCell2.appendChild(headerText2); headerRow.appendChild(headerCell1); headerRow.appendChild(headerCell2); tableHead.appendChild(headerRow); table.appendChild(tableHead);
// Schleife durch die Daten des Arrays und Erstellung der Tabellenzeilen und -zellen for (var i = 0; i < questionListCopy.length; i++) { var row = document.createElement("tr"); var nameCell = document.createElement("td"); var nameText = document.createTextNode(questionListCopy[i][0]); nameCell.appendChild(nameText); row.appendChild(nameCell); var points = questionListCopy[i][5]; var cell = document.createElement("td"); var barContainer = document.createElement("div"); barContainer.style.width = "100%"; barContainer.style.height = "20px"; barContainer.style.backgroundColor = "#d3d3d3 "; barContainer.style.position = "relative"; barContainer.style.marginBottom = "-4px" cell.appendChild(barContainer); var bar = document.createElement("div"); var barWidth = (points - min) / (max - min) * 100; // Umrechnung der Punkte in Balkenbreite bar.style.width = barWidth + "%"; bar.style.height = "100%"; bar.style.backgroundColor = "#F41096"; bar.style.position = "absolute"; bar.style.left = "0"; barContainer.appendChild(bar); // Text der Punktzahl innerhalb des Balkens, falls Platz vorhanden ist var barText = document.createElement("span"); barText.textContent = points.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "'"); barText.style.color = "white"; barText.style.position = "absolute"; barText.style.top = "50%"; barText.style.right = "10px"; barText.style.transform = "translateY(-50%)"; if (points < 10) { blackTextNumber = 10 } else if (points < 100) { blackTextNumber = 20 } else if (points < 1000) { blackTextNumber = 30 } else if (points < 10000) { blackTextNumber = 40 } else { blackTextNumber = 50 } // check if bar width is smaller than the text with the text length of points and the font size if (barWidth < 30) { barText.style.color = "black"; barText.style.right = "auto"; barText.style.left = 105 + "%"; } bar.appendChild(barText); row.appendChild(cell); tableBody.appendChild(row); } // Zusammenfügen der Tabellenelemente und Einfügen in das div-Element table.appendChild(tableBody); tableContainer.appendChild(table); } // END TABLE // make a function createQuestionContent that returns the content of the question function createQuestionContent(reviewQuestions) { for (var idx = 0; idx < reviewQuestions.length; idx++) { cleanKey = questionList[idx][0].replace(/[^a-zA-Z0-9]/g, ""); var questionContent = "
" + questionList[idx][0] + "
" + questionList[idx][2] + "
" + questionList[idx][4] + "
"
“; questionContent += “
`; reviewQuestions[idx].innerHTML = queryContent; } // Update value in text element var allSliders = document.getElementsByClassName(‘questionSlider’); Array.prototype.forEach.call(allSliders, function (slider) { // Loop over each element to attach the .oninput function slider.oninput = function (event) { var idx = slider.getAttribute(‘idx’); // now update according to span document.getElementById(‘r’ + idx + ‘-my’).innerHTML = this.value.toString().replace(/\B(?=(\d{3})+(? !\d ))/G, “‘”); } }); back reviewQuestions; } const roundStartMean = Math.round(((min + max) / 2) * 100) / 100; for (var idx = 0; idx[idx][5] = roundedStartAverage; } imageUrls = []; averageUrls = []; for (var idx = 0; idx < questionList.length; idx++) {
var id = questionList[idx][3].split("https://www.watson.ch/").pop();
var picutreUrl = "https://www.watson.ch/api/2.0/images/" + id;
pictureUrls.push(picutreUrl);
cleanKey = questionList[idx][0].replace(/[^a-zA-Z0-9]/g, "");
var key = "slider-quiz" + projectId.toString() + "-" + cleanKey;
var apiUrlWatsonMean = "https://www.watson.ch/api/2.0/key-values/" + key + "/histogram";
averageUrls.push(apiUrlWatsonMean);
}
Promise.all(
pictureUrls.map(url =>
fetch(url) .then(response => response.json()) .catch(error => console.error(error)) ) ) .then(data => { console.log(data); for (var idx = 0; ID < data.length; idx++) {
if (questionList[idx][4] != "") {
questionList[idx][4] = "Bild: " + questionList[idx][4];
} else {
if (data[idx].data.source != null && data[idx].data.source != "") {
var pictureCredit = "Bild: " + data[idx].data.source;
questionList[idx][4] = pictureCredit;
} else {
questionList[idx][4] = "";
}
}
}
reviewQuestions = createQuestionContent(reviewQuestions)
})
.catch(error => console.error(‘image’, error)); Promise.all( AverageUrls.map(url => fetch(url) .then(response => response.json()) .catch(error => console.error(error)) ) ) .then(data => { / / loop over data for (var idx = 0; idx[idx].facts); const values = Object.values(data[idx].facts); if (keys.length != 0) { // transform keys to numbers for (let i = 0; i < key.length; i++) { keys[i] = parseInt(keys[i]); } let sum = 0; for (let i = 0; i < keys.length; i++) {
sum += keys[i] * values[i];
}
average = sum / values.reduce((acc, curr) => acc + current, 0); average = Math.round(average * 100) / 100; questionList[idx][5] = average; questionList[idx][6] = keys; questionList[idx][7] = values; reviewQuestions = createQuestionContent(reviewQuestions) } } // create a copy of question list var question listCopy = question list.slice(0); // sort the queryList by the average queryListCopy.sort(function (a, b) { return b[5] – A[5]; }); // TABLE //createTable(questionListCopy); // END TABLE }) .catch(error => console.error(error)); var reviewQuestions = document.getElementsByClassName(‘reviewQuestion’); if (reviewQuestions.length != QuestionList.length) { console.log(“questionList must be the same length as the number of divs (list: ” + QuestionList.length + “, divs: ” + reviewQuestions.length + “)! “) } reviewQuestions = createQuestionContent(reviewQuestions) function sendData(questionId, noReview = false) { cleanKey = questionId.replace(/[^a-zA-Z0-9]/G, “”); // find questionId in questionList with cleanKey for (var idx = 0; idx < questionList.length; idx++) {
if (questionList[idx][0].replace(/[^a-zA-Z0-9]/g, "") == cleanKey) {
questionId = idx;
break;
}
}
let dataToSend = {
'questionId': cleanKey,
'version': 0.9,
'projectId': projectId
};
if (noReview) { // just get the mean
dataToSend['userInput'] = null;
document.querySelector("#r" + cleanKey + "-my").innerHTML = "-";
} else { // send my review
let valSlider = document.querySelector("#s" + cleanKey + "-slider-input").value;
dataToSend['userInput'] = parseFloat(valSlider);
const key = "slider-quiz" + projectId.toString() + "-" + cleanKey;
const jwt_token = localStorage.getItem("jwt_token");
const jwt_free_token = localStorage.getItem("jwt_free_token");
const user_id = localStorage.getItem("user_id");
let value
if (user_id) {
value = {
user: user_id,
value: dataToSend['userInput']
};
} else {
value = {
user: jwt_free_token,
value: dataToSend['userInput']
};
}
let optionen = {
method: 'post',
body: JSON.stringify(dataToSend)
};
fetch(`https://www.watson.ch/api/2.0/key-values/${key}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${jwt_free_token}`
},
body: JSON.stringify(value)
})
.then(response => response.json()) .catch(error => console.error(error)); } document.querySelector(“#r” + cleanKey + “-wtsn”).innerHTML = questionnaire[questionId][5].toString().replace(/\B(?=(\d{3})+(?!\d))/g, “‘”) document.querySelector(“#r” + cleanKey + “-co2” ).innerHTML = questionsList[questionId][1].toString().replace(/\B(?=(\d{3})+(?!\d))/g, “‘”) solutionsSlider = document.getElementById(“s” + cleanKey + “-slider -solution”) solutionSlider.style.display = ‘block’; SolutionSlider.value = questionsList[questionId][1]; meanSlider = document.getElementById(“s” + cleanKey + “-slider-watson-mean”) meanSlider.style.display = ‘block’; meanSlider.value = questionnaire[questionId][5] * 100; document.querySelector(“#btnRate-” + cleanKey).disabled = true; document.querySelector(“#btnView-” + cleanKey).disabled = true; document.querySelector(“#s” + cleanKey + “-slider-input”).disabled = true; }
Soource :Watson
I am Amelia James, a passionate journalist with a deep-rooted interest in current affairs. I have more than five years of experience in the media industry, working both as an author and editor for 24 Instant News. My main focus lies in international news, particularly regional conflicts and political issues around the world.
On the same day of the terrorist attack on the Krokus City Hall in Moscow,…
class="sc-cffd1e67-0 iQNQmc">1/4Residents of Tenerife have had enough of noisy and dirty tourists.It's too loud, the…
class="sc-cffd1e67-0 iQNQmc">1/7Packing his things in Munich in the summer: Thomas Tuchel.After just over a year,…
At least seven people have been killed and 57 injured in severe earthquakes in the…
The American space agency NASA would establish a uniform lunar time on behalf of the…
class="sc-cffd1e67-0 iQNQmc">1/8Bode Obwegeser was surprised by the earthquake while he was sleeping. “It was a…