From: Sam White Date: Fri, 10 Sep 2021 17:38:47 +0000 (+0000) Subject: Added initial basic version of website. X-Git-Url: https://git.dalvak.com/public/?a=commitdiff_plain;h=62769a42ea216d89dd5686db978a9461eb17c0d7;p=ycra.git Added initial basic version of website. --- 62769a42ea216d89dd5686db978a9461eb17c0d7 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..052fd12 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +public_html/includes/config.php +public_html/dev +public_html/error_log +public_html/*/error_log diff --git a/public_html/.htaccess b/public_html/.htaccess new file mode 100644 index 0000000..17c6ad5 --- /dev/null +++ b/public_html/.htaccess @@ -0,0 +1,19 @@ +# .htaccess Apache overrides file. + +# Rewrite rules. +RewriteEngine on + +# Temporary redirect to HTTPS +RewriteCond %{HTTPS} off +RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L] + +# QR code temporary redirects. +RewriteRule "^qr/sign-up$" "/index.html" [R,L] +RewriteRule "^qr/useful-links$" "/index.html" [R,L] + +# php -- BEGIN cPanel-generated handler, do not edit +# Set the “ea-php80” package as the default “PHP” programming language. + + AddHandler application/x-httpd-ea-php80 .php .php8 .phtml + +# php -- END cPanel-generated handler, do not edit diff --git a/public_html/css/bio.css b/public_html/css/bio.css new file mode 100644 index 0000000..cb4db65 --- /dev/null +++ b/public_html/css/bio.css @@ -0,0 +1,8 @@ +div.bio img { + float: left; + padding-right: 1em; +} +/* Keep sections separate when floating occurs. */ +.clear { + clear: both; +} diff --git a/public_html/css/common.css b/public_html/css/common.css new file mode 100644 index 0000000..7d1c652 --- /dev/null +++ b/public_html/css/common.css @@ -0,0 +1,91 @@ +/* + * Generic styling common to all website pages. + */ +@import url('https://rsms.me/inter/inter.css'); +html { font-family: 'Inter', sans-serif; } +@supports (font-variation-settings: normal) { + html { font-family: 'Inter var', sans-serif; } +} + +body { + margin: 0; + padding: 0; + min-height: 100vh; + + /* Fix footer at bottom on short pages. */ + display: flex; + flex-direction: column; +} + +/* Sections of page containing text. */ +div#page-content { + /* Centre text and pad from page top and sides. */ + margin: 0 auto; + padding: 1% 10%; +} + +/* Justify text in paragraphs. */ +div#page-content p { + text-align: justify; +} + +/* Appropriately pad page sections. */ +div.section { + padding: 1% 0; +} + +/* General styling for tables. */ +table { + /* Centre tables. */ + margin: 0 auto; + width: 100%; +} + +th,td{ + text-align: center; + padding: 0.5em; +} + +/* Styling for figures and captions.*/ +figure { + display: table; +} +figure figcaption { + display: table-caption; + caption-side: bottom; + text-align: justify; +} + +footer { + padding: 2em; + + background-color: #202020; + color: white; + + text-align: center; + font-size: 75%; + + /* Fix footer at bottom of short pages.*/ + margin-top: auto; +} + +footer a:link { + color: cyan; +} + +/* Conditional styling for small screen devices. */ +@media screen and (max-width: 800px){ + /* Reduce padding as screen is smaller. */ + div#page-content { + padding: 0.7% 4%; + } + + figure { + padding: 0; + margin: auto; + } + + th,td { + padding: 0.1em; + } +} diff --git a/public_html/css/fontello.css b/public_html/css/fontello.css new file mode 100644 index 0000000..9ebed4c --- /dev/null +++ b/public_html/css/fontello.css @@ -0,0 +1,58 @@ +@font-face { + font-family: 'fontello'; + src: url('../font/fontello.eot?34085483'); + src: url('../font/fontello.eot?34085483#iefix') format('embedded-opentype'), + url('../font/fontello.woff2?34085483') format('woff2'), + url('../font/fontello.woff?34085483') format('woff'), + url('../font/fontello.ttf?34085483') format('truetype'), + url('../font/fontello.svg?34085483#fontello') format('svg'); + font-weight: normal; + font-style: normal; +} +/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */ +/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */ +/* +@media screen and (-webkit-min-device-pixel-ratio:0) { + @font-face { + font-family: 'fontello'; + src: url('../font/fontello.svg?34085483#fontello') format('svg'); + } +} +*/ +[class^="icon-"], [class*=" icon-"] { + font-family: "fontello"; + font-style: normal; + font-weight: normal; + speak: never; + + display: inline-block; + text-decoration: inherit; + width: 1em; + /*margin-right: .2em;*/ + text-align: center; + /* opacity: .8; */ + + /* For safety - reset parent styles, that can break glyph codes*/ + font-variant: normal; + text-transform: none; + + /* fix buttons height, for twitter bootstrap */ + line-height: 1em; + + /* Animation center compensation - margins should be symmetric */ + /* remove if not needed */ + /*margin-left: .2em;*/ + + /* you can be more comfortable with increased icons size */ + /* font-size: 120%; */ + + /* Font smoothing. That was taken from TWBS */ + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + + /* Uncomment for 3D effect */ + /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */ +} + +/*.icon-menu:before { content: '\2630'; } *//* '☰' */ +/*.icon-cancel:before { content: '\2716'; } *//* '✖' */ diff --git a/public_html/css/navbar.css b/public_html/css/navbar.css new file mode 100644 index 0000000..37460a9 --- /dev/null +++ b/public_html/css/navbar.css @@ -0,0 +1,228 @@ +/* + * Styling for main page banner + */ + +nav { + /* Declare navbar colours. */ + --main-navbar-back: #42ADDB; + /*--main-navbar-back: #68246D;*/ + --sub-navbar-back: #3080A2; + /*--sub-navbar-back: #4B1B4E;*/ + --main-navbar-active: var(--sub-navbar-back); + /*--sub-navbar-active: #38133B;*/ + --sub-navbar-active: #00405C; + --navbar-links: white; + + /* Set height and padding of logo. + * + * If the sum of the combined height and vertical + * padding is greater than 1em + 2 * var(--link-vpadding) + * this will dictate the main navbar height. + * + * Make sure units are always specified (even when + * the variable height is zero). + * */ + --logo-height: 5em; + --logo-top-padding: 0.3em; + --logo-bottom-padding: 0.2em; + + /* Set vertical padding (both top and bottom) for links. + * + * If 1em + 2 * var(--link-vpadding) is greater than the + * sum of the height and vertical logo padding this will + * dictate the main navbar height. + */ + --link-vpadding: 1em; +} + +nav.navbar { + /* Give navbars a fixed position across page. */ + position:sticky; + margin: 0; + padding: 0; + + /* Draw over other objects. */ + z-index: 100; + + /* Use flexbox to position children (logo and ul). */ + display: flex; + + font-weight: bold; +} + +nav.navbar ul { + padding: 0; + margin: 0; + + /* Use flexbox to position children (navigation link li). */ + display: flex; + justify-content: space-between; + + list-style-type: none; +} + +nav.navbar li { + /* Stretch each link vertically to fill li element. */ + display: flex; +} + +nav.navbar li a { + /* Space links. */ + padding: var(--link-vpadding) 1em; + + /* Put link text at centre of link element. */ + display: flex; + align-items: center; + + /* Set line-height to font-size to allow sub-navbar position determination.*/ + line-height: 1.2em; + + text-decoration: none; + color: var(--navbar-links); + text-align: center; +} + +nav#mainnav { + /* Fix navbar position at top of page. */ + top: 0; + + /* Colouring. */ + background-color: var(--main-navbar-back); +} + + +/* Highlight links to current page and section. */ +nav#mainnav li a.nav-active { + background-color: var(--main-navbar-active); +} +nav#subnav li a.nav-active { + background-color: var(--sub-navbar-active); +} + + +nav#mainnav a.logo { + /* Align logo in centre of navbar link and adapt to logo height. */ + display: flex; + align-items: center; +} + +/* Size and positioning of logo. */ +nav#mainnav a.logo img{ + height: var(--logo-height); + /* Give logo some space to breathe. */ + padding: var(--logo-top-padding) 0.5em var(--logo-bottom-padding) 0.3em; +} + +nav#subnav { + /* Fix sub-navbar below main navbar. */ + top: max(calc(1em + 2 * var(--link-vpadding)), + calc(var(--logo-height) + + var(--logo-top-padding) + + var(--logo-bottom-padding) + ) + ); + + /* Colouring. */ + background-color: var(--sub-navbar-back); +} + +/* Inset sub-navbar links from edge of page.*/ +nav#subnav ul { + margin-left: 2%; +} + +/* Quotes styling. */ +nav div#quotes { + /* Vertically align quotes.*/ + display: flex; + flex-direction: column; + justify-content: center; + + /* Put quotes on right hand side of navigation bar. */ + margin-left: auto; + + /* Pad appropriately. */ + padding: 1% 2%; + + /* Prevent quotes from affecting navigation controls.*/ + max-width: 30%; + + /* Style text. */ + color: var(--navbar-links); + text-align: center; + font-weight: normal; + font-style: italic; +} + +/* Hide collapsible menu checkbox. */ +input#menutoggle { + display: none; +} + +/* Style collapsible menu icons. */ +label[for=menutoggle] { + /* Hide by default. */ + display:none; + + margin: 2% 10% 2% auto; + + /* Make mouse pointer behave like this is clickable link. */ + cursor: pointer; + + color: var(--navbar-links); +} + +/* Put collapse control on same line as logo. */ +nav.navbar div#topline { + display: flex; + flex-direction: row; + align-items: center; +} + +/* Conditional styling for small screen devices. */ +@media screen and (max-width: 990px){ + /* Align navbar elements vertically. */ + nav.navbar, nav.navbar * { + flex-direction: column; + } + + /* Hide subnavigation bar. */ + nav#subnav { + display: none; + } + + /* Allow quotes to take up all of screen width. */ + nav div#quotes { + max-width: 100%; + } + + /* Show collapsible navigation bar. */ + label[for=menutoggle] { + display: block; + font-size: calc(var(--logo-height)*0.5); + } + + /* Show burger icon and close icon at appropriate times. */ + label[for=menutoggle] span#menuclose{ + display:none; + } + input#menutoggle:checked + div#topline label[for=menutoggle] span#menubars{ + display: none; + } + input#menutoggle:checked + div#topline label[for=menutoggle] span#menuclose{ + display: block; + } + + /* Display and hide navigation links when appropriate. */ + nav#mainnav ul { + display: none; + } + input#menutoggle:checked ~ ul { + display: block; + } + + nav #quotes { + margin-left: auto; + margin-right: auto; + } +} diff --git a/public_html/font/fontello-7a886015/LICENSE.txt b/public_html/font/fontello-7a886015/LICENSE.txt new file mode 100644 index 0000000..8fa3da3 --- /dev/null +++ b/public_html/font/fontello-7a886015/LICENSE.txt @@ -0,0 +1,12 @@ +Font license info + + +## Font Awesome + + Copyright (C) 2016 by Dave Gandy + + Author: Dave Gandy + License: SIL () + Homepage: http://fortawesome.github.com/Font-Awesome/ + + diff --git a/public_html/font/fontello-7a886015/README.txt b/public_html/font/fontello-7a886015/README.txt new file mode 100644 index 0000000..d870892 --- /dev/null +++ b/public_html/font/fontello-7a886015/README.txt @@ -0,0 +1,75 @@ +This webfont is generated by https://fontello.com open source project. + + +================================================================================ +Please, note, that you should obey original font licenses, used to make this +webfont pack. Details available in LICENSE.txt file. + +- Usually, it's enough to publish content of LICENSE.txt file somewhere on your + site in "About" section. + +- If your project is open-source, usually, it will be ok to make LICENSE.txt + file publicly available in your repository. + +- Fonts, used in Fontello, don't require a clickable link on your site. + But any kind of additional authors crediting is welcome. +================================================================================ + + +Comments on archive content +--------------------------- + +- /font/* - fonts in different formats + +- /css/* - different kinds of css, for all situations. Should be ok with + twitter bootstrap. Also, you can skip style and assign icon classes + directly to text elements, if you don't mind about IE7. + +- demo.html - demo file, to show your webfont content + +- LICENSE.txt - license info about source fonts, used to build your one. + +- config.json - keeps your settings. You can import it back into fontello + anytime, to continue your work + + +Why so many CSS files ? +----------------------- + +Because we like to fit all your needs :) + +- basic file, .css - is usually enough, it contains @font-face + and character code definitions + +- *-ie7.css - if you need IE7 support, but still don't wish to put char codes + directly into html + +- *-codes.css and *-ie7-codes.css - if you like to use your own @font-face + rules, but still wish to benefit from css generation. That can be very + convenient for automated asset build systems. When you need to update font - + no need to manually edit files, just override old version with archive + content. See fontello source code for examples. + +- *-embedded.css - basic css file, but with embedded WOFF font, to avoid + CORS issues in Firefox and IE9+, when fonts are hosted on the separate domain. + We strongly recommend to resolve this issue by `Access-Control-Allow-Origin` + server headers. But if you ok with dirty hack - this file is for you. Note, + that data url moved to separate @font-face to avoid problems with + + + + + + + + + +
+

