15 Aug 2011 lkcl   » (Master)

pyjamas output in my own html file with jquery


I want to reuse my python modules on html/jquery web pages.

Therefore I need to call the generated js fucntions genrated with pyjamas from my own html file.

Which .js files should I link?
How can I call the functions?

Example python file functions.py:
def rmsToPeak( x ):
return x*1.41
def peakToRms( x ):
return x/1.41

Pyjamas output file functions.js:

/* start module: functions */Force
linebreak $pyjs.loaded_modules['functions'] = function (mod_name) {
if($pyjs.loaded_modules['functions'].was_initialized) return $pyjs.loaded_modules['functions'];
var $m = $pyjs.loaded_modules["functions"];
$m.repr = function() { return ""; };
$m.was_initialized = true;
if ((mod_name === null) || (typeof mod_name == 'undefined')) mod_name = 'functions';
$m.name = mod_name;

$m['rmsToPeak'] = function(x) {
var $mul2,$mul1;
return (typeof ($mul1=x)==typeof ($mul2=1.41) && typeof $mul1=='number'?
$m['rmsToPeak'].name = 'rmsToPeak';

$m['rmsToPeak'].bind_type = 0;
$m['rmsToPeak'].args = [null,null,['x']];
$m['peakToRms'] = function(x) {
var $div2,$div1;
return (typeof ($div1=x)==typeof ($div2=1.41) && typeof $div1=='number' && $div2 !== 0?
$m['peakToRms'].name = 'peakToRms';

$m['peakToRms'].bind_type = 0;
$m['peakToRms'].args = [null,null,['x']];
return this;
}; /* end functions */

/* end module: functions */

Syndicated 2011-08-15 17:58:35 from blog/lkcl

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!