Skip to content

Commit 63c1671

Browse files
committed
2 parents b840207 + b34661e commit 63c1671

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

_includes/comments/utterances.html

+22-23
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,50 @@
11
<!-- https://utteranc.es/ -->
2-
<script src="https://utteranc.es/client.js"
3-
repo="{{ site.comments.utterances.repo }}"
4-
issue-term="{{ site.comments.utterances.issue_term }}"
5-
crossorigin="anonymous"
6-
async>
7-
</script>
2+
<script
3+
src="https://utteranc.es/client.js"
4+
repo="{{ site.comments.utterances.repo }}"
5+
issue-term="{{ site.comments.utterances.issue_term }}"
6+
crossorigin="anonymous"
7+
async
8+
></script>
89

910
<script type="text/javascript">
10-
$(function() {
11-
const origin = "https://utteranc.es";
12-
const iframe = "iframe.utterances-frame";
13-
const lightTheme = "github-light";
14-
const darkTheme = "github-dark";
11+
(function () {
12+
const origin = 'https://utteranc.es';
13+
const iframe = 'iframe.utterances-frame';
14+
const lightTheme = 'github-light';
15+
const darkTheme = 'github-dark';
1516
let initTheme = lightTheme;
17+
const html = document.documentElement;
1618

17-
if ($("html[data-mode=dark]").length > 0
18-
|| ($("html[data-mode]").length == 0
19-
&& window.matchMedia("(prefers-color-scheme: dark)").matches)) {
19+
if (
20+
(html.hasAttribute('data-mode') && html.getAttribute('data-mode') === 'dark') ||
21+
(!html.hasAttribute('data-mode') && window.matchMedia('(prefers-color-scheme: dark)').matches)
22+
) {
2023
initTheme = darkTheme;
2124
}
2225

23-
addEventListener("message", (event) => {
26+
addEventListener('message', (event) => {
2427
let theme;
2528

2629
/* credit to <https://github.com/utterance/utterances/issues/170#issuecomment-594036347> */
2730
if (event.origin === origin) {
2831
/* page initial */
2932
theme = initTheme;
30-
31-
} else if (event.source === window && event.data &&
32-
event.data.direction === ModeToggle.ID) {
33+
} else if (event.source === window && event.data && event.data.direction === ModeToggle.ID) {
3334
/* global theme mode changed */
3435
const mode = event.data.message;
35-
theme = (mode === ModeToggle.DARK_MODE ? darkTheme : lightTheme);
36-
36+
theme = mode === ModeToggle.DARK_MODE ? darkTheme : lightTheme;
3737
} else {
3838
return;
3939
}
4040

4141
const message = {
42-
type: "set-theme",
42+
type: 'set-theme',
4343
theme: theme
4444
};
4545

4646
const utterances = document.querySelector(iframe).contentWindow;
4747
utterances.postMessage(message, origin);
4848
});
49-
50-
});
49+
})();
5150
</script>

_includes/comments/waline.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script src="{{ site.data.origin[type].waline.js | relative_url }}"></script>
22
<link rel="stylesheet" href="{{ site.data.origin[type].waline.css | relative_url }}" />
33
<div id="waline"></div>
4-
<script>
5-
$(function() {
4+
<script type="text/javascript">
5+
(function() {
66
const locale = {
77
placeholder: '{{ site.comments.waline.placeholder }}',
88
};
@@ -27,5 +27,5 @@
2727
let style = document.createElement('style');
2828
style.textContent = cssContentSelectedDark;
2929
head.appendChild(style);
30-
});
30+
})();
3131
</script>

0 commit comments

Comments
 (0)