<commit_before>button_add = ->
  f = $ "<form>"
        action: ""
        enctype: "multipart/form-data"
  i = $ "<input>"
        type: "file"
        name: "file"
        size: "10"
  s = button().text "Hochladen…"
  f.append (h2().text "Upload"),
           i,
           s
  p = {
    files: i
    iframe: true
  }
  s.click (x) ->
    x.preventDefault()
    a = $.ajax "/pi/admin/upload.php", p
    a.done (data) ->
      debugger
      f = $ "<file>"
            src: (($ data).find "file").attr "src"
      ($ ".db library").append f
      post_file ($ ".db library"), "library"
      ($ ".arena").empty()
      open_library()
  f

file = (x) ->
  div().append img().attr {src: (x.attr "src"), width: "20%"}

filelist = ->
  file ($ x) for x in records

@open_library = ->
  with_mixin [
      VIEWS_TABLE
      VIEWS_TABLE_EDIT
      records: RECORDS["library"].children()
      parent:  RECORDS["library"]
      schema:  SCHEMAS["library"]
      desc:    "Bibliothek"
      button_add: button_add
    ], ->
      ($ ".arena").append (make_containment().append_nested button_add(), filelist()),

update_library_button = ->
  ($ ".menubutton_library").text "Bibliothek (#{($ ".db library > *").length})"

@init_library = ->
  $(".db library").bind "DOMSubtreeModified", update_library_button
  update_library_button()
<commit_msg>Can remove files from the library.<commit_after>button_add = ->
  f = $ "<form>"
        action: ""
        enctype: "multipart/form-data"
  i = $ "<input>"
        type: "file"
        name: "file"
        size: "10"
  s = button().text "Hochladen…"
  f.append (h2().text "Upload"),
           i,
           s
  p = {
    files: i
    iframe: true
  }
  s.click (x) ->
    x.preventDefault()
    a = $.ajax "/pi/admin/upload.php", p
    a.done (data) ->
      f = $ "<file>"
            src: (($ data).find "file").attr "src"
      ($ ".db library").append f
      post_file ($ ".db library"), "library"
      ($ ".arena").empty()
      open_library()
  f

file = ->
  (div().addClass "record").append button_remove(),
                                   img().attr {src: (xml.attr "src"), width: "20%"}

filelist = ->
  with_mixin {xml: ($ x)}, file for x in records

@open_library = ->
  with_mixin [
      VIEWS_TABLE
      VIEWS_TABLE_EDIT
      records: RECORDS["library"].children()
      parent:  RECORDS["library"]
      schema:  SCHEMAS["library"]
      desc:    "Bibliothek"
      button_add: button_add
    ], ->
      ($ ".arena").append (make_containment().append_nested button_add(), filelist()),

update_library_button = ->
  ($ ".menubutton_library").text "Bibliothek (#{($ ".db library > *").length})"

@init_library = ->
  $(".db library").bind "DOMSubtreeModified", update_library_button
  update_library_button()
{'fraction_non_alphanumeric': 0.1815884476534296, 'fraction_numerical': 0.0036101083032490976, 'mean_word_length': 2.3145933014354068, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3663969', 'n_tokens_mistral': 962, 'n_tokens_neox': 944, 'n_words': 205}