@@ -1,7 +1,4 @@
1−//
2− // styling of input fields
3−//
4−
1+// styling of input fields
52var inputElements = document.querySelectorAll('input.tlon-input');
63for (var i = 0; i < inputElements.length; i++) {
74 //listen for changes in input
@@ -30,10 +27,7 @@ for (var i = 0; i < inputElements.length; i++) {
3027 });
3128}
3229
33−//
34− // toggling of navigation menus
35−//
36−
30+// toggling of navigation menus
3731var toggleMainNav = document.getElementById('js-main-nav-toggle');
3832if (toggleMainNav !== null) {
3933 toggleMainNav.onclick = function() {
@@ -48,20 +42,6 @@ if (toggleContentNav !== null) {
4842 }
4943}
5044
51−/*function initToggleMenu() {
52− var menu = document.querySelector(".menu");
53− var menuIcon = document.querySelector(".menu-icon");
54− var page = document.querySelector(".page");
55− menuIcon.addEventListener("click", function() {
56− menu.classList.toggle("menu-hidden");
57− page.classList.toggle("page-without-menu");
58− });
59−}*/
60−
61−//
62− // hotkeys
63−//
64−
6545function initHotKeys() {
6646
6747 var bodyEl = document.body;
@@ -98,10 +78,8 @@ function initHotKeys() {
9878 });
9979};
10080
101−//
102− // search functionality
103−//
10481
82+// search functionality
10583function debounce(func, wait) {
10684 var timeout;
10785
@@ -135,19 +113,10 @@ function makeTeaser(body, terms) {
135113 //var TEASER_MAX_WORDS = 17;
136114 var TEASER_MAX_CHARS = 63;
137115
138−
139116 var stemmedTerms = terms.map(function (w) {
140117 return elasticlunr.stemmer(w.toLowerCase());
141118 });
142119
143− console.log(stemmedTerms);
144− // create array with full word + partial Words (smallest fragment is 2 characters)
145− // first iteration is full word, then next is subset of the original word
146− /*var stemmedTerms = [];
147− for (var i = terms[0].length; i>=2; i--) {
148− stemmedTerms.push(terms[0].substring(0,i));
149− }
150− console.log(stemmedTerms);*/
151120 var termFound = false;
152121 var index = 0;
153122 var weighted = []; // contains elements of ["word", weight, index_in_document]
@@ -290,7 +259,7 @@ function initSearch() {
290259
291260 var options = {
292261 bool: "AND",
293− expand: true,
262+ expand: true, // turn on partial word search
294263 fields: {
295264 title: {boost: 2},
296265 body: {boost: 1},
@@ -342,8 +311,6 @@ function initSearch() {
342311 return;
343312 }
344313
345− // change query in order to make partial words work
346−
347314 var results = index.search(term, options).filter(function (r) {
348315 return r.doc.body !== "";
349316 });