-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathindex.html
More file actions
255 lines (213 loc) · 8.31 KB
/
index.html
File metadata and controls
255 lines (213 loc) · 8.31 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
{% extends "base.html" %}
{% set path = "repl/" %}
{% set query = "?toolbar=1&kernel=python" %}
{% set preinitcode = "\n".join([
"%pip install sympy==" ~ sympy_version
]) %}
{% set initcode = "\n".join([
"from sympy import *",
"init_printing()",
"x, y, z, t = symbols('x y z t')",
"k, m, n = symbols('k m n', integer=True)",
"f, g, h = symbols('f g h', cls=Function)"
]) %}
{% block title %}SymPy Live Shell{% endblock %}
{% block titleh1 %}SymPy Live Shell{% endblock %}
{% block extrahead %}
<!-- MathJax 3 -->
<script>window.MathJax = {"tex": {"inlineMath": [["\\(", "\\)"]], "displayMath": [["\\[", "\\]"]]}, "options": {"processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script>
<script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<!-- handler for evaluate commands -->
<script>
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
}
function statementsToCodes(text) {
var parts = text
.replace('\r\n', '\n')
.replace('\r', '\n')
.split(/#--[^\n]*/);
var codes = [];
for (var i = 0; i < parts.length; i++) {
var statement = parts[i].trim();
if (statement) {
codes.push(statement);
}
}
return codes;
}
document.addEventListener('DOMContentLoaded', function() {
// default iframe src with SymPy initcode
// see https://jupyterlite.readthedocs.io/en/stable/quickstart/embed-repl.html#configuration for URL customisation
var iframe_src = "/{{ path }}{{ query|safe }}&code={{ preinitcode|urlencode }}&code={{ initcode|urlencode }}";
// check if we have additional statements to evaluate in the query string
var statements = getURLParameter('evaluate');
if (statements) {
var codes = statementsToCodes(statements);
console.log("Additional code to evaluate:", codes);
for (var i = 0; i < codes.length; i++) {
iframe_src += '&code=' + encodeURIComponent(codes[i]);
}
}
// Add theme parameter based on initial theme
iframe_src = addThemeToUrl(iframe_src);
var iframe = document.getElementById('live-iframe');
var loader = document.getElementById('repl-loader');
var revealTriggered = false;
var fallbackTimer = null;
if (iframe) {
iframe.style.visibility = 'hidden';
iframe.setAttribute('aria-hidden', 'true');
}
function revealIframe() {
if (revealTriggered) {
return;
}
revealTriggered = true;
window.removeEventListener('message', handleBridgeReady);
if (fallbackTimer) {
clearTimeout(fallbackTimer);
}
// Allow the iframe to fade in only after the bridge confirms theme readiness.
window.setTimeout(function() {
if (loader) loader.classList.add('is-hidden');
if (iframe) {
iframe.classList.add('is-ready');
iframe.style.visibility = 'visible';
iframe.setAttribute('aria-hidden', 'false');
}
}, 150);
}
function handleBridgeReady(event) {
if (!event.data || event.data.type !== '_JUPYTER_IFRAME_COMMANDS_LOADED') {
return;
}
revealIframe();
}
window.addEventListener('message', handleBridgeReady);
if (iframe) {
iframe.addEventListener('load', function() {
if (revealTriggered) {
return;
}
if (fallbackTimer) {
clearTimeout(fallbackTimer);
}
fallbackTimer = window.setTimeout(revealIframe, 3500);
});
iframe.src = iframe_src;
}
});
function addThemeToUrl(url) {
var mode = localStorage.getItem("theme-mode") || "light";
var effective = mode === "auto" ?
(window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light") :
mode;
if (effective === "dark") {
return url + "&theme=" + encodeURIComponent("JupyterLab Dark");
}
return url;
}
</script>
<!-- # jupyter-config-data
The JSON in `jupyter-lite.json` is the last that will be loaded by most
child `index.html` pages, and every field can be overridden.
See the recognized schema as described in the documentation: -->
<script id="jupyter-config-data" type="application/json" data-jupyter-lite-root=".">
{}
</script>
{% endblock %}
{% block content %}
<div class="title-bar">
<h1 class="title-text">SymPy Live</h1>
<button class="theme-toggle" aria-label="Toggle theme" title="Toggle theme">
<i class="fa-solid" aria-hidden="true"></i>
<span class="sr-only">Toggle theme</span>
</button>
</div>
<div class="repl-frame-wrapper">
<div id="repl-loader" aria-hidden="true">
<div class="loader-spinner" aria-hidden="true"></div>
<span class="loader-text">Loading SymPy Live…</span>
</div>
<iframe
id="live-iframe"
name="sympy-live-repl"
title="SymPy Live"
src=""
width="100%"
height="500px"
loading="lazy"
>
</iframe>
</div>
<div id="usage" class="sidebar_card">
<h2>Instructions</h2>
<div class="content">
<p>
{% trans %}Press ENTER to run the code or use the Run button in the toolbar.{% endtrans %}
</p>
<p id="loading_message">
{% trans %}Note it can take up to 30 seconds before the shell finishes loading and is ready to run commands.{% endtrans %}
</p>
</div>
</div>
{% endblock %}
{% block sidebar %}
<div id="about_shell" class="sidebar_card">
<h2>{% trans %}About this page{% endtrans %}</h2>
<p>
{% trans %}SymPy Live shell allows you to use SymPy in the browser without the need to install anything on your computer.{% endtrans %}
</p>
<p>
{% trans %}The following commands are executed by default:{% endtrans %}
<pre>
[1]: from sympy import *
x, y, z, t = symbols('x y z t')
k, m, n = symbols('k m n', integer=True)
f, g, h = symbols('f g h', cls=Function)
</pre>
</p>
<p>
{% trans %}SymPy Live shell is powered by{% endtrans %} <a href="https://jupyterlite.readthedocs.io/en/stable/">JupyterLite</a>.
{% trans %}It can take up to 30 seconds before the shell code and libraries load completely and become available for using interactively.{% endtrans %}
</p>
</div>
<div id="examples" class="sidebar_card">
<h2>Example session</h2>
<div class="content">
<p>
<code>[2]: expr = (x + y)**3</code>
</p>
<p>
<code>[3]: expand(expr)</code><br>
<code>[3]: </code>\(x^{3} + 3 x^{2} y + 3 x y^{2} + y^{3}\)<br>
</p>
<p>
<code>[4]: sin(x).series(x, 0, 7)</code><br>
<code>[4]: </code>\(x - \frac{x^{3}}{6} + \frac{x^{5}}{120} + O\left(x^{7}\right)\)<br>
</p>
<p>
{% trans %}Read the tutorial in the SymPy docs to learn more about SymPy{% endtrans %}:
<a href="https://docs.sympy.org/tutorial/">{% trans %}SymPy Tutorial{% endtrans %}</a>.
</p>
</div>
</div>
<div id="quick_links" class="sidebar_card">
<h2>{% trans %}Quick Links{% endtrans %}</h2>
<ul>
<li><a href="https://www.sympy.org/">{% trans %}Website{% endtrans %}</a></li>
<li><a href="https://docs.sympy.org/">{% trans %}Docs{% endtrans %}</a></li>
<li><a href="https://docs.sympy.org/tutorial/">{% trans %}Tutorial{% endtrans %}</a></li>
<li><a href="https://github.com/sympy/sympy/releases">{% trans %}Download{% endtrans %}</a></li>
<li><a href="https://groups.google.com/group/sympy">{% trans %}Mailing list{% endtrans %}</a></li>
<li><a href="https://github.com/sympy/sympy">{% trans %}Source code{% endtrans %}</a></li>
<li><a href="https://github.com/sympy/sympy/issues/">{% trans %}Issues tracker{% endtrans %}</a></li>
<li><a href="https://github.com/sympy/sympy/wiki">{% trans %}Wiki{% endtrans %}</a></li>
<li><a href="https://github.com/sympy/sympy/wiki/introduction-to-contributing">{% trans %}Introduction to contributing{% endtrans %}</a></li>
<li><a href="https://planet.sympy.org/">{% trans %}Planet SymPy{% endtrans %}</a></li>
<li><a href="https://gitter.im/sympy/sympy">{% trans %}Chat (Gitter){% endtrans %}</a></li>
<li><a href="http://colabti.org/irclogger/irclogger_logs/sympy">{% trans %}IRC channel logs{% endtrans %}</a></li>
</ul>
</div>
{% endblock %}