From 3acca771bdd5ca1296808dc2c4f112ecbaa45fcf Mon Sep 17 00:00:00 2001
From: weru <onewesh@gmail.com>
Date: Tue, 24 Mar 2020 18:34:57 +0000
Subject: [PATCH] highlight inline code blocks
---
assets/js/index.js | 23 ++++++++++++++++++-----
1 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/assets/js/index.js b/assets/js/index.js
index 8f08356..9c8d8b5 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -97,6 +97,24 @@
return closest
}
+function hasClasses(el) {
+ if(isObj(el)) {
+ const classes = el.classList;
+ return classes.length
+ }
+}
+
+(function markInlineCodeTags(){
+ const codeBlocks = elems('code');
+ if(codeBlocks) {
+ codeBlocks.forEach(function(codeBlock){
+ if(!hasClasses(codeBlock)) {
+ codeBlock.children.length ? false : pushClass(codeBlock, 'noClass');
+ }
+ });
+ }
+})();
+
function activeHeading(position, listLinks) {
let active = 'active';
@@ -111,8 +129,6 @@
return parseInt(link.dataset.position) === position
})[0];
- console.log(linksToModify.new)
-
if (linksToModify.active != linksToModify.new) {
linksToModify.active ? deleteClass(linksToModify.active, active): false;
pushClass(linksToModify.new, active);
@@ -167,13 +183,11 @@
pageInternalLinks.forEach(function(link, index){
link.dataset.position = linkPositions[index]
});
- console.log(linkPositions);
window.addEventListener('scroll', function(e) {
// this.setTimeout(function(){
let position = window.scrollY;
let active = closestInt(position, linkPositions);
- console.log(active);
activeHeading(active, pageInternalLinks);
// }, 1500)
});
@@ -204,7 +218,6 @@
if (searchField) {
searchField.addEventListener('input', function() {
- console.log('typing')
let rawResults = idx.search(`${ this.value }`).slice(0,6);
let refs = rawResults.map(function(ref){
// return id and score in a single string
--
Gitblit v1.10.0