mirror of https://github.com/onweru/compose.git

weru
24.34.2020 3acca771bdd5ca1296808dc2c4f112ecbaa45fcf
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