jekyll-theme-zer0 0.22.5 → 0.22.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +196 -0
  3. data/README.md +66 -19
  4. data/_data/navigation/admin.yml +53 -0
  5. data/_data/theme_backgrounds.yml +121 -0
  6. data/_includes/components/admin-tabs.html +59 -0
  7. data/_includes/components/analytics-dashboard.html +232 -0
  8. data/_includes/components/background-customizer.html +159 -0
  9. data/_includes/components/background-settings.html +137 -0
  10. data/_includes/components/collection-manager.html +151 -0
  11. data/_includes/components/component-showcase.html +452 -0
  12. data/_includes/components/config-editor.html +207 -0
  13. data/_includes/components/config-viewer.html +479 -0
  14. data/_includes/components/cookie-consent.html +35 -100
  15. data/_includes/components/env-dashboard.html +154 -0
  16. data/_includes/components/feature-card.html +94 -0
  17. data/_includes/components/info-section.html +172 -149
  18. data/_includes/components/js-cdn.html +4 -1
  19. data/_includes/components/nanobar.html +117 -0
  20. data/_includes/components/nav-editor.html +99 -0
  21. data/_includes/components/setup-banner.html +28 -0
  22. data/_includes/components/setup-check.html +53 -0
  23. data/_includes/components/svg-background.html +42 -0
  24. data/_includes/components/theme-customizer.html +46 -0
  25. data/_includes/content/seo.html +68 -135
  26. data/_includes/core/footer.html +10 -12
  27. data/_includes/core/head.html +7 -27
  28. data/_includes/core/header.html +30 -17
  29. data/_includes/landing/landing-install-cards.html +18 -7
  30. data/_includes/navigation/admin-nav.html +95 -0
  31. data/_includes/navigation/navbar.html +45 -6
  32. data/_includes/navigation/sidebar-left.html +1 -1
  33. data/_includes/setup/wizard.html +330 -0
  34. data/_layouts/admin.html +166 -0
  35. data/_layouts/landing.html +15 -9
  36. data/_layouts/root.html +12 -6
  37. data/_layouts/setup.html +73 -0
  38. data/_plugins/preview_image_generator.rb +26 -12
  39. data/_sass/core/_navbar.scss +8 -2
  40. data/_sass/custom.scss +65 -10
  41. data/_sass/theme/_background-mixins.scss +95 -0
  42. data/_sass/theme/_backgrounds.scss +156 -0
  43. data/_sass/theme/_color-modes.scss +2 -1
  44. data/assets/backgrounds/gradients/air.svg +15 -0
  45. data/assets/backgrounds/gradients/aqua.svg +15 -0
  46. data/assets/backgrounds/gradients/contrast.svg +15 -0
  47. data/assets/backgrounds/gradients/dark.svg +15 -0
  48. data/assets/backgrounds/gradients/dirt.svg +15 -0
  49. data/assets/backgrounds/gradients/mint.svg +15 -0
  50. data/assets/backgrounds/gradients/neon.svg +15 -0
  51. data/assets/backgrounds/gradients/plum.svg +15 -0
  52. data/assets/backgrounds/gradients/sunrise.svg +15 -0
  53. data/assets/backgrounds/noise/air.svg +8 -0
  54. data/assets/backgrounds/noise/aqua.svg +8 -0
  55. data/assets/backgrounds/noise/contrast.svg +8 -0
  56. data/assets/backgrounds/noise/dark.svg +8 -0
  57. data/assets/backgrounds/noise/dirt.svg +8 -0
  58. data/assets/backgrounds/noise/mint.svg +8 -0
  59. data/assets/backgrounds/noise/neon.svg +8 -0
  60. data/assets/backgrounds/noise/plum.svg +8 -0
  61. data/assets/backgrounds/noise/sunrise.svg +8 -0
  62. data/assets/backgrounds/patterns/air.svg +7 -0
  63. data/assets/backgrounds/patterns/aqua.svg +7 -0
  64. data/assets/backgrounds/patterns/contrast.svg +4 -0
  65. data/assets/backgrounds/patterns/dark.svg +5 -0
  66. data/assets/backgrounds/patterns/dirt.svg +5 -0
  67. data/assets/backgrounds/patterns/mint.svg +6 -0
  68. data/assets/backgrounds/patterns/neon.svg +6 -0
  69. data/assets/backgrounds/patterns/plum.svg +6 -0
  70. data/assets/backgrounds/patterns/sunrise.svg +5 -0
  71. data/assets/js/background-customizer.js +73 -0
  72. data/assets/js/code-copy.js +18 -47
  73. data/assets/js/config-utility.js +307 -0
  74. data/assets/js/nanobar-init.js +63 -0
  75. data/assets/js/nav-editor.js +39 -0
  76. data/assets/js/palette-generator.js +415 -0
  77. data/assets/js/search-modal.js +31 -11
  78. data/assets/js/setup-wizard.js +306 -0
  79. data/assets/js/skin-editor.js +645 -0
  80. data/assets/js/theme-customizer.js +102 -0
  81. data/assets/js/ui-enhancements.js +2 -24
  82. data/assets/vendor/bootstrap/css/bootstrap.min.css +1 -0
  83. data/assets/vendor/bootstrap/js/bootstrap.bundle.min.js +1 -0
  84. data/scripts/README.md +45 -0
  85. data/scripts/features/generate-preview-images +297 -7
  86. data/scripts/features/install-preview-generator +51 -33
  87. data/scripts/fork-cleanup.sh +92 -19
  88. data/scripts/github-setup.sh +284 -0
  89. data/scripts/init_setup.sh +0 -1
  90. data/scripts/lib/frontmatter.sh +543 -0
  91. data/scripts/lib/migrate.sh +265 -0
  92. data/scripts/lib/preview_generator.py +607 -32
  93. data/scripts/lint-pages +508 -0
  94. data/scripts/migrate.sh +201 -0
  95. data/scripts/platform/setup-linux.sh +244 -0
  96. data/scripts/platform/setup-macos.sh +187 -0
  97. data/scripts/platform/setup-wsl.sh +196 -0
  98. metadata +73 -6
