<commit_before>(ns todomvc.app
  (:require-macros [cljs.core.async.macros :refer [go alt!]])
  (:require [cljs.core.async :refer [put! >! <! chan]]
            [om.core :as om]
            [om.dom :as dom :include-macros true]
            [todomvc.utils :refer [pluralize now guid]]
            [todomvc.item :as todo-item]))

(enable-console-print!)

(def ENTER_KEY 13)

(def app-state (atom {:todos []}))

;; =============================================================================
;; Todos

(defn toggle-all [e todos]
  (let [checked (.. e -target -checked)]
    (om/replace! todos
      (into [] (map #(assoc % :completed checked) todos)))))

(defn handle-new-todo-keydown [e app owner]
  (when (not (identical? (.-which e) ENTER_KEY))
    (om/update! app [:todos] conj
      {:id (guid)
       :title (.-value (dom/get-node owner "newField"))
       :completed false})))

(defn main [todos chans]
  (dom/component
    (dom/section #js {:id "main"}
      (dom/input #js {:id "toggle-all"
                      :type "checkbox"
                      :onChange #(toggle-all % todos)})
      (dom/ul #js {:id "todo-list"}
        (into-array
          (map #(om/render todos [%] chans :id)
            todos (range (count todos))))))))

(defn footer [{:keys [todos] :as app} opts]
  (let [{:keys [active completed showing chans]} opts
        clear-button (when (pos? completed)
                       (dom/button
                         #js {:id "clear-completed"
                              :onClick #(put! (:clear chans) (now))}
                         (str "Clear completed " completed)))
        selected (zipmap [:all :active :completed] (repeat "select"))]
    (dom/component
      (dom/footer #js {:id "footer"}
        (dom/span #js {:id "todo-count"}
          (dom/strong nil (count todos))
          (str " " (pluralize active "item") " left"))
        (dom/ul #js {:id "filters"}
          (dom/li nil
            (dom/a #js {:href "#/" :className (selected showing)}
              "All"))
          (dom/li nil
            (dom/a #js {:href "#/active" :className (selected showing)}
              "Active"))
          (dom/li nil
            (dom/a #js {:href "#/completed" :className (selected showing)}
              "Completed"))
          clear-button)))))

(defn toggle-todo [todo]
  (om/replace! todo (update-in todo [:completed] #(not %))))
<commit_msg>fix rendering of todo items<commit_after>(ns todomvc.app
  (:require-macros [cljs.core.async.macros :refer [go alt!]])
  (:require [cljs.core.async :refer [put! >! <! chan]]
            [om.core :as om]
            [om.dom :as dom :include-macros true]
            [todomvc.utils :refer [pluralize now guid]]
            [todomvc.item :as item]))

(enable-console-print!)

(def ENTER_KEY 13)

(def app-state (atom {:todos []}))

;; =============================================================================
;; Todos

(defn toggle-all [e todos]
  (let [checked (.. e -target -checked)]
    (om/replace! todos
      (into [] (map #(assoc % :completed checked) todos)))))

(defn handle-new-todo-keydown [e app owner]
  (when (not (identical? (.-which e) ENTER_KEY))
    (om/update! app [:todos] conj
      {:id (guid)
       :title (.-value (dom/get-node owner "newField"))
       :completed false})))

(defn main [todos chans]
  (dom/component
    (dom/section #js {:id "main"}
      (dom/input #js {:id "toggle-all"
                      :type "checkbox"
                      :onChange #(toggle-all % todos)})
      (dom/ul #js {:id "todo-list"}
        (into-array
          (map #(om/render item/todo-item todos [%] chans :id)
            todos (range (count todos))))))))

(defn footer [{:keys [todos] :as app} opts]
  (let [{:keys [active completed showing chans]} opts
        clear-button (when (pos? completed)
                       (dom/button
                         #js {:id "clear-completed"
                              :onClick #(put! (:clear chans) (now))}
                         (str "Clear completed " completed)))
        selected (zipmap [:all :active :completed] (repeat "select"))]
    (dom/component
      (dom/footer #js {:id "footer"}
        (dom/span #js {:id "todo-count"}
          (dom/strong nil (count todos))
          (str " " (pluralize active "item") " left"))
        (dom/ul #js {:id "filters"}
          (dom/li nil
            (dom/a #js {:href "#/" :className (selected showing)}
              "All"))
          (dom/li nil
            (dom/a #js {:href "#/active" :className (selected showing)}
              "Active"))
          (dom/li nil
            (dom/a #js {:href "#/completed" :className (selected showing)}
              "Completed"))
          clear-button)))))

(defn toggle-todo [todo]
  (om/replace! todo (update-in todo [:completed] #(not %))))

{'fraction_non_alphanumeric': 0.19636894824707846, 'fraction_numerical': 0.0008347245409015025, 'mean_word_length': 2.110317975340688, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3012321', 'n_tokens_mistral': 1567, 'n_tokens_neox': 1504, 'n_words': 423}