forked from hjh010501/neis-counter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
106 lines (99 loc) · 3.92 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
<!doctype html>
<html lang="ko">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
<meta name="description" content="나이스(NEIS) 글자수 계산기++">
<meta property="og:title" content="나이스(NEIS) 글자수 계산기++">
<meta property="og:type" content="website">
<meta property="og:url" content="https://jedbeom.github.io/neis-counter">
<meta property="og:locale" content="ko_KR">
<meta property="og:description" content="나이스 바이트, 손쉽게 계산하자">
<meta property="og:image" content="ogimage.png">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="google-site-verification" content="nX36SD4uz80hCzp1qlM_18NHit_OlUiLO_1tLy-XL8A" />
<link rel="stylesheet" type="text/css" href="main.css">
<title>나이스(NEIS) 글자수 계산기++</title>
</head>
<body>
<header>
<h1>🍴나이스(NEIS) 글자수 계산기++</h1>
<p>드래그해서 글씨를 선택해 보세요.</p>
<div class="title_underbar_wrapper">
<div class="title_underbar"></div>
</div>
</header>
<main>
<textarea oninput="onInput()" id="counter"></textarea>
<div id="result">
<p id="count-selection"></p>
<p id="count-all">0자, 0바이트</p>
</div>
<span class="info">영어, 숫자, 특수문자, 띄어쓰기 1바이트 / 엔터키 2바이트 / 한글 3바이트</span>
<table>
<tr>
<th>항목</td>
<th>자율활동</th>
<th>동아리활동</th>
<th>진로활동</th>
<th>교과세특</th>
<th>개인별세특</th>
</tr>
<tr>
<td>바이트</td>
<td>1500Bytes</td>
<td>1500Bytes</td>
<td>2100Bytes</td>
<td>1500Bytes</td>
<td>1500Bytes</td>
</tr>
</table>
</main>
<footer>
<span>Original work by <a href="https://github.com/hjh010501/">kidevelop</a></span> |
<span>Fork by <a href="https://github.com/JedBeom/">JedBeom</a></span>
</footer>
<script>
var textarea = document.getElementById('counter')
var countAll = document.getElementById('count-all')
var countSelection = document.getElementById('count-selection')
function init() {
let content = localStorage.getItem("save")
if (content) {
textarea.value = content
onInput()
}
}
function countByte(content) {
return new Blob([content]).size + content.split(/\r\n|\r|\n/).length - 1
}
function onInput() {
let content = textarea.value
localStorage.setItem("save", content);
var byte = countByte(content)
countAll.innerHTML = content.length + "자, " + byte + "바이트";
}
window.onload = init;
function getSelectionText() {
var text = "";
var activeEl = document.activeElement;
var activeElTagName = activeEl ? activeEl.tagName.toLowerCase() : null;
if (activeElTagName == "textarea") {
text = activeEl.value.slice(activeEl.selectionStart, activeEl.selectionEnd);
}
return text;
}
document.onmouseup = document.onkeyup = document.onselectionchange = function() {
var text = getSelectionText()
if (!text) {
countSelection.innerHTML = ""
return
}
countSelection.innerHTML = "선택된 텍스트: " + text.length + "자, " + countByte(text) + "바이트";
};
</script>
</body>
</html>