Commit b8b244d9 authored by Ricardo J. Mendez's avatar Ricardo J. Mendez

Removing unnecessary threading macros

parent 55545802
...@@ -77,8 +77,7 @@ ...@@ -77,8 +77,7 @@
the result." the result."
[url] [url]
(if (not-empty url) (if (not-empty url)
(let [element (-> (dommy/create-element :a) (let [element (dommy/set-attr! (dommy/create-element :a) :href url)
(dommy/set-attr! :href url))
shortened (str (.toLowerCase (.-host element)) (.-pathname element) (.-search element))] shortened (str (.toLowerCase (.-host element)) (.-pathname element) (.-search element))]
(hash-string shortened)) (hash-string shortened))
0)) 0))
......
...@@ -182,7 +182,7 @@ ...@@ -182,7 +182,7 @@
(let [modal-info (subscribe [:ui-state :modal-info]) (let [modal-info (subscribe [:ui-state :modal-info])
;; On the next one, we can't use not-empty because (= nil (not-empty nil)), and :show expects true/false, ;; On the next one, we can't use not-empty because (= nil (not-empty nil)), and :show expects true/false,
;; not a truth-ish value. ;; not a truth-ish value.
show? (reaction (not (empty? @modal-info)))] show? (reaction (seq @modal-info))]
(fn [] (fn []
[Modal {:show @show? :onHide #(dispatch [:modal-info-set nil])} [Modal {:show @show? :onHide #(dispatch [:modal-info-set nil])}
[ModalHeader [ModalHeader
...@@ -201,52 +201,51 @@ ...@@ -201,52 +201,51 @@
(defn list-urls [urls site-data] (defn list-urls [urls site-data]
(let [now (.now js/Date)] (let [now (.now js/Date)]
(->> (map-indexed
urls (fn [i tab]
(map-indexed (let [url (:url tab)
(fn [i tab] favicon (:icon (get site-data (host-key (hostname url))))
(let [url (:url tab) title (:title tab)
favicon (:icon (get site-data (host-key (hostname url)))) label (if (empty? title)
title (:title tab) url
label (if (empty? title) title)
url display (if (and (= url label)
title) (< 80 (count label)))
display (if (and (= url label) (clojure.string/join (concat (take 80 label) "..."))
(< 80 (count label))) label)
(clojure.string/join (concat (take 80 label) "...")) age-ms (- now (:ts tab))
label) ;; Colors picked at http://www.w3schools.com/tags/ref_colorpicker.asp
age-ms (- now (:ts tab)) color (cond
;; Colors picked at http://www.w3schools.com/tags/ref_colorpicker.asp (< age-ms ms-hour) "#00ff00"
color (cond (< age-ms ms-day) "#00cc00"
(< age-ms ms-hour) "#00ff00" (< age-ms (* 3 ms-day)) "#009900"
(< age-ms ms-day) "#00cc00" (< age-ms (* 7 ms-day)) "#ff8000"
(< age-ms (* 3 ms-day)) "#009900" (< age-ms (* 14 ms-day)) "#cc6600"
(< age-ms (* 7 ms-day)) "#ff8000" :else "#994c00"
(< age-ms (* 14 ms-day)) "#cc6600" )
:else "#994c00" ]
) ^{:key i}
] [:tr {:class "has_on_hover"}
^{:key i} [:td {:class "col-sm-1"}
[:tr {:class "has_on_hover"} (time-display (:time tab))]
[:td {:class "col-sm-1"} [:td {:class "col-sm-9"}
(time-display (:time tab))] [:a
[:td {:class "col-sm-9"} {:href url :target "_blank"}
[:a (if favicon
{:href url :target "_blank"} [:img {:src favicon
(if favicon :width 16
[:img {:src favicon :height 16}])
:width 16 display]]
:height 16}]) [:td {:class "col-sm-2"}
display]] [:i {:class "fa fa-circle" :style {:color color}}]
[:td {:class "col-sm-2"} (time-display (quot age-ms 1000))
[:i {:class "fa fa-circle" :style {:color color}}] [:span {:class "show_on_hover" :style {:text-align "right"}}
(time-display (quot age-ms 1000)) [:i {:class "fa fa-remove"
[:span {:class "show_on_hover" :style {:text-align "right"}} :style {:color "red"}
[:i {:class "fa fa-remove" :on-click #(runtime/send-message {:action :delete-url
:style {:color "red"} :data url})}]]]
:on-click #(runtime/send-message {:action :delete-url ]))
:data url})}]]] urls)))
]))))))
(defn div-urltimes [] (defn div-urltimes []
...@@ -306,21 +305,20 @@ ...@@ -306,21 +305,20 @@
[:th "Time"] [:th "Time"]
[:th "Site"]]] [:th "Site"]]]
[:tbody [:tbody
(->> (map-indexed
@to-list (fn [i site]
(map-indexed (let [url (:host site)
(fn [i site] icon (:icon site)]
(let [url (:host site) ^{:key i}
icon (:icon site)] [:tr
^{:key i} [:td {:class "col-sm-1"} (time-display (:time site))]
[:tr [:td {:class "col-sm-6"} (if icon
[:td {:class "col-sm-1"} (time-display (:time site))] [:img {:src icon
[:td {:class "col-sm-6"} (if icon :width 16
[:img {:src icon :height 16}])
:width 16 url]
:height 16}]) ]))
url] @to-list)]
]))))]
]]]]) ]]]])
)) ))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment