From d9b801f9a9e7a45e57f1966415b3ba84e92208d6 Mon Sep 17 00:00:00 2001 From: jaywcjlove Date: Fri, 17 Jan 2025 15:20:56 +0000 Subject: [PATCH] chore: update .gitattributes 31855f2209b6f320b937a23ada422fee27c0ab8b --- README-zh.html | 24 ++++++------ index.html | 24 ++++++------ js/copy.js | 8 ++-- js/demo-preview.js | 8 ++-- js/giscus.js | 46 +++++++++++----------- js/markdown-style.js | 82 ++++++++++++++++++++-------------------- js/tocbot.js | 26 +++++++------ privacy-policy.html | 24 ++++++------ privacy-policy.zh.html | 24 ++++++------ terms-of-service.html | 24 ++++++------ terms-of-service.zh.html | 24 ++++++------ 11 files changed, 158 insertions(+), 156 deletions(-) diff --git a/README-zh.html b/README-zh.html index 2c32616..27d26e0 100644 --- a/README-zh.html +++ b/README-zh.html @@ -21,16 +21,16 @@ - - - - - - + + + + + + - - - + + + top
@@ -121,14 +121,14 @@

- + diff --git a/index.html b/index.html index 07630c4..1c00f04 100644 --- a/index.html +++ b/index.html @@ -21,16 +21,16 @@ - - - - - - + + + + + + - - - + + + top
@@ -122,14 +122,14 @@

