diff --git a/client/js/lounge.js b/client/js/lounge.js index 80d59cdf..cbe2852b 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -5,7 +5,6 @@ require("jquery-ui/ui/widgets/sortable"); const $ = require("jquery"); const moment = require("moment"); const URI = require("urijs"); -const fuzzy = require("fuzzy"); // our libraries require("./libs/jquery/inputhistory"); @@ -585,34 +584,6 @@ $(function() { contextMenuActions.execute(contextAction, itemData); }); - chat.on("input", ".search", function() { - const value = $(this).val(); - const parent = $(this).closest(".users"); - const names = parent.find(".names-original"); - const container = parent.find(".names-filtered"); - - if (!value.length) { - container.hide(); - names.show(); - return; - } - - const fuzzyOptions = { - pre: "", - post: "", - extract: (el) => $(el).text(), - }; - - const result = fuzzy.filter( - value, - names.find(".user").toArray(), - fuzzyOptions - ); - - names.hide(); - container.html(templates.user_filtered({matches: result})).show(); - }); - if ($(document.body).hasClass("public") && (window.location.hash === "#connect" || window.location.hash === "")) { $("#connect").one("show", function() { const params = URI(document.location.search).search(true); diff --git a/client/js/userlist.js b/client/js/userlist.js new file mode 100644 index 00000000..bbd770d3 --- /dev/null +++ b/client/js/userlist.js @@ -0,0 +1,36 @@ +"use strict"; + +const $ = require("jquery"); +const fuzzy = require("fuzzy"); + +const templates = require("../views"); + +const chat = $("#chat"); + +chat.on("input", ".users .search", function() { + const value = $(this).val(); + const parent = $(this).closest(".users"); + const names = parent.find(".names-original"); + const container = parent.find(".names-filtered"); + + if (!value.length) { + container.hide(); + names.show(); + return; + } + + const fuzzyOptions = { + pre: "", + post: "", + extract: (el) => $(el).text(), + }; + + const result = fuzzy.filter( + value, + names.find(".user").toArray(), + fuzzyOptions + ); + + names.hide(); + container.html(templates.user_filtered({matches: result})).show(); +});