<commit_before>(ns funstructor.core
  (:require
            [chord.client :refer [ws-ch]]
            [cljs.core.async :refer [chan <! >! put! close! timeout]]
            [reagent.core :as reagent :refer [atom]])
  (:require-macros [cljs.core.async.macros :refer [go go-loop]]))

(defn opponend-field []
  [:div.opponent-field
   [:h1 "TEST!!!"]])

(defn field []
  [:div.field])

(defn hand []
  [:div.hand])

(defn legend []
  [:div.legend])

(defn game []
  [:section#game
   [opponent-field]
   [field]
   [hand]
   [legend]]
  [:div#flyingCards]
  [:section#start
   [:form#startForm {:action "#"}
    [:div.input.start
     [:label "Your name"]
     [:input {:type "text"}]]
    [:div.cb.h20]
    [:div.button.start
     [:input {:value "Play", :type "submit"}]]]])

(reagent/render-component [game] (.getElementById js/document "app"))

(defn client-ws-handler []
  (go
    (let [{:keys [ws-channel error]} (<! (ws-ch "ws://localhost:8080/ws"))]
      (if error
        (js/alert (pr-str error))
        (loop []
          (<! (timeout 1000))
          (>! ws-channel "Hello world!")
          (recur))))))

(set! (.-onload js/window)
      client-ws-handler)<commit_msg>I need to figure out how to work with core.async ...<commit_after>(ns funstructor.core
  (:require
            [chord.client :refer [ws-ch]]
            [cljs.core.async :refer [chan <! >! put! close! timeout]]
            [reagent.core :as reagent :refer [atom]])
  (:require-macros [cljs.core.async.macros :refer [go go-loop]]))

(defn init-ws-connection! []
  (go
    (let [{:keys [ws-channel error]} (<! (ws-ch "ws://localhost:8080/ws"
                                                {:format :json-kw}))]
      (if-not error
        ws-channel
        (js/alert "Error:" (pr-str error))))))

;; (defn client-ws-handler []
;;   (go
;;     (let [{:keys [ws-channel error]} (<! ws)]
;;       (if error
;;         (js/alert (pr-str error))
;;         (loop []
;;           (<! (timeout 1000))
;;           (recur))))))

;; (set! (.-onload js/window)
;;       client-ws-handler)

(defn opponent-field []
  [:div.opponent-field])

(defn field []
  [:div.field])

(defn hand []
  [:div.hand])

(defn legend []
  [:div.legend])

(defn start-new-game! []
  (let [ws (init-ws-connection!)]
    (go
      (>! ws "test!"))))

(defn login-form []
  [:section#start
   [:form#startForm {:action "#"}
    [:div.input.start
     [:label "Your name"]
     [:input {:type "text"}]]
    [:div.cb.h20]
    [:div.button.start
     [:input {:value "Play"
              :type "submit"
              :on-click start-new-game!}]]]])

(defn game []
  [:section#game
   [opponent-field]
   [field]
   [hand]
   [legend]]
  [:div#flyingCards]
  [login-form])

(reagent/render-component [game] (.getElementById js/document "app"))
{'fraction_non_alphanumeric': 0.2089766606822262, 'fraction_numerical': 0.0075403949730700175, 'mean_word_length': 2.4310344827586206, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4987107', 'n_tokens_mistral': 1061, 'n_tokens_neox': 997, 'n_words': 216}