<commit_before>currentProject = require 'zooniverse-readymade/current-project'
$ = window.jQuery

classifyPage = currentProject.classifyPages[0]
{subjectViewer, decisionTree} = classifyPage

# NOTE: This is super super hacky.
# Doing this for real will require a better DecisionTree class.

badges = {}

$(decisionTree.el).one decisionTree.RESET, ->
  labels = $(decisionTree.el).find '.readymade-choice-label'
  for choice, i in decisionTree.currentTask.choices
    badges[choice.value] = $('<span class="count-badge" data-count="0">0</span>')
    badges[choice.value].insertAfter labels[i]

subjectViewer.el.on 'add-tool', ({originalEvent: detail: [ms, tool]}) ->
  count = parseFloat(badges[tool.value].html()) + 1
  badges[tool.value].html count
  badges[tool.value].attr 'data-count', count

subjectViewer.el.on 'remove-tool', ({originalEvent: detail: [ms, tool]}) ->
  count = parseFloat(badges[tool.value].html()) - 1
  badges[tool.value].html count
  badges[tool.value].attr 'data-count', count<commit_msg>Fix counts with new tasks<commit_after>currentProject = require 'zooniverse-readymade/current-project'
$ = window.jQuery

classifyPage = currentProject.classifyPages[0]
{subjectViewer, decisionTree} = classifyPage

# NOTE: This is super super hacky.
# Doing this for real will require a better DecisionTree class.

badges = {}

$(decisionTree.el).on decisionTree.LOAD_TASK, ({originalEvent: detail: {task}}) ->
  if task.type is 'drawing'
    labels = $(decisionTree.el).find '[data-task-type="drawing"] .readymade-choice-label'
    for choice, i in task.choices
      badges[choice.value] = $('<span class="count-badge" data-count="0">0</span>')
      badges[choice.value].insertAfter labels[i]

subjectViewer.el.on 'add-tool', ({originalEvent: detail: [ms, tool]}) ->
  count = parseFloat(badges[tool.value].html()) + 1
  badges[tool.value].html count
  badges[tool.value].attr 'data-count', count

subjectViewer.el.on 'remove-tool', ({originalEvent: detail: [ms, tool]}) ->
  count = parseFloat(badges[tool.value].html()) - 1
  badges[tool.value].html count
  badges[tool.value].attr 'data-count', count
{'fraction_non_alphanumeric': 0.1561320754716981, 'fraction_numerical': 0.0047169811320754715, 'mean_word_length': 5.008498583569405, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '873378', 'n_tokens_mistral': 708, 'n_tokens_neox': 693, 'n_words': 151}