blob: 33096d0c94a2623647ec3286c714159121f3e7a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
(ns genpass.core
(:require
[reagent.core :as r]
[genpass.gen :refer [genpwd]]))
(def password (r/atom (genpwd)))
(defn magic-selection-trick-took-from-so [e]
(let [this (.-target e)]
(if (and (.getSelection js/window) (.createRange js/document))
(let [selection (.getSelection js/window)
range (.createRange js/document)]
(.selectNodeContents range this)
(.removeAllRanges selection)
(.addRange selection range))
(if (and (.-selection js/document) (-> js/document .-body .createTextRange))
(let [range (-> js/document .-body .createTextRange)]
(.moveToElementText range this)
(.select range))))))
(defn home-page []
[:div
[:nav.navbar
{:role "navigation"
:aria-label "main navigation"}
[:div.navbar-brand>a.navbar-item>h1
[:a {:href "https://github.com//gabrielgio/genpass"} "Genpass source code"]]]
[:div.section.container
[:div.field.has-text-centered
[:span.title.is-3 {:on-click magic-selection-trick-took-from-so} @password]]
[:div.field.is-grouped.is-grouped-centered
[:div.control
[:input.button.is-primary
{:value "Generate"
:type "button"
:on-click #(reset! password (genpwd))}]]]]])
(defn mount-root []
(r/render [home-page] (.getElementById js/document "app")))
(defn init! []
(mount-root))
|