|
|
@@ -2,7 +2,7 @@ module LinkedIn.ArtDecoCardAlt where
|
|
|
|
|
|
import Prelude
|
|
|
|
|
|
-import Data.Either (Either, note)
|
|
|
+import Data.Either (Either(..), note)
|
|
|
import Data.Generic.Rep (class Generic)
|
|
|
import Data.List (List)
|
|
|
import Data.List.Types (NonEmptyList)
|
|
|
@@ -18,27 +18,53 @@ import Web.DOM (Node)
|
|
|
import Web.DOM.Node (nodeName)
|
|
|
|
|
|
|
|
|
+data ArtDecoCenterHeaderAlt a = ArtDecoCenterHeaderAlt {
|
|
|
+ bold :: a
|
|
|
+}
|
|
|
+
|
|
|
+derive instance Generic (ArtDecoCenterHeaderAlt a) _
|
|
|
+derive instance Eq a => Eq (ArtDecoCenterHeaderAlt a)
|
|
|
+instance Show a => Show (ArtDecoCenterHeaderAlt a) where
|
|
|
+ show = genericShow
|
|
|
+instance Functor ArtDecoCenterHeaderAlt where
|
|
|
+ map f (ArtDecoCenterHeaderAlt {bold}) =
|
|
|
+ ArtDecoCenterHeaderAlt ({bold: f bold})
|
|
|
+
|
|
|
data ArtDecoCardAltElement a = ArtDecoCardAltElement {
|
|
|
- pvs_entity :: a
|
|
|
+ pvs_entity :: ArtDecoCenterHeaderAlt a
|
|
|
}
|
|
|
|
|
|
derive instance Generic (ArtDecoCardAltElement a) _
|
|
|
derive instance Eq a => Eq (ArtDecoCardAltElement a)
|
|
|
instance Show (ArtDecoCardAltElement Node) where
|
|
|
- show (ArtDecoCardAltElement {pvs_entity}) = "ArtDecoCardAltElement(Node " <> nodeName pvs_entity <> ")"
|
|
|
+ show (ArtDecoCardAltElement {
|
|
|
+ pvs_entity: ArtDecoCenterHeaderAlt {bold}
|
|
|
+ }) = "ArtDecoCardAltElement(Node " <> "ArtDecoCenterHeaderAlt(Node " <> nodeName bold <> ")" <> ")"
|
|
|
else instance Show a => Show (ArtDecoCardAltElement a) where
|
|
|
show = genericShow
|
|
|
instance Functor ArtDecoCardAltElement where
|
|
|
map f (ArtDecoCardAltElement {pvs_entity}) =
|
|
|
- ArtDecoCardAltElement ({pvs_entity: f pvs_entity})
|
|
|
+ ArtDecoCardAltElement ({pvs_entity: map f pvs_entity})
|
|
|
+
|
|
|
+queryArtDecoCenterHeaderAlt :: Node → Effect (Either QueryError (ArtDecoCenterHeaderAlt Node))
|
|
|
+queryArtDecoCenterHeaderAlt n = do
|
|
|
+ bold <- runOne ":scope div.t-bold > span[aria-hidden=true]" n
|
|
|
+
|
|
|
+ pure $ ado
|
|
|
+ b <- bold
|
|
|
+ in ArtDecoCenterHeaderAlt {bold: b}
|
|
|
|
|
|
queryArtDecoCardAlt :: Node → Effect (Either QueryError (ArtDecoCardAltElement Node))
|
|
|
queryArtDecoCardAlt n = do
|
|
|
pvs <- runOne ":scope div.pvs-entity--padded" n
|
|
|
|
|
|
- pure $ ado
|
|
|
- p <- pvs
|
|
|
- in ArtDecoCardAltElement {pvs_entity: p}
|
|
|
+ case pvs of
|
|
|
+ Left l -> pure $ Left l
|
|
|
+ Right p -> do
|
|
|
+ header <- queryArtDecoCenterHeaderAlt p
|
|
|
+ pure $ ado
|
|
|
+ h <- header
|
|
|
+ in ArtDecoCardAltElement {pvs_entity: h}
|
|
|
|
|
|
runOne ∷ String → Node → Effect (Either QueryError Node)
|
|
|
runOne selector node = do
|