diff options
author | Shipwreckt <Shipwreckt@mailfence.com> | 2024-05-12 16:28:43 +0100 |
---|---|---|
committer | Shipwreckt <Shipwreckt@mailfence.com> | 2024-05-12 16:28:43 +0100 |
commit | a65705b92b5fb688d2f8dc03bb97b745c2cfee27 (patch) | |
tree | 7bf0f815a23a97a4246d0301f48f770294c7dad1 /public/script.js | |
parent | f1f4e43eae2ba1110dec96643dc5c7ee917b6541 (diff) |
added the website files
Diffstat (limited to 'public/script.js')
-rw-r--r-- | public/script.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/public/script.js b/public/script.js new file mode 100644 index 0000000..008cc05 --- /dev/null +++ b/public/script.js @@ -0,0 +1,29 @@ +// Wait for the document to load before running the script +(function ($) { + + // We use some Javascript and the URL #fragment to hide/show different parts of the page + // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#Linking_to_an_element_on_the_same_page + $(window).on('load hashchange', function(){ + + // First hide all content regions, then show the content-region specified in the URL hash + // (or if no hash URL is found, default to first menu item) + $('.content-region').hide(); + + // Remove any active classes on the main-menu + $('.main-menu a').removeClass('active'); + var region = location.hash.toString() || $('.main-menu a:first').attr('href'); + + // Now show the region specified in the URL hash + $(region).show(); + + // Highlight the menu link associated with this region by adding the .active CSS class + $('.main-menu a[href="'+ region +'"]').addClass('active'); + + // Alternate method: Use AJAX to load the contents of an external file into a div based on URL fragment + // This will extract the region name from URL hash, and then load [region].html into the main #content div + // var region = location.hash.toString() || '#first'; + // $('#content').load(region.slice(1) + '.html') + + }); + +})(jQuery); |