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
4253de04
Commit
4253de04
authored
Jan 08, 2016
by
Neil Fraser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove old realtime.
parent
3bce3681
Changes
14
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
237 additions
and
424 deletions
+237
-424
blockly_compressed.js
blockly_compressed.js
+77
-78
blockly_uncompressed.js
blockly_uncompressed.js
+25
-25
core/block_svg.js
core/block_svg.js
+112
-121
core/blockly.js
core/blockly.js
+0
-22
core/contextmenu.js
core/contextmenu.js
+1
-4
core/field_colour.js
core/field_colour.js
+0
-3
core/flyout.js
core/flyout.js
+2
-4
core/inject.js
core/inject.js
+5
-17
core/mutator.js
core/mutator.js
+2
-4
core/workspace_svg.js
core/workspace_svg.js
+1
-23
core/xml.js
core/xml.js
+1
-1
demos/realtime/index.html
demos/realtime/index.html
+0
-78
python_compressed.js
python_compressed.js
+11
-10
tests/playground.html
tests/playground.html
+0
-34
No files found.
blockly_compressed.js
View file @
4253de04
This source diff could not be displayed because it is too large. You can
view the blob
instead.
blockly_uncompressed.js
View file @
4253de04
This diff is collapsed.
Click to expand it.
core/block_svg.js
View file @
4253de04
...
...
@@ -291,7 +291,6 @@ Blockly.BlockSvg.prototype.moveBy = function(dx, dy) {
this
.
getSvgRoot
().
setAttribute
(
'
transform
'
,
'
translate(
'
+
(
xy
.
x
+
dx
)
+
'
,
'
+
(
xy
.
y
+
dy
)
+
'
)
'
);
this
.
moveConnections_
(
dx
,
dy
);
Blockly
.
Realtime
.
blockChanged
(
this
);
};
/**
...
...
@@ -495,13 +494,11 @@ Blockly.BlockSvg.prototype.onMouseDown_ = function(e) {
* @private
*/
Blockly
.
BlockSvg
.
prototype
.
onMouseUp_
=
function
(
e
)
{
var
this_
=
this
;
Blockly
.
doCommand
(
function
()
{
Blockly
.
terminateDrag_
();
if
(
Blockly
.
selected
&&
Blockly
.
highlightedConnection_
)
{
// Connect two blocks together.
Blockly
.
localConnection_
.
connect
(
Blockly
.
highlightedConnection_
);
if
(
this_
.
rendered
)
{
if
(
this
.
rendered
)
{
// Trigger a connection animation.
// Determine which connection is inferior (lower in the source stack).
var
inferiorConnection
;
...
...
@@ -512,13 +509,13 @@ Blockly.BlockSvg.prototype.onMouseUp_ = function(e) {
}
inferiorConnection
.
sourceBlock_
.
connectionUiEffect
();
}
if
(
this_
.
workspace
.
trashcan
)
{
if
(
this
.
workspace
.
trashcan
)
{
// Don't throw an object in the trash can if it just got connected.
this_
.
workspace
.
trashcan
.
close
();
this
.
workspace
.
trashcan
.
close
();
}
}
else
if
(
!
this_
.
getParent
()
&&
Blockly
.
selected
.
isDeletable
()
&&
this_
.
workspace
.
isDeleteArea
(
e
))
{
var
trashcan
=
this_
.
workspace
.
trashcan
;
}
else
if
(
!
this
.
getParent
()
&&
Blockly
.
selected
.
isDeletable
()
&&
this
.
workspace
.
isDeleteArea
(
e
))
{
var
trashcan
=
this
.
workspace
.
trashcan
;
if
(
trashcan
)
{
goog
.
Timer
.
callOnce
(
trashcan
.
close
,
100
,
trashcan
);
}
...
...
@@ -533,7 +530,6 @@ Blockly.BlockSvg.prototype.onMouseUp_ = function(e) {
Blockly
.
highlightedConnection_
=
null
;
}
Blockly
.
Css
.
setCursor
(
Blockly
.
Css
.
Cursor
.
OPEN
);
});
};
/**
...
...
@@ -732,9 +728,6 @@ Blockly.BlockSvg.prototype.setDragging_ = function(adding) {
* @private
*/
Blockly
.
BlockSvg
.
prototype
.
onMouseMove_
=
function
(
e
)
{
var
this_
=
this
;
var
workspace_
=
this
.
workspace
;
Blockly
.
doCommand
(
function
()
{
if
(
e
.
type
==
'
mousemove
'
&&
e
.
clientX
<=
1
&&
e
.
clientY
==
0
&&
e
.
button
==
0
)
{
/* HACK:
...
...
@@ -747,44 +740,44 @@ Blockly.BlockSvg.prototype.onMouseMove_ = function(e) {
}
Blockly
.
removeAllRanges
();
var
oldXY
=
this_
.
getRelativeToSurfaceXY
();
var
newXY
=
workspace_
.
moveDrag
(
e
);
var
oldXY
=
this
.
getRelativeToSurfaceXY
();
var
newXY
=
this
.
workspace
.
moveDrag
(
e
);
var
group
=
this_
.
getSvgRoot
();
var
group
=
this
.
getSvgRoot
();
if
(
Blockly
.
dragMode_
==
1
)
{
// Still dragging within the sticky DRAG_RADIUS.
var
dr
=
goog
.
math
.
Coordinate
.
distance
(
oldXY
,
newXY
)
*
workspace_
.
scale
;
var
dr
=
goog
.
math
.
Coordinate
.
distance
(
oldXY
,
newXY
)
*
this
.
workspace
.
scale
;
if
(
dr
>
Blockly
.
DRAG_RADIUS
)
{
// Switch to unrestricted dragging.
Blockly
.
dragMode_
=
2
;
Blockly
.
longStop_
();
group
.
translate_
=
''
;
group
.
skew_
=
''
;
if
(
this_
.
parentBlock_
)
{
if
(
this
.
parentBlock_
)
{
// Push this block to the very top of the stack.
this_
.
setParent
(
null
);
this_
.
disconnectUiEffect
();
this
.
setParent
(
null
);
this
.
disconnectUiEffect
();
}
this_
.
setDragging_
(
true
);
workspace_
.
recordDeleteAreas
();
this
.
setDragging_
(
true
);
this
.
workspace
.
recordDeleteAreas
();
}
}
if
(
Blockly
.
dragMode_
==
2
)
{
// Unrestricted dragging.
var
dx
=
oldXY
.
x
-
this_
.
dragStartXY_
.
x
;
var
dy
=
oldXY
.
y
-
this_
.
dragStartXY_
.
y
;
var
dx
=
oldXY
.
x
-
this
.
dragStartXY_
.
x
;
var
dy
=
oldXY
.
y
-
this
.
dragStartXY_
.
y
;
group
.
translate_
=
'
translate(
'
+
newXY
.
x
+
'
,
'
+
newXY
.
y
+
'
)
'
;
group
.
setAttribute
(
'
transform
'
,
group
.
translate_
+
group
.
skew_
);
// Drag all the nested bubbles.
for
(
var
i
=
0
;
i
<
this_
.
draggedBubbles_
.
length
;
i
++
)
{
var
commentData
=
this_
.
draggedBubbles_
[
i
];
for
(
var
i
=
0
;
i
<
this
.
draggedBubbles_
.
length
;
i
++
)
{
var
commentData
=
this
.
draggedBubbles_
[
i
];
commentData
.
bubble
.
setIconLocation
(
commentData
.
x
+
dx
,
commentData
.
y
+
dy
);
}
// Check to see if any of this block's connections are within range of
// another block's connection.
var
myConnections
=
this_
.
getConnections_
(
false
);
var
myConnections
=
this
.
getConnections_
(
false
);
var
closestConnection
=
null
;
var
localConnection
=
null
;
var
radiusConnection
=
Blockly
.
SNAP_RADIUS
;
...
...
@@ -814,13 +807,12 @@ Blockly.BlockSvg.prototype.onMouseMove_ = function(e) {
}
// Provide visual indication of whether the block will be deleted if
// dropped here.
if
(
this_
.
isDeletable
())
{
workspace_
.
isDeleteArea
(
e
);
if
(
this
.
isDeletable
())
{
this
.
workspace
.
isDeleteArea
(
e
);
}
}
// This event has been handled. No need to bubble up to the document.
e
.
stopPropagation
();
});
};
/**
...
...
@@ -1600,7 +1592,6 @@ Blockly.BlockSvg.prototype.render = function(opt_bubble) {
}
}
Blockly
.
Field
.
stopCache
();
Blockly
.
Realtime
.
blockChanged
(
this
);
};
/**
...
...
core/blockly.js
View file @
4253de04
...
...
@@ -41,12 +41,6 @@ goog.require('Blockly.FieldVariable');
goog
.
require
(
'
Blockly.Generator
'
);
goog
.
require
(
'
Blockly.Msg
'
);
goog
.
require
(
'
Blockly.Procedures
'
);
// Realtime is currently badly broken. Stub it out.
Blockly
.
Realtime
=
{
isEnabled
:
function
()
{
return
false
;},
blockChanged
:
function
()
{},
doCommand
:
function
(
cmdThunk
)
{
cmdThunk
();}
};
goog
.
require
(
'
Blockly.Toolbox
'
);
goog
.
require
(
'
Blockly.WidgetDiv
'
);
goog
.
require
(
'
Blockly.WorkspaceSvg
'
);
...
...
@@ -604,22 +598,6 @@ Blockly.setMainWorkspaceMetrics_ = function(xyRatio) {
}
};
/**
* Execute a command. Generally, a command is the result of a user action
* e.g., a click, drag or context menu selection. Calling the cmdThunk function
* through doCommand() allows us to capture information that can be used for
* capabilities like undo (which is supported by the realtime collaboration
* feature).
* @param {function()} cmdThunk A function representing the command execution.
*/
Blockly
.
doCommand
=
function
(
cmdThunk
)
{
if
(
Blockly
.
Realtime
.
isEnabled
())
{
Blockly
.
Realtime
.
doCommand
(
cmdThunk
);
}
else
{
cmdThunk
();
}
};
/**
* When something in Blockly's workspace changes, call a function.
* @param {!Function} func Function to call.
...
...
core/contextmenu.js
View file @
4253de04
...
...
@@ -64,11 +64,8 @@ Blockly.ContextMenu.show = function(e, options, rtl) {
menu
.
addChild
(
menuItem
,
true
);
menuItem
.
setEnabled
(
option
.
enabled
);
if
(
option
.
enabled
)
{
var
evtHandlerCapturer
=
function
(
callback
)
{
return
function
()
{
Blockly
.
doCommand
(
callback
);
};
};
goog
.
events
.
listen
(
menuItem
,
goog
.
ui
.
Component
.
EventType
.
ACTION
,
evtHandlerCapturer
(
option
.
callback
)
);
option
.
callback
);
}
}
goog
.
events
.
listen
(
menu
,
goog
.
ui
.
Component
.
EventType
.
ACTION
,
...
...
core/field_colour.js
View file @
4253de04
...
...
@@ -108,9 +108,6 @@ Blockly.FieldColour.prototype.setValue = function(colour) {
this
.
borderRect_
.
style
.
fill
=
colour
;
}
if
(
this
.
sourceBlock_
&&
this
.
sourceBlock_
.
rendered
)
{
// Since we're not re-rendering we need to explicitly call
// Blockly.Realtime.blockChanged()
Blockly
.
Realtime
.
blockChanged
(
this
.
sourceBlock_
);
this
.
sourceBlock_
.
workspace
.
fireChangeEvent
();
}
};
...
...
core/flyout.js
View file @
4253de04
...
...
@@ -41,10 +41,8 @@ goog.require('goog.userAgent');
* @constructor
*/
Blockly
.
Flyout
=
function
(
workspaceOptions
)
{
var
flyout
=
this
;
workspaceOptions
.
getMetrics
=
function
()
{
return
flyout
.
getMetrics_
();};
workspaceOptions
.
setMetrics
=
function
(
ratio
)
{
return
flyout
.
setMetrics_
(
ratio
);};
workspaceOptions
.
getMetrics
=
this
.
getMetrics_
.
bind
(
this
);
workspaceOptions
.
setMetrics
=
this
.
setMetrics_
.
bind
(
this
);
/**
* @type {!Blockly.Workspace}
* @private
...
...
core/inject.js
View file @
4253de04
...
...
@@ -48,23 +48,11 @@ Blockly.inject = function(container, opt_options) {
throw
'
Error: container is not in current document.
'
;
}
var
options
=
Blockly
.
parseOptions_
(
opt_options
||
{});
var
workspace
;
var
startUi
=
function
()
{
var
svg
=
Blockly
.
createDom_
(
container
,
options
);
workspace
=
Blockly
.
createMainWorkspace_
(
svg
,
options
);
var
workspace
=
Blockly
.
createMainWorkspace_
(
svg
,
options
);
Blockly
.
init_
(
workspace
);
workspace
.
markFocused
();
Blockly
.
bindEvent_
(
svg
,
'
focus
'
,
workspace
,
workspace
.
markFocused
);
};
if
(
options
.
enableRealtime
)
{
var
realtimeElement
=
document
.
getElementById
(
'
realtime
'
);
if
(
realtimeElement
)
{
realtimeElement
.
style
.
display
=
'
block
'
;
}
Blockly
.
Realtime
.
startRealtime
(
startUi
,
container
,
options
.
realtimeOptions
);
}
else
{
startUi
();
}
return
workspace
;
};
...
...
core/mutator.js
View file @
4253de04
...
...
@@ -117,15 +117,13 @@ Blockly.Mutator.prototype.createEditor_ = function() {
}
else
{
var
quarkXml
=
null
;
}
var
mutator
=
this
;
var
workspaceOptions
=
{
languageTree
:
quarkXml
,
parentWorkspace
:
this
.
block_
.
workspace
,
pathToMedia
:
this
.
block_
.
workspace
.
options
.
pathToMedia
,
RTL
:
this
.
block_
.
RTL
,
getMetrics
:
function
()
{
return
mutator
.
getFlyoutMetrics_
();},
setMetrics
:
null
,
svg
:
this
.
svgDialog_
getMetrics
:
this
.
getFlyoutMetrics_
.
bind
(
this
),
setMetrics
:
null
};
this
.
workspace_
=
new
Blockly
.
WorkspaceSvg
(
workspaceOptions
);
this
.
svgDialog_
.
appendChild
(
...
...
core/workspace_svg.js
View file @
4253de04
...
...
@@ -341,7 +341,7 @@ Blockly.WorkspaceSvg.prototype.getBubbleCanvas = function() {
};
/**
* Get the SVG element that
forms the bubble surf
ace.
* Get the SVG element that
contains this worksp
ace.
* @return {!Element} SVG element.
*/
Blockly
.
WorkspaceSvg
.
prototype
.
getParentSvg
=
function
()
{
...
...
@@ -371,28 +371,6 @@ Blockly.WorkspaceSvg.prototype.translate = function(x, y) {
this
.
svgBubbleCanvas_
.
setAttribute
(
'
transform
'
,
translation
);
};
/**
* Add a block to the list of top blocks.
* @param {!Blockly.Block} block Block to remove.
*/
Blockly
.
WorkspaceSvg
.
prototype
.
addTopBlock
=
function
(
block
)
{
Blockly
.
WorkspaceSvg
.
superClass_
.
addTopBlock
.
call
(
this
,
block
);
if
(
Blockly
.
Realtime
.
isEnabled
()
&&
!
this
.
options
.
parentWorkspace
)
{
Blockly
.
Realtime
.
addTopBlock
(
block
);
}
};
/**
* Remove a block from the list of top blocks.
* @param {!Blockly.Block} block Block to remove.
*/
Blockly
.
WorkspaceSvg
.
prototype
.
removeTopBlock
=
function
(
block
)
{
Blockly
.
WorkspaceSvg
.
superClass_
.
removeTopBlock
.
call
(
this
,
block
);
if
(
Blockly
.
Realtime
.
isEnabled
()
&&
!
this
.
options
.
parentWorkspace
)
{
Blockly
.
Realtime
.
removeTopBlock
(
block
);
}
};
/**
* Returns the horizontal offset of the workspace.
* Intended for LTR/RTL compatibility in XML.
...
...
core/xml.js
View file @
4253de04
...
...
@@ -62,7 +62,7 @@ Blockly.Xml.workspaceToDom = function(workspace) {
Blockly
.
Xml
.
blockToDom_
=
function
(
block
)
{
var
element
=
goog
.
dom
.
createDom
(
block
.
isShadow
()
?
'
shadow
'
:
'
block
'
);
element
.
setAttribute
(
'
type
'
,
block
.
type
);
if
(
Blockly
.
Realtime
.
isEnabled
()
)
{
if
(
false
)
{
// Only used by realtime.
element
.
setAttribute
(
'
id
'
,
block
.
id
);
}
...
...
demos/realtime/index.html
deleted
100644 → 0
View file @
3bce3681
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
>
<title>
Blockly Demo: Realtime Collaboration
</title>
<script
src=
"../../blockly_compressed.js"
></script>
<script
src=
"../../blocks_compressed.js"
></script>
<script
src=
"../../msg/js/en.js"
></script>
<script
src=
"https://apis.google.com/js/api.js"
></script>
<style>
body
{
background-color
:
#fff
;
font-family
:
sans-serif
;
}
h1
{
font-weight
:
normal
;
font-size
:
140%
;
}
#collaborators
>
img
{
margin-right
:
5px
;
height
:
30px
;
padding-bottom
:
5px
;
width
:
30px
;
border-radius
:
3px
;
}
</style>
</head>
<body>
<h1><a
href=
"https://developers.google.com/blockly/"
>
Blockly
</a>
>
<a
href=
"../index.html"
>
Demos
</a>
>
Realtime Collaboration
</h1>
<p>
This is a simple demo of realtime collaboration in Blockly.
</p>
<p>
→
More info on
<a
href=
"https://developers.google.com/blockly/realtime-collaboration"
>
realtime collaboration in Blockly
</a>
...
</p>
<div
id=
"collaborators"
></div>
<div
id=
"blocklyDiv"
style=
"height: 480px; width: 600px;"
>
</div>
<xml
id=
"toolbox"
style=
"display: none"
>
<block
type=
"controls_if"
></block>
<block
type=
"controls_repeat_ext"
></block>
<block
type=
"logic_compare"
></block>
<block
type=
"math_number"
></block>
<block
type=
"math_arithmetic"
></block>
<block
type=
"text"
></block>
<block
type=
"text_print"
></block>
</xml>
<p>
Test realtime collaboration by opening
<a
target=
"_blank"
href=
"#"
onmouseover=
"this.href = window.location.href"
>
this link
</a>
in a separate browser window or tab and they will be
synchronized. You can even share the link with a friend!.
</p>
<br>
<br>
<!-- Text area that will be used for our collaborative chat box. -->
<textarea
id=
"chatbox"
style=
"width: 26%; height: 12em"
disabled=
"true"
></textarea>
<script>
// See https://developers.google.com/blockly/realtime-collaboration for how
// to set up your app for realtime collaboration and how to get the
// clientId that you need below.
Blockly
.
inject
(
document
.
getElementById
(
'
blocklyDiv
'
),
{
toolbox
:
document
.
getElementById
(
'
toolbox
'
),
realtime
:
true
,
realtimeOptions
:
{
clientId
:
'
YOUR CLIENT ID HERE
'
,
chatbox
:
{
elementId
:
'
chatbox
'
},
collabElementId
:
'
collaborators
'
}});
</script>
</body>
</html>
python_compressed.js
View file @
4253de04
This diff is collapsed.
Click to expand it.
tests/playground.html
View file @
4253de04
...
...
@@ -55,11 +55,6 @@
var
rtl
=
(
document
.
location
.
search
==
'
?rtl
'
);
var
workspace
=
null
;
function
enableRealtimeSpecificUi
()
{
var
realtimeDiv
=
document
.
getElementById
(
'
realtime
'
);
realtimeDiv
.
display
=
'
block
'
;
}
function
start
()
{
var
toolbox
=
document
.
getElementById
(
'
toolbox
'
);
workspace
=
Blockly
.
inject
(
'
blocklyDiv
'
,
...
...
@@ -74,11 +69,6 @@ function start() {
maxBlocks
:
Infinity
,
media
:
'
../media/
'
,
readOnly
:
false
,
realtime
:
false
,
realtimeOptions
:
{
clientId
:
'
YOUR CLIENT ID GOES HERE
'
,
chatbox
:
{
elementId
:
'
chatbox
'
},
collabElementId
:
'
collaborators
'
},
rtl
:
rtl
,
scrollbars
:
true
,
toolbox
:
toolbox
,
...
...
@@ -91,9 +81,6 @@ function start() {
scaleSpeed
:
1.1
},
});
if
(
Blockly
.
Realtime
.
isEnabled
())
{
enableRealtimeSpecificUi
();
}
}
function
toXml
()
{
...
...
@@ -559,26 +546,5 @@ h1 {
<input
type=
"button"
value=
"Spaghetti!"
onclick=
"spaghetti(8)"
>
</p>
<!-- Realtime setup buttons. -->
<div
id=
"realtime"
style=
"display: none"
>
<p>
Test realtime collaboration by opening
<a
target=
"_blank"
href=
"#"
onmouseover=
"this.href = window.location.href"
>
this link
</a>
in a separate browser window or tab and they will be
synchronized. You can even share the link with a friend!.
</p>
<br>
<br>
<!-- Undo and redo buttons. -->
<!-- TODO: Uncomment this when undo/redo are fixed. -->
<!--
<button id="undoButton" disabled>Undo</button>
<button id="redoButton" disabled>Redo</button>
<br />
-->
</div>
</body>
</html>
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