<commit_before>(ns pw.core
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [om.core :as om :include-macros true]
            [om.dom :as dom :include-macros true]
            [cljs.core.async :refer [put! chan <! >! timeout]]
            [goog.events :as events]
            [goog.dom :as gdom]
            [cljs.reader :as reader]
            [clojure.string]
            [sablono.core :as html :refer-macros [html]])
  (:import [goog.net XhrIo]
           goog.net.EventType
           [goog.events EventType]))

(def meths {:get "get" :put "put" :post "post" :delete "delete"})

(defn edn-xhr [{:keys [method url data channel]}]
  (let [xhr (XhrIo.)
        callback (fn [d] (go (>! channel d)))]
    (events/listen xhr goog.net.EventType.COMPLETE
                   (fn [e]
                     (if (.isSuccess xhr)
                       (callback (reader/read-string
                                  (.getResponseText xhr))))))
    (. xhr
       (send url (meths method) (when data (pr-str data))
             #js {"Content-Type" "application/edn"
                  "Accept" "application/edn"}))))

(defn service [] (.-value (gdom/getElement "service")))
(defn password [] (.-value (gdom/getElement "password")))

(defn fetch-password [state]
  (let [rc (chan)]
    (edn-xhr {:method :post
              :url (str "/pass/" (service))
              :data {:password (password)}
              :channel rc})
    (go (let [fetched (<! rc)]
          (om/transact! state (fn [s] (assoc s :fetched fetched)))))))

(defn output [fetched owner]
  (reify
    om/IRender
    (render [_]
      (html
       (cond
        (:error fetched) [:input#result.error
                          {:value (:error fetched) :ref "result"}]
        (:pass fetched) [:input#ugh.result
                         {:value (:pass fetched) :ref "result"}]
        :else nil)))
    om/IDidUpdate
    (did-update [_ _ _]
      (when (:pass fetched)
        (let [timeout-chan (timeout 3000)]<commit_msg>don't disappear password so quickly<commit_after>(ns pw.core
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [om.core :as om :include-macros true]
            [om.dom :as dom :include-macros true]
            [cljs.core.async :refer [put! chan <! >! timeout]]
            [goog.events :as events]
            [goog.dom :as gdom]
            [cljs.reader :as reader]
            [clojure.string]
            [sablono.core :as html :refer-macros [html]])
  (:import [goog.net XhrIo]
           goog.net.EventType
           [goog.events EventType]))

(def meths {:get "get" :put "put" :post "post" :delete "delete"})

(defn edn-xhr [{:keys [method url data channel]}]
  (let [xhr (XhrIo.)
        callback (fn [d] (go (>! channel d)))]
    (events/listen xhr goog.net.EventType.COMPLETE
                   (fn [e]
                     (if (.isSuccess xhr)
                       (callback (reader/read-string
                                  (.getResponseText xhr))))))
    (. xhr
       (send url (meths method) (when data (pr-str data))
             #js {"Content-Type" "application/edn"
                  "Accept" "application/edn"}))))

(defn service [] (.-value (gdom/getElement "service")))
(defn password [] (.-value (gdom/getElement "password")))

(defn fetch-password [state]
  (let [rc (chan)]
    (edn-xhr {:method :post
              :url (str "/pass/" (service))
              :data {:password (password)}
              :channel rc})
    (go (let [fetched (<! rc)]
          (om/transact! state (fn [s] (assoc s :fetched fetched)))))))

(defn output [fetched owner]
  (reify
    om/IRender
    (render [_]
      (html
       (cond
        (:error fetched) [:input#result.error
                          {:value (:error fetched) :ref "result"}]
        (:pass fetched) [:input#ugh.result
                         {:value (:pass fetched) :ref "result"}]
        :else nil)))
    om/IDidUpdate
    (did-update [_ _ _]
      (when (:pass fetched)
        (let [timeout-chan (timeout 60000)]
{'fraction_non_alphanumeric': 0.1576587795765878, 'fraction_numerical': 0.00224159402241594, 'mean_word_length': 1.916485112563544, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7182363', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1282, 'n_words': 345}