Define webpage title via JS

This commit is contained in:
Matthew Grove
2018-11-21 17:36:05 +00:00
parent d276f2f2d4
commit 583a1d3f2a
7 changed files with 30 additions and 18 deletions

View File

@@ -14,14 +14,14 @@
<!-- add to homescreen for Safari on iOS --> <!-- add to homescreen for Safari on iOS -->
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="BBC School Report | Reading School"> <meta name="apple-mobile-web-app-title" content="BBC Young Reporter | Reading School">
<link rel="apple-touch-icon-precomposed" href="https://matthew-grove.ml/logo.png"> <link rel="apple-touch-icon-precomposed" href="https://matthew-grove.ml/logo.png">
<!-- tile icon & colour for Windows 8 --> <!-- tile icon & colour for Windows 8 -->
<meta name="msapplication-TileImage" content="https://matthew-grove.ml/logo.png"> <meta name="msapplication-TileImage" content="https://matthew-grove.ml/logo.png">
<meta name="msapplication-TileColor" content="#d84315"> <meta name="msapplication-TileColor" content="#d84315">
<title>Article Name | BBC School Report | Reading School</title> <title>BBC Young Reporter | Reading School</title>
<meta name="description" content="News articles written by Reading School students in year 8"> <meta name="description" content="News articles written by Reading School students in year 8">
<!-- import Roboto (font) --> <!-- import Roboto (font) -->
@@ -45,6 +45,11 @@
<script src="/assets/global.js"></script> <script src="/assets/global.js"></script>
<link href="/assets/global.css" rel="stylesheet"> <link href="/assets/global.css" rel="stylesheet">
<link href="/assets/article-page.css" rel="stylesheet"> <link href="/assets/article-page.css" rel="stylesheet">
<!-- define title so that webpage & top app bar titles can be instantiated via JS -->
<script>
window.page_title = "Article Name";
</script>
</head> </head>
<body> <body>
<!-- cookie notice is included via jQuery --> <!-- cookie notice is included via jQuery -->
@@ -70,7 +75,7 @@
<figcaption class="mdc-typography--caption-text">A brass statue of a child, in a garden</figcaption> <figcaption class="mdc-typography--caption-text">A brass statue of a child, in a garden</figcaption>
</figure> </figure>
<p> <p>
</p> </p>
</div> </div>
</main> </main>

View File

