更新通知页面和通知翻译函数
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': '现金',
|
||||||
@ -443,31 +447,48 @@
|
|||||||
'The Sports Science Lab': '运动科学实验室',
|
'The Sports Science Lab': '运动科学实验室',
|
||||||
'The Jail Gym': '监狱健身房',
|
'The Jail Gym': '监狱健身房',
|
||||||
};
|
};
|
||||||
const headerDict={
|
const headerDict = {
|
||||||
"User's Name / ID":'用户名或ID',
|
"User's Name / ID": '用户名或ID',
|
||||||
'Faction':'帮派',
|
'Faction': '帮派',
|
||||||
'Company':'帮派',
|
'Company': '帮派',
|
||||||
'Places':'地点',
|
'Places': '地点',
|
||||||
'Item Market':'交易市场',
|
'Item Market': '交易市场',
|
||||||
'Forum posts':'论坛',
|
'Forum posts': '论坛',
|
||||||
'Help':'帮助',
|
'Help': '帮助',
|
||||||
'search...':'搜索',
|
'search...': '搜索',
|
||||||
'Search users by...':'高级用户搜索',
|
'Search users by...': '高级用户搜索',
|
||||||
'Property':'住房',
|
'Property': '住房',
|
||||||
'Male':'男性',
|
'Male': '男性',
|
||||||
'to':'到',
|
'to': '到',
|
||||||
'Reset':'重置',
|
'Reset': '重置',
|
||||||
'Search':'搜索',
|
'Search': '搜索',
|
||||||
'0 - 15 min':'0 - 15 分钟',
|
'0 - 15 min': '0 - 15 分钟',
|
||||||
'Not':'不',
|
'Not': '不',
|
||||||
'View Log':'查看日志',
|
'View Log': '查看日志',
|
||||||
'View Profile':'查看个人资料',
|
'View Profile': '查看个人资料',
|
||||||
'Settings':'设置',
|
'Settings': '设置',
|
||||||
'Server:':'服务器 ',
|
'Server:': '服务器 ',
|
||||||
'Dark Mode':'',
|
'Dark Mode': '',
|
||||||
'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 (': '保存的通知 (',
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 边栏
|
* 边栏
|
||||||
@ -553,87 +574,87 @@
|
|||||||
* header
|
* header
|
||||||
*/
|
*/
|
||||||
// $('div#header-root').each((i,e)=>{
|
// $('div#header-root').each((i,e)=>{
|
||||||
if($('div#header-root').length>0){
|
if ($('div#header-root').length > 0) {
|
||||||
const headerOB=new MutationObserver(_=>{
|
const headerOB = new MutationObserver(_ => {
|
||||||
headerOB.disconnect();
|
headerOB.disconnect();
|
||||||
headerTrans();
|
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()])
|
if (headerDict[$('div.find button.toggler.down').text()])
|
||||||
$('div.find button.toggler.down').text(headerDict[$('div.find button.toggler.down').text()]);
|
$('div.find button.toggler.down').text(headerDict[$('div.find button.toggler.down').text()]);
|
||||||
// pc端 搜索下拉框点击后的搜索类型文字
|
// pc端 搜索下拉框点击后的搜索类型文字
|
||||||
$('div.find li.item').each((i,e)=>{
|
$('div.find li.item').each((i, e) => {
|
||||||
if (headerDict[$(e).text()])
|
if (headerDict[$(e).text()])
|
||||||
$(e).text(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()])
|
if (headerDict[$(e).text()])
|
||||||
$(e).text(headerDict[$(e).text()]);
|
$(e).text(headerDict[$(e).text()]);
|
||||||
});
|
});
|
||||||
// 搜索框placeholder
|
// 搜索框placeholder
|
||||||
if(headerDict[$('input[class^="searchInput"]').attr('placeholder')])
|
if (headerDict[$('input[class^="searchInput"]').attr('placeholder')])
|
||||||
$('input[class^="searchInput"]').attr('placeholder',
|
$('input[class^="searchInput"]').attr('placeholder',
|
||||||
headerDict[$('input[class^="searchInput"]').attr('placeholder')]);
|
headerDict[$('input[class^="searchInput"]').attr('placeholder')]);
|
||||||
// 高级搜索框 search by
|
// 高级搜索框 search by
|
||||||
if (headerDict[$('div#header-root legend.title').text()])
|
if (headerDict[$('div#header-root legend.title').text()])
|
||||||
$('div#header-root legend.title').text(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)=>{
|
$('ul.advancedSearchFormBody label.label').each((i, e) => {
|
||||||
if(headerDict[$(e).text()])
|
if (headerDict[$(e).text()])
|
||||||
$(e).text(headerDict[$(e).text()]);
|
$(e).text(headerDict[$(e).text()]);
|
||||||
});
|
});
|
||||||
// 高级搜索框的已选中
|
// 高级搜索框的已选中
|
||||||
$('ul.advancedSearchFormBody div.select-wrapper button.toggler.down').each((i,e)=>{
|
$('ul.advancedSearchFormBody div.select-wrapper button.toggler.down').each((i, e) => {
|
||||||
if(headerDict[$(e).text()])
|
if (headerDict[$(e).text()])
|
||||||
$(e).text(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()])
|
if (headerDict[$(e).text()])
|
||||||
$(e).text(headerDict[$(e).text()]);
|
$(e).text(headerDict[$(e).text()]);
|
||||||
else if(propertyDict[$(e).text()])
|
else if (propertyDict[$(e).text()])
|
||||||
$(e).text(propertyDict[$(e).text()]);
|
$(e).text(propertyDict[$(e).text()]);
|
||||||
});
|
});
|
||||||
// 高级搜索的"Not"
|
// 高级搜索的"Not"
|
||||||
$('ul.advancedSearchFormBody label.search-condition-not').each((i,e)=>{
|
$('ul.advancedSearchFormBody label.search-condition-not').each((i, e) => {
|
||||||
if (headerDict[$(e).text()])
|
if (headerDict[$(e).text()])
|
||||||
$(e).text(headerDict[$(e).text()]);
|
$(e).text(headerDict[$(e).text()]);
|
||||||
});
|
});
|
||||||
// 高级搜索的"to"
|
// 高级搜索的"to"
|
||||||
$('ul.advancedSearchFormBody label[for*="To"]').each((i,e)=>{
|
$('ul.advancedSearchFormBody label[for*="To"]').each((i, e) => {
|
||||||
if (headerDict[$(e).text()])
|
if (headerDict[$(e).text()])
|
||||||
$(e).text(headerDict[$(e).text()]);
|
$(e).text(headerDict[$(e).text()]);
|
||||||
});
|
});
|
||||||
// 高级搜索的reset search按钮
|
// 高级搜索的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()])
|
if (headerDict[$(e).text()])
|
||||||
$(e).text(headerDict[$(e).text()]);
|
$(e).text(headerDict[$(e).text()]);
|
||||||
});
|
});
|
||||||
// 服务器时间
|
// 服务器时间
|
||||||
$('span.server-date-time').each((i,e)=>{
|
$('span.server-date-time').each((i, e) => {
|
||||||
const d=new Date($(e).text());
|
const d = new Date($(e).text());
|
||||||
if(d.format('yyyy')!=='NaN')
|
if (d.format('yyyy') !== 'NaN')
|
||||||
$(e).text()
|
$(e).text()
|
||||||
});
|
});
|
||||||
// log按钮“view log”
|
// 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"]')
|
$('div.recentHistory a[class^="link"] span[class^="text"]')
|
||||||
.text(headerDict[$('div.recentHistory a[class^="link"] span[class^="text"]').text().trim()]);
|
.text(headerDict[$('div.recentHistory a[class^="link"] span[class^="text"]').text().trim()]);
|
||||||
// 点击头像打开的菜单
|
// 点击头像打开的菜单
|
||||||
$('ul.settings-menu span').each((i,e)=>{
|
$('ul.settings-menu span').each((i, e) => {
|
||||||
if (headerDict[$(e).text()] && e.childNodes.length===1)
|
if (headerDict[$(e).text()] && e.childNodes.length === 1)
|
||||||
$(e).text(headerDict[$(e).text()]);
|
$(e).text(headerDict[$(e).text()]);
|
||||||
else if(e.childNodes.length===3)
|
else if (e.childNodes.length === 3)
|
||||||
if(headerDict[e.firstChild.nodeValue])
|
if (headerDict[e.firstChild.nodeValue])
|
||||||
e.firstChild.nodeValue=headerDict[e.firstChild.nodeValue];
|
e.firstChild.nodeValue = headerDict[e.firstChild.nodeValue];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
headerTrans();
|
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) {
|
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