Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Adrian Jones <adrianj1998@hotmail.com>
- Loading branch information
Showing
14 changed files
with
1,332 additions
and
936 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,39 @@ | ||
<?php | ||
|
||
require_once(dirname(__FILE__) . '/j4p5/js.php'); | ||
|
||
require_once(dirname(__FILE__).'/j4p5/js.php'); | ||
class jasperJavascript extends JasperExp { | ||
|
||
|
||
class jasperJavascript extends JasperExp | ||
{ | ||
static $compiled = array(); | ||
|
||
function _setVar($name,$codename,$value) { | ||
|
||
js::define($codename ,array(),array('value'=>$value)); | ||
|
||
} | ||
|
||
|
||
function run($code) | ||
{ | ||
// echo $code .' - '; | ||
$code = trim($code); | ||
if (empty($code)) | ||
return $code; | ||
$code = $this->replaceVars($code); | ||
function _setVar($name, $codename, $value) { | ||
|
||
$code = 'var result = ( '.$code .');'; | ||
js::define($codename, array(), array('value' => $value)); | ||
} | ||
|
||
#-- Run the js code. | ||
function run($code) { | ||
$code = trim($code); | ||
if (empty($code)) | ||
return $code; | ||
$code = $this->replaceVars($code); | ||
$id = md5($code); | ||
$code = 'function func_' . $id . ' () { return (' . $code . '); }'; | ||
|
||
// -- compile script | ||
if (!self::$compiled[$id]) { | ||
js::run($code, JS_DIRECT, $id); | ||
self::$compiled[$id] = jsrt::$jsfunctions['func_' . $id]; | ||
} | ||
|
||
js::run($code); | ||
$func = self::$compiled[$id]; | ||
|
||
//-- Run the js code. | ||
|
||
$result = php_str(call_user_func($func)); | ||
// $result = php_str(jsrt::idv('result')); | ||
|
||
$result = php_str(jsrt::idv('result')); | ||
return $result; | ||
} | ||
|
||
return $result ; | ||
|
||
} | ||
|
||
} | ||
} | ||
|
||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.