From b5e90f03dd656a934947455de702c27b9035e215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Mon, 13 Sep 2021 21:09:44 +0200 Subject: [PATCH] theme: ensure IE11 compatiblity #89 --- layouts/partials/footer.html | 2 +- static/js/relearn.js | 4 ++-- static/js/search.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 2070942bb3..4fe3947846 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -42,7 +42,7 @@ {{- $.Scratch.Set "mermaidInitialize" "{ \"startOnLoad\": true }" }} {{- end }} diff --git a/static/js/relearn.js b/static/js/relearn.js index 840a8ef5ff..cbf867d0df 100644 --- a/static/js/relearn.js +++ b/static/js/relearn.js @@ -104,7 +104,7 @@ function initMermaid() { $(element).parent().replaceWith('
' + content + '
'); }); - if (mermaid) { + if (typeof mermaid != 'undefined') { mermaid.mermaidAPI.initialize( Object.assign( {}, mermaid.mermaidAPI.getSiteConfig(), { startOnLoad: true } ) ); mermaid.contentLoaded(); $(".mermaid svg").svgPanZoom({}) @@ -538,7 +538,7 @@ jQuery(function() { jQuery.extend({ highlight: function(node, re, nodeName, className) { - if (node.nodeType === 3 && node.parentElement.namespaceURI == 'http://www.w3.org/1999/xhtml') { // text nodes + if (node.nodeType === 3 && node.parentElement && node.parentElement.namespaceURI == 'http://www.w3.org/1999/xhtml') { // text nodes var match = node.data.match(re); if (match) { var highlight = document.createElement(nodeName || 'span'); diff --git a/static/js/search.js b/static/js/search.js index 82c906ec43..8065cf1bfb 100644 --- a/static/js/search.js +++ b/static/js/search.js @@ -45,7 +45,7 @@ function initLunr() { function search(term) { // Find the item in our index corresponding to the lunr one to have more info // Remove Lunr special search characters: https://lunrjs.com/guides/searching.html - var searchTerm = lunr.tokenizer(term.replace(/[*:^~+-]/, ' ')).flatMap(token => searchPatterns(token.str)).join(' '); + var searchTerm = lunr.tokenizer(term.replace(/[*:^~+-]/, ' ')).reduce( function(a,token){return a.concat(searchPatterns(token.str))}, []).join(' '); return !searchTerm ? [] : lunrIndex.search(searchTerm).map(function(result) { return { index: result.ref, matches: Object.keys(result.matchData.metadata) } }); @@ -75,7 +75,7 @@ $(function() { var page = pagesIndex[item.index]; var numContextWords = 2; var contextPattern = '(?:\\S+ +){0,' + numContextWords + '}\\S*\\b(?:' + - item.matches.map(match => match.replace(/\W/g, '\\$&')).join('|') + + item.matches.map( function(match){return match.replace(/\W/g, '\\$&')} ).join('|') + ')\\b\\S*(?: +\\S+){0,' + numContextWords + '}'; var context = page.content.match(new RegExp(contextPattern, 'i')); var divcontext = document.createElement('div');