aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/genpass/core.cljs43
-rw-r--r--src/genpass/gen.cljc17
2 files changed, 0 insertions, 60 deletions
diff --git a/src/genpass/core.cljs b/src/genpass/core.cljs
deleted file mode 100644
index f0ca298..0000000
--- a/src/genpass/core.cljs
+++ /dev/null
@@ -1,43 +0,0 @@
-(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://gitlab.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))
diff --git a/src/genpass/gen.cljc b/src/genpass/gen.cljc
deleted file mode 100644
index 12dbc2f..0000000
--- a/src/genpass/gen.cljc
+++ /dev/null
@@ -1,17 +0,0 @@
-(ns genpass.gen)
-
-(def low-case [\a \b \c \d \e \f \g \h \i \j \k \l \m \n \o \p \q \r \s \t \u \v \W \x \Y \z])
-(def upper-case [\A \B \C \D \E \F \G \H \I \J \K \L \M \N \O \P \Q \R \S \T \U \V \W \X \Y \Z])
-(def number [\0 \1 \2 \3 \4 \5 \6 \7 \8 \9])
-(def special-char [\! \@ \# \% \^ \& \* \( \) \{ \} \[ \] \- \+ \= \~])
-(def all-char (concat low-case upper-case number special-char))
-
-(defn rand-char []
- (nth all-char (rand-int (dec (count all-char)))))
-
-(defn genpwd
- ([] (genpwd 12))
- ([length]
- (->> (range length)
- (map (fn [_] (rand-char)))
- (apply str)))) \ No newline at end of file