@@ -3,18 +3,18 @@ $(document).ready(function(){
$(".mdc-drawer").load("/page-inserts/navbar.html", function(){ $(".mdc-drawer").load("/page-inserts/navbar.html", function(){
// include top app bar // include top app bar
$(".mdc-top-app-bar").load("/page-inserts/top-app-bar.html", function(){ $(".mdc-top-app-bar").load("/page-inserts/top-app-bar.html", function(){
// initiate MDC drawer // initiate MDC drawer
const drawer = new mdc.drawer.MDCDrawer.attachTo(document.querySelector(".mdc-drawer")); const drawer = new mdc.drawer.MDCDrawer.attachTo(document.querySelector(".mdc-drawer"));
// initiate MDC top app bar // initiate MDC top app bar
const mdc_top_app_bar = new mdc.topAppBar.MDCTopAppBar.attachTo(document.querySelector('.mdc-top-app-bar')); const mdc_top_app_bar = new mdc.topAppBar.MDCTopAppBar.attachTo(document.querySelector('.mdc-top-app-bar'));
mdc_top_app_bar.listen("MDCTopAppBar:nav", () => { mdc_top_app_bar.listen("MDCTopAppBar:nav", () => {
drawer.open = !drawer.open; drawer.open = !drawer.open;
}); });
// initiate MDC items // initiate MDC items
mdc.autoInit(); mdc.autoInit();
@@ -29,7 +29,10 @@ $(document).ready(function(){
} }
// set top app bar title // set top app bar title
$(".mdc-top-app-bar__title").html(window.page_title); if (window.page_title != null) {
$(".mdc-top-app-bar__title").html(window.page_title + " | BBC Young Reporter | Reading School");
document.title= window.page_title + " | BBC Young Reporter | Reading School";
}
// give 'seleted' styling to correct item on navbar // give 'seleted' styling to correct item on navbar
$(drawer_item_link_query_selector + "']").addClass("mdc-list-item--activated"); $(drawer_item_link_query_selector + "']").addClass("mdc-list-item--activated");
@@ -43,7 +46,7 @@ $(document).ready(function(){
jQuery("time.timeago").timeago(); jQuery("time.timeago").timeago();
// include cookie notice // include cookie notice
if(Cookies.get("reading-school-bbc-school-report-cookies-accepted") != "true") { if(Cookies.get("reading-school-bbc-young-reporter-cookies-accepted") != "true") {
$("#cookies").load("/page-inserts/cookie-notice.html", function(){ $("#cookies").load("/page-inserts/cookie-notice.html", function(){
$("#cookies").show(); $("#cookies").show();
$("#cookies").animate({bottom: "0px"}, 1000); $("#cookies").animate({bottom: "0px"}, 1000);
@@ -53,7 +56,7 @@ $(document).ready(function(){
$("#cookies").animate({bottom: "-100px"}, 1000); $("#cookies").animate({bottom: "-100px"}, 1000);
setTimeout(function(){$("#cookies").hide()},1000); setTimeout(function(){$("#cookies").hide()},1000);
$(".source-code-link").animate({bottom: "15px"}, 1000); $(".source-code-link").animate({bottom: "15px"}, 1000);
Cookies.set("reading-school-bbc-school-report-cookies-accepted", "true", {expires: 30}); Cookies.set("reading-school-bbc-young-reporter-cookies-accepted", "true", {expires: 30});
}); });
}); });
} }

View File

@@ -14,14 +14,14 @@
<!-- add to homescreen for Safari on iOS --> <!-- add to homescreen for Safari on iOS -->
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="BBC School Report | Reading School"> <meta name="apple-mobile-web-app-title" content="BBC Young Reporter | Reading School">
<link rel="apple-touch-icon-precomposed" href="https://matthew-grove.ml/logo.png"> <link rel="apple-touch-icon-precomposed" href="https://matthew-grove.ml/logo.png">
<!-- tile icon & colour for Windows 8 --> <!-- tile icon & colour for Windows 8 -->
<meta name="msapplication-TileImage" content="https://matthew-grove.ml/logo.png"> <meta name="msapplication-TileImage" content="https://matthew-grove.ml/logo.png">
<meta name="msapplication-TileColor" content="#d84315"> <meta name="msapplication-TileColor" content="#d84315">
<title>Name | BBC School Report | Reading School</title> <title>BBC Young Reporter | Reading School</title>
<meta name="description" content="News articles written by Reading School students in year 8"> <meta name="description" content="News articles written by Reading School students in year 8">
<!-- import Roboto (font) --> <!-- import Roboto (font) -->
@@ -45,6 +45,11 @@
<script src="/assets/global.js"></script> <script src="/assets/global.js"></script>
<link href="/assets/global.css" rel="stylesheet"> <link href="/assets/global.css" rel="stylesheet">
<link href="/assets/mdc-card-list.css" rel="stylesheet"> <link href="/assets/mdc-card-list.css" rel="stylesheet">
<!-- define title so that webpage & top app bar titles can be instantiated via JS -->
<script>
window.page_title = "Name";
</script>
</head> </head>
<body> <body>
<!-- cookie notice is included via jQuery --> <!-- cookie notice is included via jQuery -->

View File

@@ -14,14 +14,14 @@
<!-- add to homescreen for Safari on iOS --> <!-- add to homescreen for Safari on iOS -->
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="BBC School Report | Reading School"> <meta name="apple-mobile-web-app-title" content="BBC Young Reporter | Reading School">
<link rel="apple-touch-icon-precomposed" href="https://matthew-grove.ml/logo.png"> <link rel="apple-touch-icon-precomposed" href="https://matthew-grove.ml/logo.png">
<!-- tile icon & colour for Windows 8 --> <!-- tile icon & colour for Windows 8 -->
<meta name="msapplication-TileImage" content="https://matthew-grove.ml/logo.png"> <meta name="msapplication-TileImage" content="https://matthew-grove.ml/logo.png">
<meta name="msapplication-TileColor" content="#d84315"> <meta name="msapplication-TileColor" content="#d84315">
<title>BBC School Report | Reading School</title> <title>BBC Young Reporter | Reading School</title>
<meta name="description" content="News articles written by Reading School students in year 8"> <meta name="description" content="News articles written by Reading School students in year 8">
<!-- import Roboto (font) --> <!-- import Roboto (font) -->

View File

@@ -1,7 +1,7 @@
<div class="mdc-top-app-bar__row"> <div class="mdc-top-app-bar__row">
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start"> <section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start">
<a href="javascript:void(0);" class="material-icons mdc-top-app-bar__navigation-icon">menu</a> <a href="javascript:void(0);" class="material-icons mdc-top-app-bar__navigation-icon">menu</a>
<span class="mdc-top-app-bar__title">BBC School Report | Reading School</span> <span class="mdc-top-app-bar__title">BBC Young Reporter | Reading School</span>
</section> </section>
<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-end" role="toolbar"> <section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-end" role="toolbar">
<img src="/images/logo-white.png" class="mdc-top-app-bar__action-item" aria-label="Reading School" alt="Reading School Logo" style="height:45px;width:35px;padding:0;"/> <img src="/images/logo-white.png" class="mdc-top-app-bar__action-item" aria-label="Reading School" alt="Reading School Logo" style="height:45px;width:35px;padding:0;"/>

View File

@@ -3,7 +3,7 @@
<head> <head>
<script src="/vle/bbcnews/assets/cookies.js"></script> <script src="/vle/bbcnews/assets/cookies.js"></script>
<script> <script>
Cookies.remove("reading-school-bbc-school-report-cookies-accepted"); Cookies.remove("reading-school-bbc-young-reporter-cookies-accepted");
</script> </script>
</head> </head>
<body> <body>

View File

@@ -1 +0,0 @@
window.page_title = "BBC School Report | Reading School"