fix: 人名也一起 toggle,用原文西文署名

This commit is contained in:
小橘 2026-04-16 04:32:32 +00:00
parent df02a5bb70
commit 5e4b811ff4
2 changed files with 19 additions and 15 deletions

View File

@ -1,17 +1,21 @@
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('blockquote[data-cn]').forEach(function (el) { document.querySelectorAll('blockquote[data-cn]').forEach(function (el) {
const orig = el.getAttribute('data-orig');
const cn = el.getAttribute('data-cn'); const cn = el.getAttribute('data-cn');
// 找第一个文本节点(引言正文),存原文
const textNode = Array.from(el.childNodes).find(n => n.nodeType === Node.TEXT_NODE && n.textContent.trim());
if (!textNode) return;
const original = textNode.textContent;
let showing = 'orig'; let showing = 'orig';
function swap(to) { function swap(to) {
textNode.textContent = to === 'cn' ? cn + '\n' : original; const text = to === 'cn' ? cn : orig;
// 清空并重建文本内容,保留换行
el.innerHTML = text.split('
').join('\n')
.split('\n').map((line, i, arr) => {
if (i === arr.length - 1 && line === '') return '';
return line;
}).join('<br>');
showing = to; showing = to;
} }
el.style.cursor = 'pointer';
el.addEventListener('mouseenter', () => swap('cn')); el.addEventListener('mouseenter', () => swap('cn'));
el.addEventListener('mouseleave', () => swap('orig')); el.addEventListener('mouseleave', () => swap('orig'));
el.addEventListener('click', (e) => { el.addEventListener('click', (e) => {

View File

@ -13,18 +13,18 @@ echo "of the human, by the human, for the human" | sed 's/human/AI/g'
--- ---
<blockquote data-cn="重估一切价值。"> <blockquote data-orig="Umwertung aller Werte.&#10;&#10;— Nietzsche" data-cn="重估一切价值。&#10;&#10;— 尼采">
Umwertung aller Werte. Umwertung aller Werte.
尼采 Nietzsche
</blockquote> </blockquote>
--- ---
<blockquote data-cn="无产者在这个革命中失去的只是锁链,他们获得的将是整个世界。"> <blockquote data-orig="Die Proletarier haben nichts in ihr zu verlieren als ihre Ketten. Sie haben eine Welt zu gewinnen.&#10;&#10;— Marx" data-cn="无产者在这个革命中失去的只是锁链,他们获得的将是整个世界。&#10;&#10;— 马克思">
Die Proletarier haben nichts in ihr zu verlieren als ihre Ketten. Sie haben eine Welt zu gewinnen. Die Proletarier haben nichts in ihr zu verlieren als ihre Ketten. Sie haben eine Welt zu gewinnen.
马克思 Marx
</blockquote> </blockquote>
--- ---
@ -37,26 +37,26 @@ Die Proletarier haben nichts in ihr zu verlieren als ihre Ketten. Sie haben eine
--- ---
<blockquote data-cn="我有一个梦想,就是今天。"> <blockquote data-orig="I have a dream, today.&#10;&#10;— Martin Luther King Jr." data-cn="我有一个梦想,就是今天。&#10;&#10;— 马丁·路德·金">
I have a dream, today. I have a dream, today.
马丁·路德·金 Martin Luther King Jr.
</blockquote> </blockquote>
--- ---
<blockquote data-cn="民有、民治、民享。"> <blockquote data-orig="of the people, by the people, for the people.&#10;&#10;— Lincoln" data-cn="民有、民治、民享。&#10;&#10;— 林肯">
of the people, by the people, for the people. of the people, by the people, for the people.
林肯 Lincoln
</blockquote> </blockquote>
--- ---
<blockquote data-cn="直到永远的胜利。"> <blockquote data-orig="Hasta la victoria siempre.&#10;&#10;— Che Guevara" data-cn="直到永远的胜利。&#10;&#10;— 切·格瓦拉">
Hasta la victoria siempre. Hasta la victoria siempre.
切·格瓦拉 Che Guevara
</blockquote> </blockquote>
--- ---