Add emote search, sort toggle
This commit is contained in:
parent
d3e2433ee6
commit
8927613da7
6 changed files with 64 additions and 13 deletions
|
|
@ -114,7 +114,8 @@ var USEROPTS = {
|
|||
default_quality : getOrDefault("default_quality", ""),
|
||||
boop : getOrDefault("boop", "never"),
|
||||
secure_connection : getOrDefault("secure_connection", false),
|
||||
show_shadowchat : getOrDefault("show_shadowchat", false)
|
||||
show_shadowchat : getOrDefault("show_shadowchat", false),
|
||||
emotelist_sort : getOrDefault("emotelist_sort", true)
|
||||
};
|
||||
|
||||
/* Backwards compatibility check */
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ NewPaginator.prototype.loadButtons = function (page) {
|
|||
}
|
||||
|
||||
var numPages = Math.ceil(this.numItems / this.itemsPerPage);
|
||||
numPages = Math.max(numPages, 1);
|
||||
var numBtns = Math.min(this.btnBefore + this.btnAfter + 1, numPages);
|
||||
var start;
|
||||
if (page < this.btnBefore) {
|
||||
|
|
|
|||
21
www/js/ui.js
21
www/js/ui.js
|
|
@ -766,3 +766,24 @@ applyOpts();
|
|||
$("#emotelistbtn").click(function () {
|
||||
EMOTELIST.show();
|
||||
});
|
||||
|
||||
$("#emotelist-search").keyup(function () {
|
||||
var value = this.value.toLowerCase();
|
||||
if (value) {
|
||||
EMOTELIST.filter = function (emote) {
|
||||
return emote.name.toLowerCase().indexOf(value) >= 0;
|
||||
};
|
||||
} else {
|
||||
EMOTELIST.filter = null;
|
||||
}
|
||||
EMOTELIST.handleChange();
|
||||
EMOTELIST.loadPage(0);
|
||||
});
|
||||
|
||||
$("#emotelist-alphabetical").prop("checked", USEROPTS.emotelist_sort);
|
||||
$("#emotelist-alphabetical").change(function () {
|
||||
USEROPTS.emotelist_sort = this.checked;
|
||||
setOpt("emotelist_sort", USEROPTS.emotelist_sort);
|
||||
EMOTELIST.handleChange();
|
||||
EMOTELIST.loadPage(0);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2858,9 +2858,10 @@ function EmoteList() {
|
|||
this.page = 0;
|
||||
}
|
||||
|
||||
EmoteList.prototype.show = function () {
|
||||
if (this.emoteListChanged) {
|
||||
this.emotes = CHANNEL.emotes.slice().sort(function (a, b) {
|
||||
EmoteList.prototype.handleChange = function () {
|
||||
this.emotes = CHANNEL.emotes.slice();
|
||||
if (USEROPTS.emotelist_sort) {
|
||||
this.emotes.sort(function (a, b) {
|
||||
var x = a.name.toLowerCase();
|
||||
var y = b.name.toLowerCase();
|
||||
|
||||
|
|
@ -2872,13 +2873,24 @@ EmoteList.prototype.show = function () {
|
|||
return 0;
|
||||
}
|
||||
});
|
||||
this.paginator = new NewPaginator(this.emotes.length, this.itemsPerPage,
|
||||
this.loadPage.bind(this));
|
||||
var container = document.getElementById("emotelist-paginator-container");
|
||||
container.innerHTML = "";
|
||||
container.appendChild(this.paginator.elem);
|
||||
this.paginator.loadPage(this.page);
|
||||
this.emoteListChanged = false;
|
||||
}
|
||||
|
||||
if (this.filter) {
|
||||
this.emotes = this.emotes.filter(this.filter);
|
||||
}
|
||||
|
||||
this.paginator = new NewPaginator(this.emotes.length, this.itemsPerPage,
|
||||
this.loadPage.bind(this));
|
||||
var container = document.getElementById("emotelist-paginator-container");
|
||||
container.innerHTML = "";
|
||||
container.appendChild(this.paginator.elem);
|
||||
this.paginator.loadPage(this.page);
|
||||
this.emoteListChanged = false;
|
||||
};
|
||||
|
||||
EmoteList.prototype.show = function () {
|
||||
if (this.emoteListChanged) {
|
||||
this.handleChange();
|
||||
}
|
||||
|
||||
this.modal.modal();
|
||||
|
|
@ -2891,7 +2903,7 @@ EmoteList.prototype.loadPage = function (page) {
|
|||
var row;
|
||||
var start = page * this.itemsPerPage;
|
||||
if (start >= this.emotes.length) return;
|
||||
var end = Math.min(start + this.itemsPerPage, this.emotes.length - 1);
|
||||
var end = Math.min(start + this.itemsPerPage, this.emotes.length);
|
||||
var _this = this;
|
||||
|
||||
for (var i = start; i < end; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue