chore: delete JS comments from HTML

This commit is contained in:
Cotes Chung 2024-04-29 03:25:26 +08:00
parent 796c386037
commit 778ebdf250
No known key found for this signature in database
GPG key ID: 0D9E54843167A808
4 changed files with 13 additions and 11 deletions

View file

@ -10,7 +10,7 @@
this.page.identifier = '{{ page.url }}';
};
/* Lazy loading */
{%- comment -%} Lazy loading {%- endcomment -%}
var disqus_observer = new IntersectionObserver(
function (entries) {
if (entries[0].isIntersecting) {
@ -30,10 +30,10 @@
disqus_observer.observe(document.getElementById('disqus_thread'));
/* Auto switch theme */
{%- comment -%} Auto switch theme {%- endcomment -%}
function reloadDisqus() {
if (event.source === window && event.data && event.data.direction === ModeToggle.ID) {
/* Disqus hasn't been loaded */
{%- comment -%} Disqus hasn't been loaded {%- endcomment -%}
if (typeof DISQUS === 'undefined') {
return;
}

View file

@ -47,7 +47,7 @@
event.data &&
event.data.direction === ModeToggle.ID
) {
/* global theme mode changed */
{%- comment -%} global theme mode changed {%- endcomment -%}
const mode = event.data.message;
const theme = mode === ModeToggle.DARK_MODE ? darkTheme : lightTheme;

View file

@ -25,12 +25,12 @@
addEventListener('message', (event) => {
let theme;
/* credit to <https://github.com/utterance/utterances/issues/170#issuecomment-594036347> */
{%- comment -%} credit to <https://github.com/utterance/utterances/issues/170#issuecomment-594036347> {%- endcomment -%}
if (event.origin === origin) {
/* page initial */
{%- comment -%} page initial {%- endcomment -%}
theme = initTheme;
} else if (event.source === window && event.data && event.data.direction === ModeToggle.ID) {
/* global theme mode changed */
{%- comment -%} global theme mode changed {%- endcomment -%}
const mode = event.data.message;
theme = mode === ModeToggle.DARK_MODE ? darkTheme : lightTheme;
} else {

View file

@ -11,7 +11,9 @@
let expectedTheme = mode === ModeToggle.DARK_MODE ? 'dark' : 'default';
let config = { theme: expectedTheme };
/* Re-render the SVG <https://github.com/mermaid-js/mermaid/issues/311#issuecomment-332557344> */
{%- comment -%}
Re-render the SVG <https://github.com/mermaid-js/mermaid/issues/311#issuecomment-332557344>
{%- endcomment -%}
const mermaidList = document.getElementsByClassName('mermaid');
[...mermaidList].forEach((elem) => {
@ -37,16 +39,16 @@
}
let mermaidConf = {
theme: initTheme /* <default | dark | forest | neutral> */
theme: initTheme {%- comment -%} <default | dark | forest | neutral> {%- endcomment -%}
};
/* Create mermaid tag */
{%- comment -%} Create mermaid tag {%- endcomment -%}
const basicList = document.getElementsByClassName('language-mermaid');
[...basicList].forEach((elem) => {
const svgCode = elem.textContent;
const backup = elem.parentElement;
backup.classList.add('d-none');
/* create mermaid node */
{%- comment -%} create mermaid node {%- endcomment -%}
let mermaid = document.createElement('pre');
mermaid.classList.add('mermaid');
const text = document.createTextNode(svgCode);