Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
89d1aafd
Commit
89d1aafd
authored
Apr 28, 2015
by
Neil Fraser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update demos to use non-deprecated workspace calls.
parent
c014799d
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
47 additions
and
32 deletions
+47
-32
appengine/README.txt
appengine/README.txt
+5
-2
appengine/app.yaml
appengine/app.yaml
+3
-2
demos/code/code.js
demos/code/code.js
+1
-1
demos/generator/index.html
demos/generator/index.html
+1
-1
demos/graph/index.html
demos/graph/index.html
+11
-5
demos/interpreter/index.html
demos/interpreter/index.html
+6
-6
demos/maxBlocks/index.html
demos/maxBlocks/index.html
+3
-4
demos/plane/plane.js
demos/plane/plane.js
+15
-9
demos/rtl/index.html
demos/rtl/index.html
+2
-2
No files found.
appengine/README.txt
View file @
89d1aafd
...
...
@@ -32,8 +32,11 @@ blockly/
|- javascript_compressed.js
`- python_compressed.js
Instructions for fetching
Closure
may be found here:
Instructions for fetching
the optional Closure library
may be found here:
https://developers.google.com/blockly/hacking/closure
Go to https://appengine.google.com/ and create your App Engine application.
Modify the 'application' name of app.yaml to your App Engine application name.
Finally, upload this directory structure to your App Engine account,
wait a minute, then go to http://YOURNAME.appspot.com/
wait a minute, then go to http://YOUR
APP
NAME.appspot.com/
appengine/app.yaml
View file @
89d1aafd
...
...
@@ -74,8 +74,9 @@ skip_files:
-
^(.*/)?\..*$
# Custom skip patterns.
-
^static/appengine/.*$
-
^static/apps/json/.*$
-
^static/apps/_soy/.+\.jar$
-
^static/demos/plane/soy/.+\.jar$
-
^static/demos/plane/template.soy$
-
^static/demos/plane/xlf/.*$
-
^static/i18n/.*$
-
^static/msg/json/.*$
-
^.+\.soy$
demos/code/code.js
View file @
89d1aafd
...
...
@@ -483,7 +483,7 @@ Code.runJS = function() {
throw
MSG
[
'
timeout
'
];
}
};
var
code
=
Blockly
.
JavaScript
.
workspaceToCode
();
var
code
=
Blockly
.
JavaScript
.
workspaceToCode
(
Code
.
workspace
);
Blockly
.
JavaScript
.
INFINITE_LOOP_TRAP
=
null
;
try
{
eval
(
code
);
...
...
demos/generator/index.html
View file @
89d1aafd
...
...
@@ -115,7 +115,7 @@
<script>
var
workspace
=
Blockly
.
inject
(
document
.
getElementById
(
'
blocklyDiv
'
),
{
toolbox
:
document
.
getElementById
(
'
toolbox
'
)});
Blockly
.
Xml
.
domToWorkspace
(
Blockly
.
mainW
orkspace
,
Blockly
.
Xml
.
domToWorkspace
(
w
orkspace
,
document
.
getElementById
(
'
startBlocks
'
));
function
showCode
()
{
...
...
demos/graph/index.html
View file @
89d1aafd
...
...
@@ -174,6 +174,12 @@ Blockly.JavaScript['graph_set_y'] = function(block) {
*/
var
Graph
=
{};
/**
* Main Blockly workspace.
* @type Blockly.WorkspaceSvg
*/
Graph
.
workspace
=
null
;
/**
* Cached copy of the function string.
* @type ?string
...
...
@@ -198,7 +204,7 @@ Graph.options_ = {
* https://developers.google.com/chart/interactive/docs/gallery/linechart
*/
Graph
.
drawVisualization
=
function
()
{
var
formula
=
Blockly
.
JavaScript
.
workspaceToCode
();
var
formula
=
Blockly
.
JavaScript
.
workspaceToCode
(
Graph
.
workspace
);
if
(
formula
===
Graph
.
oldFormula_
)
{
// No change in the formula, don't recompute.
return
;
...
...
@@ -263,14 +269,14 @@ Graph.resize = function() {
* Initialize Blockly and the graph. Called on page load.
*/
Graph
.
init
=
function
()
{
Blockly
.
inject
(
document
.
getElementById
(
'
blocklyDiv
'
),
Graph
.
workspace
=
Blockly
.
inject
(
document
.
getElementById
(
'
blocklyDiv
'
),
{
toolbox
:
document
.
getElementById
(
'
toolbox
'
)});
Blockly
.
Xml
.
domToWorkspace
(
Blockly
.
mainW
orkspace
,
Blockly
.
Xml
.
domToWorkspace
(
Graph
.
w
orkspace
,
document
.
getElementById
(
'
startBlocks
'
));
// When Blockly changes, update the graph.
Blockly
.
addChangeListener
(
Graph
.
drawVisualization
);
}
Graph
.
workspace
.
addChangeListener
(
Graph
.
drawVisualization
);
}
;
window
.
addEventListener
(
'
load
'
,
Graph
.
init
);
window
.
addEventListener
(
'
resize
'
,
Graph
.
resize
);
...
...
demos/interpreter/index.html
View file @
89d1aafd
...
...
@@ -121,9 +121,9 @@
</xml>
<script>
Blockly
.
inject
(
document
.
getElementById
(
'
blocklyDiv
'
),
var
workspace
=
Blockly
.
inject
(
document
.
getElementById
(
'
blocklyDiv
'
),
{
toolbox
:
document
.
getElementById
(
'
toolbox
'
)});
Blockly
.
Xml
.
domToWorkspace
(
Blockly
.
mainW
orkspace
,
Blockly
.
Xml
.
domToWorkspace
(
w
orkspace
,
document
.
getElementById
(
'
startBlocks
'
));
var
myInterpreter
=
null
;
...
...
@@ -157,7 +157,7 @@
var
highlightPause
=
false
;
function
highlightBlock
(
id
)
{
Blockly
.
mainW
orkspace
.
highlightBlock
(
id
);
w
orkspace
.
highlightBlock
(
id
);
highlightPause
=
true
;
}
...
...
@@ -165,14 +165,14 @@
// Generate JavaScript code and parse it.
Blockly
.
JavaScript
.
STATEMENT_PREFIX
=
'
highlightBlock(%1);
\n
'
;
Blockly
.
JavaScript
.
addReservedWords
(
'
highlightBlock
'
);
var
code
=
Blockly
.
JavaScript
.
workspaceToCode
();
var
code
=
Blockly
.
JavaScript
.
workspaceToCode
(
workspace
);
myInterpreter
=
new
Interpreter
(
code
,
initApi
);
alert
(
'
Ready to execute this code:
\n\n
'
+
code
);
document
.
getElementById
(
'
stepButton
'
).
disabled
=
''
;
highlightPause
=
false
;
Blockly
.
mainW
orkspace
.
traceOn
(
true
);
Blockly
.
mainW
orkspace
.
highlightBlock
(
null
);
w
orkspace
.
traceOn
(
true
);
w
orkspace
.
highlightBlock
(
null
);
}
function
stepCode
()
{
...
...
demos/maxBlocks/index.html
View file @
89d1aafd
...
...
@@ -79,15 +79,14 @@
</xml>
<script>
Blockly
.
inject
(
document
.
getElementById
(
'
blocklyDiv
'
),
var
workspace
=
Blockly
.
inject
(
document
.
getElementById
(
'
blocklyDiv
'
),
{
maxBlocks
:
5
,
toolbox
:
document
.
getElementById
(
'
toolbox
'
)});
function
onchange
()
{
document
.
getElementById
(
'
capacity
'
).
innerHTML
=
Blockly
.
mainW
orkspace
.
remainingCapacity
();
document
.
getElementById
(
'
capacity
'
).
innerHTML
=
w
orkspace
.
remainingCapacity
();
}
Blockly
.
addChangeListener
(
onchange
);
workspace
.
addChangeListener
(
onchange
);
</script>
</body>
...
...
demos/plane/plane.js
View file @
89d1aafd
...
...
@@ -74,6 +74,12 @@ Plane.LANGUAGE_NAME = {
*/
Plane
.
LANGUAGE_RTL
=
[
'
ar
'
,
'
fa
'
,
'
he
'
];
/**
* Main Blockly workspace.
* @type Blockly.WorkspaceSvg
*/
Plane
.
workspace
=
null
;
/**
* Extracts a parameter from the URL.
* If the parameter is absent default_value is returned.
...
...
@@ -137,11 +143,11 @@ Plane.loadBlocks = function(defaultXml) {
// Language switching stores the blocks during the reload.
delete
window
.
sessionStorage
.
loadOnceBlocks
;
var
xml
=
Blockly
.
Xml
.
textToDom
(
loadOnce
);
Blockly
.
Xml
.
domToWorkspace
(
Blockly
.
mainW
orkspace
,
xml
);
Blockly
.
Xml
.
domToWorkspace
(
Plane
.
w
orkspace
,
xml
);
}
else
if
(
defaultXml
)
{
// Load the editor with default starting blocks.
var
xml
=
Blockly
.
Xml
.
textToDom
(
defaultXml
);
Blockly
.
Xml
.
domToWorkspace
(
Blockly
.
mainW
orkspace
,
xml
);
Blockly
.
Xml
.
domToWorkspace
(
Plane
.
w
orkspace
,
xml
);
}
};
...
...
@@ -154,7 +160,7 @@ Plane.changeLanguage = function() {
// not load Blockly.
// MSIE 11 does not support sessionStorage on file:// URLs.
if
(
typeof
Blockly
!=
'
undefined
'
&&
window
.
sessionStorage
)
{
var
xml
=
Blockly
.
Xml
.
workspaceToDom
(
Blockly
.
mainW
orkspace
);
var
xml
=
Blockly
.
Xml
.
workspaceToDom
(
Plane
.
w
orkspace
);
var
text
=
Blockly
.
Xml
.
domToText
(
xml
);
window
.
sessionStorage
.
loadOnceBlocks
=
text
;
}
...
...
@@ -256,7 +262,7 @@ Plane.init = function() {
'
width=725, initial-scale=.35, user-scalable=no
'
);
}
Blockly
.
inject
(
document
.
getElementById
(
'
blockly
'
),
Plane
.
workspace
=
Blockly
.
inject
(
document
.
getElementById
(
'
blockly
'
),
{
media
:
'
../../media/
'
,
rtl
:
Plane
.
isRtl
(),
toolbox
:
document
.
getElementById
(
'
toolbox
'
)});
...
...
@@ -268,7 +274,7 @@ Plane.init = function() {
'
</xml>
'
;
Plane
.
loadBlocks
(
defaultXml
);
Blockly
.
addChangeListener
(
Plane
.
recalculate
);
Plane
.
workspace
.
addChangeListener
(
Plane
.
recalculate
);
// Initialize the slider.
var
svg
=
document
.
getElementById
(
'
plane
'
);
...
...
@@ -327,14 +333,14 @@ Plane.initLanguage = function() {
Plane
.
recalculate
=
function
()
{
// Find the 'set' block and use it as the formula root.
var
rootBlock
=
null
;
var
blocks
=
Blockly
.
mainW
orkspace
.
getTopBlocks
(
false
);
var
blocks
=
Plane
.
w
orkspace
.
getTopBlocks
(
false
);
for
(
var
i
=
0
,
block
;
block
=
blocks
[
i
];
i
++
)
{
if
(
block
.
type
==
'
plane_set_seats
'
)
{
rootBlock
=
block
;
}
}
var
seats
=
NaN
;
Blockly
.
JavaScript
.
init
(
Blockly
.
mainW
orkspace
);
Blockly
.
JavaScript
.
init
(
Plane
.
w
orkspace
);
var
code
=
Blockly
.
JavaScript
.
blockToCode
(
rootBlock
);
try
{
seats
=
eval
(
code
);
...
...
@@ -352,8 +358,8 @@ Plane.recalculate = function() {
block
.
customUpdate
&&
block
.
customUpdate
();
}
}
updateBlocks
(
Blockly
.
mainW
orkspace
.
getAllBlocks
());
updateBlocks
(
Blockly
.
mainW
orkspace
.
flyout_
.
workspace_
.
getAllBlocks
());
updateBlocks
(
Plane
.
w
orkspace
.
getAllBlocks
());
updateBlocks
(
Plane
.
w
orkspace
.
flyout_
.
workspace_
.
getAllBlocks
());
};
/**
...
...
demos/rtl/index.html
View file @
89d1aafd
...
...
@@ -23,9 +23,9 @@
</style>
<script>
function
init
()
{
Blockly
.
inject
(
document
.
getElementById
(
'
svgDiv
'
),
var
workspace
=
Blockly
.
inject
(
document
.
getElementById
(
'
svgDiv
'
),
{
rtl
:
true
,
toolbox
:
document
.
getElementById
(
'
toolbox
'
)});
Blockly
.
Xml
.
domToWorkspace
(
Blockly
.
mainW
orkspace
,
Blockly
.
Xml
.
domToWorkspace
(
w
orkspace
,
document
.
getElementById
(
'
startBlocks
'
));
//window.onbeforeunload = function() {
// return 'Leaving this page will result in the loss of your work.';
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment