autodoc.git / modref / site.js

version» Context lines:

autodoc.git/modref/site.js:7:   if (!window.console) {    window.console = { log: function(){}, error: function(){} };   }      /*    Encapsulate so we don't clutter the global scope   */   (function(window, document) {   'use strict';    + var doDebug = false; + var isdebug = document.location.search.indexOf('debug=1') > -1 || doDebug; + var wdebug = isdebug ? window.console.log : function(){}; +    // The scroll position at which the navbar sticks. This actually gets   // calculated dynamically upon page load.   var stickyScrollBreak = 70,    // Window width when we go to mobile mode    mobileBreakPoint = 800,    // The navbar to the left, HTMLElement    navbar, innerNavbar,    // Content wrapper, HTMLElement    content,    // The page footer
autodoc.git/modref/site.js:56:   }      // And if on the start page hide the Top link in the side navbar   function hideTopLink() {    var top = document.getElementsByClassName('top head');    top[0].style.display = 'none';   }      // Called when DOM is ready   function onPageLoad() { -  var versionElems, dateElems, i, tmp; +  var versionElems, dateElems, i, max;       maybeHideNavbox();    navbar = document.getElementsByClassName('navbar')[0];    content = document.getElementsByClassName('content')[0];    footer = document.getElementsByTagName('footer')[0];    footerHeight = footer.offsetHeight;    windowHeight = window.outerHeight;    headerHeight = document.getElementsByTagName('header')[0].offsetHeight;    navbarHeight = windowHeight - content.offsetTop - footerHeight;    innerNavbar = document.getElementById('navbar');    burger = document.getElementById('burger');       // When the doc is compiled with FLAG_NO_DYNAMIC the version and publish date -  // will not be written to the pages but inserted with JS. If the VERSION -  // symbol exists we need to put the version and pubdate in the elements with +  // will not be written to the pages but inserted with JS. If the NO_DYNAMIC +  // symbol is true we need to put the version and pubdate in the elements with    // attributes data-id="version" and data-id="date". -  if (PikeDoc.VERSION) { +  if (PikeDoc.NO_DYNAMIC) {    versionElems = document.querySelectorAll('[data-id="version"]');    dateElems = document.querySelectorAll('[data-id="date"]'); -  +  max = Math.max(versionElems.length, dateElems.length);    -  for (i = 0; i < versionElems.length; i++) { +  for (i = 0; i < max; i++) { +  if (versionElems[i] !== undefined) {    versionElems[i].innerHTML = PikeDoc.VERSION;    } -  -  for (i = 0; i < dateElems.length; i++) { +  if (dateElems[i] !== undefined) {    dateElems[i].innerHTML = PikeDoc.PUBDATE;    }    } -  else { -  tmp = document.querySelector('[data-id="version"]'); -  PikeDoc.VERSION = tmp.textContent; -  tmp = document.querySelector('[data-id="date"]'); -  PikeDoc.PUBDATE = tmp.textContent; +     }       stickyScrollBreak = headerHeight;   }      var iAmSticky;   // Invoked when DOM is ready, and use as callback for onscroll.   function onPageScroll() {    // If scrollY is larger than the sticky position ...    if (window.scrollY > stickyScrollBreak) {
autodoc.git/modref/site.js:210:    // The cache seems buggy as hell when the pages are view directly from    // the file system.    var cache = document.location.hostname && window.sessionStorage;    var m, isChecked = false;       function init() {    if (m || PikeDoc.current.link === 'index.html') {    return true;    }    -  if (!cache) { +  if (!cache || (isChecked && !m)) {    return false;    }    -  if (isChecked && !m) { -  return false; -  } -  +     m = cache.getItem(PikeDoc.current.link);    isChecked = true;       if (m) {    m = JSON.parse(m);    var ok = validateDate(m.time);    if (!ok) {    isChecked = false;    cache.removeItem(PikeDoc.current.link);    } -  +     return ok;    } -  return false; +     -  +  return false;    }       function validateDate(time) { -  var t = PikeDoc.PUBDATE; -  // window.console.log('PUBDATE: ', t); -  if (!t) { -  t = new Date(); -  // Cache for one day -  t.setTime(Date.now() - (3600*1000)*24); -  return t < new Date(time); -  } -  +     return getPubDate() < new Date(time);    }       function getPubDate() { -  if (PikeDoc.PUBDATE) { -  return new Date(Date.parse(PikeDoc.PUBDATE)); +  return new Date(PikeDoc.GENERATED*1000);    } -  return new Date(); -  } +        function store() {    if (cache) {    var obj = {    time: Date.now(),    value: innerNavbar.innerHTML    };       cache.setItem(PikeDoc.current.link||'root', JSON.stringify(obj));    }
autodoc.git/modref/site.js:457:       isAllLoaded = true;    maybeRenderNavbar();    }    }       var jsMap = {};    var scriptQueue = 0;       function loadScript(link, namespace, inherits) { -  //window.console.log('load: ', link); +  wdebug('load: ', link);    if (cacheFactory.hasCache()) {    return;    }       link = helpers.adjustLink(link);       // Already loaded    if (jsMap[link]) { -  //window.console.log('Already loaded: ', link); +  wdebug('Already loaded: ', link);    return;    }    -  // window.console.log('+++ Load:', link); +  wdebug('+++ Load:', link);       jsMap[link] = true;       if (inherits) {    addInherit(inherits);    }       scriptQueue += 1;       var s = createElem('script', { src: link });
autodoc.git/modref/site.js:557:    }       /* Render the left navigation bar. */    function navbar() {    var s = createElem('div', { class: 'sidebar init' });    // If the cache already has set the menu, then clear it. The cache is    // almost certainly run before this method.    var old = innerNavbar.querySelectorAll('.sidebar');    var i, tmp;    if (old.length) { -  // window.console.log('Clear cached menu and regenerate', old); +  wdebug('Clear cached menu and regenerate', old);    for (i = 0; i < old.length; i++) {    tmp = old[i];    tmp.parentNode.removeChild(tmp);    }    }       innerNavbar.appendChild(s);       lowNavbar(s, 'Modules', types.module, '');    lowNavbar(s, 'Classes', types.class, '');
autodoc.git/modref/site.js:580:    lowNavbar(s, 'Methods', types.method, '()');    lowNavbar(s, 'Operators', types.operator, '()');    lowNavbar(s, 'Members', types.member, '()');    lowNavbar(s, 'Namespaces', types.namespace, '::');    lowNavbar(s, 'Appendices', types.appendix, '');       cacheFactory.store();    }       function maybeRenderNavbar() { -  //window.console.log('maybeRenderNavbar(', isAllLoaded, isDomReady, scriptQueue, ')'); +  wdebug('maybeRenderNavbar(', isAllLoaded, isDomReady, scriptQueue, ')');    if (isAllLoaded && isDomReady && scriptQueue === 0) {    navbar();    requestAnimationFrame(function() {    innerNavbar.querySelector('.sidebar').classList.remove('init');    });    }    }       (function() {    // If the refdoc lives in pike.lysator.liu.se we add some custom Google
autodoc.git/modref/site.js:638:    }    }());       return {    registerSymbol: registerSymbol,    endInherit: endInherit,    loadScript: loadScript,    domReady: domReady,    isInline: isInline,    current: current, -  finish: finish, +  finish: finish    }; -  +    }());    -  + // This is explicitly set to false in the HTML page if the docs are generated + // with inlined Pike version and timestamp. + PikeDoc.FLAG_NO_DYNAMIC = true; +    }(window, document));