增加替换名称里的其他语言搜索
This commit is contained in:
parent
ac9dbf9ab6
commit
6dcafcf1b7
|
@ -373,4 +373,8 @@
|
|||
.dialog-close::before
|
||||
{
|
||||
content: "Close";
|
||||
}
|
||||
.dialog .dialog-content .additional-string::before
|
||||
{
|
||||
content: "Other Languages";
|
||||
}
|
|
@ -365,4 +365,8 @@
|
|||
.dialog-close::before
|
||||
{
|
||||
content: "閉じる";
|
||||
}
|
||||
.dialog .dialog-content .additional-string::before
|
||||
{
|
||||
content: "他の言語";
|
||||
}
|
|
@ -362,4 +362,8 @@
|
|||
.dialog-close::before
|
||||
{
|
||||
content: "가까이";
|
||||
}
|
||||
.dialog .dialog-content .additional-string::before
|
||||
{
|
||||
content: "다른 언어";
|
||||
}
|
|
@ -368,4 +368,8 @@
|
|||
.dialog-close::before
|
||||
{
|
||||
content: "關閉";
|
||||
}
|
||||
.dialog .dialog-content .additional-string::before
|
||||
{
|
||||
content: "其他語言";
|
||||
}
|
|
@ -368,4 +368,8 @@
|
|||
.dialog-close::before
|
||||
{
|
||||
content: "关闭";
|
||||
}
|
||||
.dialog .dialog-content .additional-string::before
|
||||
{
|
||||
content: "其他語言";
|
||||
}
|
|
@ -1 +1 @@
|
|||
[{"code":"ja","ckey":{"card":"64a6c487a7ab70a9562faf34081e132a","skill":"45427fb4f7e3f8bbfaa92d5bec86c60d"},"updateTime":1607085288297},{"code":"en","ckey":{"card":"1a832423f4d360bdceb73fc0cf5b6c5a","skill":"40b9acf5827237c5c4a450bd8289c4f9"},"updateTime":1607084419797},{"code":"ko","ckey":{"card":"ac1d751a35eb983592f5d3c7b367144e","skill":"908399019cc34e9a73b5344855093243"},"updateTime":1607084419797}]
|
||||
[{"code":"ja","ckey":{"card":"fe38b781bf7a2d736b80eb978dafa50b","skill":"45427fb4f7e3f8bbfaa92d5bec86c60d"},"updateTime":1607595558269},{"code":"en","ckey":{"card":"13c53ec60b057b7a6547b8d9659a9664","skill":"40b9acf5827237c5c4a450bd8289c4f9"},"updateTime":1607595293431},{"code":"ko","ckey":{"card":"7d4e3027765ad46bc6d45843f9d909be","skill":"908399019cc34e9a73b5344855093243"},"updateTime":1607595293431}]
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -52,13 +52,19 @@ officialAPI.forEach(function(lang) {
|
|||
console.log("正在读取自定义 " + lcode + " 信息");
|
||||
const ljson = fs.readFileSync("custom/" + lcode +".json", 'utf-8'); //使用同步读取
|
||||
const ccard = JSON.parse(ljson);//将字符串转换为json对象
|
||||
ccard.forEach(function(cm,idx){ //每个文件内的名字循环
|
||||
ccard.forEach(function(cm){ //每个文件内的名字循环
|
||||
let m = monCards[cm.id];
|
||||
if (m)
|
||||
{
|
||||
if (!m.otLangName) //如果没有其他语言名称属性,则添加一个对象属性
|
||||
m.otLangName = {};
|
||||
m.otLangName[lcode] = cm.name;
|
||||
if (!m.otTags) //如果没有其他语言名称属性,则添加一个对象属性
|
||||
m.otTags = [];
|
||||
|
||||
let newTags = Array.from(new Set(cm.tags));
|
||||
newTags = newTags.filter(tag=>!m.altName.includes(tag) && !m.otTags.includes(tag));
|
||||
m.otTags.push(...newTags);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -128,8 +134,10 @@ for (let li = 0;li < officialAPI.length; li++)
|
|||
if (_m && isSame) //如果有这个怪物,且与原语言怪物是同一只
|
||||
{
|
||||
const otName = _m.name;
|
||||
const searchRegString = "^(?:\\?+|\\*+|초월\\s*\\?+)"; //名字以问号、星号、韩文的问号开头
|
||||
if (!new RegExp(searchRegString,"i").test(otName))
|
||||
if (/^(?:\?+|\*+|초월\s*\?+)/i.test(otName)) //名字以问号、星号、韩文的问号开头
|
||||
{
|
||||
return; //跳过
|
||||
}else
|
||||
{
|
||||
if (!m.otLangName) //如果没有其他语言名称属性,则添加一个对象属性
|
||||
m.otLangName = {};
|
||||
|
@ -145,6 +153,13 @@ for (let li = 0;li < officialAPI.length; li++)
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!m.otTags) //如果没有其他语言标签属性,则添加一个数组属性
|
||||
m.otTags = [];
|
||||
|
||||
let otTags = Array.from(new Set(_m.otTags ? _m.altName.concat(_m.otTags) : _m.altName));
|
||||
otTags = otTags.filter(tag=>!m.altName.includes(tag) && !m.otTags.includes(tag));
|
||||
m.otTags.push(...otTags);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const fs = require('fs');
|
||||
const sourceFolder = "Download-pad.skyozora.com/pad.skyozora.com";
|
||||
const outJSON = "custom/cht.json";
|
||||
const path = require('path');//解析需要遍历的文件夹
|
||||
const sourceFolder = "Download-pad.skyozora.com/pad.skyozora.com"; //战友网数据的存储问文件夹
|
||||
const outJSON = "custom/cht.json"; //输出的JSON文件
|
||||
|
||||
fs.access(outJSON,function(err){
|
||||
let monArr;
|
||||
|
@ -10,44 +10,76 @@ fs.access(outJSON,function(err){
|
|||
monArr = [];
|
||||
}else
|
||||
{
|
||||
monArr = JSON.parse(fs.readFileSync(outJSON, 'utf-8'));//读取繁体中文数据避免重复工作
|
||||
try
|
||||
{
|
||||
monArr = JSON.parse(fs.readFileSync(outJSON, 'utf-8'));//读取繁体中文数据避免重复工作
|
||||
}catch(e)
|
||||
{
|
||||
monArr = [];
|
||||
}
|
||||
}
|
||||
|
||||
//根据文件路径读取文件,返回文件列表
|
||||
fs.readdir(sourceFolder,function(err,files){
|
||||
fs.readdir(sourceFolder,function(err,files){console.log()
|
||||
if(err){
|
||||
console.warn(err);
|
||||
}else{
|
||||
//遍历读取到的文件列表
|
||||
files.forEach(function(filename){
|
||||
let searchID = /^(\d+)\.html$/i.exec(filename);
|
||||
if (searchID && !monArr.some(function(cn){return cn.id == searchID[1];}))
|
||||
const searchID = /^(\d+)\.html$/i.exec(filename);
|
||||
const mId = searchID ? parseInt(searchID[1],10) : null;
|
||||
if (mId != null && !monArr.some(cn => cn.id == mId))
|
||||
{
|
||||
const filepath = path.join(sourceFolder, filename);//合并当前文件的路径
|
||||
const htmlText = fs.readFileSync(filepath, 'utf-8'); //使用同步读取
|
||||
let searchName = /<h2 .+>\s*?([\s\S]*)\s*?<\/h2>/igm.exec(htmlText);
|
||||
try
|
||||
|
||||
const m = {
|
||||
id: mId,
|
||||
name: null,
|
||||
tags: [],
|
||||
};
|
||||
|
||||
//添加分类tag
|
||||
const regTags = /<a [^>]+?\s?class="category"\s?[^>]+>\s*<span>\s*#([^<]+?)\s*<\/span>\s*<\/a>/igm;
|
||||
let resTags;
|
||||
while(resTags = regTags.exec(htmlText))
|
||||
{
|
||||
let mname = searchName[1].trim();
|
||||
mname = mname.replace("探偵","偵探"); //把日语的探侦都换成侦探
|
||||
if (mname.length>0)
|
||||
let mTag = resTags[1].trim();
|
||||
if (mTag.length>0)
|
||||
{
|
||||
const m = {
|
||||
id:searchID[1],
|
||||
name:mname,
|
||||
};
|
||||
m.tags.push(mTag);
|
||||
}
|
||||
}
|
||||
|
||||
//添加怪物名
|
||||
const regName = /<h2 .+>\s*?([\s\S]*)\s*?<\/h2>/igm;
|
||||
let resName = regName.exec(htmlText);
|
||||
if (resName)
|
||||
{
|
||||
let mName = resName[1].trim();
|
||||
mName = mName.replace(/探偵/g,"偵探"); //把日语的探侦都换成侦探
|
||||
if (mName.length>0)
|
||||
{
|
||||
m.name = mName;
|
||||
monArr.push(m);
|
||||
if (monArr.length % 100 == 0)
|
||||
{
|
||||
console.log("已添加 " + monArr.length + " 个数据");
|
||||
const str = JSON.stringify(monArr);
|
||||
fs.writeFileSync(outJSON,str,function(err){
|
||||
//每添加一部分就写入一次,避免每次重头再来
|
||||
if(err){
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
}else
|
||||
{
|
||||
console.log(filename + "的中文名为空。");
|
||||
console.log(filename + " 的中文名为空。");
|
||||
}
|
||||
}catch(e)
|
||||
}else
|
||||
{
|
||||
console.log(filename,e);
|
||||
console.log(filename + " 未找到中文名Node。");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -74,7 +74,7 @@ class Card{
|
|||
return t == 0 || t == 12 || t == 14; //0進化用;12能力覺醒用;14強化合成用;15販賣用
|
||||
}) && (flags & 1<<3) === 0; //進化用、能力覺醒用、強化合成用,且flag有1000时
|
||||
card.is8Latent = (flags & 1<<5) !== 0; //是否支持8个潜觉
|
||||
card.altName = data[i++]; //替换名字
|
||||
card.altName = data[i++].split("|").filter(str=>str.length); //替换名字(分类标签)
|
||||
card.limitBreakIncr = data[i++]; //110级增长
|
||||
card.voiceId = data[i++]; //语音觉醒的ID
|
||||
card.blockSkinId = data[i++]; //珠子皮肤ID
|
||||
|
|
56
script.js
56
script.js
|
@ -974,12 +974,16 @@ function initialize() {
|
|||
{
|
||||
showSearch(Cards.filter(card =>
|
||||
{
|
||||
const altNames = card.altName.split("|");
|
||||
const names = [card.name];
|
||||
if (card.otLangName)
|
||||
{
|
||||
names.push(...Object.values(card.otLangName));
|
||||
}
|
||||
const altNames = card.altName;
|
||||
if (card.otTags)
|
||||
{
|
||||
altNames.push(...card.otTags);
|
||||
}
|
||||
return altNames.some(astr=>astr.includes(str)) || names.some(astr=>astr.includes(str));
|
||||
}
|
||||
));
|
||||
|
@ -993,14 +997,16 @@ function initialize() {
|
|||
}
|
||||
//input.blur(); //取消焦点
|
||||
}
|
||||
stringSearchDialog.show = function(strArr)
|
||||
stringSearchDialog.show = function(originalStrArr = [], additionalStrArr = [])
|
||||
{
|
||||
const stringSearchContent = this.querySelector(".dialog-content");
|
||||
const ul = document.createElement("ul");
|
||||
if (strArr.length > 0 && strArr[0].length > 0)
|
||||
const fragment = document.createDocumentFragment();
|
||||
if (originalStrArr.length > 0 && originalStrArr[0].length > 0)
|
||||
{
|
||||
strArr.forEach(str=>{
|
||||
const li = ul.appendChild(document.createElement("li"));
|
||||
const ul_original = document.createElement("ul");
|
||||
ul_original.className = "original-string";
|
||||
originalStrArr.forEach(str=>{
|
||||
const li = ul_original.appendChild(document.createElement("li"));
|
||||
const ipt = li.appendChild(document.createElement("input"));
|
||||
ipt.className = "string-value";
|
||||
ipt.value = str;
|
||||
|
@ -1012,9 +1018,26 @@ function initialize() {
|
|||
searchBtn.className = "string-search";
|
||||
searchBtn.onclick = function(){searchByString(ipt.value)};
|
||||
});
|
||||
fragment.appendChild(ul_original);
|
||||
}
|
||||
if (additionalStrArr.length > 0 && additionalStrArr[0].length > 0)
|
||||
{
|
||||
const ul_additional = document.createElement("ul");
|
||||
ul_additional.className = "additional-string";
|
||||
additionalStrArr.forEach(str=>{
|
||||
const li = ul_additional.appendChild(document.createElement("li"));
|
||||
const ipt = li.appendChild(document.createElement("input"));
|
||||
ipt.className = "string-value";
|
||||
ipt.value = str;
|
||||
ipt.readOnly = true;
|
||||
const searchBtn = li.appendChild(document.createElement("button"));
|
||||
searchBtn.className = "string-search";
|
||||
searchBtn.onclick = function(){searchByString(ipt.value)};
|
||||
});
|
||||
fragment.appendChild(ul_additional);
|
||||
}
|
||||
stringSearchContent.innerHTML = "";
|
||||
stringSearchContent.appendChild(ul);
|
||||
stringSearchContent.appendChild(fragment);
|
||||
this.classList.remove(className_displayNone);
|
||||
}
|
||||
stringSearchDialog.close = function()
|
||||
|
@ -1026,18 +1049,11 @@ function initialize() {
|
|||
|
||||
const mAltName = smonsterinfoBox.querySelector(".monster-altName");
|
||||
mAltName.onclick = function() { //搜索合作
|
||||
const altName = this.getAttribute('data-altName');
|
||||
if (altName.length > 0)
|
||||
//const mid = parseInt(this.getAttribute('data-monId'));
|
||||
const card = Cards[editBox.mid];
|
||||
if (card)
|
||||
{
|
||||
stringSearchDialog.show(altName.split("|"));
|
||||
/*
|
||||
showSearch(Cards.filter(card =>
|
||||
splitAltName.some(alt =>
|
||||
alt.length > 0 &&
|
||||
(card.altName.includes(alt) || card.name.includes(alt))
|
||||
)
|
||||
));
|
||||
*/
|
||||
stringSearchDialog.show(card.altName, card.otTags);
|
||||
}
|
||||
};
|
||||
//创建一个新的怪物头像
|
||||
|
@ -2325,9 +2341,9 @@ function editBoxChangeMonId(id) {
|
|||
mCollabId.classList.remove(className_displayNone);
|
||||
}
|
||||
const mAltName = monInfoBox.querySelector(".monster-altName");
|
||||
mAltName.textContent = card.altName;
|
||||
mAltName.textContent = card.altName.join("|");
|
||||
|
||||
mAltName.setAttribute("data-altName", card.altName);
|
||||
//mAltName.setAttribute("data-monId", card.id);
|
||||
|
||||
if (card.altName.length == 0) { //当没有合作名
|
||||
mAltName.classList.add(className_displayNone);
|
||||
|
|
13
style.css
13
style.css
|
@ -2117,8 +2117,14 @@ ul{
|
|||
{
|
||||
transform: scale(1.1);
|
||||
}
|
||||
.dialog .dialog-content input
|
||||
.dialog .dialog-content .additional-string
|
||||
{
|
||||
border-top: 2px solid white;
|
||||
margin-top: 5px;
|
||||
}
|
||||
.dialog .dialog-content .additional-string::before
|
||||
{
|
||||
content: "其他語言";
|
||||
}
|
||||
.dialog .dialog-control
|
||||
{
|
||||
|
@ -2185,4 +2191,9 @@ ul{
|
|||
{
|
||||
box-sizing: border-box;
|
||||
width: calc(100% - 50px * 2);
|
||||
}
|
||||
.dialog-search-string .additional-string .string-value
|
||||
{
|
||||
box-sizing: border-box;
|
||||
width: calc(100% - 50px * 1);
|
||||
}
|
Loading…
Reference in New Issue