Permalink
Browse files

add kees jsimport example... as an example :)

git-svn-id: https://pyjamas.svn.sourceforge.net/svnroot/pyjamas/trunk@1194 7a2bd370-bda8-463c-979e-2900ccfb811e
  • Loading branch information...
1 parent fa7c052 commit 5cf14fa2f304a382694bdeb61ae0bb6b8e38e915 lkcl committed Aug 17, 2009
Showing with 46 additions and 0 deletions.
  1. +2 −0 CHANGELOG
  2. +2 −0 examples/buildall.sh
  3. +5 −0 examples/index.html
  4. +7 −0 examples/jsimport/build.sh
  5. +4 −0 examples/jsimport/example.js
  6. +26 −0 examples/jsimport/examplejs.py
View
2 CHANGELOG
@@ -1,6 +1,8 @@
Changes made to Pyjamas since 0.5p1
-----------------------------------
+ * Added jsimport example (direct from kees's commit message :)
+
* Added __pyjamas__.jsimport(path, mode, location)
* remove dependency of pywin32 in pyjd MSHTML port.
View
2 examples/buildall.sh
@@ -30,6 +30,7 @@ fi
(cd gridedit; ./build.sh $options)
(cd infohierarchy; ./build.sh $options)
(cd jsobject; ./build.sh $options)
+(cd jsimport; ./build.sh $options)
(cd showcase; python compile.py $options)
(cd slideshow; ./build.sh $options)
(cd splitpanel; ./build.sh $options)
@@ -40,3 +41,4 @@ fi
(cd xmldoc; ./build.sh $options)
(cd lightout; ./build.sh $options)
(cd employeeadmin; ./build.sh $options)
+
View
5 examples/index.html
@@ -114,6 +114,11 @@
<a href="jsobject/output/TestDict.html">see demo2</a> |
<a href="jsobject/">source directory</a><p>
+<h2>jsimport</h2>
+<p>javascript import example<br />
+<a href="jsimport/output/examplejs.html">see demo</a> |
+<a href="jsimport/">source directory</a><p>
+
<h2>splitpanel</h2>
<p>splitpanel example<br />
<a href="splitpanel/output/SplitPanel.html">see demo</a> |
View
7 examples/jsimport/build.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+# you will need to read the top level README, and run boostrap.py
+# and buildout in order to make pyjsbuild
+
+options="$*"
+#if [ -z $options ] ; then options="-O";fi
+../../bin/pyjsbuild --print-statements $options examplejs
View
4 examples/jsimport/example.js
@@ -0,0 +1,4 @@
+examplevar = 'Unaltered';
+function get_examplevar( ) {
+ return examplevar;
+}
View
26 examples/jsimport/examplejs.py
@@ -0,0 +1,26 @@
+# WARNING: the use of javascript pretty much trashes all chance of using
+# pyjamas-desktop. give serious consideration to doing something OTHER
+# than including random bits of javascript off the internet in a pyjamas
+# application. the larger the random bit of javascript, the more chance
+# there is that it will interact in some horrendous way with the pyjamas
+# infrastructure.
+#
+# if you ABSOLUTELY MUST use javascript, here's how to do it.
+#
+
+from pyjamas import log
+
+# this simply tells the compiler that the two names are to be dropped
+# into the javascript global namespace
+from __javascript__ import examplevar, get_examplevar
+
+# the default behaviour of jsimport is to include the javascript file
+# "inline" - unmodified - direct into the compiler output
+from __pyjamas__ import jsimport
+
+jsimport("example.js")
+
+log.writebr(examplevar)
+examplevar = 'Altered'
+log.writebr( get_examplevar() )
+

0 comments on commit 5cf14fa

Please sign in to comment.