From cacf38d5f8563486688cd5c3397d367c3af1735e Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Thu, 23 Jun 2011 13:45:59 -0400 Subject: [PATCH] working on javascript injection --- js-assembler/runtime-src/runtime.js | 5 ++++- scribblings/manual.scrbl | 28 ++++++++++++++++++++++++++-- scribblings/scribble-helpers.rkt | 20 ++++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 scribblings/scribble-helpers.rkt diff --git a/js-assembler/runtime-src/runtime.js b/js-assembler/runtime-src/runtime.js index 87b9ed8..2129c35 100644 --- a/js-assembler/runtime-src/runtime.js +++ b/js-assembler/runtime-src/runtime.js @@ -1230,7 +1230,10 @@ if(this['plt'] === undefined) { this['plt'] = {}; } - // Extensions. A small experiment. + + + + // Javascript-specific extensions. A small experiment. installPrimitiveProcedure( 'viewport-width', 0, diff --git a/scribblings/manual.scrbl b/scribblings/manual.scrbl index 1e20a26..f528728 100644 --- a/scribblings/manual.scrbl +++ b/scribblings/manual.scrbl @@ -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[ diff --git a/scribblings/scribble-helpers.rkt b/scribblings/scribble-helpers.rkt new file mode 100644 index 0000000..2f9555a --- /dev/null +++ b/scribblings/scribble-helpers.rkt @@ -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 \ No newline at end of file