cleaning up code

This commit is contained in:
Danny Yoo 2011-05-27 15:23:00 -04:00
parent 6028c19f80
commit 71d8854084

View File

@ -73,16 +73,7 @@
(define (package-standalone-xhtml source-code op) (define (package-standalone-xhtml source-code op)
(display *header* op) (display *header* op)
(display (quote-cdata (get-runtime)) op) (display (quote-cdata (get-runtime)) op)
(display (quote-cdata (get-code source-code)) op)
(let ([buffer (open-output-string)])
(package source-code
#:should-follow? (lambda (p) #t)
#:output-port buffer)
(display (quote-cdata (get-output-string buffer))
op))
;; FIXME: Finally, invoke the main module.
(display (quote-cdata *invoke-main-module-text*) op)
(display *footer* op)) (display *footer* op))
@ -97,22 +88,23 @@
<title>Example</title> <title>Example</title>
</head> </head>
<script> <script>
EOF EOF
) )
(define (get-code source-code)
(let ([buffer (open-output-string)])
(package source-code
#:should-follow? (lambda (p) #t)
#:output-port buffer)
(get-output-string buffer)))
(define *footer* (define *footer*
#<<EOF #<<EOF
</script>
<body onload='invokeMainModule()'>
</body>
</html>
EOF
)
<![CDATA[
(define *invoke-main-module-text*
#<<EOF
var invokeMainModule = function() { var invokeMainModule = function() {
var MACHINE = new plt.runtime.Machine(); var MACHINE = new plt.runtime.Machine();
invoke(MACHINE, invoke(MACHINE,
@ -136,5 +128,11 @@ var invokeMainModule = function() {
}, },
{}); {});
}; };
$(document).ready(invokeMainModule);
]]>
</script>
<body></body>
</html>
EOF EOF
) )