<commit_before>window.LC = window.LC ? {}


slice = Array.prototype.slice


LC._last = (array, n = null) ->
  if n
    return slice.call(array, Math.max(array.length - n, 0))
  else
    return array[array.length - 1]


LC.init = (el, opts = {}) ->
  opts.primaryColor ?= '#000'
  opts.secondaryColor ?= '#fff'
  opts.backgroundColor ?= 'transparent'
  opts.imageURLPrefix ?= 'lib/img'
  opts.keyboardShortcuts ?= true
  opts.loadSnapshot ?= null
  opts.loadSnapshotJSON ?= null
  opts.preserveCanvasContents ?= false
  opts.sizeToContainer ?= true
  opts.watermarkImage ?= null
  unless 'toolClasses' of opts
    opts.toolClasses = [
        LC.PencilWidget, LC.EraserWidget, LC.LineWidget, LC.RectangleWidget,
        LC.PanWidget, LC.EyeDropperWidget
    ]

  $el = $(el)
  $el.addClass('literally')
  $tbEl = $('<div class="toolbar">')

  $el.append($tbEl)

  unless $el.find('canvas').length
    $el.append('<canvas>')
  lc = new LC.LiterallyCanvas($el.find('canvas').get(0), opts)
  tb = new LC.Toolbar(lc, $tbEl, opts)
  tb.selectTool(tb.tools[0])

  resize = ->
    if opts.sizeToContainer
      lc.$canvas.css('height', "#{$el.height() - $tbEl.height()}px")
    lc.updateSize()

  $el.resize(resize)
  $(window).resize(resize)
  resize()

  [lc, tb]


$.fn.literallycanvas = (opts = {}) ->
  @each (ix, el) =>
    [el.literallycanvas, el.literallycanvasToolbar] = LC.init(el, opts)
  this


$.fn.canvasForExport = ->
  @get(0).literallycanvas.canvasForExport()<commit_msg>Remove $.canvasForExport; add onInit callback to opts<commit_after>window.LC = window.LC ? {}


slice = Array.prototype.slice


LC._last = (array, n = null) ->
  if n
    return slice.call(array, Math.max(array.length - n, 0))
  else
    return array[array.length - 1]


LC.init = (el, opts = {}) ->
  opts.primaryColor ?= '#000'
  opts.secondaryColor ?= '#fff'
  opts.backgroundColor ?= 'transparent'
  opts.imageURLPrefix ?= 'lib/img'
  opts.keyboardShortcuts ?= true
  opts.loadSnapshot ?= null
  opts.loadSnapshotJSON ?= null
  opts.preserveCanvasContents ?= false
  opts.sizeToContainer ?= true
  opts.watermarkImage ?= null
  unless 'toolClasses' of opts
    opts.toolClasses = [
        LC.PencilWidget, LC.EraserWidget, LC.LineWidget, LC.RectangleWidget,
        LC.PanWidget, LC.EyeDropperWidget
    ]

  $el = $(el)
  $el.addClass('literally')
  $tbEl = $('<div class="toolbar">')

  $el.append($tbEl)

  unless $el.find('canvas').length
    $el.append('<canvas>')
  lc = new LC.LiterallyCanvas($el.find('canvas').get(0), opts)
  tb = new LC.Toolbar(lc, $tbEl, opts)
  tb.selectTool(tb.tools[0])

  resize = ->
    if opts.sizeToContainer
      lc.$canvas.css('height', "#{$el.height() - $tbEl.height()}px")
    lc.updateSize()

  $el.resize(resize)
  $(window).resize(resize)
  resize()

  if 'onInit' of opts
    opts.onInit(lc)

  [lc, tb]


$.fn.literallycanvas = (opts = {}) ->
  @each (ix, el) =>
    [el.literallycanvas, el.literallycanvasToolbar] = LC.init(el, opts)
  this
{'fraction_non_alphanumeric': 0.1706496129249411, 'fraction_numerical': 0.005048805116122518, 'mean_word_length': 3.4624624624624625, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 18, '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': '311183', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1070, 'n_words': 202}