working on javascript injection

This commit is contained in:
Danny Yoo 2011-06-23 13:45:59 -04:00
parent a90cebd373
commit cacf38d5f8
3 changed files with 50 additions and 3 deletions

View File

@ -1230,7 +1230,10 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
// Extensions. A small experiment.
// Javascript-specific extensions. A small experiment.
installPrimitiveProcedure(
'viewport-width',
0,

View File

@ -6,9 +6,23 @@
racket/sandbox
(for-label racket/base)
racket/runtime-path
"scribble-helpers.rkt"
"../js-assembler/get-js-vm-implemented-primitives.rkt")
@inject-javascript|{
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-24146890-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
}|
@(define-runtime-path whalesong-path "..")
@ -26,6 +40,14 @@
@author+email["Danny Yoo" "dyoo@cs.wpi.edu"]
@centered{@smaller{Source code can be found at:
@url{https://github.com/dyoo/whalesong}. The latest version of this
document lives in @url{http://hashcollision.org/whalesong}.}}
@;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@; Warning Will Robinson, Warning!
@;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -35,6 +57,8 @@
@;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@section{Introduction}
@;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -442,7 +466,7 @@ time of this writing, it does NOT check for cycles.
@subsection{Vectors}
Vectors can be constructed with @{plt.runtime.makeVector(x ...)}, which takes
Vectors can be constructed with @tt{plt.runtime.makeVector(x ...)}, which takes
in any number of arguments. They can be tested with @tt{plt.runtime.isVector},
and support the following methods and attributes:
@itemlist[

View File

@ -0,0 +1,20 @@
#lang racket/base
(provide inject-javascript)
(require scribble/core
scribble/html-properties
scriblib/render-cond)
;; Adds JavaScript if we're rendering in HTML.
(define (inject-javascript . body)
(cond-element
[latex ""]
[html (make-element (make-style #f (list (make-script-property "text/javascript"
body)))
'())]
[text ""]))
;;(define (google-analytics)
;; (make-tag