#!/usr/bin/runhugs +l \begin{code} import IO import Xhtml1 import Random import Time import SWlib import CGI (cgiVars) main = withEucKrEnv $ do cgivars <-cgiVars s <- filecontent $ cgivars$$"book"++"/."++cgivars$$"fstch"++".list" t <- getClockTime >>= (\c -> return $ ctSec $ toUTCTime c ) let g = mkStdGen t let wordlist = fst $ random_shuffle (read s::[String]) g putStr $ "Content-type: text/html\n\n"++html (cgivars$$"book") wordlist html book words = xhtml1Doc Transitional "UTF-8" << thehtml << ( thehead ( thetitle << "Smart Word start" +++ meta "text/html charset=UTF-8" !["http-equiv"-="Content-type"]) +++ thebody!["onload"-="onload()"] << ( h1 << "Smart Word loading ..." +++ hr +++ script "text/javascript" << ( CDATA $ "\n" ) +++ form "sw.cgi" !["method"-="post","name"-="f"] << p << -- +++ form "sw.lhs" !["method"-="post","name"-="f"] << p << ( input!["type"-="hidden","name"-="answer","value"-=""] +++ input!["type"-="hidden","name"-="words", "value"-=(encodeDQ $ show $ words)] +++ input!["type"-="hidden","name"-="ans","value"-=""] +++ input!["type"-="hidden","name"-="book","value"-=book] +++ input!["type"-="submit","name"-="s","value"-="start"] ) ) ) \end{code}