From 1cb2d824d0d490d7f980c49db451c4dd6a775671 Mon Sep 17 00:00:00 2001 From: bom Date: Thu, 24 Feb 2022 14:08:43 +0100 Subject: [PATCH] refactor app to use common function --- src/main/dda/masto_embed/app.cljs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/dda/masto_embed/app.cljs b/src/main/dda/masto_embed/app.cljs index d42acae..325ded6 100644 --- a/src/main/dda/masto_embed/app.cljs +++ b/src/main/dda/masto_embed/app.cljs @@ -25,20 +25,19 @@ (def masto-embed "masto-embed") -(defn host-url-from-document [] +(defn element-from-document-by-name [name] (-> js/document (.getElementById masto-embed) - (.getAttribute "host_url"))) + (.getAttribute name))) + +(defn host-url-from-document [] + (element-from-document-by-name "host_url")) (defn account-name-from-document [] - (-> js/document - (.getElementById masto-embed) - (.getAttribute "account_name"))) + (element-from-document-by-name "account_name")) (defn account-id-from-document [] - (-> js/document - (.getElementById masto-embed) - (.getAttribute "account_id"))) + (element-from-document-by-name "account_id")) (defn render-to-document [input]