<commit_before>import doSortParams from '../common/doSortParams';
import generateRecipeTable from './generateRecipeTable';
import getForage from '../ajax/getForage';
import numberSort from '../system/numberSort';
import {pCC} from '../support/layout';
import stringSort from '../system/stringSort';
import {
  gotRecipeBook,
  output,
  parseInventingStart,
  recipebook
} from './parseInventing';

function testSortType(evt) {
  var sortType = evt.target.getAttribute('sorttype');
  if (!sortType) {sortType = 'string';}
  sortType = sortType.toLowerCase();
  return sortType;
}

function sortRecipeBook(sortType) {
  if (sortType === 'number') {
    recipebook.recipe.sort(numberSort);
  } else {
    recipebook.recipe.sort(stringSort);
  }
}

function sortRecipeTable(evt) { // Legacy
  doSortParams(evt.target.getAttribute('sortKey'));
  var sortType = testSortType(evt);
  sortRecipeBook(sortType);
  generateRecipeTable(output, recipebook);
}

function rmEvtHdl(evt) {
  if (evt.target.id === 'rfsh') {
    parseInventingStart();
  }
  if (evt.target.id === 'sortName') {
    sortRecipeTable(evt);
  }
}

export default function injectRecipeManager(injector) { // jQuery.min
  var content = injector || pCC;
  getForage('fsh_recipeBook').done(gotRecipeBook.bind(null, content));
  content.addEventListener('click', rmEvtHdl);
}<commit_msg>test for jQuery in injectRecipeManager<commit_after>import doSortParams from '../common/doSortParams';
import generateRecipeTable from './generateRecipeTable';
import getForage from '../ajax/getForage';
import numberSort from '../system/numberSort';
import {pCC} from '../support/layout';
import stringSort from '../system/stringSort';
import {
  gotRecipeBook,
  output,
  parseInventingStart,
  recipebook
} from './parseInventing';

function testSortType(evt) {
  var sortType = evt.target.getAttribute('sorttype');
  if (!sortType) {sortType = 'string';}
  sortType = sortType.toLowerCase();
  return sortType;
}

function sortRecipeBook(sortType) {
  if (sortType === 'number') {
    recipebook.recipe.sort(numberSort);
  } else {
    recipebook.recipe.sort(stringSort);
  }
}

function sortRecipeTable(evt) { // Legacy
  doSortParams(evt.target.getAttribute('sortKey'));
  var sortType = testSortType(evt);
  sortRecipeBook(sortType);
  generateRecipeTable(output, recipebook);
}

function rmEvtHdl(evt) {
  if (evt.target.id === 'rfsh') {
    parseInventingStart();
  }
  if (evt.target.id === 'sortName') {
    sortRecipeTable(evt);
  }
}

export default function injectRecipeManager(injector) { // jQuery.min
  if (typeof $ !== 'function') {return;}
  var content = injector || pCC;
  getForage('fsh_recipeBook').done(gotRecipeBook.bind(null, content));
  content.addEventListener('click', rmEvtHdl);
}
{'fraction_non_alphanumeric': 0.14550072568940495, 'fraction_numerical': 0.0, 'mean_word_length': 4.954643628509719, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4209495', 'n_tokens_mistral': 891, 'n_tokens_neox': 919, 'n_words': 178}