From dc05cacefa7846d338c95b5581914f799cbe13ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Sun, 12 Jul 2020 11:13:39 +0200 Subject: [PATCH] Prettier code This also fixes two undeclared variables and the regex is only created once per word --- examples/index.js | 92 ++++++++++++++++------------- examples/webpack/example-builder.js | 2 +- 2 files changed, 51 insertions(+), 43 deletions(-) diff --git a/examples/index.js b/examples/index.js index 089815a608..eede9227a1 100644 --- a/examples/index.js +++ b/examples/index.js @@ -1,42 +1,45 @@ (function () { - var template, target; + 'use strict'; + /* global info, jugl */ + let template, target; function listExamples(examples) { - target.innerHTML = ""; - var node = template.process({ + target.innerHTML = ''; + template.process({ context: {examples: examples}, clone: true, - parent: target + parent: target, }); - document.getElementById("count").innerHTML = "(" + examples.length + ")"; + document.getElementById('count').innerHTML = '(' + examples.length + ')'; } - var timerId; + let timerId; function inputChange() { if (timerId) { window.clearTimeout(timerId); } - var text = this.value; - timerId = window.setTimeout(function() { + const text = this.value; + timerId = window.setTimeout(function () { filterList(text); }, 500); } function filterList(text) { - var examples; + let examples; if (text.length < 2) { examples = info.examples; } else { - var words = text.split(/\W+/); - var scores = {}; - for(var i=0; i