-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwordcount.html
More file actions
143 lines (138 loc) Β· 4.35 KB
/
wordcount.html
File metadata and controls
143 lines (138 loc) Β· 4.35 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
---
layout: default
sitemap: false
regenerate: true
---
<aside>Came here by accident? This is the page that I use to look at my blog post word counts! It is not officially part of my blog.</aside>
<h1>Blog Posts.</h1>
<div class="controls">
<input type="number" id="first" placeholder="First" oninput="inputsChanged()">
<input type="number" id="last" placeholder="Last" oninput="inputsChanged()">
</div>
<span class="total-word-count"><b>Total Word Count:</b> <span id="word-count">0000</span></span>
<table>
<tbody>
<tr>
<th>Post number</th>
<th>Post Date</th>
<th>Post Name</th>
<th>Word count</th>
<th>Read time ({{site.wpm}} WPM)</th>
<th>Proofread</th>
</tr>
{% assign posts = site.posts | reverse %}
{% for post in posts %}
{% assign post_words = post.content | number_of_words | minus: post.wordsAdjust %}
<tr>
<td class="post-num">#{{forloop.index}}</td>
<td class="post-date">{{post.date | date: "%A %-d %B %Y"}}</td>
<td class="post-title"><a href="{{post.url}}" target="_blank">{{post.title}}</a></td>
<td class="post-words">{{post_words}}</td>
<td class="post-read-time">{{post_words | divided_by: site.wpm}} mins</td>
<td class="post-checked">{% if post.checked contains 'grammarly' %}<img src="/assets/img/grammarly.png" title="Grammarly">{% endif %}{% if post.checked contains 'hemingway' %}<img src="/assets/img/hemingway.png" title="Hemingway">{% endif %}{% if post.checked == nil %}<img src="/assets/img/x-emoji.png" title="None">{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
<br>
<script type="text/javascript">
document.onload = init();
function init() {
var rows = document.getElementsByTagName('tr');
var wordCount = 0;
for(var i = 1; i < rows.length; i++) {
wordCount += Number(rows[i].getElementsByClassName("post-words")[0].innerText);
}
document.getElementById('word-count').innerHTML = wordCount;
}
function tableRange(first,last) {
var rows = document.getElementsByTagName('tr');
var wordCount = 0;
for(var i = 1; i < rows.length; i++) {
if(i >= first && i <= last) {
rows[i].style.display = 'table-row';
wordCount += Number(rows[i].getElementsByClassName("post-words")[0].innerText);
} else {
rows[i].style.display = 'none';
}
}
document.getElementById('word-count').innerHTML = wordCount;
}
function inputsChanged() {
console.log("hey");
var first = Number(document.getElementById("first").value);
var last = Number(document.getElementById("last").value);
if(first == NaN || first == 0) {
first = 1;
}
if(last == NaN || last == 0) {
last = document.getElementsByTagName('tr').length - 1;
}
tableRange(first,last);
}
</script>
<style>
/* I'm doing the styling here because this page is sort of 'unofficial'. */
html, body {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: auto;
margin: 2rem;
}
table {
border-collapse: collapse;
margin-bottom: 3rem;
}
table, th, td {
border: 1px solid black;
padding: 1rem;
width: -webkit-fill-available;
text-align: left;
}
a {
text-decoration: underline;
}
.total-word-count {
display: block;
background-color: #656565;
color: white;
width: -webkit-fill-available;
text-align: center;
padding: 1rem;
}
#first, #last {
width: calc(48% - 1rem);
margin: 0;
border: none;
height: 2rem;
font-size: 1rem;
padding: 0;
padding-left: 1rem;
}
#first {
margin-right: 2%;
}
.controls, .total-word-count {
margin-bottom: 1rem;
}
h1 {
margin-bottom: 2rem;
font-size: 3rem;
}
aside {
display: block;
margin-bottom: 1rem;
font-size: 0.7rem;
}
.post-checked {
text-align: center;
}
.post-checked img {
width: 2em;
height: 2em;
margin: 0 5px;
}
</style>