全站通知:
用户:646195980/i18n.js
刷
历
编
跳到导航
跳到搜索
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
- Opera:按 Ctrl-F5。
//From:https://wiki.biligame.com/bluearchive/模板:面包屑
RLQ.push(['jquery', () => {
$(function(){
var locales = $(".locales")
var localesB = $(".localesB")
var locales_storage = {}
var localesB_storage = {}
var useable = {"cn": true, "tw":false, "jp" : false, "kr" : false, "en" : false, "th" : false}
var last_active = $(".lang_active")
var lang = localStorage.getItem("gt_lang") || 'cn'
var lang_list = ["cn","tw","jp","kr","en","th"]
function getLocales(){
locales.each(function(index){
let dom = this;
for (var i of lang_list){
v = dom.dataset[i]
if(v){useable[i] = true;}
if(!locales_storage[index]){locales_storage[index]={}};
locales_storage[index][i] = v || "";
}
});
localesB.each(function(index){
let dom = this;
for (var i of lang_list){
v = dom.dataset[i]
if(!localesB_storage[index]){localesB_storage[index]={}};
localesB_storage[index][i] = b64DecodeUnicode(v) || "";
}
});
}
function Locales(){
for (var i of lang_list){
if(useable[i]){
LocalesControl(i);
}
}
}
function LocalesControl(i){
$("#"+i).removeClass('disable')
$("#"+i).click(function(e){
if(event.target!=last_active[0]){
setLocales(i,$(this));
last_active = $(this)
}
});
}
function setLocales(l,dom){
lang = l;
$("#" + lang).addClass('lang_active')
last_active.removeClass('lang_active')
locales.each(function(index){
$(this).html(locales_storage[index][lang]);
});
localesB.each(function(index){
$(this).html(localesB_storage[index][lang]);
});
localStorage.setItem("gt_lang",lang);
}
function clearLocales(){
locales.each(function(){
for (var i of lang_list){
this.removeAttribute("data-"+i);
}
});
localesB.each(function(){
for (var i of lang_list){
this.removeAttribute("data-"+i);
}
});
}
function initLocales(){
if(lang!='cn' && useable[lang]){
setLocales(lang);
last_active = $("#"+lang);
}
}
function b64DecodeUnicode(str){
return decodeURIComponent(atob(str).split('').map(function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
getLocales();
Locales();
initLocales();
clearLocales();
})
}]);