Update index.html
Browse files- index.html +89 -18
index.html
CHANGED
|
@@ -1,19 +1,90 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="ko">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
| 6 |
+
<title>4000์ ๋จ์ ๋ถํ ๊ธฐ</title>
|
| 7 |
+
<style>
|
| 8 |
+
body { font-family: Arial, sans-serif; padding: 20px; }
|
| 9 |
+
textarea { width: 100%; height: 180px; resize: vertical; }
|
| 10 |
+
.chunk { border: 1px solid #ccc; padding: 8px; margin: 8px 0; border-radius: 6px; background: #f9f9f9; }
|
| 11 |
+
pre { margin: 6px 0 0 0; white-space: pre-wrap; word-break: break-word; }
|
| 12 |
+
.toolbar { margin-bottom: 8px; }
|
| 13 |
+
</style>
|
| 14 |
+
</head>
|
| 15 |
+
<body>
|
| 16 |
+
<h1>4000์ ๋จ์ ๋ถํ ๊ธฐ</h1>
|
| 17 |
+
<p>ํ
์คํธ๋ฅผ ์
๋ ฅํ๊ณ ์๋ ๋ฒํผ์ ๋๋ฌ 4000๊ธ์์ฉ ๋ถํ ํฉ๋๋ค.</p>
|
| 18 |
+
<div class="toolbar">
|
| 19 |
+
<textarea id="input" placeholder="์ฌ๊ธฐ์ ํ
์คํธ๋ฅผ ์
๋ ฅํ์ธ์"></textarea>
|
| 20 |
+
<br/>
|
| 21 |
+
<button id="splitBtn">4000์ ๋จ์๋ก ๋ถํ </button>
|
| 22 |
+
<button id="clearBtn" type="button">์ด๊ธฐํ</button>
|
| 23 |
+
</div>
|
| 24 |
+
<div id="output" aria-live="polite"></div>
|
| 25 |
+
|
| 26 |
+
<script>
|
| 27 |
+
(function(){
|
| 28 |
+
const input = document.getElementById('input');
|
| 29 |
+
const splitBtn = document.getElementById('splitBtn');
|
| 30 |
+
const clearBtn = document.getElementById('clearBtn');
|
| 31 |
+
const output = document.getElementById('output');
|
| 32 |
+
const CHUNK = 4000;
|
| 33 |
+
|
| 34 |
+
function chunkText(text) {
|
| 35 |
+
// Unicode code points ๋จ์๋ก ์์ ํ๊ฒ ๋ถํ
|
| 36 |
+
const cps = Array.from(text);
|
| 37 |
+
const chunks = [];
|
| 38 |
+
for (let i = 0; i < cps.length; i += CHUNK) {
|
| 39 |
+
chunks.push(cps.slice(i, i + CHUNK).join(''));
|
| 40 |
+
}
|
| 41 |
+
return chunks;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
function renderChunks(chunks) {
|
| 45 |
+
output.innerHTML = '';
|
| 46 |
+
if (!chunks.length) return;
|
| 47 |
+
const ol = document.createElement('ol');
|
| 48 |
+
chunks.forEach((chunk, idx) => {
|
| 49 |
+
const li = document.createElement('li');
|
| 50 |
+
li.className = 'chunk';
|
| 51 |
+
const header = document.createElement('div');
|
| 52 |
+
header.style.fontWeight = 'bold';
|
| 53 |
+
header.textContent = `Chunk ${idx + 1} (${chunk.length} chars)`;
|
| 54 |
+
const pre = document.createElement('pre');
|
| 55 |
+
pre.textContent = chunk;
|
| 56 |
+
const copyBtn = document.createElement('button');
|
| 57 |
+
copyBtn.textContent = 'ํด๋ฆฝ๋ณด๋์ ๋ณต์ฌ';
|
| 58 |
+
copyBtn.style.marginLeft = '8px';
|
| 59 |
+
copyBtn.addEventListener('click', async () => {
|
| 60 |
+
try {
|
| 61 |
+
await navigator.clipboard.writeText(chunk);
|
| 62 |
+
copyBtn.textContent = '๋ณต์ฌ๋จ';
|
| 63 |
+
setTimeout(() => { copyBtn.textContent = 'ํด๋ฆฝ๋ณด๋์ ๋ณต์ฌ'; }, 1500);
|
| 64 |
+
} catch (e) {
|
| 65 |
+
copyBtn.textContent = '์คํจ';
|
| 66 |
+
setTimeout(() => { copyBtn.textContent = 'ํด๋ฆฝ๋ณด๋์ ๋ณต์ฌ'; }, 1500);
|
| 67 |
+
}
|
| 68 |
+
});
|
| 69 |
+
li.appendChild(header);
|
| 70 |
+
li.appendChild(pre);
|
| 71 |
+
li.appendChild(copyBtn);
|
| 72 |
+
ol.appendChild(li);
|
| 73 |
+
});
|
| 74 |
+
output.appendChild(ol);
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
splitBtn.addEventListener('click', () => {
|
| 78 |
+
const text = input.value;
|
| 79 |
+
const chunks = chunkText(text);
|
| 80 |
+
renderChunks(chunks);
|
| 81 |
+
});
|
| 82 |
+
|
| 83 |
+
clearBtn.addEventListener('click', () => {
|
| 84 |
+
input.value = '';
|
| 85 |
+
output.innerHTML = '';
|
| 86 |
+
});
|
| 87 |
+
})();
|
| 88 |
+
</script>
|
| 89 |
+
</body>
|
| 90 |
</html>
|