Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: fc9a7b198f
Fetching contributors…

Cannot retrieve contributors at this time

45 lines (42 sloc) 1.853 kB
<!doctype html>
<html>
<head>
<title>Fibonacci Demo</title>
<link href="css/bootstrap.min.css" rel="stylesheet" >
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/libjs.O2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var fibSrc = "function fibonacci(n) {" +
"if (n==0 || n==1) {" +
" return n;" +
" }" +
" var prev2 = 0, prev1 = 1, fib = 1, i;" +
" for (i=2; i<=n; i++) {" +
" fib = prev1 + prev2;" +
" prev2 = prev1;" +
" prev1 = fib;" +
" }" +
" return fib;" +
" }";
var jsObjs = JSJS.Init();
JSJS.EvaluateScript(jsObjs.cx, jsObjs.glob, fibSrc);
$("#calcjsjs").click(function() {
var iternum = parseInt($('#iteration_num').val());
var result = JSJS.CallFunctionName(jsObjs.cx, jsObjs.glob, "fibonacci", [JSJS.Types.i32], [iternum], JSJS.Types.i32);
$('code').text(result);
});
});
</script>
</head>
<body>
<div class="container" style="width: 100%; text-align: center;">
<form class="form-inline" style="text-align: center; width: 100%; margin-top: 5px; line-height: 30px;">
<label style="line-height: 30px; font-size: 26px;" class="control-label" for="iteration_num">Fibonacci Iteration Number:</label>
<input style="height: 30px; font-size: 26px;" type="text" class="input-large" id="iteration_num" value="10">
<button type="button" id="calcjsjs" class="btn btn-large btn-primary">Calculate</button>
</form>
<code style="line-height: 30px; font-size: 26px;"></code>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.