Skip to content

Commit bf4a363

Browse files
committed
Address browser change in use of prompt()
1 parent d319db0 commit bf4a363

23 files changed

+71
-44
lines changed

GlowScriptOfffline3.2.zip

6.33 MB
Binary file not shown.

GlowScriptOffline/glowscript_libraries/RScompiler.3.1.min.js renamed to GlowScriptOffline/glowscript_libraries/RScompiler.3.2.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GlowScriptOffline/glowscript_libraries/compiler.3.1.min.js

-3
This file was deleted.

GlowScriptOffline/glowscript_libraries/compiler.3.2.min.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GlowScriptOffline/glowscript_libraries/glow.3.1.min.js renamed to GlowScriptOffline/glowscript_libraries/glow.3.2.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GlowScriptOffline/glowscript_libraries/symbols.3.2.min.js

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

GlowScriptOffline3.1.zip

-2 Bytes
Binary file not shown.

build_original.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
shader_file = "\n".join(shader_file)
2828
open("lib/glow/shaders.gen.js", "wb").write(shader_file)
2929

30-
version = "3.1"
30+
version = "3.2"
3131
# TODO: Extract this information from run.js
3232

3333
glowscript_libraries = {

docs/MakingNewVersion.txt

+8-16
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,19 @@ for example, GlowScript version 2.2 uses the same verdir value as 2.1 for jquery
5050
In untrusted/run.js, update choice of jquery library.
5151
Add to css/redmond a folder with the new name if necessary (sometimes no change is needed)
5252

53+
In ide/templates/index.html change "V e r s i o n X.Y" appropriately, and at the end of
54+
the file update the package/symbols version.
55+
56+
There is a jquery version reference in untrusted/run.html.
57+
5358
Modify build_original.py and lib/glow/property.js to have version = "0.4" and
54-
run it to create the final packages for 0.4.
55-
Then change build_original.py and lib/glow/property.js to have version = "0.5dev" and save build_original.py,
56-
so that the 0.4 package doesn't get overwritten by accident.
59+
run it to create the final packages for 0.4.
60+
since the IDE doesn't yet dynamically load symbols based on the version header.
5761

5862
There is a Glowscript program in build-tools/Symbols.js which you need to copy into (presumably local)
5963
glowscript and run to compile the symbols.
6064
You have to copy and paste the results into the appropriate file (package/symbols.X.Y.min.js).
61-
You also have to make a change at the end of ide/templates/index.html to point to the new Symbols file,
62-
since the IDE doesn't yet dynamically load symbols based on the version header.
63-
64-
Also change "G l o w S c r i p t X.Y" appropriately in ide/index.html.
65-
66-
There is a jquery version reference in untrusted/run.html.
67-
68-
There is a reference to version number in ide/api.py upgradeProgram().
69-
Not clear that this is ever used.
65+
You also have to make a change at the end of ide/templates/index.html to point to the new Symbols file.
7066

7167
At some point hopefully the build process will be more automated
7268
(using node to run this and other javascript parts locally).
@@ -95,10 +91,6 @@ If okay, go to https://console.cloud.google.com/appengine/versions?project=glows
9591
but this is no longer relevant; exported files now reference glowscript.org.
9692
*********************************************************************************************
9793

98-
Note that at this point property.js should have version 0.5dev.
99-
100-
If using the graphical Google App Engine launcher, click "Deploy" to upload the new version.
101-
10294
After July 30, 2020, the graphical Google App Engine launcher will not work, and one must
10395
use the gcloud machinery in a terminal. See www.glowscript.org/docs/GlowScriptDocs/local.html
10496
for instructions on installing gcloud. To deploy the new version, in a terminal cd to the

ide/ide.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ $(function () {
7272
}
7373
}
7474

75-
parseVersionHeader.defaultVersion = "3.1"
75+
parseVersionHeader.defaultVersion = "3.2"
7676
parseVersionHeader.defaultHeader = "GlowScript " + parseVersionHeader.defaultVersion+' VPython'
7777
parseVersionHeader.errorMessage = "GlowScript " + parseVersionHeader.defaultVersion
7878
// Map each version that can be loaded to a packaged version (usually itself), or "unpackaged" if it is the current development version
@@ -97,6 +97,7 @@ $(function () {
9797
"2.9": "2.9",
9898
"3.0": "3.0",
9999
"3.1": "3.1",
100+
"3.2": "3.2",
100101
"0.4dev" : "0.4",
101102
"0.5dev" : "0.5",
102103
"0.6dev" : "0.6",
@@ -115,7 +116,8 @@ $(function () {
115116
"2.9dev" : "2.9",
116117
"3.0dev" : "3.0",
117118
"3.1dev" : "3.1",
118-
"3.2dev" : "unpackaged"
119+
"3.1dev" : "3.2",
120+
"3.3dev" : "unpackaged"
119121
}
120122

121123
/******** Functions to talk to the API on the server ***********/

ide/templates/index.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
<div class="header">
4242
<div class="headerInner">
43-
<h2>glowscript.org</h2>
43+
<h2>VPython in the browser</h2>
4444
</div>
4545
</div>
4646

@@ -52,9 +52,9 @@ <h2>glowscript.org</h2>
5252

5353
<img src="../docs/VPythonDocs/images/cover.jpg" width="226" height="240" class="right">
5454

55-
<p>GlowScript is an easy-to-use, powerful environment for creating 3D animations and publishing them on the web.
56-
Here at glowscript.org, you can write and run GlowScript programs right in your browser, store them in the
57-
cloud for free, and easily share them with others.</p>
55+
<p>VPython is an easy-to-use, powerful environment for creating 3D animations.
56+
Here at glowscript.org, you can write and run VPython programs right in your browser, store them in the
57+
cloud for free, and easily share them with others. You can also use VPython with installed Python: see <a href=https:vpython.org>vpython.org</a>.</p>
5858

5959
</div>
6060

@@ -75,7 +75,7 @@ <h2>glowscript.org</h2>
7575

7676
<div id="footerWrap">
7777
<div id="footerInner">
78-
<h2>G l o w S c r i p t&nbsp;&nbsp; 3.0</h2>
78+
<h2>V e r s i o n&nbsp;&nbsp; 3.2</h2>
7979
<a href="/#/user/GlowScriptDemos/folder/Examples/" target="_blank">Example programs</a> |
8080
<a href="https://groups.google.com/forum/?fromgroups#!forum/glowscript-users" target="_blank">Forum</a>
8181
</div>
@@ -328,7 +328,7 @@ <h2>G l o w S c r i p t&nbsp;&nbsp; 3.0</h2>
328328
<script type="text/javascript" language="javascript" src="lib/editor.js"></script>
329329
<script type="text/javascript" language="javascript" src="lib/ace/mode-javascript.js"></script>
330330
<script type="text/javascript" language="javascript" src="lib/ace/mode-python.js"></script>
331-
<script type="text/javascript" language="javascript" src="package/symbols.3.1.min.js"></script>
331+
<script type="text/javascript" language="javascript" src="package/symbols.3.2.min.js"></script>
332332
<script type="text/javascript" language="javascript" src="ide.js"></script>
333333

334334
</body>

lib/compiling/GScompiler.js

+19-2
Original file line numberDiff line numberDiff line change
@@ -1196,12 +1196,29 @@ where compile() was called, in untrusted/run.js.
11961196
program = program.replace(new RegExp(string_insert, 'g'), '')
11971197

11981198
if (loadfonts) { // if text object is in user program
1199-
var s = "scene = canvas();\n"
1200-
var sc = program.indexOf(s) + s.length
1199+
let s = "scene = canvas();\n"
1200+
let sc = program.indexOf(s) + s.length
12011201
s = " fontloading();\n await waitforfonts();\n" // wait for font files
12021202
program = program.slice(0,sc)+s+program.slice(sc,program.length)
12031203
}
12041204

1205+
// October 2021: Safari gives a CORS error when attempting to call input() in primitives.js,
1206+
// and it looks like Chrome will also start doing this. For now (version 3.1), we leave the
1207+
// copy of input() in primitives.js, to cater to existing exported programs that call input(),
1208+
// though those exported programs will eventually break, lacking the copy we now insert into
1209+
// exported code.
1210+
if (program.indexOf('input') >= 0) { // if user code invokes input(), insert the function:
1211+
let s = "scene = canvas();\n"
1212+
let sc = program.indexOf(s) + s.length
1213+
s = "\n function input(arg) {\n"
1214+
s += " arg = arg || {}\n"
1215+
s += " if (arg.prompt !== undefined && arg.prompt != '') return prompt(arg.prompt)\n"
1216+
s += " else if (typeof arg === 'string') return prompt(arg)\n"
1217+
s += " else return prompt()\n"
1218+
s += " }\n"
1219+
program = program.slice(0,sc)+s+program.slice(sc,program.length)
1220+
}
1221+
12051222
// var p = program.split('\n')
12061223
// for (var i=0; i<p.length; i++) console.log(i, p[i])
12071224
// console.log('fcts', fcts)

lib/glow/primitives.js

-8
Original file line numberDiff line numberDiff line change
@@ -2857,13 +2857,6 @@
28572857
}
28582858
return cwtext
28592859
}
2860-
2861-
function input(arg) { // mimics Python input function
2862-
arg = arg || {}
2863-
if (arg.prompt !== undefined && arg.prompt != '') return prompt(arg.prompt)
2864-
else if (toType(arg) == 'string' ) return prompt(arg)
2865-
else return prompt()
2866-
}
28672860

28682861
var mathfunctions = ["e", "E", "abs", "sqrt", "sin", "cos", "tan", "asin", "acos", "atan", "atan2",
28692862
"exp", "log", "pow", "pi", "ceil", "floor", "round", "random","factorial", "combin", "radians", "degrees"]
@@ -3277,7 +3270,6 @@
32773270
button: button,
32783271
slider: slider,
32793272
menu: menu,
3280-
input: input,
32813273
}
32823274

32833275
Export(exports)

lib/glow/property.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
;(function () {
22
"use strict";
33

4-
var glowscript = { version: "3.1" }
4+
var glowscript = { version: "3.2" }
55

66
// GlowScript uses lots of javascript properties (Object.defineProperty) with getters and setters
77
// This is an attempt to create a more declarative syntax for declaring an object with lots of properties

package/RScompiler.3.1.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package/RScompiler.3.2.min.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package/RSrun.3.2.min.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package/compiler.3.1.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package/compiler.3.2.min.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package/glow.3.1.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package/glow.3.2.min.js

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package/symbols.3.2.min.js

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)