1+ // Custom script to add drasyl-java documentation banner to every page
2+ ( function ( ) {
3+ 'use strict' ;
4+
5+ // Wait for DOM to be ready
6+ function addCustomAdmonition ( ) {
7+ // Check if the banner already exists to avoid duplicates
8+ if ( document . querySelector ( '.custom-drasyl-java-banner' ) ) {
9+ return ;
10+ }
11+
12+ // Create the banner HTML
13+ const bannerHTML = `
14+ <div class="theme-admonition theme-admonition-info alert alert--info admonition_node_modules-@docusaurus-theme-classic-lib-theme-Admonition-styles-module custom-drasyl-java-banner">
15+ <div class="admonitionHeading_node_modules-@docusaurus-theme-classic-lib-theme-Admonition-styles-module">
16+ <span class="admonitionIcon_node_modules-@docusaurus-theme-classic-lib-theme-Admonition-styles-module">
17+ <svg viewBox="0 0 14 16">
18+ <path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path>
19+ </svg>
20+ </span>
21+ drasyl-java documentation
22+ </div>
23+ <div class="admonitionContent_node_modules-@docusaurus-theme-classic-lib-theme-Admonition-styles-module">
24+ <p>You're viewing the documentation for the original <strong>drasyl</strong> project, now renamed to <strong>drasyl-java</strong>.<br>
25+ It provides a high-performance framework for building distributed applications.</p>
26+ <p>If you're looking for the new <strong>drasyl</strong> documentation, a secure, software-defined overlay network solution,<br>
27+ please visit <a href="https://docs.drasyl.org">docs.drasyl.org</a>.</p>
28+ </div>
29+ </div>
30+ ` ;
31+
32+ // Find the main content area to insert the banner
33+ const mainContent = document . querySelector ( 'main .row .col' ) ;
34+
35+ if ( mainContent ) {
36+ // Create a temporary container to parse the HTML
37+ const temp = document . createElement ( 'div' ) ;
38+ temp . innerHTML = bannerHTML ;
39+ const bannerElement = temp . firstElementChild ;
40+
41+ // Insert the banner at the beginning of the main content
42+ if ( mainContent . firstChild ) {
43+ mainContent . insertBefore ( bannerElement , mainContent . firstChild ) ;
44+ } else {
45+ mainContent . appendChild ( bannerElement ) ;
46+ }
47+ }
48+ }
49+
50+ // Run when DOM is ready
51+ if ( document . readyState === 'loading' ) {
52+ document . addEventListener ( 'DOMContentLoaded' , addCustomAdmonition ) ;
53+ } else {
54+ addCustomAdmonition ( ) ;
55+ }
56+
57+ // Also run on navigation events (for SPA behavior)
58+ if ( typeof window !== 'undefined' ) {
59+ // Listen for navigation events
60+ window . addEventListener ( 'load' , addCustomAdmonition ) ;
61+
62+ // For Docusaurus navigation - check periodically for new content
63+ setInterval ( function ( ) {
64+ const mainContent = document . querySelector ( 'main .row .col' ) ;
65+ if ( mainContent && ! mainContent . querySelector ( '.custom-drasyl-java-banner' ) ) {
66+ addCustomAdmonition ( ) ;
67+ }
68+ } , 250 ) ;
69+
70+ // Also listen for popstate events (browser back/forward)
71+ window . addEventListener ( 'popstate' , function ( ) {
72+ setTimeout ( addCustomAdmonition , 100 ) ;
73+ } ) ;
74+
75+ // Listen for pushstate/replacestate events
76+ const originalPushState = history . pushState ;
77+ const originalReplaceState = history . replaceState ;
78+
79+ history . pushState = function ( ) {
80+ originalPushState . apply ( this , arguments ) ;
81+ setTimeout ( addCustomAdmonition , 100 ) ;
82+ } ;
83+
84+ history . replaceState = function ( ) {
85+ originalReplaceState . apply ( this , arguments ) ;
86+ setTimeout ( addCustomAdmonition , 100 ) ;
87+ } ;
88+ }
89+ } ) ( ) ;
0 commit comments