From ce260e0f5c221cdc8bb20daf1c1482086fc4bcb0 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Mon, 11 Jul 2016 23:55:07 -0700 Subject: [PATCH 1/2] Greatly improve performance of channel settings emote list The channel settings emote list is now paginated and leverages the same basic code as the emote browser, but with a different renderer. Fixes #594 and kills an ugly function. --- templates/channeloptions.pug | 12 ++- www/js/callbacks.js | 9 +-- www/js/util.js | 144 ++++++++++++++++++++++------------- 3 files changed, 107 insertions(+), 58 deletions(-) diff --git a/templates/channeloptions.pug b/templates/channeloptions.pug index 3527dd87..dfff94e1 100644 --- a/templates/channeloptions.pug +++ b/templates/channeloptions.pug @@ -179,12 +179,22 @@ mixin emotes .form-group .col-sm-8.col-sm-offset-4 button#cs-emotes-newsubmit.btn.btn-primary Create Emote - table.table.table-striped.table-condensed + form.form-inline + .form-group + input.emotelist-search.form-control(type="text", placeholder="Search") + .form-group + .checkbox + label + input.emotelist-alphabetical(type="checkbox") + | Sort alphabetically + .emotelist-paginator-container + table.emotelist-table.table.table-striped.table-condensed thead tr th Delete th Name th Image + tbody button#cs-emotes-export.btn.btn-default Export emote list button#cs-emotes-import.btn.btn-default Import emote list diff --git a/www/js/callbacks.js b/www/js/callbacks.js index ae309e85..581bbff5 100644 --- a/www/js/callbacks.js +++ b/www/js/callbacks.js @@ -968,10 +968,8 @@ Callbacks = { emoteList: function (data) { loadEmotes(data); - var tbl = $("#cs-emotes table"); - tbl.data("entries", data); - formatCSEmoteList(); EMOTELIST.handleChange(); + CSEMOTELIST.handleChange(); }, updateEmote: function (data) { @@ -981,15 +979,16 @@ Callbacks = { if (CHANNEL.emotes[i].name === data.name) { found = true; CHANNEL.emotes[i] = data; - formatCSEmoteList(); break; } } if (!found) { CHANNEL.emotes.push(data); - formatCSEmoteList(); } + + EMOTELIST.handleChange(); + CSEMOTELIST.handleChange(); }, removeEmote: function (data) { diff --git a/www/js/util.js b/www/js/util.js index d2564c40..71232181 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -2477,58 +2477,6 @@ function formatCSChatFilterList() { }); } -function formatCSEmoteList() { - var tbl = $("#cs-emotes table"); - tbl.find("tbody").remove(); - var entries = CHANNEL.emotes || []; - entries.forEach(function (f) { - var tr = $("").appendTo(tbl); - var del = $("