<commit_before>jQuery ($) ->
  $.fn.scrap_form = () ->
    @each ->
      new ScrapForm(@)
    @

  $.fn.type_setter = (scrapform) ->
    @change ->
      console.log "change!", @
      if $(@).is('checked')
        scrapform.setType($(@).val())


  class ScrapForm
    constructor: (element) ->
      @_container = $(element)
      @_header = @_container.find('.scraptypes')
      @_fields = @_container.find('.fields')
      @_header.find('input:radio').change @setType
      @_body = @_fields.find('.body')
      @_caption = @_fields.find('.caption')
      @_image = @_fields.find('.upload')
      @_event = @_fields.find('.scrapevent')
      @setType()
    
    setType: () =>
      scraptype = @_header.find('input:radio:checked').val()
      @_fields.attr("class", "fields #{scraptype}")
      switch scraptype
        when "text"
          @_body.find('textarea').attr("placeholder", "Your remarks")
          @textBased()
        when "quote"
          @_body.find('textarea').attr("placeholder", "Quote text")
          @textBased()
        when "link"
          @_body.find('textarea').attr("placeholder", "Link address")
          @textBased()
        when "video"
          @_body.find('textarea').attr("placeholder", "Youtube ID")
          @textBased()
        when "image"
          @imageBased()
        when "event"
          @eventBased()
      
    imageBased: () =>
      @_image.find('input').prop('disabled', false);
      @_image.show()
      @_event.hide()
      @_body.hide()

    textBased: () =>
      @_image.find('input').prop('disabled', true);
      @_image.hide()
      @_event.hide()
      @_body.show()

    eventBased: () =>
      @_image.find('input').prop('disabled', true);
      @_image.hide()
      @_event.show()
      @_body.hide()
        <commit_msg>fix for creating non-event scraps<commit_after>jQuery ($) ->
  $.fn.scrap_form = () ->
    @each ->
      new ScrapForm(@)
    @

  $.fn.type_setter = (scrapform) ->
    @change ->
      console.log "change!", @
      if $(@).is('checked')
        scrapform.setType($(@).val())


  class ScrapForm
    constructor: (element) ->
      @_container = $(element)
      @_header = @_container.find('.scraptypes')
      @_fields = @_container.find('.fields')
      @_header.find('input:radio').change @setType
      @_body = @_fields.find('.body')
      @_caption = @_fields.find('.caption')
      @_image = @_fields.find('.upload')
      @_event = @_fields.find('.scrapevent')
      @setType()
    
    setType: () =>
      scraptype = @_header.find('input:radio:checked').val()
      @_fields.attr("class", "fields #{scraptype}")
      switch scraptype
        when "text"
          @_body.find('textarea').attr("placeholder", "Your remarks")
          @textBased()
        when "quote"
          @_body.find('textarea').attr("placeholder", "Quote text")
          @textBased()
        when "link"
          @_body.find('textarea').attr("placeholder", "Link address")
          @textBased()
        when "video"
          @_body.find('textarea').attr("placeholder", "Youtube ID")
          @textBased()
        when "image"
          @imageBased()
        when "event"
          @eventBased()
      
    imageBased: () =>
      @_image.show().find('input').prop('disabled', false);
      @_event.hide().find('input').prop('disabled', true);
      @_body.hide().find('input, textarea').prop('disabled', true);

    textBased: () =>
      @_image.hide().find('input').prop('disabled', true);
      @_event.hide().find('input').prop('disabled', true);
      @_body.show().find('input, textarea').prop('disabled', false);

    eventBased: () =>
      @_image.hide().find('input').prop('disabled', true);
      @_event.show().find('input').prop('disabled', false);
      @_body.hide().find('input, textarea').prop('disabled', true);
        
{'fraction_non_alphanumeric': 0.1968112911657083, 'fraction_numerical': 0.0, 'mean_word_length': 2.441546762589928, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '815614', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1206, 'n_words': 190}