diff --git a/assets/global.js b/assets/global.js index 6d4f2dd..d1b34ee 100644 --- a/assets/global.js +++ b/assets/global.js @@ -4,23 +4,32 @@ $(document).ready(function(){ // initiate MDC drawer const drawer = new mdc.drawer.MDCDrawer.attachTo(document.querySelector('.mdc-drawer')); - // initiate MDC top app bar - const mdc_top_app_bar = new mdc.topAppBar.MDCTopAppBar.attachTo(document.querySelector('.mdc-top-app-bar')); - mdc_top_app_bar.setScrollTarget(document.getElementById('main-content')); - mdc_top_app_bar.listen('MDCTopAppBar:nav', () => { - drawer.open = !drawer.open; + // include top app bar + $(".mdc-top-app-bar").load("/page-inserts/top-app-bar.html", function(){ + // initiate MDC top app bar + const mdc_top_app_bar = new mdc.topAppBar.MDCTopAppBar.attachTo(document.querySelector('.mdc-top-app-bar')); + mdc_top_app_bar.setScrollTarget(document.getElementById('main-content')); + mdc_top_app_bar.listen('MDCTopAppBar:nav', () => { + drawer.open = !drawer.open; + }); + + // include source code link + $(".source-code-link").load("/page-inserts/source-code-link.html"); + + // initiate MDC items + mdc.autoInit(); + + // get current URL with no forward slash at the end and no domain + var drawer_item_link_query_selector = ".mdc-list-item[href='" + window.location.pathname; + if (drawer_item_link_query_selector.substring(drawer_item_link_query_selector.length - 1) == "/") { + drawer_item_link_query_selector = drawer_item_link_query_selector.substring(0,drawer_item_link_query_selector.length - 1); + } + + // give 'seleted' styling to correct item on navbar + $(drawer_item_link_query_selector + "']").addClass("mdc-list-item--activated"); + $(drawer_item_link_query_selector + "']").attr("aria-selected", "true"); + $(drawer_item_link_query_selector + "/']").addClass("mdc-list-item--activated"); + $(drawer_item_link_query_selector + "/']").attr("aria-selected", "true"); }); - - // include source code link - $(".source-code-link").load("/page-inserts/source-code-link.html"); - - // initiate MDC items - mdc.autoInit(); - - var drawer_item_link_query_selector = ".mdc-list-item[href='" + window.activated_drawer_item_link; - $(drawer_item_link_query_selector + "']").addClass("mdc-list-item--activated"); - $(drawer_item_link_query_selector + "']").attr("aria-selected", "true"); - $(drawer_item_link_query_selector + "/']").addClass("mdc-list-item--activated"); - $(drawer_item_link_query_selector + "/']").attr("aria-selected", "true"); }); }); diff --git a/luhn-algorithm/index.html b/luhn-algorithm/index.html index c115b5e..6eab0a3 100644 --- a/luhn-algorithm/index.html +++ b/luhn-algorithm/index.html @@ -48,14 +48,7 @@