-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathin-clause.html
More file actions
540 lines (477 loc) · 16.4 KB
/
in-clause.html
File metadata and controls
540 lines (477 loc) · 16.4 KB
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>多行转 IN 语句 - IT 工具集</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
min-height: 100vh;
color: #fff;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 30px 20px;
}
header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 30px;
}
.back-link {
color: #00ff88;
text-decoration: none;
font-size: 0.95rem;
display: flex;
align-items: center;
gap: 8px;
opacity: 0.8;
transition: opacity 0.2s;
}
.back-link:hover { opacity: 1; }
h1 {
font-size: 1.8rem;
font-weight: 400;
color: #00ff88;
}
.options-bar {
background: rgba(0, 0, 0, 0.3);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 12px;
padding: 20px;
margin-bottom: 20px;
display: flex;
gap: 30px;
flex-wrap: wrap;
align-items: center;
}
.option-group {
display: flex;
align-items: center;
gap: 10px;
}
.option-group label {
color: #888;
font-size: 0.9rem;
}
select, input[type="text"] {
padding: 10px 15px;
background: rgba(0, 0, 0, 0.3);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 6px;
color: #fff;
font-size: 0.95rem;
}
select:focus, input:focus {
outline: none;
border-color: #00ff88;
}
.editor-container {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
}
@media (max-width: 768px) {
.editor-container { grid-template-columns: 1fr; }
.options-bar { flex-direction: column; align-items: flex-start; }
}
.editor-panel {
background: rgba(0, 0, 0, 0.3);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 12px;
overflow: hidden;
}
.panel-header {
padding: 15px 20px;
background: rgba(0, 0, 0, 0.2);
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
display: flex;
justify-content: space-between;
align-items: center;
}
.panel-header h3 {
font-weight: 400;
font-size: 1rem;
color: #aaa;
}
.line-count {
font-size: 0.85rem;
color: #00ff88;
background: rgba(0, 255, 136, 0.1);
padding: 4px 12px;
border-radius: 20px;
}
textarea {
width: 100%;
height: 400px;
background: transparent;
border: none;
padding: 20px;
color: #e0e0e0;
font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
font-size: 14px;
line-height: 1.6;
resize: vertical;
}
textarea:focus {
outline: none;
}
textarea::placeholder {
color: #555;
}
#output {
color: #00ff88;
}
.toolbar {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin-top: 20px;
}
.toolbar-left,
.toolbar-right {
display: flex;
gap: 10px;
flex-wrap: wrap;
align-items: center;
}
.toolbar-right {
justify-content: flex-start;
}
@media (max-width: 768px) {
.toolbar {
grid-template-columns: 1fr;
}
}
button {
padding: 12px 24px;
border: none;
border-radius: 8px;
font-size: 0.95rem;
cursor: pointer;
transition: all 0.2s;
font-weight: 500;
}
.btn-primary {
background: linear-gradient(135deg, #00ff88, #00cc6a);
color: #0f0c29;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 5px 20px rgba(0, 255, 136, 0.3);
}
.btn-secondary {
background: rgba(255, 255, 255, 0.1);
color: #fff;
border: 1px solid rgba(255, 255, 255, 0.2);
}
.btn-secondary:hover {
background: rgba(255, 255, 255, 0.15);
}
.presets {
margin-top: 20px;
display: flex;
gap: 10px;
flex-wrap: wrap;
}
.preset-btn {
padding: 8px 16px;
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 20px;
color: #aaa;
font-size: 0.85rem;
cursor: pointer;
transition: all 0.2s;
}
.preset-btn:hover {
background: rgba(0, 255, 136, 0.1);
border-color: #00ff88;
color: #00ff88;
}
.examples {
margin-top: 30px;
background: rgba(0, 0, 0, 0.2);
border-radius: 12px;
padding: 20px;
}
.examples h4 {
color: #888;
font-weight: 400;
margin-bottom: 15px;
}
.example-item {
display: flex;
gap: 20px;
margin-bottom: 10px;
font-size: 0.9rem;
font-family: 'Consolas', monospace;
}
.example-label {
color: #888;
min-width: 120px;
}
.example-value {
color: #00ff88;
}
.toast {
position: fixed;
bottom: 30px;
left: 50%;
transform: translateX(-50%) translateY(100px);
background: #00ff88;
color: #0f0c29;
padding: 12px 30px;
border-radius: 8px;
font-weight: 500;
opacity: 0;
transition: all 0.3s;
z-index: 1000;
}
.toast.show {
transform: translateX(-50%) translateY(0);
opacity: 1;
}
</style>
</head>
<body>
<div class="container">
<header>
<a href="index.html" class="back-link">← 返回工具集</a>
<h1>📝 多行转 IN 语句</h1>
<div style="width: 100px;"></div>
</header>
<!-- 选项栏 -->
<div class="options-bar">
<div class="option-group">
<label>数据类型:</label>
<select id="dataType">
<option value="string">字符串(带引号)</option>
<option value="number">数字(无引号)</option>
</select>
</div>
<div class="option-group">
<label>引号类型:</label>
<select id="quoteType">
<option value="single">单引号 '</option>
<option value="double">双引号 "</option>
</select>
</div>
<div class="option-group">
<label>前缀:</label>
<input type="text" id="prefix" value="IN (" style="width: 100px;">
</div>
<div class="option-group">
<label>后缀:</label>
<input type="text" id="suffix" value=")" style="width: 80px;">
</div>
</div>
<div class="editor-container">
<div class="editor-panel">
<div class="panel-header">
<h3>输入(每行一个值)</h3>
<span class="line-count" id="lineCount">0 行</span>
</div>
<textarea id="input" placeholder="粘贴多行数据,例如: user001 user002 user003 支持自动去重和去除空行"></textarea>
</div>
<div class="editor-panel">
<div class="panel-header">
<h3>输出结果</h3>
<span class="line-count" id="charCount">0 字符</span>
</div>
<textarea id="output" readonly placeholder="转换结果将显示在这里..."></textarea>
</div>
</div>
<div class="toolbar">
<div class="toolbar-left">
<button class="btn-primary" onclick="convert()">转换</button>
<button class="btn-secondary" onclick="deduplicate()">去重</button>
<button class="btn-secondary" onclick="sortLines()">排序</button>
<button class="btn-secondary" onclick="clearAll()">清空</button>
</div>
<div class="toolbar-right">
<button class="btn-secondary" onclick="copyOutput()">复制结果</button>
</div>
</div>
<div class="presets">
<span style="color: #666; font-size: 0.85rem; margin-right: 10px;">快捷格式:</span>
<button class="preset-btn" onclick="preset('in-string')">IN ('a','b')</button>
<button class="preset-btn" onclick="preset('in-number')">IN (1,2,3)</button>
<button class="preset-btn" onclick="preset('comma')">a, b, c</button>
<button class="preset-btn" onclick="preset('comma-quote')">a', 'b', 'c'</button>
<button class="preset-btn" onclick="preset('or')">a OR b OR c</button>
<button class="preset-btn" onclick="preset('pipe')">a|b|c</button>
</div>
<div class="examples">
<h4>输出示例</h4>
<div class="example-item">
<span class="example-label">字符串 IN:</span>
<span class="example-value">IN ('user001', 'user002', 'user003')</span>
</div>
<div class="example-item">
<span class="example-label">数字 IN:</span>
<span class="example-value">IN (1001, 1002, 1003)</span>
</div>
<div class="example-item">
<span class="example-label">逗号分隔:</span>
<span class="example-value">user001, user002, user003</span>
</div>
</div>
</div>
<div id="toast" class="toast"></div>
<script>
const input = document.getElementById('input');
const output = document.getElementById('output');
const lineCount = document.getElementById('lineCount');
const charCount = document.getElementById('charCount');
// 实时统计行数
input.addEventListener('input', () => {
const lines = getLines();
lineCount.textContent = lines.length + ' 行';
});
// 获取有效行
function getLines() {
return input.value
.split('\n')
.map(s => s.trim())
.filter(s => s.length > 0);
}
// 转换
function convert() {
const lines = getLines();
if (lines.length === 0) {
showToast('请输入数据');
return;
}
const dataType = document.getElementById('dataType').value;
const quoteType = document.getElementById('quoteType').value;
const prefix = document.getElementById('prefix').value;
const suffix = document.getElementById('suffix').value;
const quote = quoteType === 'single' ? "'" : '"';
let result;
if (dataType === 'string') {
result = prefix + lines.map(l => quote + l + quote).join(', ') + suffix;
} else {
result = prefix + lines.join(', ') + suffix;
}
output.value = result;
charCount.textContent = result.length + ' 字符';
}
// 预设格式
function preset(type) {
const prefix = document.getElementById('prefix');
const suffix = document.getElementById('suffix');
const dataType = document.getElementById('dataType');
const quoteType = document.getElementById('quoteType');
switch (type) {
case 'in-string':
prefix.value = "IN (";
suffix.value = ")";
dataType.value = "string";
quoteType.value = "single";
break;
case 'in-number':
prefix.value = "IN (";
suffix.value = ")";
dataType.value = "number";
break;
case 'comma':
prefix.value = "";
suffix.value = "";
dataType.value = "number";
break;
case 'comma-quote':
prefix.value = "'";
suffix.value = "'";
dataType.value = "string";
quoteType.value = "single";
break;
case 'or':
// 特殊处理
const lines = getLines();
if (lines.length === 0) {
showToast('请先输入数据');
return;
}
output.value = lines.join(' OR ');
charCount.textContent = output.value.length + ' 字符';
return;
case 'pipe':
const lines2 = getLines();
if (lines2.length === 0) {
showToast('请先输入数据');
return;
}
output.value = lines2.join('|');
charCount.textContent = output.value.length + ' 字符';
return;
}
convert();
}
// 去重
function deduplicate() {
const lines = getLines();
const unique = [...new Set(lines)];
input.value = unique.join('\n');
lineCount.textContent = unique.length + ' 行';
showToast(`已去重: ${lines.length} → ${unique.length} 行`);
}
// 排序
function sortLines() {
const lines = getLines();
// 尝试数字排序,失败则字符串排序
const isNumeric = lines.every(l => !isNaN(l));
if (isNumeric) {
lines.sort((a, b) => parseFloat(a) - parseFloat(b));
} else {
lines.sort();
}
input.value = lines.join('\n');
showToast('已排序');
}
// 复制
function copyOutput() {
if (!output.value) {
showToast('没有可复制的内容');
return;
}
navigator.clipboard.writeText(output.value).then(() => {
showToast('已复制到剪贴板');
}).catch(() => {
output.select();
document.execCommand('copy');
showToast('已复制到剪贴板');
});
}
// 清空
function clearAll() {
input.value = '';
output.value = '';
lineCount.textContent = '0 行';
charCount.textContent = '0 字符';
}
function showToast(message) {
const toast = document.getElementById('toast');
toast.textContent = message;
toast.classList.add('show');
setTimeout(() => {
toast.classList.remove('show');
}, 2000);
}
// 快捷键
document.addEventListener('keydown', (e) => {
if (e.ctrlKey || e.metaKey) {
if (e.key === 'Enter') {
e.preventDefault();
convert();
}
}
});
</script>
</body>
</html>