Skip to content

Commit caad70c

Browse files
committed
🤖 Auto-update eBook files and GitHub Pages [skip ci]
1 parent 0874e2f commit caad70c

File tree

6 files changed

+18
-253
lines changed

6 files changed

+18
-253
lines changed
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

index.html

Lines changed: 18 additions & 253 deletions
Original file line numberDiff line numberDiff line change
@@ -455,155 +455,7 @@
455455
color: var(--code-text);
456456
font-weight: 400;
457457
}
458-
/* Copy Button Styles - No Overlay Version */
459-
.code-block-wrapper {
460-
position: relative;
461-
margin: 2rem 0;
462-
isolation: isolate;
463-
}
464-
465-
.code-block-wrapper pre {
466-
margin: 0;
467-
}
468-
469-
.copy-button {
470-
position: absolute;
471-
top: 0.75rem;
472-
right: 0.75rem;
473-
background: rgba(91, 124, 153, 0.9);
474-
color: white;
475-
border: none;
476-
border-radius: 6px;
477-
padding: 0.5rem 0.75rem;
478-
font-size: 0.75rem;
479-
font-weight: 500;
480-
font-family: 'Inter', sans-serif;
481-
cursor: pointer;
482-
display: flex;
483-
align-items: center;
484-
gap: 0.4rem;
485-
transition: all 0.2s ease;
486-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
487-
z-index: 100;
488-
opacity: 0;
489-
transform: translateY(-2px);
490-
pointer-events: auto;
491-
-webkit-tap-highlight-color: transparent;
492-
-webkit-touch-callout: none;
493-
-webkit-user-select: none;
494-
-moz-user-select: none;
495-
user-select: none;
496-
}
497-
498-
.code-block-wrapper:hover .copy-button {
499-
opacity: 1;
500-
transform: translateY(0);
501-
}
502-
503-
.copy-button:hover {
504-
background: var(--primary-hover);
505-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
506-
transform: translateY(-1px);
507-
}
508-
509-
.copy-button:active {
510-
transform: translateY(0);
511-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
512-
}
513-
514-
.copy-button:focus {
515-
outline: none;
516-
}
517-
518-
.copy-button:focus-visible {
519-
outline: 2px solid var(--accent-color);
520-
outline-offset: 2px;
521-
}
522-
523-
.copy-button.copied {
524-
background: var(--success-color);
525-
opacity: 1;
526-
}
527-
528-
.copy-button i {
529-
font-size: 0.875rem;
530-
pointer-events: none;
531-
}
532-
533-
.copy-button .copy-text {
534-
pointer-events: none;
535-
user-select: none;
536-
}
537-
538-
.copy-button .copy-icon {
539-
display: inline-block;
540-
}
541-
542-
.copy-button .check-icon {
543-
display: none;
544-
}
545-
546-
.copy-button.copied .copy-icon {
547-
display: none;
548-
}
549-
550-
.copy-button.copied .check-icon {
551-
display: inline-block;
552-
animation: checkmark 0.3s ease;
553-
}
554-
555-
@keyframes checkmark {
556-
0% {
557-
transform: scale(0) rotate(-45deg);
558-
}
559-
50% {
560-
transform: scale(1.2) rotate(0deg);
561-
}
562-
100% {
563-
transform: scale(1) rotate(0deg);
564-
}
565-
}
566-
567-
/* Completely remove all pseudo-elements that could show overlays */
568-
.copy-button::before,
569-
.copy-button::after {
570-
display: none !important;
571-
content: none !important;
572-
opacity: 0 !important;
573-
visibility: hidden !important;
574-
}
575458

