This repository has been archived by the owner on Jan 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmandelbrot_enhanced-nojit.html
155 lines (152 loc) · 6.32 KB
/
mandelbrot_enhanced-nojit.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<html>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<meta charset="utf-8">
<title>PyPy.js no-JIT - enhanced Mandelbrot</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
<style>
noscript {
color: #f00;
}
pre {
width: 100%;
height: 20%;
margin: 1em;
padding: 1em;
border: 5px solid #ddd;
overflow: auto;
}
#mandelbrot {
display:block;
border: 1px solid #000;
margin: 0 auto;
}
.after_load {
display:none;
}
.move_buttons {
text-align: center;
vertical-align: middle;
display: block;
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body>
<div class='container'>
<div class="row">
<div class="col-sm-12">
<h1>PyPy.js no-JIT - enhanced Mandelbrot</h1>
<a href="https://github.com/jedie/pypyjs-examples"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/e7bbb0521b397edbd5fe43e7f760759336b5e05f/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png"></a>
<noscript><h3>Please enable JavaScript for using PyPy.js</h3></noscript>
</div>
</div>
<div class="row after_load">
<div class="col-sm-2 move_buttons">
<button type="button" class="change_mandelbrot btn btn-default" id="move_top">↑</button><br />
<button type="button" class="change_mandelbrot btn btn-default" id="move_left">←</button>
<button type="button" class="change_mandelbrot btn btn-default" id="move_right">→</button><br />
<button id="zoom_out" class="change_mandelbrot btn btn-default">-</button>
<button type="button" class="change_mandelbrot btn btn-default" id="move_bottom">↓</button>
<button id="zoom_in" class="change_mandelbrot btn btn-default">+</button>
</div>
<div class="col-sm-10">
<canvas id="mandelbrot"></canvas>
</div>
</div>
<div class="row after_load">
<div class="col-sm-12">
<div class="progress">
<div class="progress-bar progress-bar-info progress-bar-striped" id="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">
init...
</div>
</div>
</div>
</div>
<div class="row after_load">
<div class="col-sm-12">
<form class="form-inline" id="data_form" role="form" action="">
<div class="input-group input-group-sm">
<label for="iterations">iterations:</label>
<input type="number" id="iterations" min="1" max="400" step="1" value="40">
<button id="pause" class="btn btn-default">pause</button>
<button id="update" class="btn btn-default">update</button>
</div>
</div>
</form>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<pre id="output"></pre>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<p>
PyPy.js is an experiment in building a fast and compliant python environment for the web.
<br/>
It uses the <a href="http://pypy.org/">PyPy</a> python interpreter, compiled for the web via
<a href="http://emscripten.org">emscripten</a>, with a custom JIT backend that emits <a href="http://asmjs.org">asm.js</a>
code at runtime.
</p>
</div>
</div>
</div>
<script src="pypyjs-release-nojit/lib/Promise.min.js" type="text/javascript" charset="utf-8" onerror="JavaScript:alert('Error loading file ['+this.src+'] !');"></script>
<script src="pypyjs-release-nojit/lib/FunctionPromise.js" type="text/javascript" charset="utf-8" onerror="JavaScript:alert('Error loading file ['+this.src+'] !');"></script>
<script src="pypyjs-release-nojit/lib/pypyjs.js" type="text/javascript" charset="utf-8" onerror="JavaScript:alert('Error loading file ['+this.src+'] !');"></script>
<script src="https://code.jquery.com/jquery-1.12.4.min.js" onerror="JavaScript:alert('Error loading file ['+this.src+'] !');"></script>
<script type="text/javascript" charset="utf-8">
try {
jQuery(document);
} catch (e) {
alert("Error, jQuery JS not loaded!\n Original error was:" + e);
}
function console_exec(code) {
pypyjs.exec(code).then(function() {
console.log("OK");
}, function (err) {
// err is an instance of PyPyJS.Error
console.log("ERROR: "+err.name+": "+err.message+"!)");
pypyjs.stderr(err.trace); // the human-readable traceback, as a string
});
}
$(document).ready(function() {
$("form").submit(function() {
// never "submit" the actions-form
return false;
});
out = $("#output");
pypyjs.stdout = pypyjs.stderr = function(data) {
out.append(data);
out.scrollTop(out.prop("scrollHeight")); // auto scroll down
}
pypyjs.stdout.reset = pypyjs.stderr.reset = function(data) {
out.empty();
}
pypyjs.stdout("loading PyPy.js...");
var pseudo_status = setInterval(function(){ pypyjs.stdout("."); }, 500);
pypyjs.ready().then(function() {
clearInterval(pseudo_status);
pypyjs.stdout.reset();
var py_filename="mandelbrot_enhanced.py";
pypyjs.stdout("request '" + py_filename + "'...");
$.get( py_filename, function( data ) {
$(".after_load").slideDown("slow");
pypyjs.stdout("exec...");
console_exec( data );
clearInterval(pseudo_status);
pypyjs.stdout("OK\n");
}).fail(function() {
clearInterval(pseudo_status);
pypyjs.stderr("error!");
});
});
});
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</body>
</html>