Skip to content

Commit

Permalink
add kees jsimport example... as an example :)
Browse files Browse the repository at this point in the history
git-svn-id: https://pyjamas.svn.sourceforge.net/svnroot/pyjamas/trunk@1194 7a2bd370-bda8-463c-979e-2900ccfb811e
  • Loading branch information
lkcl committed Aug 17, 2009
1 parent fa7c052 commit 5cf14fa
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions 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.
Expand Down
2 changes: 2 additions & 0 deletions examples/buildall.sh
Expand Up @@ -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)
Expand All @@ -40,3 +41,4 @@ fi
(cd xmldoc; ./build.sh $options)
(cd lightout; ./build.sh $options)
(cd employeeadmin; ./build.sh $options)

5 changes: 5 additions & 0 deletions examples/index.html
Expand Up @@ -114,6 +114,11 @@ <h2>jsobject</h2>
<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> |
Expand Down
7 changes: 7 additions & 0 deletions 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
4 changes: 4 additions & 0 deletions examples/jsimport/example.js
@@ -0,0 +1,4 @@
examplevar = 'Unaltered';
function get_examplevar( ) {
return examplevar;
}
26 changes: 26 additions & 0 deletions 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.