AMR/docs/extra.js

126 lines
6.9 KiB
JavaScript
Raw Normal View History

2019-01-02 23:24:07 +01:00
/*
# ==================================================================== #
# TITLE #
# Antimicrobial Resistance (AMR) Data Analysis for R #
2019-01-02 23:24:07 +01:00
# #
# SOURCE #
2020-07-08 14:48:06 +02:00
# https://github.com/msberends/AMR #
2019-01-02 23:24:07 +01:00
# #
# LICENCE #
2021-12-23 18:56:28 +01:00
# (c) 2018-2022 Berends MS, Luz CF et al. #
2020-10-08 11:16:03 +02:00
# Developed at the University of Groningen, the Netherlands, in #
# collaboration with non-profit organisations Certe Medical #
# Diagnostics & Advice, and University Medical Center Groningen. #
2019-01-02 23:24:07 +01:00
# #
# This R package is free software; you can freely use and distribute #
# it for both personal and commercial purposes under the terms of the #
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
# the Free Software Foundation. #
# We created this package for both routine data analysis and academic #
# research and it was publicly released in the hope that it will be #
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
2020-10-08 11:16:03 +02:00
# #
# Visit our website for the full manual and a complete tutorial about #
# how to conduct AMR data analysis: https://msberends.github.io/AMR/ #
2019-01-02 23:24:07 +01:00
# ==================================================================== #
*/
2019-06-02 19:50:22 +02:00
// Add updated Font Awesome 5.8.2 library
$('head').append('<!-- Updated Font Awesome library --><link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">');
2018-12-30 10:27:28 +01:00
$(document).ready(function() {
2019-01-21 15:53:01 +01:00
2019-06-02 19:50:22 +02:00
// remove version label from header
$(".version.label").remove();
2020-07-09 14:12:11 +02:00
// redirect GitLab to GitHub
2019-01-21 15:53:01 +01:00
var url_old = window.location.href;
2020-07-08 17:48:57 +02:00
var url_new = url_old.replace("gitlab", "github");
2019-01-21 15:53:01 +01:00
if (url_old != url_new) {
2019-01-21 21:24:40 +01:00
window.location.replace(url_new);
2019-01-21 15:53:01 +01:00
}
// Edit title of manual
$('.template-reference-index h1').text('Manual');
2019-01-21 15:53:01 +01:00
2021-04-29 17:16:30 +02:00
// replace 'Value' in manual with 'Returned value'
2019-07-09 11:22:46 +02:00
$(".template-reference-topic h2#value").text("Returned value");
2021-04-29 17:16:30 +02:00
// replace \donttest and \dontrun texts in Examples
if ($(".ref-examples pre").length > 0) {
$(".ref-examples pre").html($(".ref-examples pre").html().replaceAll("# \\donttest{", ""));
$(".ref-examples pre").html($(".ref-examples pre").html().replaceAll("# \\dontrun{", ""));
$(".ref-examples pre").html($(".ref-examples pre").html().replaceAll("# }", ""));
}
2021-05-03 10:47:32 +02:00
// remove leading newline in code examples on changelog
2021-05-05 15:47:39 +02:00
if ($("body .template-news").length > 0) {
$("body .template-news").html($("body .template-news").html().replaceAll('sourceCode R">\n<span', 'sourceCode R"><span'));
}
// change H1 header on dev version on changelog, since pkgdown uses the version number from the installed version
// (rather then using the DESCRIPTION file)
$("h1[id^=unreleased]").text("Current development version");
2021-05-03 10:47:32 +02:00
2019-06-02 19:50:22 +02:00
// PR for 'R for Data Science' on How To pages
2019-02-11 10:27:10 +01:00
if ($(".template-article").length > 0) {
2021-04-29 17:16:30 +02:00
$('#pkgdown-sidebar').prepend(
2019-05-17 13:01:17 +02:00
'<div id="r4ds">' +
2021-04-29 17:16:30 +02:00
' <div class="txt">' +
' <p>' +
' Learn R reading this great book: <i>R for Data Science</i>.' +
' <br><br>' +
' <a target="_blank" href="https://r4ds.had.co.nz/">' +
' Click to read it online - it was published for free.' +
' </a>' +
' </p>' +
' </div>' +
' <div class="img">' +
' <a target="_blank" href="https://r4ds.had.co.nz/">' +
' <img src="https://github.com/msberends/AMR/raw/main/docs/cover_r4ds.png">' +
2021-04-29 17:16:30 +02:00
' </a>' +
' </div>' +
2019-05-17 13:01:17 +02:00
'</div>');
2019-02-11 10:27:10 +01:00
}
2019-02-09 22:16:24 +01:00
2019-06-02 19:50:22 +02:00
// edit footer
2019-01-22 19:55:11 +01:00
$('footer').html(
'<div>' +
2021-12-06 11:12:30 +01:00
'<p><code>AMR</code> (for R). Developed at the <a target="_blank" href="https://www.rug.nl">University of Groningen</a> in collaboration with non-profit organisations<br><a target="_blank" href="https://www.certe.nl">Certe Medical Diagnostics and Advice Foundation</a> and <a target="_blank" href="https://www.umcg.nl">University Medical Center Groningen</a>.</p>' +
'<a target="_blank" href="https://www.rug.nl"><img src="https://github.com/msberends/AMR/raw/main/docs/logo_rug.png" class="footer_logo"></a>' +
2019-01-22 19:55:11 +01:00
'</div>');
2019-01-02 23:24:07 +01:00
2019-02-14 15:18:17 +01:00
// doctoral titles of authors
function doct_tit(x) {
if (typeof(x) != "undefined") {
2019-08-30 14:50:56 +02:00
// authors
x = x.replace(/Author, maintainer/g, "Maintainer");
x = x.replace(/Author, contributor/g, "Maintainer");
2019-08-30 14:50:56 +02:00
x = x.replace(/Author, thesis advisor/g, "Doctoral advisor");
x = x.replace(/Thesis advisor/g, "Doctoral advisor");
2021-12-09 10:48:25 +01:00
x = x.replace("Matthijs", "Dr Matthijs");
x = x.replace("Christian", "Dr Christian");
x = x.replace("Alex", "Prof. Alex");
x = x.replace("Bhanu", "Prof. Bhanu");
x = x.replace("Casper", "Prof. Casper");
2021-12-09 10:48:25 +01:00
x = x.replace("Corinna", "Dr Corinna");
2019-08-30 14:50:56 +02:00
// others
2021-12-09 10:48:25 +01:00
x = x.replace("Bart", "Dr Bart");
x = x.replace("Sofia", "Dr Sofia");
x = x.replace("Dennis", "Dr Dennis");
x = x.replace("Judith", "Dr Judith");
x = x.replace("Gwen", "Dr Gwen");
x = x.replace("Anthony", "Dr Anthony");
x = x.replace("Rogier", "Dr Rogier");
2019-02-14 15:18:17 +01:00
}
return(x);
}
$(".template-authors").html(doct_tit($(".template-authors").html()));
2019-12-27 11:56:54 +01:00
$(".template-citation-authors").html(doct_tit($(".template-citation-authors").html()));
$('.template-citation-authors h1').eq(0).html("All contributors of the <code>AMR</code> package");
$('.template-citation-authors h1').eq(1).html("How to cite the <code>AMR</code> package");
2019-02-14 15:18:17 +01:00
$(".developers").html(doct_tit($(".developers").html()));
$(".developers a[href='authors.html']").text("All contributors...");
2018-12-30 10:27:28 +01:00
});
2020-07-09 14:12:11 +02:00
$('head').append("<!-- Global site tag (gtag.js) - Google Analytics --> <script async src=\"https://www.googletagmanager.com/gtag/js?id=UA-172114740-1\"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-172114740-1'); </script><!-- Matomo --><script type='text/javascript'> var _paq = _paq || []; /* tracker methods like 'setCustomDimension' should be called before 'trackPageView' */ _paq.push(['setDomains', ['*.msberends.github.io/AMR']]); _paq.push(['enableCrossDomainLinking']); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u='https://analyse.uscloud.nl/'; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', '3']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); })();</script><!-- End Matomo Code -->");