更新通知页面和通知翻译函数
This commit is contained in:
parent
3ee6724f18
commit
eeef884832
@ -29,6 +29,9 @@
|
||||
'Gym': '健身房',
|
||||
'Biology Modules': '生物学课程',
|
||||
'Traveling': '飞行中',
|
||||
'Events': '通知',
|
||||
'Received Events': '收到的通知',
|
||||
'Saved Events': '保存的通知',
|
||||
};
|
||||
const titleLinksDict = {
|
||||
'Personal stats': '个人统计信息',
|
||||
@ -47,6 +50,7 @@
|
||||
'People': "用户列表",
|
||||
'Computer': '电脑',
|
||||
'Market': '市场',
|
||||
'Back': '返回',
|
||||
};
|
||||
const sidebarDict = { // todo 从json加载
|
||||
'Money': '现金',
|
||||
@ -443,31 +447,48 @@
|
||||
'The Sports Science Lab': '运动科学实验室',
|
||||
'The Jail Gym': '监狱健身房',
|
||||
};
|
||||
const headerDict={
|
||||
"User's Name / ID":'用户名或ID',
|
||||
'Faction':'帮派',
|
||||
'Company':'帮派',
|
||||
'Places':'地点',
|
||||
'Item Market':'交易市场',
|
||||
'Forum posts':'论坛',
|
||||
'Help':'帮助',
|
||||
'search...':'搜索',
|
||||
'Search users by...':'高级用户搜索',
|
||||
'Property':'住房',
|
||||
'Male':'男性',
|
||||
'to':'到',
|
||||
'Reset':'重置',
|
||||
'Search':'搜索',
|
||||
'0 - 15 min':'0 - 15 分钟',
|
||||
'Not':'不',
|
||||
'View Log':'查看日志',
|
||||
'View Profile':'查看个人资料',
|
||||
'Settings':'设置',
|
||||
'Server:':'服务器 ',
|
||||
'Dark Mode':'',
|
||||
'News Ticker':'',
|
||||
'Logout':'',
|
||||
const headerDict = {
|
||||
"User's Name / ID": '用户名或ID',
|
||||
'Faction': '帮派',
|
||||
'Company': '帮派',
|
||||
'Places': '地点',
|
||||
'Item Market': '交易市场',
|
||||
'Forum posts': '论坛',
|
||||
'Help': '帮助',
|
||||
'search...': '搜索',
|
||||
'Search users by...': '高级用户搜索',
|
||||
'Property': '住房',
|
||||
'Male': '男性',
|
||||
'to': '到',
|
||||
'Reset': '重置',
|
||||
'Search': '搜索',
|
||||
'0 - 15 min': '0 - 15 分钟',
|
||||
'Not': '不',
|
||||
'View Log': '查看日志',
|
||||
'View Profile': '查看个人资料',
|
||||
'Settings': '设置',
|
||||
'Server:': '服务器 ',
|
||||
'Dark Mode': '',
|
||||
'News Ticker': '',
|
||||
'Logout': '',
|
||||
};
|
||||
const eventsDict = {
|
||||
// "ALL EVENTS": "所有通知",
|
||||
// "RECEIVED": "收到的通知",
|
||||
// "SAVED": "已保存通知",
|
||||
"Delete selected": "删除已选",
|
||||
"Save selected": "保存已选",
|
||||
"Check All": "勾选所有",
|
||||
"Uncheck All": "取消勾选所有",
|
||||
// "Events": "通知",
|
||||
// "Log": "日志",
|
||||
// "Back": "返回",
|
||||
// "Recruit Citizens": "招募市民",
|
||||
// "Tutorial": "教程",
|
||||
'ALL EVENTS (': '全部通知 (',
|
||||
'RECEIVED (': '收到的通知 (',
|
||||
'SAVED (': '保存的通知 (',
|
||||
}
|
||||
|
||||
/**
|
||||
* 边栏
|
||||
@ -553,87 +574,87 @@
|
||||
* header
|
||||
*/
|
||||
// $('div#header-root').each((i,e)=>{
|
||||
if($('div#header-root').length>0){
|
||||
const headerOB=new MutationObserver(_=>{
|
||||
if ($('div#header-root').length > 0) {
|
||||
const headerOB = new MutationObserver(_ => {
|
||||
headerOB.disconnect();
|
||||
headerTrans();
|
||||
headerOB.observe($('div#header-root')[0], {childList: true, subtree: true, attributes:true});
|
||||
headerOB.observe($('div#header-root')[0], {childList: true, subtree: true, attributes: true});
|
||||
});
|
||||
|
||||
const headerTrans=function headerTrans() {
|
||||
const headerTrans = function headerTrans() {
|
||||
// 搜索内容下拉框中的文字 已选中
|
||||
if (headerDict[$('div.find button.toggler.down').text()])
|
||||
$('div.find button.toggler.down').text(headerDict[$('div.find button.toggler.down').text()]);
|
||||
// pc端 搜索下拉框点击后的搜索类型文字
|
||||
$('div.find li.item').each((i,e)=>{
|
||||
$('div.find li.item').each((i, e) => {
|
||||
if (headerDict[$(e).text()])
|
||||
$(e).text(headerDict[$(e).text()]);
|
||||
});
|
||||
// 手机端 搜索下拉框点击后的搜索类型文字
|
||||
$('li[class^="search-type-"] label').each((i,e)=>{
|
||||
$('li[class^="search-type-"] label').each((i, e) => {
|
||||
if (headerDict[$(e).text()])
|
||||
$(e).text(headerDict[$(e).text()]);
|
||||
});
|
||||
// 搜索框placeholder
|
||||
if(headerDict[$('input[class^="searchInput"]').attr('placeholder')])
|
||||
if (headerDict[$('input[class^="searchInput"]').attr('placeholder')])
|
||||
$('input[class^="searchInput"]').attr('placeholder',
|
||||
headerDict[$('input[class^="searchInput"]').attr('placeholder')]);
|
||||
// 高级搜索框 search by
|
||||
if (headerDict[$('div#header-root legend.title').text()])
|
||||
$('div#header-root legend.title').text(headerDict[$('div#header-root legend.title').text()]);
|
||||
// 高级搜索框的条件 左 键
|
||||
$('ul.advancedSearchFormBody label.label').each((i,e)=>{
|
||||
if(headerDict[$(e).text()])
|
||||
$('ul.advancedSearchFormBody label.label').each((i, e) => {
|
||||
if (headerDict[$(e).text()])
|
||||
$(e).text(headerDict[$(e).text()]);
|
||||
});
|
||||
// 高级搜索框的已选中
|
||||
$('ul.advancedSearchFormBody div.select-wrapper button.toggler.down').each((i,e)=>{
|
||||
if(headerDict[$(e).text()])
|
||||
$('ul.advancedSearchFormBody div.select-wrapper button.toggler.down').each((i, e) => {
|
||||
if (headerDict[$(e).text()])
|
||||
$(e).text(headerDict[$(e).text()]);
|
||||
});
|
||||
// 高级搜索的下拉选项
|
||||
$('ul.advancedSearchFormBody li.item').each((i,e)=>{
|
||||
$('ul.advancedSearchFormBody li.item').each((i, e) => {
|
||||
if (headerDict[$(e).text()])
|
||||
$(e).text(headerDict[$(e).text()]);
|
||||
else if(propertyDict[$(e).text()])
|
||||
else if (propertyDict[$(e).text()])
|
||||
$(e).text(propertyDict[$(e).text()]);
|
||||
});
|
||||
// 高级搜索的"Not"
|
||||
$('ul.advancedSearchFormBody label.search-condition-not').each((i,e)=>{
|
||||
$('ul.advancedSearchFormBody label.search-condition-not').each((i, e) => {
|
||||
if (headerDict[$(e).text()])
|
||||
$(e).text(headerDict[$(e).text()]);
|
||||
});
|
||||
// 高级搜索的"to"
|
||||
$('ul.advancedSearchFormBody label[for*="To"]').each((i,e)=>{
|
||||
$('ul.advancedSearchFormBody label[for*="To"]').each((i, e) => {
|
||||
if (headerDict[$(e).text()])
|
||||
$(e).text(headerDict[$(e).text()]);
|
||||
});
|
||||
// 高级搜索的reset search按钮
|
||||
$('form.form-search-extend div.bottom button').each((i,e)=>{
|
||||
$('form.form-search-extend div.bottom button').each((i, e) => {
|
||||
if (headerDict[$(e).text()])
|
||||
$(e).text(headerDict[$(e).text()]);
|
||||
});
|
||||
// 服务器时间
|
||||
$('span.server-date-time').each((i,e)=>{
|
||||
const d=new Date($(e).text());
|
||||
if(d.format('yyyy')!=='NaN')
|
||||
$('span.server-date-time').each((i, e) => {
|
||||
const d = new Date($(e).text());
|
||||
if (d.format('yyyy') !== 'NaN')
|
||||
$(e).text()
|
||||
});
|
||||
// log按钮“view log”
|
||||
if(headerDict[$('div.recentHistory a[class^="link"] span[class^="text"]').text().trim()])
|
||||
if (headerDict[$('div.recentHistory a[class^="link"] span[class^="text"]').text().trim()])
|
||||
$('div.recentHistory a[class^="link"] span[class^="text"]')
|
||||
.text(headerDict[$('div.recentHistory a[class^="link"] span[class^="text"]').text().trim()]);
|
||||
// 点击头像打开的菜单
|
||||
$('ul.settings-menu span').each((i,e)=>{
|
||||
if (headerDict[$(e).text()] && e.childNodes.length===1)
|
||||
$('ul.settings-menu span').each((i, e) => {
|
||||
if (headerDict[$(e).text()] && e.childNodes.length === 1)
|
||||
$(e).text(headerDict[$(e).text()]);
|
||||
else if(e.childNodes.length===3)
|
||||
if(headerDict[e.firstChild.nodeValue])
|
||||
e.firstChild.nodeValue=headerDict[e.firstChild.nodeValue];
|
||||
else if (e.childNodes.length === 3)
|
||||
if (headerDict[e.firstChild.nodeValue])
|
||||
e.firstChild.nodeValue = headerDict[e.firstChild.nodeValue];
|
||||
});
|
||||
};
|
||||
headerTrans();
|
||||
headerOB.observe($('div#header-root')[0], {childList: true, subtree: true, attributes:true});
|
||||
headerOB.observe($('div#header-root')[0], {childList: true, subtree: true, attributes: true});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1227,25 +1248,35 @@
|
||||
* 通知页面
|
||||
*/
|
||||
if (window.location.href.indexOf('events.php') >= 0) {
|
||||
titleTrans();
|
||||
let events;
|
||||
const eventMutation = new MutationObserver(() => {
|
||||
eventMutation.disconnect();
|
||||
events = $('span.mail-link');
|
||||
eventsTrans(events);
|
||||
eventMutation.observe($('div#events-main-wrapper')[0], {childList: true, subtree: true});
|
||||
const ob = new MutationObserver(() => {
|
||||
ob.disconnect();
|
||||
titleTrans();
|
||||
contentTitleLinksTrans();
|
||||
eventsTrans();
|
||||
ob.observe($('div.content-wrapper')[0], {childList: true, subtree: true});
|
||||
});
|
||||
|
||||
//初始化中内容未加载
|
||||
let eventInterval = setInterval(() => {
|
||||
events = $('span.mail-link');
|
||||
if (events.length === 0) {
|
||||
return;
|
||||
}
|
||||
clearInterval(eventInterval);
|
||||
eventMutation.observe($('div#events-main-wrapper')[0], {childList: true, subtree: true});
|
||||
eventsTrans(events);
|
||||
}, 1000);
|
||||
eventsTrans();
|
||||
ob.observe($('div.content-wrapper')[0], {childList: true, subtree: true});
|
||||
return;
|
||||
// let events;
|
||||
// const eventMutation = new MutationObserver(() => {
|
||||
// eventMutation.disconnect();
|
||||
// // events = $('span.mail-link');
|
||||
// // eventsTrans(events);
|
||||
// eventsTrans();
|
||||
// eventMutation.observe($('div#events-main-wrapper')[0], {childList: true, subtree: true});
|
||||
// });
|
||||
//
|
||||
// //初始化中内容未加载
|
||||
// let eventInterval = setInterval(() => {
|
||||
// // events = $('span.mail-link');
|
||||
// // if (events.length === 0) {
|
||||
// // return;
|
||||
// // }
|
||||
// clearInterval(eventInterval);
|
||||
// eventMutation.observe($('div#events-main-wrapper')[0], {childList: true, subtree: true});
|
||||
// eventsTrans(events);
|
||||
// }, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1258,37 +1289,34 @@
|
||||
* 通知翻译函数
|
||||
* @param events
|
||||
*/
|
||||
function eventsTrans(events) {
|
||||
|
||||
const eventsDict = {
|
||||
"ALL EVENTS": "所有通知",
|
||||
"RECEIVED": "收到的通知",
|
||||
"SAVED": "已保存通知",
|
||||
"Delete selected": "删除已选",
|
||||
"Save selected": "保存已选",
|
||||
"Check All": "勾选所有",
|
||||
"Uncheck All": "取消勾选所有",
|
||||
"Events": "通知",
|
||||
"Log": "日志",
|
||||
"Back": "返回",
|
||||
"Recruit Citizens": "招募市民",
|
||||
"Tutorial": "教程"
|
||||
}
|
||||
|
||||
function eventsTrans(events = $('span.mail-link')) {
|
||||
const index = window.location.href.indexOf('events.php#/step=received') >= 0 ? 1 : 0;
|
||||
const isReceived = index === 1;
|
||||
/**
|
||||
* 通知的类型选择栏
|
||||
*/
|
||||
$('div[class^="mailbox-wrapper m-top10"] a[class^="btn torn-btn black"]')
|
||||
.contents().each((i, e) => {
|
||||
if (e.nodeValue)
|
||||
if (eventsDict[e.nodeValue.trim()])
|
||||
e.nodeValue = eventsDict[e.nodeValue.trim()];
|
||||
});
|
||||
// .each((i, e) => {
|
||||
// let word = $(e).text().trim()
|
||||
//
|
||||
// if (word.indexOf("(") > 0) {
|
||||
// if (eventsDict[word.split(" (")[0]]) {
|
||||
// $(e).text($(e).text()
|
||||
// .replace(word.split(" (")[0], eventsDict[word.split(" (")[0]]));
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
if (events.length === 0) return;
|
||||
events.each((i, e) => {
|
||||
|
||||
/** 选择栏**/
|
||||
$('div[class^="mailbox-wrapper m-top10"] a[class^="btn torn-btn black"]').each((i, e) => {
|
||||
let word = $(e).text().trim()
|
||||
|
||||
if (word.indexOf("(") > 0) {
|
||||
if (eventsDict[word.split(" (")[0]]) {
|
||||
$(e).text($(e).text()
|
||||
.replace(word.split(" (")[0], eventsDict[word.split(" (")[0]]));
|
||||
}
|
||||
}
|
||||
});
|
||||
if (isReceived) {// todo “收到的信息” 暂时删除发送人节点 不影响显示
|
||||
$(e).children(':first').remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* 赛车
|
||||
@ -1377,7 +1405,7 @@
|
||||
* You were sent Duke's Safe from DUKE
|
||||
* You were sent a Diamond Bladed Knife from charapower
|
||||
*/
|
||||
if ($(e).text().indexOf('sent') >= 0) {
|
||||
if ($(e).text().indexOf('were sent') >= 0) {
|
||||
if ($(e).text().split('from someone').length > 1) return; // todo 收到匿名发来的物资
|
||||
const isWithMsg = $(e).text().indexOf('message') >= 0;
|
||||
const msg = isWithMsg ? $(e).text().split(' with the message: ')[1] : null;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user