更新通知页面和通知翻译函数
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': '现金',
|
||||
@ -468,6 +472,23 @@
|
||||
'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 (': '保存的通知 (',
|
||||
}
|
||||
|
||||
/**
|
||||
* 边栏
|
||||
@ -1227,25 +1248,35 @@
|
||||
* 通知页面
|
||||
*/
|
||||
if (window.location.href.indexOf('events.php') >= 0) {
|
||||
const ob = new MutationObserver(() => {
|
||||
ob.disconnect();
|
||||
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});
|
||||
contentTitleLinksTrans();
|
||||
eventsTrans();
|
||||
ob.observe($('div.content-wrapper')[0], {childList: true, subtree: true});
|
||||
});
|
||||
|
||||
//初始化中内容未加载
|
||||
let eventInterval = setInterval(() => {
|
||||
events = $('span.mail-link');
|
||||
if (events.length === 0) {
|
||||
eventsTrans();
|
||||
ob.observe($('div.content-wrapper')[0], {childList: true, subtree: true});
|
||||
return;
|
||||
}
|
||||
clearInterval(eventInterval);
|
||||
eventMutation.observe($('div#events-main-wrapper')[0], {childList: true, subtree: true});
|
||||
eventsTrans(events);
|
||||
}, 1000);
|
||||
// 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