Spaces:
Running
Running
admin
commited on
Commit
Β·
c38c77c
1
Parent(s):
6b6a477
add word count
Browse files- index.html +2 -1
- js/main.js +7 -1
index.html
CHANGED
@@ -23,7 +23,8 @@
|
|
23 |
<div id="Tab2" class="tabcontent">
|
24 |
<h1>String β Length</h1>
|
25 |
<textarea rows="14"></textarea>
|
26 |
-
|
|
|
27 |
</div>
|
28 |
<div id="Tab3" class="tabcontent">
|
29 |
<h1>Plaintext β MD5</h1>
|
|
|
23 |
<div id="Tab2" class="tabcontent">
|
24 |
<h1>String β Length</h1>
|
25 |
<textarea rows="14"></textarea>
|
26 |
+
String Len : <text id="len">0</text><br>
|
27 |
+
Word Count : <text id="words">0</text>
|
28 |
</div>
|
29 |
<div id="Tab3" class="tabcontent">
|
30 |
<h1>Plaintext β MD5</h1>
|
js/main.js
CHANGED
@@ -42,6 +42,11 @@ function toBase64() {
|
|
42 |
};
|
43 |
}
|
44 |
|
|
|
|
|
|
|
|
|
|
|
45 |
$(function () {
|
46 |
toBase64();
|
47 |
|
@@ -53,7 +58,8 @@ $(function () {
|
|
53 |
});
|
54 |
|
55 |
$('textarea').bind('input propertychange', function () {
|
56 |
-
$('
|
|
|
57 |
});
|
58 |
$('text').click(function () {
|
59 |
clipbd($(this).text());
|
|
|
42 |
};
|
43 |
}
|
44 |
|
45 |
+
function countWords(text) {
|
46 |
+
const words = text.match(/[a-zA-Z0-9_]+/g) || [];
|
47 |
+
return words.length;
|
48 |
+
}
|
49 |
+
|
50 |
$(function () {
|
51 |
toBase64();
|
52 |
|
|
|
58 |
});
|
59 |
|
60 |
$('textarea').bind('input propertychange', function () {
|
61 |
+
$('#len').text($(this).val().length);
|
62 |
+
$('#words').text(countWords($(this).val()));
|
63 |
});
|
64 |
$('text').click(function () {
|
65 |
clipbd($(this).text());
|