更新通知页面和通知翻译函数
This commit is contained in:
parent
3ee6724f18
commit
eeef884832
@ -29,6 +29,9 @@
|
|||||||
'Gym': '健身房',
|
'Gym': '健身房',
|
||||||
'Biology Modules': '生物学课程',
|
'Biology Modules': '生物学课程',
|
||||||
'Traveling': '飞行中',
|
'Traveling': '飞行中',
|
||||||
|
'Events': '通知',
|
||||||
|
'Received Events': '收到的通知',
|
||||||
|
'Saved Events': '保存的通知',
|
||||||
};
|
};
|
||||||
const titleLinksDict = {
|
const titleLinksDict = {
|
||||||
'Personal stats': '个人统计信息',
|
'Personal stats': '个人统计信息',
|
||||||
@ -47,6 +50,7 @@
|
|||||||
'People': "用户列表",
|
'People': "用户列表",
|
||||||
'Computer': '电脑',
|
'Computer': '电脑',
|
||||||
'Market': '市场',
|
'Market': '市场',
|
||||||
|
'Back': '返回',
|
||||||
};
|
};
|
||||||
const sidebarDict = { // todo 从json加载
|
const sidebarDict = { // todo 从json加载
|
||||||
'Money': '现金',
|
'Money': '现金',
|
||||||
@ -468,6 +472,23 @@
|
|||||||
'News Ticker': '',
|
'News Ticker': '',
|
||||||
'Logout': '',
|
'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) {
|
if (window.location.href.indexOf('events.php') >= 0) {
|
||||||
|
const ob = new MutationObserver(() => {
|
||||||
|
ob.disconnect();
|
||||||
titleTrans();
|
titleTrans();
|
||||||
let events;
|
contentTitleLinksTrans();
|
||||||
const eventMutation = new MutationObserver(() => {
|
eventsTrans();
|
||||||
eventMutation.disconnect();
|
ob.observe($('div.content-wrapper')[0], {childList: true, subtree: true});
|
||||||
events = $('span.mail-link');
|
|
||||||
eventsTrans(events);
|
|
||||||
eventMutation.observe($('div#events-main-wrapper')[0], {childList: true, subtree: true});
|
|
||||||
});
|
});
|
||||||
|
eventsTrans();
|
||||||
//初始化中内容未加载
|
ob.observe($('div.content-wrapper')[0], {childList: true, subtree: true});
|
||||||
let eventInterval = setInterval(() => {
|
|
||||||
events = $('span.mail-link');
|
|
||||||
if (events.length === 0) {
|
|
||||||
return;
|
return;
|
||||||
}
|
// let events;
|
||||||
clearInterval(eventInterval);
|
// const eventMutation = new MutationObserver(() => {
|
||||||
eventMutation.observe($('div#events-main-wrapper')[0], {childList: true, subtree: true});
|
// eventMutation.disconnect();
|
||||||
eventsTrans(events);
|
// // events = $('span.mail-link');
|
||||||
}, 1000);
|
// // 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
|
* @param events
|
||||||
*/
|
*/
|
||||||
function eventsTrans(events) {
|
function eventsTrans(events = $('span.mail-link')) {
|
||||||
|
const index = window.location.href.indexOf('events.php#/step=received') >= 0 ? 1 : 0;
|
||||||
const eventsDict = {
|
const isReceived = index === 1;
|
||||||
"ALL EVENTS": "所有通知",
|
/**
|
||||||
"RECEIVED": "收到的通知",
|
* 通知的类型选择栏
|
||||||
"SAVED": "已保存通知",
|
*/
|
||||||
"Delete selected": "删除已选",
|
$('div[class^="mailbox-wrapper m-top10"] a[class^="btn torn-btn black"]')
|
||||||
"Save selected": "保存已选",
|
.contents().each((i, e) => {
|
||||||
"Check All": "勾选所有",
|
if (e.nodeValue)
|
||||||
"Uncheck All": "取消勾选所有",
|
if (eventsDict[e.nodeValue.trim()])
|
||||||
"Events": "通知",
|
e.nodeValue = eventsDict[e.nodeValue.trim()];
|
||||||
"Log": "日志",
|
});
|
||||||
"Back": "返回",
|
// .each((i, e) => {
|
||||||
"Recruit Citizens": "招募市民",
|
// let word = $(e).text().trim()
|
||||||
"Tutorial": "教程"
|
//
|
||||||
}
|
// 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;
|
if (events.length === 0) return;
|
||||||
events.each((i, e) => {
|
events.each((i, e) => {
|
||||||
|
|
||||||
/** 选择栏**/
|
if (isReceived) {// todo “收到的信息” 暂时删除发送人节点 不影响显示
|
||||||
$('div[class^="mailbox-wrapper m-top10"] a[class^="btn torn-btn black"]').each((i, e) => {
|
$(e).children(':first').remove();
|
||||||
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]]));
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 赛车
|
* 赛车
|
||||||
@ -1377,7 +1405,7 @@
|
|||||||
* You were sent Duke's Safe from DUKE
|
* You were sent Duke's Safe from DUKE
|
||||||
* You were sent a Diamond Bladed Knife from charapower
|
* 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 收到匿名发来的物资
|
if ($(e).text().split('from someone').length > 1) return; // todo 收到匿名发来的物资
|
||||||
const isWithMsg = $(e).text().indexOf('message') >= 0;
|
const isWithMsg = $(e).text().indexOf('message') >= 0;
|
||||||
const msg = isWithMsg ? $(e).text().split(' with the message: ')[1] : null;
|
const msg = isWithMsg ? $(e).text().split(' with the message: ')[1] : null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user