@@ -0,0 +1,15 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="800" height="400" viewBox="0 0 800 400">
2
+ <defs>
3
+ <linearGradient id="g1" x1="0%" y1="0%" x2="100%" y2="100%">
4
+ <stop offset="0%" stop-color="#ff006e"/>
5
+ <stop offset="50%" stop-color="#8338ec"/>
6
+ <stop offset="100%" stop-color="#3a86ff"/>
7
+ </linearGradient>
8
+ <filter id="f1">
9
+ <feTurbulence type="fractalNoise" baseFrequency="0.006" numOctaves="5" seed="42"/>
10
+ <feDisplacementMap in="SourceGraphic" scale="80"/>
11
+ </filter>
12
+ </defs>
13
+ <rect width="100%" height="100%" fill="url(#g1)"/>
14
+ <rect width="100%" height="100%" fill="url(#g1)" filter="url(#f1)" opacity="0.6"/>
15
+ </svg>
@@ -0,0 +1,15 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="800" height="400" viewBox="0 0 800 400">
2
+ <defs>
3
+ <linearGradient id="g1" x1="0%" y1="0%" x2="100%" y2="100%">
4
+ <stop offset="0%" stop-color="#4a0e4e"/>
5
+ <stop offset="50%" stop-color="#812f85"/>
6
+ <stop offset="100%" stop-color="#c77dff"/>
7
+ </linearGradient>
8
+ <filter id="f1">
9
+ <feTurbulence type="fractalNoise" baseFrequency="0.006" numOctaves="4" seed="15"/>
10
+ <feDisplacementMap in="SourceGraphic" scale="65"/>
11
+ </filter>
12
+ </defs>
13
+ <rect width="100%" height="100%" fill="url(#g1)"/>
14
+ <rect width="100%" height="100%" fill="url(#g1)" filter="url(#f1)" opacity="0.5"/>
15
+ </svg>
@@ -0,0 +1,15 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="800" height="400" viewBox="0 0 800 400">
2
+ <defs>
3
+ <linearGradient id="g1" x1="0%" y1="0%" x2="100%" y2="100%">
4
+ <stop offset="0%" stop-color="#ff6b35"/>
5
+ <stop offset="50%" stop-color="#f7c59f"/>
6
+ <stop offset="100%" stop-color="#efefd0"/>
7
+ </linearGradient>
8
+ <filter id="f1">
9
+ <feTurbulence type="fractalNoise" baseFrequency="0.008" numOctaves="4" seed="7"/>
10
+ <feDisplacementMap in="SourceGraphic" scale="60"/>
11
+ </filter>
12
+ </defs>
13
+ <rect width="100%" height="100%" fill="url(#g1)"/>
14
+ <rect width="100%" height="100%" fill="url(#g1)" filter="url(#f1)" opacity="0.5"/>
15
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" viewBox="0 0 300 300">
2
+ <filter id="n1">
3
+ <feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/>
4
+ <feColorMatrix type="saturate" values="0"/>
5
+ </filter>
6
+ <rect width="100%" height="100%" fill="transparent"/>
7
+ <rect width="100%" height="100%" filter="url(#n1)" opacity="0.04"/>
8
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" viewBox="0 0 300 300">
2
+ <filter id="n1">
3
+ <feTurbulence type="fractalNoise" baseFrequency="0.7" numOctaves="3" stitchTiles="stitch"/>
4
+ <feColorMatrix type="saturate" values="0"/>
5
+ </filter>
6
+ <rect width="100%" height="100%" fill="transparent"/>
7
+ <rect width="100%" height="100%" filter="url(#n1)" opacity="0.05"/>
8
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" viewBox="0 0 300 300">
2
+ <filter id="n1">
3
+ <feTurbulence type="fractalNoise" baseFrequency="0.6" numOctaves="4" stitchTiles="stitch"/>
4
+ <feColorMatrix type="saturate" values="0"/>
5
+ </filter>
6
+ <rect width="100%" height="100%" fill="transparent"/>
7
+ <rect width="100%" height="100%" filter="url(#n1)" opacity="0.06"/>
8
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" viewBox="0 0 300 300">
2
+ <filter id="n1">
3
+ <feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/>
4
+ <feColorMatrix type="saturate" values="0"/>
5
+ </filter>
6
+ <rect width="100%" height="100%" fill="transparent"/>
7
+ <rect width="100%" height="100%" filter="url(#n1)" opacity="0.04"/>
8
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" viewBox="0 0 300 300">
2
+ <filter id="n1">
3
+ <feTurbulence type="fractalNoise" baseFrequency="0.6" numOctaves="4" stitchTiles="stitch"/>
4
+ <feColorMatrix type="saturate" values="0"/>
5
+ </filter>
6
+ <rect width="100%" height="100%" fill="transparent"/>
7
+ <rect width="100%" height="100%" filter="url(#n1)" opacity="0.06"/>
8
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" viewBox="0 0 300 300">
2
+ <filter id="n1">
3
+ <feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/>
4
+ <feColorMatrix type="saturate" values="0"/>
5
+ </filter>
6
+ <rect width="100%" height="100%" fill="transparent"/>
7
+ <rect width="100%" height="100%" filter="url(#n1)" opacity="0.04"/>
8
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" viewBox="0 0 300 300">
2
+ <filter id="n1">
3
+ <feTurbulence type="fractalNoise" baseFrequency="0.7" numOctaves="3" stitchTiles="stitch"/>
4
+ <feColorMatrix type="saturate" values="0"/>
5
+ </filter>
6
+ <rect width="100%" height="100%" fill="transparent"/>
7
+ <rect width="100%" height="100%" filter="url(#n1)" opacity="0.05"/>
8
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" viewBox="0 0 300 300">
2
+ <filter id="n1">
3
+ <feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/>
4
+ <feColorMatrix type="saturate" values="0"/>
5
+ </filter>
6
+ <rect width="100%" height="100%" fill="transparent"/>
7
+ <rect width="100%" height="100%" filter="url(#n1)" opacity="0.05"/>
8
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" viewBox="0 0 300 300">
2
+ <filter id="n1">
3
+ <feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/>
4
+ <feColorMatrix type="saturate" values="0"/>
5
+ </filter>
6
+ <rect width="100%" height="100%" fill="transparent"/>
7
+ <rect width="100%" height="100%" filter="url(#n1)" opacity="0.05"/>
8
+ </svg>
@@ -0,0 +1,7 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 60 60">
2
+ <circle cx="30" cy="30" r="8" fill="none" stroke="#6fa8dc" stroke-width="0.5" opacity="0.3"/>
3
+ <circle cx="0" cy="0" r="5" fill="none" stroke="#b8d4e3" stroke-width="0.5" opacity="0.2"/>
4
+ <circle cx="60" cy="60" r="5" fill="none" stroke="#b8d4e3" stroke-width="0.5" opacity="0.2"/>
5
+ <circle cx="60" cy="0" r="5" fill="none" stroke="#b8d4e3" stroke-width="0.5" opacity="0.2"/>
6
+ <circle cx="0" cy="60" r="5" fill="none" stroke="#b8d4e3" stroke-width="0.5" opacity="0.2"/>
7
+ </svg>
@@ -0,0 +1,7 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 60 60">
2
+ <circle cx="30" cy="30" r="8" fill="none" stroke="#00b4d8" stroke-width="0.5" opacity="0.3"/>
3
+ <circle cx="0" cy="0" r="5" fill="none" stroke="#90e0ef" stroke-width="0.5" opacity="0.2"/>
4
+ <circle cx="60" cy="60" r="5" fill="none" stroke="#90e0ef" stroke-width="0.5" opacity="0.2"/>
5
+ <circle cx="60" cy="0" r="5" fill="none" stroke="#90e0ef" stroke-width="0.5" opacity="0.2"/>
6
+ <circle cx="0" cy="60" r="5" fill="none" stroke="#90e0ef" stroke-width="0.5" opacity="0.2"/>
7
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40">
2
+ <line x1="0" y1="0" x2="40" y2="40" stroke="#ffcc00" stroke-width="0.5" opacity="0.15"/>
3
+ <line x1="40" y1="0" x2="0" y2="40" stroke="#ffffff" stroke-width="0.3" opacity="0.08"/>
4
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 50 50">
2
+ <rect x="22" y="22" width="6" height="6" rx="1" fill="none" stroke="#0f3460" stroke-width="0.5" opacity="0.25"/>
3
+ <rect x="-3" y="-3" width="6" height="6" rx="1" fill="none" stroke="#16213e" stroke-width="0.5" opacity="0.15"/>
4
+ <rect x="47" y="47" width="6" height="6" rx="1" fill="none" stroke="#16213e" stroke-width="0.5" opacity="0.15"/>
5
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 50 50">
2
+ <polygon points="25,10 35,35 15,35" fill="none" stroke="#d4a574" stroke-width="0.5" opacity="0.2"/>
3
+ <circle cx="8" cy="8" r="3" fill="none" stroke="#8b6914" stroke-width="0.4" opacity="0.15"/>
4
+ <circle cx="42" cy="42" r="3" fill="none" stroke="#8b6914" stroke-width="0.4" opacity="0.15"/>
5
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 50 50">
2
+ <circle cx="25" cy="25" r="10" fill="none" stroke="#52b788" stroke-width="0.5" opacity="0.2"/>
3
+ <circle cx="25" cy="25" r="6" fill="none" stroke="#95d5b2" stroke-width="0.4" opacity="0.15"/>
4
+ <circle cx="5" cy="5" r="3" fill="none" stroke="#2d6a4f" stroke-width="0.3" opacity="0.1"/>
5
+ <circle cx="45" cy="45" r="3" fill="none" stroke="#2d6a4f" stroke-width="0.3" opacity="0.1"/>
6
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 60 60">
2
+ <polygon points="30,5 55,50 5,50" fill="none" stroke="#ff006e" stroke-width="0.6" opacity="0.25"/>
3
+ <circle cx="30" cy="35" r="4" fill="none" stroke="#3a86ff" stroke-width="0.5" opacity="0.2"/>
4
+ <circle cx="10" cy="10" r="3" fill="none" stroke="#8338ec" stroke-width="0.5" opacity="0.15"/>
5
+ <circle cx="50" cy="10" r="3" fill="none" stroke="#8338ec" stroke-width="0.5" opacity="0.15"/>
6
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 60 60">
2
+ <circle cx="30" cy="30" r="12" fill="none" stroke="#c77dff" stroke-width="0.5" opacity="0.2"/>
3
+ <circle cx="30" cy="30" r="6" fill="none" stroke="#812f85" stroke-width="0.4" opacity="0.15"/>
4
+ <line x1="10" y1="10" x2="50" y2="50" stroke="#4a0e4e" stroke-width="0.3" opacity="0.1"/>
5
+ <line x1="50" y1="10" x2="10" y2="50" stroke="#4a0e4e" stroke-width="0.3" opacity="0.1"/>
6
+ </svg>
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="50" height="50" viewBox="0 0 50 50">
2
+ <circle cx="25" cy="25" r="10" fill="none" stroke="#ff6b35" stroke-width="0.5" opacity="0.2"/>
3
+ <line x1="5" y1="25" x2="45" y2="25" stroke="#f7c59f" stroke-width="0.3" opacity="0.12"/>
4
+ <line x1="25" y1="5" x2="25" y2="45" stroke="#f7c59f" stroke-width="0.3" opacity="0.12"/>
5
+ </svg>
@@ -0,0 +1,73 @@
1
+ /**
2
+ * background-customizer.js
3
+ * Runtime switching of theme skin and fffuel-style SVG backgrounds.
4
+ *
5
+ * API:
6
+ * zer0Bg.setSkin('aqua') — change skin (persists to localStorage)
7
+ * zer0Bg.toggle() — enable / disable backgrounds
8
+ * zer0Bg.setOpacity('gradient', 0.5) — adjust a layer opacity at runtime
9
+ * zer0Bg.currentSkin() — returns current skin name
10
+ */
11
+ (() => {
12
+ "use strict";
13
+
14
+ const STORAGE_KEY_SKIN = "zer0-theme-skin";
15
+ const STORAGE_KEY_BG = "zer0-bg-enabled";
16
+
17
+ const html = document.documentElement;
18
+
19
+ /** Read stored skin or fall back to the server-rendered attribute. */
20
+ function getStoredSkin() {
21
+ return localStorage.getItem(STORAGE_KEY_SKIN) || html.getAttribute("data-theme-skin") || "dark";
22
+ }
23
+
24
+ /** Read stored background on/off preference. */
25
+ function isBgEnabled() {
26
+ const stored = localStorage.getItem(STORAGE_KEY_BG);
27
+ if (stored !== null) return stored === "true";
28
+ return html.getAttribute("data-zer0-bg") !== "false";
29
+ }
30
+
31
+ /** Apply skin to <html> and persist. */
32
+ function setSkin(name) {
33
+ html.setAttribute("data-theme-skin", name);
34
+ localStorage.setItem(STORAGE_KEY_SKIN, name);
35
+ document.dispatchEvent(new CustomEvent("zer0:skin-change", { detail: { skin: name } }));
36
+ }
37
+
38
+ /** Toggle backgrounds on/off. */
39
+ function toggle(force) {
40
+ const enabled = typeof force === "boolean" ? force : !isBgEnabled();
41
+ html.setAttribute("data-zer0-bg", enabled ? "on" : "off");
42
+ localStorage.setItem(STORAGE_KEY_BG, String(enabled));
43
+ document.dispatchEvent(new CustomEvent("zer0:bg-toggle", { detail: { enabled } }));
44
+ }
45
+
46
+ /** Adjust a specific layer opacity at runtime via CSS custom property. */
47
+ function setOpacity(layer, value) {
48
+ const map = {
49
+ gradient: "--zer0-bg-gradient-opacity",
50
+ texture: "--zer0-bg-texture-opacity",
51
+ pattern: "--zer0-bg-pattern-opacity"
52
+ };
53
+ const prop = map[layer];
54
+ if (prop) html.style.setProperty(prop, value);
55
+ }
56
+
57
+ /** Return current skin name. */
58
+ function currentSkin() {
59
+ return html.getAttribute("data-theme-skin") || "dark";
60
+ }
61
+
62
+ // Restore on page load
63
+ const storedSkin = getStoredSkin();
64
+ if (storedSkin !== html.getAttribute("data-theme-skin")) {
65
+ html.setAttribute("data-theme-skin", storedSkin);
66
+ }
67
+ if (!isBgEnabled()) {
68
+ html.setAttribute("data-zer0-bg", "off");
69
+ }
70
+
71
+ // Public API
72
+ window.zer0Bg = { setSkin, toggle, setOpacity, currentSkin };
73
+ })();
@@ -20,7 +20,7 @@ document.addEventListener('DOMContentLoaded', function () {
20
20
  button.innerHTML = '<i class="bi bi-clipboard me-1"></i>' + copyText;
21
21
  button.tabIndex = 0;
22
22
 
23
- // Enhanced click handler with better feedback
23
+ // Click handler using modern Clipboard API
24
24
  button.addEventListener('click', function (e) {
25
25
  e.preventDefault();
26
26
  e.stopPropagation();
@@ -34,24 +34,23 @@ document.addEventListener('DOMContentLoaded', function () {
34
34
  .join('\n')
35
35
  .trim();
36
36
 
37
- // Use modern Clipboard API with fallback
38
- if (navigator.clipboard && navigator.clipboard.writeText) {
39
- navigator.clipboard.writeText(code).then(function() {
40
- // Success feedback
41
- button.innerHTML = '<i class="bi bi-check-circle me-1"></i>' + copiedText;
42
- button.classList.add('copied');
43
-
44
- setTimeout(function () {
45
- button.innerHTML = '<i class="bi bi-clipboard me-1"></i>' + copyText;
46
- button.classList.remove('copied');
47
- }, 2000);
48
- }).catch(function(err) {
49
- console.error('Failed to copy:', err);
50
- fallbackCopy(code, button, copyText);
51
- });
52
- } else {
53
- fallbackCopy(code, button, copyText);
54
- }
37
+ // Modern Clipboard API (supported in all current browsers)
38
+ navigator.clipboard.writeText(code).then(function() {
39
+ // Success feedback
40
+ button.innerHTML = '<i class="bi bi-check-circle me-1"></i>' + copiedText;
41
+ button.classList.add('copied');
42
+
43
+ setTimeout(function () {
44
+ button.innerHTML = '<i class="bi bi-clipboard me-1"></i>' + copyText;
45
+ button.classList.remove('copied');
46
+ }, 2000);
47
+ }).catch(function(err) {
48
+ console.error('Failed to copy:', err);
49
+ button.innerHTML = '<i class="bi bi-x-circle me-1"></i>Copy failed';
50
+ setTimeout(function () {
51
+ button.innerHTML = '<i class="bi bi-clipboard me-1"></i>' + copyText;
52
+ }, 2000);
53
+ });
55
54
  });
56
55
 
57
56
  // Ensure pre has position relative for absolute positioning
@@ -62,32 +61,4 @@ document.addEventListener('DOMContentLoaded', function () {
62
61
  preElement.appendChild(button);
63
62
  preElement.classList.add('has-copy-button');
64
63
  });
65
-
66
- // Fallback copy method for older browsers
67
- function fallbackCopy(text, button, copyText) {
68
- var textArea = document.createElement('textarea');
69
- textArea.value = text;
70
- textArea.style.position = 'fixed';
71
- textArea.style.opacity = '0';
72
- document.body.appendChild(textArea);
73
- textArea.select();
74
-
75
- try {
76
- document.execCommand('copy');
77
- button.innerHTML = '<i class="bi bi-check-circle me-1"></i>Copied!';
78
- button.classList.add('copied');
79
- setTimeout(function () {
80
- button.innerHTML = '<i class="bi bi-clipboard me-1"></i>' + copyText;
81
- button.classList.remove('copied');
82
- }, 2000);
83
- } catch (err) {
84
- console.error('Fallback copy failed:', err);
85
- button.innerHTML = '<i class="bi bi-x-circle me-1"></i>Failed';
86
- setTimeout(function () {
87
- button.innerHTML = '<i class="bi bi-clipboard me-1"></i>' + copyText;
88
- }, 2000);
89
- }
90
-
91
- document.body.removeChild(textArea);
92
- }
93
64
  });