- + diff --git a/js/copy.js b/js/copy.js index a3fe52d..ec77c45 100644 --- a/js/copy.js +++ b/js/copy.js @@ -8,7 +8,7 @@ function copyTextToClipboard(text, cb) { el.style = { position: 'absolute', left: '-9999px', - } + }; document.body.appendChild(el); const selected = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; el.select(); @@ -25,16 +25,16 @@ function copyTextToClipboard(text, cb) { document.getSelection().addRange(selected); } cb && cb(isCopy); -}; +} function copied(target, str) { target.classList.add('active'); const input = target.parentElement.querySelector('input'); if (input) { - copyTextToClipboard(input.value || '', function() { + copyTextToClipboard(input.value || '', function () { setTimeout(() => { target.classList.remove('active'); }, 2000); }); } -} \ No newline at end of file +} diff --git a/js/demo-preview.js b/js/demo-preview.js index c96cf9f..05d088a 100644 --- a/js/demo-preview.js +++ b/js/demo-preview.js @@ -3,7 +3,7 @@ const demo = document.querySelectorAll('.idoc-demo-warpper .idoc-demo-previw'); function getButton(elm, type = 'BUTTON') { let btn; do { - elm = elm.nextElementSibling + elm = elm.nextElementSibling; if (elm.tagName === type) { btn = elm; elm = undefined; @@ -19,13 +19,13 @@ if (demo && demo.length > 0) { if (button) { button.innerHTML = item.classList.contains('ishiden') ? 'Preview' : 'Show Code'; if (item.tagName === 'DIV') { - item.innerHTML = item.previousElementSibling.defaultValue + item.innerHTML = item.previousElementSibling.defaultValue; } button.onclick = () => { item.classList.toggle('ishiden'); button.innerHTML = item.classList.contains('ishiden') ? 'Preview' : 'Show Code'; - } + }; } } }); -} \ No newline at end of file +} diff --git a/js/giscus.js b/js/giscus.js index 729dd0b..1e0fd5b 100644 --- a/js/giscus.js +++ b/js/giscus.js @@ -1,34 +1,34 @@ -;(() => { +(() => { const targetElement = document.documentElement; - const defaultTheme = targetElement.getAttribute("data-color-mode"); - changeGiscusTheme(defaultTheme) + const defaultTheme = targetElement.getAttribute('data-color-mode'); + changeGiscusTheme(defaultTheme); const observer = new MutationObserver((mutationsList, observer) => { - for(const mutation of mutationsList) { + for (const mutation of mutationsList) { if (mutation.type === 'attributes') { - const value = targetElement.getAttribute("data-color-mode"); - changeGiscusTheme(value) + const value = targetElement.getAttribute('data-color-mode'); + changeGiscusTheme(value); } } }); - + observer.observe(targetElement, { attributes: true, - attributeOldValue: true + attributeOldValue: true, }); - - function changeGiscusTheme(theme = "light") { - const iframe = document.querySelector('.giscus-frame'); - if (iframe) { - const config = { - giscus: { - setConfig: { - theme: theme.toLocaleLowerCase(), - }, - } - }; - iframe.contentWindow.postMessage(config, 'https://giscus.app'); - const script = document.querySelector("script[data-script-id=\"giscus\"]") - script.setAttribute("data-theme", theme) - } + + function changeGiscusTheme(theme = 'light') { + const iframe = document.querySelector('.giscus-frame'); + if (iframe) { + const config = { + giscus: { + setConfig: { + theme: theme.toLocaleLowerCase(), + }, + }, + }; + iframe.contentWindow.postMessage(config, 'https://giscus.app'); + const script = document.querySelector('script[data-script-id="giscus"]'); + script.setAttribute('data-theme', theme); + } } })(); diff --git a/js/markdown-style.js b/js/markdown-style.js index 0227a9b..b4aa91e 100644 --- a/js/markdown-style.js +++ b/js/markdown-style.js @@ -3,7 +3,7 @@ * @version 1.1.0 * @author 小弟调调 * https://github.com/jaywcjlove/markdown-style - * + * * Integrate markdown styles into web components, Markdown CSS styles will not be conflicted. * The minimal amount of CSS to replicate the GitHub Markdown style. Support dark-mode/night mode. */ @@ -1002,48 +1002,46 @@ markdown-style ::-webkit-calendar-picker-indicator { `; class MarkdownStyle extends HTMLElement { - get theme() { - const value = this.getAttribute('theme'); - return value === null ? '' : value; + get theme() { + const value = this.getAttribute('theme'); + return value === null ? '' : value; + } + set theme(name) { + this.setAttribute('theme', name); + } + constructor() { + super(); + this.shadow = this.attachShadow({ mode: 'open' }); + this.shadow.appendChild(__TEMPLATE__.content.cloneNode(true)); + const style = Array.prototype.slice.call(this.shadow.children).find((item) => item.tagName === 'STYLE'); + if (style) { + const id = '__MARKDOWN_STYLE__'; + const findStyle = document.getElementById(id); + if (!findStyle) { + style.id = id; + document.head.append(style); + } } - set theme(name) { - this.setAttribute('theme', name); + } + connectedCallback() { + const disableThemeAutoSwitch = this.getAttribute('theme-auto-switch-disabled'); + if (disableThemeAutoSwitch == '' || (disableThemeAutoSwitch && disableThemeAutoSwitch.toLowerCase() === 'true')) { + return; } - constructor() { - super(); - this.shadow = this.attachShadow({ mode: 'open' }); - this.shadow.appendChild(__TEMPLATE__.content.cloneNode(true)); - const style = Array.prototype.slice - .call(this.shadow.children) - .find((item) => item.tagName === 'STYLE'); - if (style) { - const id = '__MARKDOWN_STYLE__'; - const findStyle = document.getElementById(id); - if (!findStyle) { - style.id = id; - document.head.append(style); - } - } - } - connectedCallback() { - const disableThemeAutoSwitch = this.getAttribute('theme-auto-switch-disabled'); - if (disableThemeAutoSwitch == "" || disableThemeAutoSwitch && disableThemeAutoSwitch.toLowerCase() === 'true') { - return; - } - if (!this.theme) { - const { colorMode } = document.documentElement.dataset; - this.theme = colorMode; - const observer = new MutationObserver((mutationsList, observer) => { - this.theme = document.documentElement.dataset.colorMode; - }); - observer.observe(document.documentElement, { attributes: true }); - window.matchMedia('(prefers-color-scheme: light)').onchange = (event) => { - this.theme = event.matches ? 'light' : 'dark'; - }; - window.matchMedia('(prefers-color-scheme: dark)').onchange = (event) => { - this.theme = event.matches ? 'dark' : 'light'; - }; - } + if (!this.theme) { + const { colorMode } = document.documentElement.dataset; + this.theme = colorMode; + const observer = new MutationObserver((mutationsList, observer) => { + this.theme = document.documentElement.dataset.colorMode; + }); + observer.observe(document.documentElement, { attributes: true }); + window.matchMedia('(prefers-color-scheme: light)').onchange = (event) => { + this.theme = event.matches ? 'light' : 'dark'; + }; + window.matchMedia('(prefers-color-scheme: dark)').onchange = (event) => { + this.theme = event.matches ? 'dark' : 'light'; + }; } + } } -customElements.define('markdown-style', MarkdownStyle); \ No newline at end of file +customElements.define('markdown-style', MarkdownStyle); diff --git a/js/tocbot.js b/js/tocbot.js index b6cebb1..a7e89de 100644 --- a/js/tocbot.js +++ b/js/tocbot.js @@ -1,11 +1,11 @@ -;(() => { +(() => { function debounce(fn, delay = 1000) { - let time = null + let time = null; function _debounce(...args) { if (time !== null) clearTimeout(time); - time = setTimeout(() => fn.apply(this, args), delay) + time = setTimeout(() => fn.apply(this, args), delay); } - return _debounce + return _debounce; } const scrollSmoothOffset = 56; @@ -25,7 +25,7 @@ location.hash = anchor.getAttribute('href'); updateScroll(); updateAnchor(); - tocsCollapse() + tocsCollapse(); }); }); } @@ -53,7 +53,7 @@ if (element) { const tocElement = document.querySelector(`a.tocs-link[href='${decodeURIComponent(element.hash)}']`); if (tocElement) { - updateAnchor(tocElement) + updateAnchor(tocElement); tocsCollapse(tocElement); } else { const first = document.querySelector('a.tocs-link[href*="#"]'); @@ -65,7 +65,7 @@ } } - document.addEventListener('scroll',debounce(scrollListener, 30), false); + document.addEventListener('scroll', debounce(scrollListener, 30), false); function updateAnchor(element) { const anchorContainer = document.querySelectorAll('.tocs aside.inner.toc a.tocs-link'); @@ -98,7 +98,12 @@ if (!element) { element = document.querySelector(`a.tocs-link[href='${decodeURIComponent(location.hash)}']`); } - if (element && element.parentElement && element.parentElement.tagName !== 'ASIDE' && !element.parentElement.classList.contains('toc')) { + if ( + element && + element.parentElement && + element.parentElement.tagName !== 'ASIDE' && + !element.parentElement.classList.contains('toc') + ) { isOpen(element.parentElement); if (element.parentElement.classList.contains('is-collapsed')) { element.parentElement.classList.add('is-open'); @@ -121,8 +126,7 @@ updateSiderBarScroll(); updateScroll(); updateAnchor(); - tocsCollapse() + tocsCollapse(); clearTimeout(timer); }, 100); - -})(); \ No newline at end of file +})(); diff --git a/privacy-policy.html b/privacy-policy.html index 158765c..79c0dfc 100644 --- a/privacy-policy.html +++ b/privacy-policy.html @@ -21,16 +21,16 @@ - - - - - - + + + + + + - - - + + + top
@@ -70,14 +70,14 @@

- + diff --git a/privacy-policy.zh.html b/privacy-policy.zh.html index 81a0cf2..bf72d31 100644 --- a/privacy-policy.zh.html +++ b/privacy-policy.zh.html @@ -21,16 +21,16 @@ - - - - - - + + + + + + - - - + + + top
@@ -70,14 +70,14 @@

- + diff --git a/terms-of-service.html b/terms-of-service.html index 1c07a6d..8a2fcc2 100644 --- a/terms-of-service.html +++ b/terms-of-service.html @@ -21,16 +21,16 @@ - - - - - - + + + + + + - - - + + + top
@@ -72,14 +72,14 @@

- + diff --git a/terms-of-service.zh.html b/terms-of-service.zh.html index 5f28cd6..38ff42c 100644 --- a/terms-of-service.zh.html +++ b/terms-of-service.zh.html @@ -21,16 +21,16 @@ - - - - - - + + + + + + - - - + + + top
@@ -72,14 +72,14 @@

- +