<commit_before>(ns virt.chat
  (:require-macros [cljs.core.async.macros :refer [go alt!]])
  (:require [clojure.string :as string]
            [cljs.core.async :refer [put! <! >! chan timeout]]
            [om.core :as om :include-macros true]
            [om.dom :as dom :include-macros true]
            [cljs-http.client :as http]))


(def app-state (atom {}))


(defn parse-url-param [param-name]
  (let [encoded-param-name (string/replace (js/encodeURI param-name) #"[\.\+\*]" "\\$&")
        re (js/RegExp (str "^(?:.*[&\\?]" encoded-param-name "(?:\\=([^&]*))?)?.*$") "i")]
    (js/decodeURI (.replace (.. js/window -location -search) re "$1"))))


(defn header [app owner]
  (reify
    om/IRenderState
    (render-state [_ {:keys [comm]}]
      (dom/header nil
        (dom/div nil)
        (dom/div nil
          (dom/div #js {:id "header-title"} "Chat"))
        (dom/div nil
          (dom/button #js {:id "new-button"
                           :className "transparent-button"}
                      "New"))))))

(defn leaf-channel [channel owner {:keys [channel-id]}]
  (reify
    om/IWillMount
    (will-mount [_]
      (let [wsUri (str "ws://" window.location.host (str "/api/watch/" (om/get-shared owner :cosm-id) "/" channel-id))
            ws (js/WebSocket. wsUri)
            comm (chan)]
        (set! (.-onmessage ws)
          (fn [e]
            ;(om/update! channel :messages (cljs.reader/read-string (.-data e)))<commit_msg>Add home button in chat<commit_after>(ns virt.chat
  (:require-macros [cljs.core.async.macros :refer [go alt!]])
  (:require [clojure.string :as string]
            [cljs.core.async :refer [put! <! >! chan timeout]]
            [om.core :as om :include-macros true]
            [om.dom :as dom :include-macros true]
            [cljs-http.client :as http]))


(def app-state (atom {}))


(defn parse-url-param [param-name]
  (let [encoded-param-name (string/replace (js/encodeURI param-name) #"[\.\+\*]" "\\$&")
        re (js/RegExp (str "^(?:.*[&\\?]" encoded-param-name "(?:\\=([^&]*))?)?.*$") "i")]
    (js/decodeURI (.replace (.. js/window -location -search) re "$1"))))


(defn header [app owner]
  (reify
    om/IRenderState
    (render-state [_ {:keys [comm]}]
      (dom/header nil
        (dom/div nil
          (dom/button #js {:id "home-button"
                           :className "transparent-button"
                           :onClick #(set! (.-location js/window) "/")}
                      "Home"))
        (dom/div nil
          (dom/div #js {:id "header-title"} "Chat"))
        (dom/div nil
          (dom/button #js {:id "new-button"
                           :className "transparent-button"}
                      "New"))))))

(defn leaf-channel [channel owner {:keys [channel-id]}]
  (reify
    om/IWillMount
    (will-mount [_]
      (let [wsUri (str "ws://" window.location.host (str "/api/watch/" (om/get-shared owner :cosm-id) "/" channel-id))
            ws (js/WebSocket. wsUri)
            comm (chan)]
        (set! (.-onmessage ws)
          (fn [e]
            ;(om/update! channel :messages (cljs.reader/read-string (.-data e)))
{'fraction_non_alphanumeric': 0.19672657252888318, 'fraction_numerical': 0.0006418485237483953, 'mean_word_length': 2.020348837209302, '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': '4526470', 'n_tokens_mistral': 1095, 'n_tokens_neox': 1050, 'n_words': 248}