diff --git a/app/js/conf.js b/app/js/conf.js index db74825..7dac997 100644 --- a/app/js/conf.js +++ b/app/js/conf.js @@ -1,2 +1,3 @@ export const artSize = 96; -export const ytPath = "_youtube"; \ No newline at end of file +export const ytPath = "_youtube"; +export const locale = "cs"; diff --git a/app/js/lib/search.js b/app/js/lib/search.js index 070e099..9bae8c6 100644 --- a/app/js/lib/search.js +++ b/app/js/lib/search.js @@ -1,11 +1,8 @@ import * as html from "./html.js"; +import * as conf from "../conf.js"; const OPEN = "open"; - -export function normalize(str) { - // FIXME diac/translit - return str.toLowerCase(); -} +const collator = new Intl.Collator(conf.locale, {usage:"search", sensitivity:"base"}); export default class Search extends EventTarget { constructor(parent) { @@ -33,9 +30,10 @@ export default class Search extends EventTarget { getNode() { return this._node; } match(str) { - let q = normalize(this._input.value.trim()); + let q = this._input.value.trim(); if (!q) { return true; } - return normalize(str).split(" ").some(str => str.indexOf(q) == 0); + let len = q.length; + return str.split(" ").some(str => collator.compare(q, str.substring(0, len)) == 0); } reset() {