<commit_before>(ns org.broadinstitute.firecloud-ui.common)


(def keymap
  {:backspace 8 :tab 9 :enter 13 :shift 16 :ctrl 17 :alt 18 :capslock 20 :esc 27 :space 32
   :pgup 33 :pgdown 34 :end 35 :home 67 :left 37 :up 38 :right 39 :down 40 :insert 45 :del 46})

(defn create-key-handler
  ([keys func] (create-key-handler keys (fn [e] true) func))
  ([keys modifier func] (fn [e]
                          (when (modifier e)
                            (let [keycode (.-keyCode e)]
                              (when (some #(= keycode (% keymap)) keys)
                                (func e)))))))

(defn clear! [refs & ids]
  (doseq [id ids]
    (set! (.-value (.getDOMNode (@refs id))) "")))

(defn get-text [refs & ids]
  (if (= 1 (count ids))
    (-> (@refs (first ids)) .getDOMNode .-value clojure.string/trim)
    (map
      (fn [id]
        (-> (@refs id) .getDOMNode .-value clojure.string/trim))
      ids)))

(defn clear-both [] [:div {:style {:clear "both"}}])

(defn scroll-to [x y] (.scrollTo js/window x y))
<commit_msg>First pass at smooth scrolling<commit_after>(ns org.broadinstitute.firecloud-ui.common)


(def keymap
  {:backspace 8 :tab 9 :enter 13 :shift 16 :ctrl 17 :alt 18 :capslock 20 :esc 27 :space 32
   :pgup 33 :pgdown 34 :end 35 :home 67 :left 37 :up 38 :right 39 :down 40 :insert 45 :del 46})

(defn create-key-handler
  ([keys func] (create-key-handler keys (fn [e] true) func))
  ([keys modifier func] (fn [e]
                          (when (modifier e)
                            (let [keycode (.-keyCode e)]
                              (when (some #(= keycode (% keymap)) keys)
                                (func e)))))))

(defn clear! [refs & ids]
  (doseq [id ids]
    (set! (.-value (.getDOMNode (@refs id))) "")))

(defn get-text [refs & ids]
  (if (= 1 (count ids))
    (-> (@refs (first ids)) .getDOMNode .-value clojure.string/trim)
    (map
      (fn [id]
        (-> (@refs id) .getDOMNode .-value clojure.string/trim))
      ids)))

(defn clear-both [] [:div {:style {:clear "both"}}])

(defn- animate [steps-remaining x y step-x step-y period]
  (if (zero? steps-remaining)
    (.scrollTo js/window x y)
    (js/setTimeout
      #(do (.scrollBy js/window step-x step-y)
           (animate (dec steps-remaining) x y step-x step-y period))
      period)))

(defn scroll-to [x y]
  (let [duration 100
        period 5
        frames (/ duration period)
        step-x (/ (- x (.-scrollX js/window)) frames)
        step-y (/ (- y (.-scrollY js/window)) frames)]
    (animate frames x y step-x step-y period)))

{'fraction_non_alphanumeric': 0.16393442622950818, 'fraction_numerical': 0.03044496487119438, 'mean_word_length': 2.1447852760736197, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1211901', 'n_tokens_mistral': 998, 'n_tokens_neox': 877, 'n_words': 295}