Move the user list client code to its own file
This commit is contained in:
parent
fd4492ab41
commit
25517f3ad7
@ -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: "<b>",
|
||||
post: "</b>",
|
||||
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);
|
||||
|
36
client/js/userlist.js
Normal file
36
client/js/userlist.js
Normal file
@ -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: "<b>",
|
||||
post: "</b>",
|
||||
extract: (el) => $(el).text(),
|
||||
};
|
||||
|
||||
const result = fuzzy.filter(
|
||||
value,
|
||||
names.find(".user").toArray(),
|
||||
fuzzyOptions
|
||||
);
|
||||
|
||||
names.hide();
|
||||
container.html(templates.user_filtered({matches: result})).show();
|
||||
});
|
Loading…
Reference in New Issue
Block a user