1/*! Created by: Udo Schmal | https://www.gocher.me/ */ 2(function() { 3 'use strict'; 4 function Pages(pageslist) { 5 var store = 'pages-' + window.location.pathname; 6 var self = pageslist; 7 var current = 0; 8 var pages = pageslist.children; 9 var maxlength = 5; 10 var previous, next, placeholderPrevious, placeholderNext; 11 var pagination = []; 12 var navi = document.createElement("ul"); 13 navi.className = "paginator"; 14 pageslist.parentNode.insertBefore(navi, pages.nextSibling); 15 function updateBefore() { 16 pagination[current].classList.remove("current"); 17 pages[current].classList.remove("current"); 18 } 19 function updateAfter() { 20 if (pages.length > 5) { 21 if (current == 0) { 22 previous.classList.add('hidden'); 23 previous.style.visibility = 'hidden'; 24 } else { 25 previous.classList.remove('hidden'); 26 previous.style.visibility = ''; 27 } 28 if (current < 4) { 29 placeholderPrevious.classList.add('none'); 30 placeholderPrevious.style.display = 'none'; 31 } else { 32 placeholderPrevious.classList.remove('none'); 33 placeholderPrevious.style.display = ''; 34 } 35 if (current < 2) { 36 for (var i=1; i < pages.length-1; i++) { 37 if (i > 4) { 38 pagination[i].classList.add('none'); 39 pagination[i].style.display = 'none'; 40 } else { 41 pagination[i].classList.remove('none'); 42 pagination[i].style.display = ''; 43 } 44 } 45 } else if (current > pages.length-3) { 46 for (var i=1; i < pages.length-1; i++) { 47 if (i < pages.length-5) { 48 pagination[i].classList.add('none'); 49 pagination[i].style.display = 'none'; 50 } else { 51 pagination[i].classList.remove('none'); 52 pagination[i].style.display = ''; 53 } 54 } 55 } else { 56 for (var i=1; i < pages.length-1; i++) { 57 if ((i < current-2) || (i > current+2)) { 58 pagination[i].classList.add('none'); 59 pagination[i].style.display = 'none'; 60 } else { 61 pagination[i].classList.remove('none'); 62 pagination[i].style.display = ''; 63 } 64 } 65 } 66 if (current > pages.length-5) { 67 placeholderNext.classList.add('none'); 68 placeholderNext.style.display = 'none'; 69 } else { 70 placeholderNext.classList.remove('none'); 71 placeholderNext.style.display = ''; 72 } 73 if (current == pages.length-1) { 74 next.classList.add('hidden'); 75 next.style.visibility = 'hidden'; 76 } else { 77 next.classList.remove('hidden'); 78 next.style.visibility = ''; 79 } 80 } 81 sessionStorage.setItem(store, current); 82 pagination[current].classList.add("current"); 83 pages[current].classList.add("current"); 84 document.body.scrollTop = 0; // For Safari 85 document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera 86 } 87 function btn(event) { 88 updateBefore(); 89 if (this.classList.contains('previous')) { 90 current = current > 0 ? current - 1 : 1; 91 } else { 92 current = current < pages.length-1 ? current + 1 : pages.length-1; 93 } 94 updateAfter(); 95 event.stopPropagation(); 96 } 97 function toggle(event) { 98 updateBefore(); 99 current = this.pageid; 100 updateAfter(); 101 event.stopPropagation(); 102 } 103 if (pages.length > 5) { 104 previous = document.createElement("li"); 105 previous.className = 'previous'; 106 previous.addEventListener('mousedown', btn); 107 navi.appendChild(previous); 108 } 109 var item; 110 for (var i=0; i<pages.length; i++) { 111 if (pages[i].classList.contains("current")) { 112 current = i; 113 }; 114 item = document.createElement("li"); 115 item.appendChild(document.createTextNode(i+1)); 116 item.pageid = i; 117 navi.appendChild(item); 118 item.addEventListener('mousedown', toggle); 119 pagination.push(item); 120 if (pages.length > 5) { 121 if (i==0) { 122 placeholderPrevious = document.createElement("li"); 123 placeholderPrevious.className = 'placeholder'; 124 placeholderPrevious.appendChild(document.createTextNode('...')); 125 navi.appendChild(placeholderPrevious); 126 } 127 if (i==pages.length-2) { 128 placeholderNext = document.createElement("li"); 129 placeholderNext.className = 'placeholder'; 130 placeholderNext.appendChild(document.createTextNode('...')); 131 navi.appendChild(placeholderNext); 132 } 133 } 134 } 135 if (pages.length > 5) { 136 next = document.createElement("li"); 137 next.className = 'next'; 138 next.addEventListener('mousedown', btn); 139 navi.appendChild(next); 140 } 141 if (sessionStorage.getItem(store)) { 142 current = sessionStorage.getItem(store); 143 } 144 updateAfter(); 145 } 146 var pagesList = document.querySelectorAll("ul[data-type='pages']"); 147 for (var i=0; i<pagesList.length; i++) { 148 new Pages(pagesList[i]); 149 } 150})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.