Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions _layouts/default.html
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>
61 changes: 61 additions & 0 deletions assets/js/programmingLanguageSwitch.js
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);
}
14 changes: 14 additions & 0 deletions docs/Concepts/Memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,27 @@ title: Memory
nav_order: 1
parent: Concepts
has_children: false
include_programming_language_switch_script: true
---

{{ page.title }}
======================

{% include under_construction.html %}

<div id="cppContent">
<!-- Your default C++ content goes here -->
This is C++ content for Object-Oriented Programming.
</div>

<div id="csharpContent" style="display:none;">
<!-- Your C# content goes here -->
This is C# content for Object-Oriented Programming.
</div>

<button onclick="setLanguageAndShowContent('cpp')">C++</button>
<button onclick="setLanguageAndShowContent('csharp')">C#</button>


<br>

Expand Down
19 changes: 17 additions & 2 deletions docs/Concepts/OOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,29 @@ title: OOP
nav_order: 1
parent: Concepts
has_children: false
include_programming_language_switch_script: true
---

{{ page.title }}
======================

{% include under_construction.html %}

<div id="cppContent">
<!-- Your default C++ content goes here -->
This is C++ content for Object-Oriented Programming.
</div>

<br>
<div id="csharpContent" style="display:none;">
<!-- Your C# content goes here -->
This is C# content for Object-Oriented Programming.
</div>

<br>
<div id="pythonContent" style="display:none;">
<!-- Your C# content goes here -->
This is python content for Object-Oriented Programming.
</div>

<button onclick="setLanguageAndShowContent('cpp')">C++</button>
<button onclick="setLanguageAndShowContent('csharp')">C#</button>
<button onclick="setLanguageAndShowContent('python')">Python</button>