<commit_before>/* -*- js2-basic-offset: 2; indent-tabs-mode: nil; -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80; */
"use strict";

// Broken AMDs
require("../../shims/can.view.mustache");

let {addMethod} = require("genfun"),
    {clone, init} = require("../../lib/proto"),
    can = require("../../shims/can"),
    insertCss = require("insert-css"),
    viewCss = require("./chat.styl"),
    {addLine} = require("../../models/chatlog"),
    {EventListener, listen} = require("../../lib/eventListener"),
    fs = require("fs"),
    chatTemplateText = fs.readFileSync(__dirname + "/chat.mustache");

/**
 * Chat Controller
 *
 */
let Chat = clone(),
    chatTemplate = can.view.mustache(chatTemplateText),
    events = { "form submit": sendMessage },
    listener = clone(EventListener, events),
    cssInserted = false;

/*
 * Init
 */
addMethod(init, [Chat], function(chat, el, chatlog) {
  chat.el = el;
  chat.log = chatlog;
  initDom(chat);
  if (!cssInserted) {
    insertCss(viewCss);
    cssInserted = true;
  }
});

function initDom(chat) {
  chat.el.html(chatTemplate({ log: chat.log }, {isEntryType: isEntryType}));
  chat.listenerHandle = listen(listener, chat, chat.el);
}

function isEntryType(entryType, options) {
  if (this.entryType === entryType) {
    return options.fn(this);
  } else {
    return false;
  }
}

/*
 * Chat message handling
 */
function sendMessage(chat, _el, event) {
  event.preventDefault();
  let input = chat.el.find("input[type=text]");
  addLine(chat.log, input.val());
  input.val("");
}

/*
 * Exports
 */
module.exports.Chat = Chat;
<commit_msg>Style and linting considerations<commit_after>/* -*- js2-basic-offset: 2; indent-tabs-mode: nil; -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80; */
"use strict";

// Broken AMDs
require("../../shims/can.view.mustache");

let {addMethod} = require("genfun"),
    {clone, init} = require("../../lib/proto"),
    can = require("../../shims/can"),
    insertCss = require("insert-css"),
    viewCss = require("./chat.styl"),
    {addLine} = require("../../models/chatlog"),
    {EventListener, listen} = require("../../lib/eventListener"),
    fs = require("fs"),
    chatTemplateText = fs.readFileSync(__dirname + "/chat.mustache");

/**
 * Chat Controller
 *
 */
let Chat = clone(),
    chatTemplate = can.view.mustache(chatTemplateText),
    events = { "form submit": sendMessage },
    listener = clone(EventListener, events),
    cssInserted = false;

/*
 * Init
 */
addMethod(init, [Chat], function(chat, el, chatlog) {
  chat.el = el;
  chat.log = chatlog;
  initDom(chat);
  if (!cssInserted) {
    insertCss(viewCss);
    cssInserted = true;
  }
});

function initDom(chat) {
  chat.el.html(chatTemplate({ log: chat.log }, { isEntryType: isEntryType }));
  chat.listenerHandle = listen(listener, chat, chat.el);
}

function isEntryType(entryType, options) {
  /*jshint validthis: true*/
  if (this.entryType === entryType) {
    return options.fn(this);
  } else {
    return false;
  }
}

/*
 * Chat message handling
 */
function sendMessage(chat, _el, event) {
  event.preventDefault();
  let input = chat.el.find("input[type=text]");
  addLine(chat.log, input.val());
  input.val("");
}

/*
 * Exports
 */
module.exports.Chat = Chat;

{'fraction_non_alphanumeric': 0.19512946979038223, 'fraction_numerical': 0.0036991368680641184, 'mean_word_length': 3.4029850746268657, 'pattern_counts': {'":': 2, '<': 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': '7232191', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1099, 'n_words': 226}