fontello font demo

+ +
+
+
+
+ icon-menu0x2630 +
+
+ icon-cancel0x2716 +
+
+ + + diff --git a/public_html/font/fontello-7a886015/font/fontello.eot b/public_html/font/fontello-7a886015/font/fontello.eot new file mode 100644 index 0000000..3048c87 Binary files /dev/null and b/public_html/font/fontello-7a886015/font/fontello.eot differ diff --git a/public_html/font/fontello-7a886015/font/fontello.svg b/public_html/font/fontello-7a886015/font/fontello.svg new file mode 100644 index 0000000..c45cb7e --- /dev/null +++ b/public_html/font/fontello-7a886015/font/fontello.svg @@ -0,0 +1,14 @@ + + + +Copyright (C) 2021 by original authors @ fontello.com + + + + + + + + + + diff --git a/public_html/font/fontello-7a886015/font/fontello.ttf b/public_html/font/fontello-7a886015/font/fontello.ttf new file mode 100644 index 0000000..07a8ca0 Binary files /dev/null and b/public_html/font/fontello-7a886015/font/fontello.ttf differ diff --git a/public_html/font/fontello-7a886015/font/fontello.woff b/public_html/font/fontello-7a886015/font/fontello.woff new file mode 100644 index 0000000..d46a600 Binary files /dev/null and b/public_html/font/fontello-7a886015/font/fontello.woff differ diff --git a/public_html/font/fontello-7a886015/font/fontello.woff2 b/public_html/font/fontello-7a886015/font/fontello.woff2 new file mode 100644 index 0000000..6119336 Binary files /dev/null and b/public_html/font/fontello-7a886015/font/fontello.woff2 differ diff --git a/public_html/font/fontello.eot b/public_html/font/fontello.eot new file mode 100644 index 0000000..3048c87 Binary files /dev/null and b/public_html/font/fontello.eot differ diff --git a/public_html/font/fontello.svg b/public_html/font/fontello.svg new file mode 100644 index 0000000..c45cb7e --- /dev/null +++ b/public_html/font/fontello.svg @@ -0,0 +1,14 @@ + + + +Copyright (C) 2021 by original authors @ fontello.com + + + + + + + + + + diff --git a/public_html/font/fontello.ttf b/public_html/font/fontello.ttf new file mode 100644 index 0000000..07a8ca0 Binary files /dev/null and b/public_html/font/fontello.ttf differ diff --git a/public_html/font/fontello.woff b/public_html/font/fontello.woff new file mode 100644 index 0000000..d46a600 Binary files /dev/null and b/public_html/font/fontello.woff differ diff --git a/public_html/font/fontello.woff2 b/public_html/font/fontello.woff2 new file mode 100644 index 0000000..6119336 Binary files /dev/null and b/public_html/font/fontello.woff2 differ diff --git a/public_html/font/fontello.zip b/public_html/font/fontello.zip new file mode 100644 index 0000000..09e0cc8 Binary files /dev/null and b/public_html/font/fontello.zip differ diff --git a/public_html/images/founding-members/charlie-linford.jpg b/public_html/images/founding-members/charlie-linford.jpg new file mode 100644 index 0000000..037deac Binary files /dev/null and b/public_html/images/founding-members/charlie-linford.jpg differ diff --git a/public_html/images/founding-members/elena-brake.jpg b/public_html/images/founding-members/elena-brake.jpg new file mode 100644 index 0000000..57ce08a Binary files /dev/null and b/public_html/images/founding-members/elena-brake.jpg differ diff --git a/public_html/images/founding-members/elisha-small.jpg b/public_html/images/founding-members/elisha-small.jpg new file mode 100644 index 0000000..66b34f7 Binary files /dev/null and b/public_html/images/founding-members/elisha-small.jpg differ diff --git a/public_html/images/founding-members/emily-hall.jpg b/public_html/images/founding-members/emily-hall.jpg new file mode 100644 index 0000000..adc5de6 Binary files /dev/null and b/public_html/images/founding-members/emily-hall.jpg differ diff --git a/public_html/images/founding-members/josephine-leggett.jpg b/public_html/images/founding-members/josephine-leggett.jpg new file mode 100644 index 0000000..6778dd1 Binary files /dev/null and b/public_html/images/founding-members/josephine-leggett.jpg differ diff --git a/public_html/images/founding-members/matthew-jerome.jpg b/public_html/images/founding-members/matthew-jerome.jpg new file mode 100644 index 0000000..8ced58c Binary files /dev/null and b/public_html/images/founding-members/matthew-jerome.jpg differ diff --git a/public_html/images/founding-members/sam-white.jpg b/public_html/images/founding-members/sam-white.jpg new file mode 100644 index 0000000..ac504b6 Binary files /dev/null and b/public_html/images/founding-members/sam-white.jpg differ diff --git a/public_html/images/logo/logo.png b/public_html/images/logo/logo.png new file mode 100644 index 0000000..f68fb11 Binary files /dev/null and b/public_html/images/logo/logo.png differ diff --git a/public_html/images/logo/text.png b/public_html/images/logo/text.png new file mode 100644 index 0000000..a895cd2 Binary files /dev/null and b/public_html/images/logo/text.png differ diff --git a/public_html/images/logo/y.png b/public_html/images/logo/y.png new file mode 100644 index 0000000..68304f8 Binary files /dev/null and b/public_html/images/logo/y.png differ diff --git a/public_html/includes/html-templating.php b/public_html/includes/html-templating.php new file mode 100644 index 0000000..aac4210 --- /dev/null +++ b/public_html/includes/html-templating.php @@ -0,0 +1,27 @@ + + "> + [ 'name' => 'Home', + 'path' => 'index.php' + ], + /* + 'about' => [ 'name' => 'About', + 'path' => '#' + ], + 'join' => [ 'name' => 'Join', + 'path' => '#' + ], + 'links' => [ 'name' => 'Useful Links', + 'path' => '#' + ], + 'register' => [ 'name' => 'Register', + 'path' => '#' + ], + 'login' => [ 'name' => 'Login', + 'path' => '#' + ]*/ + ]; +} + +function navbar() { + $pages = get_menu_pages();?> + + diff --git a/public_html/includes/template.php b/public_html/includes/template.php new file mode 100644 index 0000000..38ab376 --- /dev/null +++ b/public_html/includes/template.php @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + YCRA<?php + if (function_exists('page_title')) esc(' | ' . page_title());?> + + + +
+
+ + + diff --git a/public_html/includes/utils.php b/public_html/includes/utils.php new file mode 100644 index 0000000..ee5bb6c --- /dev/null +++ b/public_html/includes/utils.php @@ -0,0 +1,46 @@ + + + + Young Change Ringers Association + + +

