-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin2.html
More file actions
49 lines (48 loc) · 1.99 KB
/
admin2.html
File metadata and controls
49 lines (48 loc) · 1.99 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
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>一括変換ツール</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="page-wrapper">
<h1>一括変換ツール</h1>
<div class="admin-box">
<p>SRTファイルや歌詞テキストを貼り付けてください</p>
<textarea id="inputText" placeholder="01:20 歌詞のように入力"></textarea>
<button class="btn btn-red" style="width:100%" onclick="convert()">コードを生成する</button>
<pre id="result"></pre>
</div>
<a href="index.html" class="btn back-link">← 戻る</a>
</div>
<script>
function convert() {
const input = document.getElementById('inputText').value.trim();
if (!input) return;
let resultArray = [];
if (input.includes('-->')) { // SRT形式
const blocks = input.split(/\n\s*\n/);
blocks.forEach(block => {
const lines = block.split('\n');
const timeMatch = block.match(/(\d{2}):(\d{2}):(\d{2})/);
if (timeMatch) {
const timeStr = `${timeMatch[2]}:${timeMatch[3]}`;
const text = lines.slice(2).join(' ').trim();
if (text && text !== '♪') resultArray.push(` ["${timeStr}", "${text}", ""]`);
}
});
} else { // 自由形式
const lines = input.split('\n');
lines.forEach(line => {
const match = line.match(/(\d{1,2}:\d{2})\s+(.*)/);
if (match) resultArray.push(` ["${match[1]}", "${match[2]}", ""]`);
});
}
const output = document.getElementById('result');
output.textContent = `const myData = [\n${resultArray.join(',\n')}\n];`;
output.style.display = "block";
}
</script>
</body>
</html>