-
-
Notifications
You must be signed in to change notification settings - Fork 4
Language specific examples #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JDSherbert
merged 4 commits into
VerzatileDevOrg:main
from
VerzatileDev:language-specific-Examples
Jan 9, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,64 @@ | ||
| --- | ||
| layout: table_wrappers | ||
| include_language_switch_script: false | ||
| --- | ||
|
|
||
| <!DOCTYPE html> | ||
|
|
||
| <html lang="{{ site.lang | default: 'en-US' }}"> | ||
| {% include head.html %} | ||
| <body> | ||
| <!-- Skip to main content link for accessibility --> | ||
| <a class="skip-to-main" href="#main-content">Skip to main content</a> | ||
|
|
||
| <!-- Include icons and sidebar components --> | ||
| {% include icons/icons.html %} | ||
| {% include components/sidebar.html %} | ||
|
|
||
| <!-- Main content section --> | ||
| <div class="main" id="top"> | ||
| {% include components/header.html %} | ||
|
|
||
| <!-- Main content wrapper with breadcrumbs --> | ||
| <div class="main-content-wrap"> | ||
| {% include components/breadcrumbs.html %} | ||
|
|
||
| <!-- Main content container --> | ||
| <div id="main-content" class="main-content"> | ||
| <main> | ||
| <!-- Include anchor headings for heading links --> | ||
| {% if site.heading_anchors != false %} | ||
| {% include vendor/anchor_headings.html html=content beforeHeading="true" anchorBody="<svg viewBox=\"0 0 16 16\" aria-hidden=\"true\"><use xlink:href=\"#svg-link\"></use></svg>" anchorClass="anchor-heading" anchorAttrs="aria-labelledby=\"%html_id%\"" %} | ||
| {% else %} | ||
| {{ content }} | ||
| {% endif %} | ||
|
|
||
| <!-- Include children navigation if page has children and TOC is enabled --> | ||
| {% if page.has_children == true and page.has_toc != false %} | ||
| {% include components/children_nav.html %} | ||
| {% endif %} | ||
| </main> | ||
|
|
||
| <!-- Include site footer --> | ||
| {% include components/footer.html %} | ||
| </div> | ||
| </div> | ||
|
|
||
| <!-- Include search footer if search is enabled --> | ||
| {% if site.search_enabled != false %} | ||
| {% include components/search_footer.html %} | ||
| {% endif %} | ||
| </div> | ||
|
|
||
| <!-- Include Mermaid diagrams if enabled --> | ||
| {% if site.mermaid %} | ||
| {% include components/mermaid.html %} | ||
| {% endif %} | ||
|
|
||
| <!-- Includes Button switch to change from one Programming Language to another (Must be Enabled Or won't be possible) --> | ||
| <!-- To Enable use " include_programming_language_switch_script: true " on .md pages --> | ||
| {% if page.include_programming_language_switch_script %} | ||
| <script src="{{ '/assets/js/programmingLanguageSwitch.js' | relative_url }}" defer></script> | ||
| {% endif %} | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // Set the language preference in localStorage and update the displayed content immediately | ||
| function setLanguagePreference(language, pagePath) { | ||
| // Set language preference in localStorage | ||
| localStorage.setItem('languagePreference_' + pagePath, language); | ||
| // Update the displayed content based on the selected language | ||
| showContent(language, pagePath); | ||
| } | ||
|
|
||
| // Get the language preference from localStorage | ||
| function getLanguagePreference(pagePath) { | ||
| return localStorage.getItem('languagePreference_' + pagePath); | ||
| } | ||
|
|
||
| // Show the content based on the selected language | ||
| function showContent(language, pagePath) { | ||
| // Map each language to its corresponding content element | ||
| var contentMap = { | ||
| 'cpp': 'cppContent', | ||
| 'csharp': 'csharpContent', | ||
| 'python': 'pythonContent' | ||
| }; | ||
|
|
||
| // Iterate over each language in the contentMap | ||
| Object.keys(contentMap).forEach(function (key) { | ||
| // Get the content element based on the language | ||
| var contentElement = document.getElementById(contentMap[key]); | ||
|
|
||
| // Check if the content element exists | ||
| if (contentElement) { | ||
| // Set the display property based on whether it's the selected language | ||
| contentElement.style.display = (language === key) ? 'block' : 'none'; | ||
| } | ||
| }); | ||
|
|
||
| // Log a message indicating the switch to the specified language | ||
| console.log(`Switching to ${language} content`); | ||
| } | ||
|
|
||
| // Perform actions after the DOM has fully loaded | ||
| document.addEventListener('DOMContentLoaded', function () { | ||
| // Get the current page path | ||
| var pagePath = window.location.pathname; | ||
| console.log('Page Path:', pagePath); | ||
|
|
||
| // Retrieve the saved language preference from localStorage | ||
| var savedLanguage = getLanguagePreference(pagePath); | ||
| console.log('Saved Language:', savedLanguage); | ||
|
|
||
| // If a language preference is saved, update the displayed content | ||
| if (savedLanguage) { | ||
| showContent(savedLanguage, pagePath); | ||
| } | ||
| }); | ||
|
|
||
| // Set the language preference and update the displayed content on button click | ||
| function setLanguageAndShowContent(language) { | ||
| // Get the current page path | ||
| var pagePath = window.location.pathname; | ||
| // Set the language preference in localStorage and update the displayed content | ||
| setLanguagePreference(language, pagePath); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.