From 681fc155a7b55ad6226771ca4833b7824410287c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Sun, 12 Jul 2020 10:59:56 +0200 Subject: [PATCH] Move js code into separate file to benefit from code analysis --- examples/index.html | 122 +--------------------------- examples/index.js | 120 +++++++++++++++++++++++++++ examples/webpack/config.js | 1 + examples/webpack/example-builder.js | 2 +- 4 files changed, 123 insertions(+), 122 deletions(-) create mode 100644 examples/index.js diff --git a/examples/index.html b/examples/index.html index 46ad23293a..8714671b4b 100644 --- a/examples/index.html +++ b/examples/index.html @@ -70,128 +70,8 @@ } + - OpenLayers Examples diff --git a/examples/index.js b/examples/index.js new file mode 100644 index 0000000000..089815a608 --- /dev/null +++ b/examples/index.js @@ -0,0 +1,120 @@ +(function () { + var template, target; + + function listExamples(examples) { + target.innerHTML = ""; + var node = template.process({ + context: {examples: examples}, + clone: true, + parent: target + }); + document.getElementById("count").innerHTML = "(" + examples.length + ")"; + } + + var timerId; + function inputChange() { + if (timerId) { + window.clearTimeout(timerId); + } + var text = this.value; + timerId = window.setTimeout(function() { + filterList(text); + }, 500); + } + + function filterList(text) { + var examples; + if (text.length < 2) { + examples = info.examples; + } else { + var words = text.split(/\W+/); + var scores = {}; + for(var i=0; i