Code cleanup
This commit is contained in:
parent
a5859ff737
commit
05eeaae01a
19
src/Main.hs
19
src/Main.hs
|
@ -32,7 +32,7 @@ setup w = void $ do
|
|||
UI.div #. "container" # set UI.id_ "cont" #+ [
|
||||
UI.h1 #+ [string "Minesweeper"],
|
||||
UI.h4 #+ [string "Jack Harley jharley@tcd.ie"],
|
||||
mkElement "table" # set UI.id_ "grid" #+ rows iob b 0
|
||||
mkElement "table" # set UI.id_ "table" #+ rows iob b 0
|
||||
]]
|
||||
|
||||
where
|
||||
|
@ -44,22 +44,19 @@ setup w = void $ do
|
|||
|
||||
cell iob b (r,c) = do
|
||||
cell <- mkElement "td" #. (squareBgColour b (r,c) ++ " " ++ squareTextColour b (r,c))
|
||||
#+ [string $ squareAscii b (r,c)]
|
||||
#+ [string $ squareAscii b (r,c)]
|
||||
|
||||
on UI.click cell $ \_ -> do
|
||||
liftIO $ modifyIORef' iob $ \oldB -> uncover oldB (r,c)
|
||||
b <- liftIO $ readIORef iob
|
||||
|
||||
cont <- getElementById w "cont"
|
||||
let cont' = fromJust cont
|
||||
table <- getElementById w "table"
|
||||
let table' = fromJust table
|
||||
|
||||
getBody w #+ [
|
||||
UI.div #. "container" # set UI.id_ "cont" # set children [] #+ [
|
||||
UI.h1 #+ [string "Minesweeper"],
|
||||
UI.h4 #+ [string "Jack Harley jharley@tcd.ie"],
|
||||
mkElement "table" # set UI.id_ "grid" #+ rows iob b 0
|
||||
]]
|
||||
cont <- getElementById w "cont"
|
||||
let cont' = return $ fromJust cont
|
||||
cont' #+ [mkElement "table" # set UI.id_ "table" #+ rows iob b 0]
|
||||
|
||||
delete cont'
|
||||
delete table'
|
||||
|
||||
return cell
|
Loading…
Reference in New Issue