Young Change Ringers Association

+

Coming soon...

+ + diff --git a/public_html/index.php b/public_html/index.php new file mode 100644 index 0000000..45bfa78 --- /dev/null +++ b/public_html/index.php @@ -0,0 +1,109 @@ + +
+

+ <?php esc($name);?> portrait /> + +
+
Why did you want to create the YCRA?' + . "

$why_create

"; + return bio($name, + 'founding-members/'.strtolower(str_replace(' ', '-', $name)).'.jpg', + $desc); +} + +function additional_stylesheets() { + stylesheet('bio'); +} + +function content() {?> +
+

Young Change Ringers Association

+ +

The Young Change Ringers Association (YCRA) is a non-territorial + association for anyone young enough to handle a bell, up to the age of 30. + We aim to be an Association for young ringers, by young ringers.

+ +

For more information about us check out our article on + page 2021/820 of + The Ringing World.

+ +

Alternatively, come and speak to us on the 11th of September at the + Ringing World National Youth + Contest in Worcester.

+ + +
+ +
+

Who are the founding members?

+ + ringing family, I was + really lucky to find a group of friends who supported me in ringing and + helped me navigate ringing etiquette. I wanted to help create a group that + would create a safe space for other young ringers to find friends + like I did."; + founding_member_bio('Josephine Leggett', $why_create); + + $why_create = "It's a great way to get more kids involved in the larger + ringing community so that everyone has the opportunities that some of us + take for granted."; + founding_member_bio('Charlie Linford', $why_create); + + $why_create = "To help other young ringers find a group of like-minded + people to help, support and encourage them while learning to ring. I was + fortunate enough to have this while ringing at university (and when I went + to ring elsewhere over the summer) and it is definitely one of the main + reasons I enjoy ringing so much."; + founding_member_bio('Sam White', $why_create);?> +
+ + diff --git a/public_html/js/scroll.js b/public_html/js/scroll.js new file mode 100644 index 0000000..3f9d9f7 --- /dev/null +++ b/public_html/js/scroll.js @@ -0,0 +1,36 @@ +/* + * Scroll to selected navigation link location. +*/ + +document.querySelectorAll('a[href^="#"]').forEach(anchor => { + // for every in-page link + anchor.addEventListener('click', function(e) { + // Stop the default behaviour. + e.preventDefault(); + + // Get body position relative to user's viewport. + var bodyPosition = document.body.getBoundingClientRect().top; + + // Handle requests to scroll to top of page. + if (this.getAttribute('href') == "#top") + elementPosition = bodyPosition; + else + { + // Get element to scroll to and position relative to viewport. + var element = document.querySelector(this.getAttribute('href')); + var elementPosition = element.getBoundingClientRect().top; + } + + // Get position to scroll to relative to top of page, compensating height + // of navbars. + var headerOffset = document.getElementById('mainnav').scrollHeight + + document.getElementById('subnav').scrollHeight; + var offsetPosition = elementPosition - bodyPosition - headerOffset; + + // Scroll. + window.scrollTo({ + top: offsetPosition, + behavior: "smooth" + }); + }); +}); diff --git a/public_html/js/scrollactivehighlight.js b/public_html/js/scrollactivehighlight.js new file mode 100644 index 0000000..fdd16db --- /dev/null +++ b/public_html/js/scrollactivehighlight.js @@ -0,0 +1,76 @@ +/* + * Sets navigation item to active if in view. +*/ + +/* Return the percentage of the elem given visible to the user. Accounts for + * header offset if provided. */ +function getPercentVisible(elem, headerOffset = 0) +{ + var elementHeight = elem.clientHeight; + + /* Find location of top and bottom of element bounding box relative to top + * of viewport accounting for header offset given. */ + var rect = elem.getBoundingClientRect(); + var elemTop = rect.top - headerOffset; + var elemBottom = rect.bottom - headerOffset; + + // Viewport height excluding headers. + var viewHeight = window.innerHeight - headerOffset; + + /* Determine pixels of element visible. */ + var amountVisble = 0; + // Element not in view. + if (elemBottom <= 0 || elemTop >= viewHeight) + amountVisible = 0; + // Top of element not in view. + else if (elemTop < 0 && elemBottom > 0) + amountVisible = elemBottom; + // Element fills entire view. + else if (elemTop < 0 && elemBottom > viewHeight) + amountVisible = viewHeight; + // Whole element in view. + else if (elemTop >= 0 && elemBottom <= viewHeight) + amountVisible = elementHeight; + // Bottom of element not in view. + else if (elemTop >= 0 && elemBottom > viewHeight) + amountVisible = viewHeight - elemTop; + + // Return the percentage of the element in view. + return amountVisible / elementHeight * 100; +} + + +// Get all sub-navbar elements. +var subnavbarElem = document.querySelectorAll("nav#subnav a"); + +// Get height of header. +var headerOffset = document.getElementById('mainnav').offsetHeight + + document.getElementById('subnav').offsetHeight; + +// Run whenever page is scrolled. +window.addEventListener('scroll', function (event) { + // Create 2D array. + vis = new Array(2); + vis[0] = new Array(subnavbarElem.length); + vis[1] = new Array(subnavbarElem.length); + + // For each subnavbar element. + for (var i = 0; i < subnavbarElem.length; i++) + { + // Remove any already set active classes. + subnavbarElem[i].classList.remove("active"); + + // Get the section element the navbar link refers to. + sectionId = subnavbarElem[i].getAttribute('href'); + section = document.querySelector(sectionId); + + // Store the navbar link element and the percentage of the section visible. + vis[0][i] = subnavbarElem[i]; + vis[1][i] = getPercentVisible(section, headerOffset); + } + + // Find index of element with greatest percentage visible and make this the active element. + let imax = vis[1].indexOf(Math.max(...vis[1])); + vis[0][imax].classList.add("active"); +}, false); +