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.div #. "container" # set UI.id_ "cont" #+ [
|
||||||
UI.h1 #+ [string "Minesweeper"],
|
UI.h1 #+ [string "Minesweeper"],
|
||||||
UI.h4 #+ [string "Jack Harley jharley@tcd.ie"],
|
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
|
where
|
||||||
|
@ -44,22 +44,19 @@ setup w = void $ do
|
||||||
|
|
||||||
cell iob b (r,c) = do
|
cell iob b (r,c) = do
|
||||||
cell <- mkElement "td" #. (squareBgColour b (r,c) ++ " " ++ squareTextColour b (r,c))
|
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
|
on UI.click cell $ \_ -> do
|
||||||
liftIO $ modifyIORef' iob $ \oldB -> uncover oldB (r,c)
|
liftIO $ modifyIORef' iob $ \oldB -> uncover oldB (r,c)
|
||||||
b <- liftIO $ readIORef iob
|
b <- liftIO $ readIORef iob
|
||||||
|
|
||||||
cont <- getElementById w "cont"
|
table <- getElementById w "table"
|
||||||
let cont' = fromJust cont
|
let table' = fromJust table
|
||||||
|
|
||||||
getBody w #+ [
|
cont <- getElementById w "cont"
|
||||||
UI.div #. "container" # set UI.id_ "cont" # set children [] #+ [
|
let cont' = return $ fromJust cont
|
||||||
UI.h1 #+ [string "Minesweeper"],
|
cont' #+ [mkElement "table" # set UI.id_ "table" #+ rows iob b 0]
|
||||||
UI.h4 #+ [string "Jack Harley jharley@tcd.ie"],
|
|
||||||
mkElement "table" # set UI.id_ "grid" #+ rows iob b 0
|
|
||||||
]]
|
|
||||||
|
|
||||||
delete cont'
|
delete table'
|
||||||
|
|
||||||
return cell
|
return cell
|
Loading…
Reference in New Issue