123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803 |
- (function ($) {
-
-
- function getNavBarHeight() {
- let $navbar = $('#navbar-main');
- let navbar_offset = $navbar.outerHeight();
- console.debug('Navbar height: ' + navbar_offset);
- return navbar_offset;
- }
-
- function scrollToAnchor(target) {
-
-
- target = (typeof target === 'undefined' || typeof target === 'object') ? decodeURIComponent(window.location.hash) : target;
-
- if ($(target).length) {
-
- target = '#' + $.escapeSelector(target.substring(1));
- let elementOffset = Math.ceil($(target).offset().top - getNavBarHeight());
- $('body').addClass('scrolling');
- $('html, body').animate({
- scrollTop: elementOffset
- }, 600, function () {
- $('body').removeClass('scrolling');
- });
- } else {
- console.debug('Cannot scroll to target `#' + target + '`. ID not found!');
- }
- }
-
- function fixScrollspy() {
- let $body = $('body');
- let data = $body.data('bs.scrollspy');
- if (data) {
- data._config.offset = getNavBarHeight();
- $body.data('bs.scrollspy', data);
- $body.scrollspy('refresh');
- }
- }
- function removeQueryParamsFromUrl() {
- if (window.history.replaceState) {
- let urlWithoutSearchParams = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.hash;
- window.history.replaceState({path: urlWithoutSearchParams}, '', urlWithoutSearchParams);
- }
- }
-
- window.addEventListener("hashchange", scrollToAnchor);
-
- $('#navbar-main li.nav-item a.nav-link, .js-scroll').on('click', function (event) {
-
- let hash = this.hash;
-
- if (this.pathname === window.location.pathname && hash && $(hash).length && ($(".js-widget-page").length > 0)) {
-
- event.preventDefault();
-
-
- let elementOffset = Math.ceil($(hash).offset().top - getNavBarHeight());
-
-
-
-
- $('html, body').animate({
- scrollTop: elementOffset
- }, 800);
- }
- });
-
- $(document).on('click', '.navbar-collapse.show', function (e) {
-
- let targetElement = $(e.target).is('a') ? $(e.target) : $(e.target).parent();
- if (targetElement.is('a') && targetElement.attr('class') != 'dropdown-toggle') {
- $(this).collapse('hide');
- }
- });
-
-
- let pubFilters = {};
-
- let searchRegex;
-
- let filterValues;
-
- let $grid_pubs = $('#container-publications');
-
- $grid_pubs.isotope({
- itemSelector: '.isotope-item',
- percentPosition: true,
- masonry: {
-
- columnWidth: '.grid-sizer'
- },
- filter: function () {
- let $this = $(this);
- let searchResults = searchRegex ? $this.text().match(searchRegex) : true;
- let filterResults = filterValues ? $this.is(filterValues) : true;
- return searchResults && filterResults;
- }
- });
-
- let $quickSearch = $('.filter-search').keyup(debounce(function () {
- searchRegex = new RegExp($quickSearch.val(), 'gi');
- $grid_pubs.isotope();
- }));
-
- function debounce(fn, threshold) {
- let timeout;
- threshold = threshold || 100;
- return function debounced() {
- clearTimeout(timeout);
- let args = arguments;
- let _this = this;
- function delayed() {
- fn.apply(_this, args);
- }
- timeout = setTimeout(delayed, threshold);
- };
- }
-
- function concatValues(obj) {
- let value = '';
- for (let prop in obj) {
- value += obj[prop];
- }
- return value;
- }
- $('.pub-filters').on('change', function () {
- let $this = $(this);
-
- let filterGroup = $this[0].getAttribute('data-filter-group');
-
- pubFilters[filterGroup] = this.value;
-
- filterValues = concatValues(pubFilters);
-
- $grid_pubs.isotope();
-
- if (filterGroup == "pubtype") {
-
- let url = $(this).val();
- if (url.substr(0, 9) == '.pubtype-') {
- window.location.hash = url.substr(9);
- } else {
- window.location.hash = '';
- }
- }
- });
-
- function filter_publications() {
- let urlHash = window.location.hash.replace('#', '');
- let filterValue = '*';
-
- if (urlHash != '' && !isNaN(urlHash)) {
- filterValue = '.pubtype-' + urlHash;
- }
-
- let filterGroup = 'pubtype';
- pubFilters[filterGroup] = filterValue;
- filterValues = concatValues(pubFilters);
-
- $grid_pubs.isotope();
-
- $('.pubtype-select').val(filterValue);
- }
-
- function initMap() {
- if ($('#map').length) {
- let map_provider = $('#map-provider').val();
- let lat = $('#map-lat').val();
- let lng = $('#map-lng').val();
- let zoom = parseInt($('#map-zoom').val());
- let address = $('#map-dir').val();
- let api_key = $('#map-api-key').val();
- if (map_provider == 1) {
- let map = new GMaps({
- div: '#map',
- lat: lat,
- lng: lng,
- zoom: zoom,
- zoomControl: true,
- zoomControlOpt: {
- style: 'SMALL',
- position: 'TOP_LEFT'
- },
- panControl: false,
- streetViewControl: false,
- mapTypeControl: false,
- overviewMapControl: false,
- scrollwheel: true,
- draggable: true
- });
- map.addMarker({
- lat: lat,
- lng: lng,
- click: function (e) {
- let url = 'https://www.google.com/maps/place/' + encodeURIComponent(address) + '/@' + lat + ',' + lng + '/';
- window.open(url, '_blank')
- },
- title: address
- })
- } else {
- let map = new L.map('map').setView([lat, lng], zoom);
- if (map_provider == 3 && api_key.length) {
- L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
- attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
- tileSize: 512,
- maxZoom: 18,
- zoomOffset: -1,
- id: 'mapbox/streets-v11',
- accessToken: api_key
- }).addTo(map);
- } else {
- L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
- maxZoom: 19,
- attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
- }).addTo(map);
- }
- let marker = L.marker([lat, lng]).addTo(map);
- let url = lat + ',' + lng + '#map=' + zoom + '/' + lat + '/' + lng + '&layers=N';
- marker.bindPopup(address + '<p><a href="https://www.openstreetmap.org/directions?engine=osrm_car&route=' + url + '">Routing via OpenStreetMap</a></p>');
- }
- }
- }
-
- function printLatestRelease(selector, repo) {
- $.getJSON('https://api.github.com/repos/' + repo + '/tags').done(function (json) {
- let release = json[0];
- $(selector).append(' ' + release.name);
- }).fail(function (jqxhr, textStatus, error) {
- let err = textStatus + ", " + error;
- console.log("Request Failed: " + err);
- });
- }
-
- function toggleSearchDialog() {
- if ($('body').hasClass('searching')) {
-
- $('[id=search-query]').blur();
- $('body').removeClass('searching compensate-for-scrollbar');
-
- removeQueryParamsFromUrl();
-
- $('#fancybox-style-noscroll').remove();
- } else {
-
- if (!$('#fancybox-style-noscroll').length && document.body.scrollHeight > window.innerHeight) {
- $('head').append(
- '<style id="fancybox-style-noscroll">.compensate-for-scrollbar{margin-right:' +
- (window.innerWidth - document.documentElement.clientWidth) +
- 'px;}</style>'
- );
- $('body').addClass('compensate-for-scrollbar');
- }
-
- $('body').addClass('searching');
- $('.search-results').css({opacity: 0, visibility: 'visible'}).animate({opacity: 1}, 200);
- $('#search-query').focus();
- }
- }
-
-
- function canChangeTheme() {
-
- return Boolean(window.wcDarkLightEnabled);
- }
- function getThemeMode() {
- return parseInt(localStorage.getItem('dark_mode') || 2);
- }
- function changeThemeModeClick(newMode) {
- console.info('Request to set theme.');
- if (!canChangeTheme()) {
- console.info('Cannot set theme - admin disabled theme selector.');
- return;
- }
- let isDarkTheme;
- switch (newMode) {
- case 0:
- localStorage.setItem('dark_mode', '1');
- isDarkTheme = true;
- console.info('User changed theme variation to Dark.');
- showActiveTheme(0);
- break;
- case 1:
- localStorage.setItem('dark_mode', '2');
- if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
-
- isDarkTheme = true;
- } else if (window.matchMedia('(prefers-color-scheme: light)').matches) {
-
- isDarkTheme = false;
- } else {
- isDarkTheme = isSiteThemeDark;
- }
- console.info('User changed theme variation to Auto.');
- showActiveTheme(1);
- break;
- default:
- localStorage.setItem('dark_mode', '0');
- isDarkTheme = false;
- console.info('User changed theme variation to Light.');
- showActiveTheme(2);
- break;
- }
- renderThemeVariation(isDarkTheme);
- }
- function showActiveTheme(mode){
- switch (mode) {
- case 0:
-
- $('.js-set-theme-light').removeClass('dropdown-item-active');
- $('.js-set-theme-dark').addClass('dropdown-item-active');
- $('.js-set-theme-auto').removeClass('dropdown-item-active');
- break;
- case 1:
-
- $('.js-set-theme-light').removeClass('dropdown-item-active');
- $('.js-set-theme-dark').removeClass('dropdown-item-active');
- $('.js-set-theme-auto').addClass('dropdown-item-active');
- break;
- default:
-
- $('.js-set-theme-light').addClass('dropdown-item-active');
- $('.js-set-theme-dark').removeClass('dropdown-item-active');
- $('.js-set-theme-auto').removeClass('dropdown-item-active');
- break;
- }
- }
- function getThemeVariation() {
- if (!canChangeTheme()) {
- return isSiteThemeDark;
- }
- let currentThemeMode = getThemeMode();
- let isDarkTheme;
- switch (currentThemeMode) {
- case 0:
- isDarkTheme = false;
- break;
- case 1:
- isDarkTheme = true;
- break;
- default:
- if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
-
- isDarkTheme = true;
- } else if (window.matchMedia('(prefers-color-scheme: light)').matches) {
-
- isDarkTheme = false;
- } else {
- isDarkTheme = isSiteThemeDark;
- }
- break;
- }
- return isDarkTheme;
- }
-
- function renderThemeVariation(isDarkTheme, init = false) {
-
- const codeHlEnabled = $('link[title=hl-light]').length > 0;
- const codeHlLight = $('link[title=hl-light]')[0];
- const codeHlDark = $('link[title=hl-dark]')[0];
- const diagramEnabled = $('script[title=mermaid]').length > 0;
-
- if (!init) {
-
-
- if ((isDarkTheme === false && !$('body').hasClass('dark')) || (isDarkTheme === true && $('body').hasClass('dark'))) {
- return;
- }
- }
- if (isDarkTheme === false) {
- if (!init) {
-
- $('body').css({opacity: 0, visibility: 'visible'}).animate({opacity: 1}, 500);
- }
- $('body').removeClass('dark');
- if (codeHlEnabled) {
- codeHlLight.disabled = false;
- codeHlDark.disabled = true;
- }
- if (diagramEnabled) {
- if (init) {
- mermaid.initialize({theme: 'default', securityLevel: 'loose'});
- } else {
-
- location.reload();
- }
- }
- } else if (isDarkTheme === true) {
- if (!init) {
-
- $('body').css({opacity: 0, visibility: 'visible'}).animate({opacity: 1}, 500);
- }
- $('body').addClass('dark');
- if (codeHlEnabled) {
- codeHlLight.disabled = true;
- codeHlDark.disabled = false;
- }
- if (diagramEnabled) {
- if (init) {
- mermaid.initialize({theme: 'dark', securityLevel: 'loose'});
- } else {
-
- location.reload();
- }
- }
- }
- }
- function initThemeVariation() {
-
- if (canChangeTheme) {
- let themeMode = getThemeMode();
- switch (themeMode) {
- case 0:
- showActiveTheme(2);
- console.info('Initialize theme variation to Light.');
- break;
- case 1:
- showActiveTheme(0);
- console.info('Initialize theme variation to Dark.');
- break;
- default:
- showActiveTheme(1);
- console.info('Initialize theme variation to Auto.');
- break;
- }
- }
-
- let isDarkTheme = getThemeVariation();
- renderThemeVariation(isDarkTheme, true);
- }
-
- function normalizeCarouselSlideHeights() {
- $('.carousel').each(function () {
-
- let items = $('.carousel-item', this);
-
- items.css('min-height', 0);
-
- let maxHeight = Math.max.apply(null, items.map(function () {
- return $(this).outerHeight()
- }).get());
- items.css('min-height', maxHeight + 'px');
- })
- }
-
-
- function fixHugoOutput() {
-
-
- $('#TableOfContents').addClass('nav flex-column');
- $('#TableOfContents li').addClass('nav-item');
- $('#TableOfContents li a').addClass('nav-link');
-
- $("input[type='checkbox'][disabled]").parents('ul').addClass('task-list');
- }
-
- function fixMermaid() {
- let mermaids = [];
- [].push.apply(mermaids, document.getElementsByClassName('language-mermaid'));
- for (let i = 0; i < mermaids.length; i++) {
- $(mermaids[i]).unwrap('pre');
- $(mermaids[i]).replaceWith(function () {
-
- return $("<div />").append($(this).contents()).addClass('mermaid');
- });
- }
- }
-
- $(document).ready(function () {
- fixHugoOutput();
- fixMermaid();
-
-
- if (code_highlighting) {
- hljs.initHighlighting();
- }
-
- initThemeVariation();
-
- $('.js-set-theme-light').click(function (e) {
- e.preventDefault();
- changeThemeModeClick(2);
- });
- $('.js-set-theme-dark').click(function (e) {
- e.preventDefault();
- changeThemeModeClick(0);
- });
- $('.js-set-theme-auto').click(function (e) {
- e.preventDefault();
- changeThemeModeClick(1);
- });
-
-
- const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
- darkModeMediaQuery.addListener((e) => {
- if (!canChangeTheme()) {
-
- return;
- }
- const darkModeOn = e.matches;
- console.log(`OS dark mode preference changed to ${darkModeOn ? '🌒 on' : '☀️ off'}.`);
- let currentThemeVariation = parseInt(localStorage.getItem('dark_mode') || 2);
- let isDarkTheme;
- if (currentThemeVariation === 2) {
- if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
-
- isDarkTheme = true;
- } else if (window.matchMedia('(prefers-color-scheme: light)').matches) {
-
- isDarkTheme = false;
- } else {
-
- isDarkTheme = isSiteThemeDark;
- }
- renderThemeVariation(isDarkTheme);
- }
- });
- });
-
- $(window).on('load', function () {
-
- $('.projects-container').each(function (index, container) {
- let $container = $(container);
- let $section = $container.closest('section');
- let layout;
- if ($section.find('.isotope').hasClass('js-layout-row')) {
- layout = 'fitRows';
- } else {
- layout = 'masonry';
- }
- $container.imagesLoaded(function () {
-
- $container.isotope({
- itemSelector: '.isotope-item',
- layoutMode: layout,
- masonry: {
- gutter: 20
- },
- filter: $section.find('.default-project-filter').text()
- });
-
- $section.find('.project-filters a').click(function () {
- let selector = $(this).attr('data-filter');
- $container.isotope({filter: selector});
- $(this).removeClass('active').addClass('active').siblings().removeClass('active all');
- return false;
- });
-
-
-
-
-
- if (window.location.hash) {
- scrollToAnchor();
- }
- });
- });
-
- if ($('.pub-filters-select')) {
- filter_publications();
-
-
- }
-
- $('.back-to-top').click(function (event) {
- event.preventDefault();
- $('html, body').animate({
- 'scrollTop': 0
- }, 800, function () {
- window.location.hash = "";
- });
- });
-
- $('.js-cite-modal').click(function (e) {
- e.preventDefault();
- let filename = $(this).attr('data-filename');
- let modal = $('#modal');
- modal.find('.modal-body code').load(filename, function (response, status, xhr) {
- if (status == 'error') {
- let msg = "Error: ";
- $('#modal-error').html(msg + xhr.status + " " + xhr.statusText);
- } else {
- $('.js-download-cite').attr('href', filename);
- }
- });
- modal.modal('show');
- });
-
- $('.js-copy-cite').click(function (e) {
- e.preventDefault();
-
- let range = document.createRange();
- let code_node = document.querySelector('#modal .modal-body');
- range.selectNode(code_node);
- window.getSelection().addRange(range);
- try {
-
- document.execCommand('copy');
- } catch (e) {
- console.log('Error: citation copy failed.');
- }
-
- window.getSelection().removeRange(range);
- });
-
- initMap();
-
- let githubReleaseSelector = '.js-github-release';
- if ($(githubReleaseSelector).length > 0)
- printLatestRelease(githubReleaseSelector, $(githubReleaseSelector).data('repo'));
-
- $('.js-search').click(function (e) {
- e.preventDefault();
- toggleSearchDialog();
- });
- $(document).on('keydown', function (e) {
- if (e.which == 27) {
-
- if ($('body').hasClass('searching')) {
- toggleSearchDialog();
- }
- } else if (e.which == 191 && e.shiftKey == false && !$('input,textarea').is(':focus')) {
-
- e.preventDefault();
- toggleSearchDialog();
- }
- });
-
- $('[data-toggle="tooltip"]').tooltip();
- });
-
- $(window).on('load resize orientationchange', normalizeCarouselSlideHeights);
-
- $('body').on('mouseenter mouseleave', '.dropdown', function (e) {
- var dropdown = $(e.target).closest('.dropdown');
- var menu = $('.dropdown-menu', dropdown);
- dropdown.addClass('show');
- menu.addClass('show');
- setTimeout(function () {
- dropdown[dropdown.is(':hover') ? 'addClass' : 'removeClass']('show');
- menu[dropdown.is(':hover') ? 'addClass' : 'removeClass']('show');
- }, 300);
-
- fixScrollspy();
- if (window.location.hash) {
-
- if (window.location.hash == "#top") {
- window.location.hash = ""
- } else if (!$('.projects-container').length) {
-
-
-
-
- scrollToAnchor();
- }
- }
-
- let resizeTimer;
- $(window).resize(function () {
- clearTimeout(resizeTimer);
- resizeTimer = setTimeout(fixScrollspy, 200);
- });
- });
- })(jQuery);
|