Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit c1df9304 authored by Marc Coiffier's avatar Marc Coiffier
Browse files

Notify the user of changes in the console's state when it becomes active (in WiQEE)

parent 49070244
......@@ -131,27 +131,37 @@ main = JS.concurrent $ void $ do
JS.appendChild rootTitle closeBtn
JS.appendChild console root'
JS.setChildren root' (rootTitle:rootChildren)
withSubElems root ["capricon-trigger"] $ \[trig] -> void $ do
withSubElems root' ["capricon-input"] $ \[inp] -> void $ do
withSubElems root' ["capricon-input"] $ \[inpCons] -> void $ do
let toggleActive = do
JS.toggleClass root' "active"
JS.focus inp
JS.focus inpCons
JS.onEvent closeBtn JS.Click (const toggleActive)
JS.onEvent trig JS.Click $ \_ -> toggleActive
withSubElems root' ["capricon-input","capricon-output"] $ \[inp,out] -> do
JS.withElemsQS root' ".capricon-context" $ \case
[con] -> do
context <- JS.getProp con "textContent"
let text = pref+" "+context
(state',_) <- runWordsState (stringWords text) state
JS.onEvent inp JS.KeyPress $ \case
JS.KeyData 13 False False False False -> do
Just v <- JS.getValue inp
(_,x) <- runWordsState (stringWords v) state'
JS.setProp out "textContent" (toString x)
_ -> unit
next state' ""
withSubElems root ["capricon-input"] $ \[inpMain] -> do
withSubElems root' ["capricon-input","capricon-output"] $ \[inp,out] -> do
JS.withElemsQS root' ".capricon-context" $ \case
[con] -> do
context <- JS.getProp con "textContent"
let text = pref+" "+context
(state',_) <- runWordsState (stringWords text) state
let onEnter x = \case
JS.KeyData 13 False False False False -> x
_ -> return ()
runCode inp = do
Just v <- JS.getValue inp
(_,x) <- runWordsState (stringWords v) state'
JS.setProp out "textContent" (toString x)
return v
JS.onEvent inp JS.KeyPress $ onEnter $ void $ runCode inp
JS.onEvent inpMain JS.KeyPress $ onEnter $ do
v <- runCode inpMain
JS.setClass root' "active" True
JS.focus inp
JS.setProp inp "value" v
next state' ""
cloneNode :: MonadIO m => JS.Elem -> m JS.Elem
cloneNode x = liftIO $ JS.ffi "(function (n) { return n.cloneNode(true); })" x
......@@ -514,5 +514,5 @@ outputComment c = (runExtraState $ do outputText =~ (\o t -> o (commentText+t)))
+ hide +"\"></span><span class=\"capricon-reveal\" data-linecount=\""
+ fromString (show nlines)+"\">"
wrapEnd = "</span></label>"
userInput = "<div class=\"user-input\"><button class=\"capricon-trigger\">Open/Close console</button><span class=\"capricon-input-prefix\">Evaluate in this context (press Enter to run):</span><input type=\"text\" class=\"capricon-input\" /><pre class=\"capricon-output\"></pre></div>"
userInput = "<div class=\"user-input\"><button class=\"capricon-trigger\">Try It</button><label class=\"capricon-input-prefix\">&gt;&nbsp;<input type=\"text\" class=\"capricon-input\" /></label><pre class=\"capricon-output\"></pre></div>"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment