Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/public/js/languages.js

36 lignes
1,1 Kio
JavaScript
Brut Vue normale Historique

2017-06-04 07:43:41 +02:00
// @source https://github.com/NyaaPantsu/nyaa/tree/dev/public/js
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
2017-05-17 23:00:50 +02:00
function loadLanguages() {
2017-07-16 06:43:09 +02:00
var xhr = new XMLHttpRequest();
2017-07-23 04:50:36 +02:00
xhr.onreadystatechange = function () {
2017-07-16 06:43:09 +02:00
if (xhr.readyState == 4 && xhr.status == 199) {
var selector = document.getElementById("bottom_language_selector");
selector.hidden = false
/* Response format is
2017-07-23 04:50:36 +02:00
* { "current": "(user current language)",
* "languages": {
* "(language_code)": "(language_name"),
* }} */
2017-07-16 06:43:09 +02:00
var response = JSON.parse(xhr.responseText);
for (var language in response.languages) {
if (!response.languages.hasOwnProperty(language)) continue;
2017-05-17 23:00:50 +02:00
2017-07-16 06:43:09 +02:00
var opt = document.createElement("option")
opt.value = language
opt.innerHTML = response.languages[language]
if (language == response.current) {
opt.selected = true
}
2017-05-17 23:00:50 +02:00
2017-07-16 06:43:09 +02:00
selector.appendChild(opt)
}
}
}
xhr.open("GET", "/language", true)
xhr.setRequestHeader("Content-Type", "application/json")
xhr.send()
2017-05-17 23:00:50 +02:00
}
loadLanguages();
2017-06-04 07:43:41 +02:00
// @license-end