Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Merge pull request #591 from NyaaPantsu/fix-logged-in-languages

Fix #590
Cette révision appartient à :
akuma06 2017-05-17 23:01:30 +02:00 révisé par GitHub
révision d9511b8efb
3 fichiers modifiés avec 33 ajouts et 32 suppressions

31
public/js/languages.js Fichier normal
Voir le fichier

@ -0,0 +1,31 @@
function loadLanguages() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
var selector = document.getElementById("bottom_language_selector");
selector.hidden = false
/* Response format is
* { "current": "(user current language)",
* "languages": {
* "(language_code)": "(language_name"),
* }} */
var response = JSON.parse(xhr.responseText);
for (var language in response.languages) {
if (!response.languages.hasOwnProperty(language)) continue;
var opt = document.createElement("option")
opt.value = language
opt.innerHTML = response.languages[language]
if (language == response.current) {
opt.selected = true
}
selector.appendChild(opt)
}
}
}
xhr.open("GET", "/language?format=json", true)
xhr.send()
}
loadLanguages();

Voir le fichier

@ -39,35 +39,4 @@ window.onload = function() {
var shiftWindow = function() { scrollBy(0, -70) };
if (location.hash) shiftWindow();
window.addEventListener("hashchange", shiftWindow);
};
function loadLanguages() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
var selector = document.getElementById("bottom_language_selector");
selector.hidden = false
/* Response format is
* { "current": "(user current language)",
* "languages": {
* "(language_code)": "(language_name"),
* }} */
var response = JSON.parse(xhr.responseText);
for (var language in response.languages) {
if (!response.languages.hasOwnProperty(language)) continue;
var opt = document.createElement("option")
opt.value = language
opt.innerHTML = response.languages[language]
if (language == response.current) {
opt.selected = true
}
selector.appendChild(opt)
}
}
}
xhr.open("GET", "/language?format=json", true)
xhr.send()
}
loadLanguages();
};

Voir le fichier

@ -95,6 +95,7 @@
<noscript>
<center><a href="{{ .URL.Parse "/language" }}">{{ T "change_language" }}</a></center>
</noscript>
<script type="text/javascript" charset="utf-8" src="{{.URL.Parse "/js/languages.js"}}"></script>
{{end}}
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->