576-
.copy-button:hover::before,
577-
.copy-button:hover::after,
578-
.copy-button:focus::before,
579-
.copy-button:focus::after,
580-
.copy-button:active::before,
581-
.copy-button:active::after {
582-
display: none !important;
583-
content: none !important;
584-
}
585-
586-
/* Dark mode adjustments */
587-
body.dark-mode .copy-button {
588-
background: rgba(127, 169, 155, 0.9);
589-
}
590-
591-
body.dark-mode .copy-button:hover {
592-
background: var(--accent-color);
593-
}
594-
595-
/* Mobile optimizations */
596-
@media (max-width: 768px) {
597-
.copy-button {
598-
opacity: 1;
599-
padding: 0.45rem 0.65rem;
600-
font-size: 0.7rem;
601-
}
602-
603-
.copy-button i {
604-
font-size: 0.8rem;
605-
}
606-
}
607459
/* Blockquotes */
608460
.content-wrapper blockquote {
609461
margin: 2.5rem 0;
@@ -21810,6 +21662,10 @@ <h2>Download Other Formats</h2>
2181021662
</button>
2181121663

2181221664
<script>
21665+
// State management
21666+
let sidebarOpen = window.innerWidth > 1024;
21667+
let currentFontSize = 'medium';
21668+
2181321669
// Initialize
2181421670
document.addEventListener('DOMContentLoaded', function() {
2181521671
initializeApp();
@@ -21821,7 +21677,6 @@ <h2>Download Other Formats</h2>
2182121677
loadPreferences();
2182221678
setupEventListeners();
2182321679
updateActiveNavigation();
21824-
initializeCopyButtons();
2182521680

2182621681
if (window.innerWidth > 1024) {
2182721682
toggleSidebar();
@@ -21885,6 +21740,7 @@ <h2>Download Other Formats</h2>
2188521740

2188621741
sidebar.classList.toggle('open');
2188721742
mainContent.classList.toggle('sidebar-open');
21743+
sidebarOpen = sidebar.classList.contains('open');
2188821744
}
2188921745

2189021746
// Reading progress
@@ -21937,6 +21793,7 @@ <h2>Download Other Formats</h2>
2193721793
const body = document.body;
2193821794
body.classList.remove('font-small', 'font-medium', 'font-large');
2193921795
body.classList.add('font-' + size);
21796+
currentFontSize = size;
2194021797

2194121798
// Update button states
2194221799
document.querySelectorAll('.font-size-btn').forEach(btn => {
@@ -22007,13 +21864,8 @@ <h2>Download Other Formats</h2>
2200721864
}, 10);
2200821865
});
2200921866

22010-
// Combined click handler for navigation and sidebar control
21867+
// Navigation click handlers
2201121868
document.addEventListener('click', function(e) {
22012-
const sidebar = document.getElementById('sidebar');
22013-
const mainContent = document.getElementById('main-content');
22014-
const isMobile = window.innerWidth <= 1024;
22015-
22016-
// Handle navigation item clicks
2201721869
if (e.target.closest('.nav-item[data-target]')) {
2201821870
e.preventDefault();
2201921871
const navItem = e.target.closest('.nav-item[data-target]');
@@ -22028,25 +21880,29 @@ <h2>Download Other Formats</h2>
2202821880
}
2202921881

2203021882
// Close sidebar on mobile after navigation
22031-
if (isMobile) {
21883+
if (window.innerWidth <= 1024) {
21884+
const sidebar = document.getElementById('sidebar');
21885+
const mainContent = document.getElementById('main-content');
2203221886
sidebar.classList.remove('open');
2203321887
mainContent.classList.remove('sidebar-open');
2203421888
}
22035-
return; // Exit early
2203621889
}
22037-
22038-
// Handle clicking outside sidebar on mobile
22039-
if (isMobile && sidebar.classList.contains('open')) {
21890+
});
21891+
21892+
// Close sidebar when clicking outside on mobile
21893+
document.addEventListener('click', function(e) {
21894+
if (window.innerWidth <= 1024) {
21895+
const sidebar = document.getElementById('sidebar');
21896+
const mainContent = document.getElementById('main-content');
2204021897
const sidebarToggle = document.querySelector('.sidebar-toggle');
2204121898

22042-
if (!sidebar.contains(e.target) && !sidebarToggle.contains(e.target)) {
21899+
if (!sidebar.contains(e.target) && !sidebarToggle.contains(e.target) && sidebar.classList.contains('open')) {
2204321900
sidebar.classList.remove('open');
2204421901
mainContent.classList.remove('sidebar-open');
2204521902
}
2204621903
}
2204721904
});
2204821905

22049-
2205021906
// Handle window resize
2205121907
let resizeTimeout;
2205221908
window.addEventListener('resize', function() {
@@ -22081,97 +21937,6 @@ <h2>Download Other Formats</h2>
2208121937
}
2208221938
}
2208321939
});
22084-
22085-
// Copy to Clipboard Functionality - No Overlays Version
22086-
function initializeCopyButtons() {
22087-
const preElements = document.querySelectorAll('.content-wrapper pre');
22088-
22089-
preElements.forEach((pre) => {
22090-
if (pre.parentElement.classList.contains('code-block-wrapper')) {
22091-
return;
22092-
}
22093-
22094-
const wrapper = document.createElement('div');
22095-
wrapper.className = 'code-block-wrapper';
22096-
pre.parentNode.insertBefore(wrapper, pre);
22097-
wrapper.appendChild(pre);
22098-
22099-
const copyButton = document.createElement('button');
22100-
copyButton.className = 'copy-button';
22101-
copyButton.type = 'button';
22102-
copyButton.setAttribute('aria-label', 'Copy code to clipboard');
22103-
copyButton.setAttribute('title', ''); // Prevent default tooltip
22104-
copyButton.innerHTML = `
22105-
<i class="fas fa-copy copy-icon" aria-hidden="true"></i>
22106-
<i class="fas fa-check check-icon" aria-hidden="true"></i>
22107-
<span class="copy-text">Copy</span>
22108-
`;
22109-
22110-
copyButton.addEventListener('click', async function(e) {
22111-
e.preventDefault();
22112-
e.stopPropagation();
22113-
e.stopImmediatePropagation();
22114-
22115-
const code = pre.querySelector('code');
22116-
const textToCopy = code ? code.textContent : pre.textContent;
22117-
22118-
try {
22119-
await navigator.clipboard.writeText(textToCopy);
22120-
22121-
// Visual feedback
22122-
copyButton.classList.add('copied');
22123-
const copyText = copyButton.querySelector('.copy-text');
22124-
if (copyText) copyText.textContent = 'Copied!';
22125-
22126-
setTimeout(() => {
22127-
copyButton.classList.remove('copied');
22128-
if (copyText) copyText.textContent = 'Copy';
22129-
}, 2000);
22130-
22131-
} catch (err) {
22132-
// Fallback for older browsers
22133-
const textArea = document.createElement('textarea');
22134-
textArea.value = textToCopy;
22135-
textArea.style.position = 'fixed';
22136-
textArea.style.left = '-999999px';
22137-
textArea.style.top = '-999999px';
22138-
document.body.appendChild(textArea);
22139-
textArea.focus();
22140-
textArea.select();
22141-
22142-
try {
22143-
document.execCommand('copy');
22144-
textArea.remove();
22145-
22146-
copyButton.classList.add('copied');
22147-
const copyText = copyButton.querySelector('.copy-text');
22148-
if (copyText) copyText.textContent = 'Copied!';
22149-
22150-
setTimeout(() => {
22151-
copyButton.classList.remove('copied');
22152-
if (copyText) copyText.textContent = 'Copy';
22153-
}, 2000);
22154-
22155-
} catch (err) {
22156-
console.error('Failed to copy text: ', err);
22157-
textArea.remove();
22158-
}
22159-
}
22160-
22161-
return false;
22162-
}, { capture: true });
22163-
22164-
copyButton.addEventListener('touchstart', function(e) {
22165-
e.stopPropagation();
22166-
}, { passive: true });
22167-
22168-
copyButton.addEventListener('touchend', function(e) {
22169-
e.stopPropagation();
22170-
}, { passive: true });
22171-
22172-
wrapper.appendChild(copyButton);
22173-
});
22174-
}
2217521940
</script>
2217621941
</body>
2217721942
</html>

0 commit comments

Comments
 (0)