Remove excessive word counts

Resolves:

  - Duplicate event listeners are registered during every word count,
    increasing the number of word counts until the browser becomes
    unresponsive.
  - The word count is triggered multiple times on input due to listening
    to redundant events.
This commit is contained in:
Andrew Kvalheim 2022-03-18 19:52:48 -07:00
parent ed8a2696bb
commit 9de2cba061

View file

@ -133,7 +133,7 @@ function get_color() {
function word_count(text, divId, maxcount) {
var area = document.getElementById(text.id)
Countable.live(area, function(counter) {
Countable.once(area, function(counter) {
$('#' + divId).text(counter.words);
if (counter.words > maxcount)
$('#' + divId).css('color', 'red');
@ -157,7 +157,7 @@ $( document ).ready(function() {
.trigger('change');
/* Count the proposal abstract length */
$("#event_abstract").bind('change keyup paste input', function() {
$("#event_abstract").on('input', function() {
var $selected = $("#event_event_type_id option:selected")
var max = $selected.data("max-words");
word_count(this, 'abstract-count', max);