Skip to content

Commit 602bb45

Browse files
committed
Use const for JavaScript
bliki-ja@d7733b3 で `let` を使っているため、モダンブラウザで動く前提としている判断です。 値を変更しないケースで `let` あるいは `var` を使っているケースを、`const` に置き換えます。 なお、vendor として導入されていそうな js/jquery.toc.js は手入れをしていません。
1 parent 7d620e2 commit 602bb45

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

404.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
<script>
1010
function redirectToUrlWithoutTrailingSlash() {
11-
var currentUrl = window.location.href;
12-
if(currentUrl.endsWith('/')) {
13-
var newUrl = currentUrl.slice(0, -1);
11+
const currentUrl = window.location.href;
12+
if (currentUrl.endsWith('/')) {
13+
const newUrl = currentUrl.slice(0, -1);
1414
window.location.href = newUrl;
1515
}
1616
}

_includes/footer.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ <h3 class="footer-heading">{{ site.title }}</h3>
5454

5555
<script>
5656
(function() {
57-
var cx = '010278526350603011374:ubkdl6gezwc';
58-
var gcse = document.createElement('script');
57+
const cx = '010278526350603011374:ubkdl6gezwc';
58+
const gcse = document.createElement('script');
5959
gcse.type = 'text/javascript';
6060
gcse.async = true;
6161
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
6262
'//cse.google.com/cse.js?cx=' + cx;
63-
var s = document.getElementsByTagName('script')[0];
63+
const s = document.getElementsByTagName('script')[0];
6464
s.parentNode.insertBefore(gcse, s);
6565
})();
6666
</script>
@@ -77,7 +77,7 @@ <h3 class="footer-heading">{{ site.title }}</h3>
7777
{% else %}
7878
<script>
7979
$('#page-content').toc({
80-
showAlways:
80+
showAlways:
8181
});
8282
</script>
8383
{% endif %}

random/index.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ title: Random
44
---
55

66
<script type="text/javascript">
7-
let posts = [{% for post in site.posts %}"{{ post.url }}"{% unless forloop.last %},{% endunless %}{% endfor %}];
8-
let randomIndex = Math.floor(Math.random() * posts.length);
9-
let post = posts[randomIndex];
7+
const posts = [{% for post in site.posts %}"{{ post.url }}"{% unless forloop.last %},{% endunless %}{% endfor %}];
8+
const randomIndex = Math.floor(Math.random() * posts.length);
9+
const post = posts[randomIndex];
1010
window.location.href = post;
1111
</script>

tags/index.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ title: tag
1919

2020
<script>
2121
function getTag() {
22-
var href = window.location.href;
22+
const href = window.location.href;
2323
if (href.indexOf('?') == -1) {
2424
return "";
2525
}
26-
var hashes = href.slice(href.indexOf('?') + 1).split('&');
26+
const hashes = href.slice(href.indexOf('?') + 1).split('&');
2727
return unescape(hashes[0]);
2828
}
2929

30-
var tag = getTag();
30+
const tag = getTag();
3131
if (tag == "") {
3232
$(".tagsec").each(function() {$(this).show()});
3333
} else {

0 commit comments

Comments
 (0)