-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
227 lines (203 loc) · 7.16 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<!DOCTYPE html>
<html lang="zh">
<link rel="icon" type="image/x-icon" href="static/icon.png" />
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>舞萌查询工具</title>
<style>
body {
font-family: 'Arial', sans-serif;
background-color: #f0f4f8;
color: #333;
margin: 0;
padding: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.container {
max-width: 400px;
padding: 20px;
background-color: #ffffff;
border-radius: 15px;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
border: 1px solid #bbdefb;
}
h1 {
text-align: center;
color: #1976d2;
font-size: 24px;
margin-bottom: 20px;
}
select,
input[type="text"],
button {
width: 100%;
padding: 12px;
margin-bottom: 15px;
border: 1px solid #90caf9;
border-radius: 8px;
font-size: 16px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
box-sizing: border-box;
}
input[type="text"] {
height: 48px;
}
button {
width: 100%;
background-color: #42a5f5;
color: white;
border: none;
cursor: pointer;
font-weight: bold;
font-size: 18px;
height: 50px;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #1e88e5;
}
.result-container {
display: none;
margin-top: 20px;
max-width: 100%;
width: 100%;
}
#result {
max-height: 300px;
overflow-y: auto;
padding: 10px;
background-color: #e3f2fd;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border: 1px solid #90caf9;
flex: 1;
}
#result div {
padding: 10px;
border-bottom: 1px solid #90caf9;
background-color: #ffffff;
border-radius: 8px;
margin-bottom: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
transition: background-color 0.3s ease;
cursor: pointer;
}
#result div:hover {
background-color: #bbdefb;
}
#result div:last-child {
border-bottom: none;
}
#result::-webkit-scrollbar {
width: 0px;
}
.copy-message {
display: none;
color: #4caf50;
margin-top: 10px;
text-align: center;
font-weight: bold;
}
.not-found {
color: #f44336;
font-weight: bold;
text-align: center;
margin-top: 10px;
display: none;
}
@media (max-width: 600px) {
.container {
margin: 20px;
max-width: 90%;
}
select,
input[type="text"],
button {
width: 100%;
}
}
</style>
</head>
<body>
<div class="container">
<h1>舞萌查询工具</h1>
<select id="xmlSelect">
<option value="xml/CharaSort.xml">旅行伙伴</option>
<option value="xml/FrameSort.xml">背景板</option>
<option value="xml/IconSort.xml">头像</option>
<option value="xml/LoginBonusSort.xml">盖章</option>
<option value="xml/PartnerSort.xml">搭档</option>
<option value="xml/PlateSort.xml">姓名框</option>
<option value="xml/TitleSort.xml">称号</option>
</select>
<input type="text" id="searchInput" placeholder="通过 ID 或者内容检索...">
<button onclick="loadAndSearchXML()">检索</button>
<div class="result-container">
<div id="result"></div>
</div>
<div id="copyMessage" class="copy-message">ID 已复制到剪贴板!</div>
<div id="notFoundMessage" class="not-found">未找到相关内容</div>
</div>
<script>
// 加载选择的 XML 文件并进行搜索
function loadAndSearchXML() {
const selectedFile = document.getElementById('xmlSelect').value; // 获取选中的 XML 文件路径
fetch(selectedFile)
.then(response => response.text()) // 获取 XML 文件的文本内容
.then(data => {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(data, "application/xml");
searchXML(xmlDoc); // 调用搜索函数并传递 XML 文档对象
})
.catch(error => {
console.error('Error loading XML file:', error);
document.querySelector('.result-container').style.display = 'none';
});
}
// 搜索 XML 数据
function searchXML(xmlDoc) {
const input = document.getElementById('searchInput').value.toLowerCase();
const resultDiv = document.getElementById('result');
const resultContainer = document.querySelector('.result-container');
const copyMessage = document.getElementById('copyMessage');
const notFoundMessage = document.getElementById('notFoundMessage');
resultDiv.innerHTML = ''; // 清空之前的搜索结果
notFoundMessage.style.display = 'none'; // 默认隐藏未找到提示
const stringIDs = xmlDoc.getElementsByTagName('StringID');
let found = false;
// 遍历 <StringID> 节点
for (let i = 0; i < stringIDs.length; i++) {
const id = stringIDs[i].getElementsByTagName('id')[0].textContent.toLowerCase();
const str = stringIDs[i].getElementsByTagName('str')[0].textContent.toLowerCase();
if (id.includes(input) || str.includes(input)) {
const resultItem = document.createElement('div');
resultItem.innerHTML = `ID: ${id}, ${str}`;
resultItem.onclick = () => copyToClipboard(id);
resultDiv.appendChild(resultItem);
found = true;
}
}
if (found) {
resultContainer.style.display = 'block';
notFoundMessage.style.display = 'none';
} else {
resultContainer.style.display = 'none';
notFoundMessage.style.display = 'block';
}
// 复制ID
function copyToClipboard(text) {
navigator.clipboard.writeText(text).then(() => {
copyMessage.style.display = 'block';
setTimeout(() => {
copyMessage.style.display = 'none';
}, 3000);
});
}
}
</script>
</body>
</html>