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
ca966979
Commit
ca966979
authored
Nov 11, 2014
by
Neil Fraser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Block Factory when types are saved.
parent
0f187fc3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
35 deletions
+46
-35
appengine/index_redirect.py
appengine/index_redirect.py
+1
-1
demos/blockfactory/blocks.js
demos/blockfactory/blocks.js
+45
-34
No files found.
appengine/index_redirect.py
View file @
ca966979
print
(
"Status: 302"
)
print
(
"Location: /static/
app
s/index.html"
)
print
(
"Location: /static/
demo
s/index.html"
)
demos/blockfactory/blocks.js
View file @
ca966979
...
...
@@ -45,40 +45,7 @@ Blockly.Blocks['factory_base'] = {
[
'
↑ top connection
'
,
'
TOP
'
],
[
'
↓ bottom connection
'
,
'
BOTTOM
'
]],
function
(
option
)
{
var
block
=
this
.
sourceBlock_
;
var
outputExists
=
block
.
getInput
(
'
OUTPUTTYPE
'
);
var
topExists
=
block
.
getInput
(
'
TOPTYPE
'
);
var
bottomExists
=
block
.
getInput
(
'
BOTTOMTYPE
'
);
if
(
option
==
'
LEFT
'
)
{
if
(
!
outputExists
)
{
block
.
appendValueInput
(
'
OUTPUTTYPE
'
)
.
setCheck
(
'
Type
'
)
.
appendField
(
'
output type
'
);
block
.
moveInputBefore
(
'
OUTPUTTYPE
'
,
'
COLOUR
'
);
}
}
else
if
(
outputExists
)
{
block
.
removeInput
(
'
OUTPUTTYPE
'
);
}
if
(
option
==
'
TOP
'
||
option
==
'
BOTH
'
)
{
if
(
!
topExists
)
{
block
.
appendValueInput
(
'
TOPTYPE
'
)
.
setCheck
(
'
Type
'
)
.
appendField
(
'
top type
'
);
block
.
moveInputBefore
(
'
TOPTYPE
'
,
'
COLOUR
'
);
}
}
else
if
(
topExists
)
{
block
.
removeInput
(
'
TOPTYPE
'
);
}
if
(
option
==
'
BOTTOM
'
||
option
==
'
BOTH
'
)
{
if
(
!
bottomExists
)
{
block
.
appendValueInput
(
'
BOTTOMTYPE
'
)
.
setCheck
(
'
Type
'
)
.
appendField
(
'
bottom type
'
);
block
.
moveInputBefore
(
'
BOTTOMTYPE
'
,
'
COLOUR
'
);
}
}
else
if
(
bottomExists
)
{
block
.
removeInput
(
'
BOTTOMTYPE
'
);
}
this
.
sourceBlock_
.
updateShape_
(
option
);
});
this
.
appendDummyInput
()
.
appendField
(
dropdown
,
'
CONNECTIONS
'
);
...
...
@@ -95,6 +62,50 @@ Blockly.Blocks['factory_base'] = {
*/
this
.
setTooltip
(
'
Build a custom block by plugging
\n
'
+
'
fields, inputs and other blocks here.
'
);
},
mutationToDom
:
function
()
{
var
container
=
document
.
createElement
(
'
mutation
'
);
container
.
setAttribute
(
'
connections
'
,
this
.
getFieldValue
(
'
CONNECTIONS
'
));
return
container
;
},
domToMutation
:
function
(
xmlElement
)
{
var
connections
=
xmlElement
.
getAttribute
(
'
connections
'
);
this
.
updateShape_
(
connections
);
},
updateShape_
:
function
(
option
)
{
var
outputExists
=
this
.
getInput
(
'
OUTPUTTYPE
'
);
var
topExists
=
this
.
getInput
(
'
TOPTYPE
'
);
var
bottomExists
=
this
.
getInput
(
'
BOTTOMTYPE
'
);
if
(
option
==
'
LEFT
'
)
{
if
(
!
outputExists
)
{
this
.
appendValueInput
(
'
OUTPUTTYPE
'
)
.
setCheck
(
'
Type
'
)
.
appendField
(
'
output type
'
);
this
.
moveInputBefore
(
'
OUTPUTTYPE
'
,
'
COLOUR
'
);
}
}
else
if
(
outputExists
)
{
this
.
removeInput
(
'
OUTPUTTYPE
'
);
}
if
(
option
==
'
TOP
'
||
option
==
'
BOTH
'
)
{
if
(
!
topExists
)
{
this
.
appendValueInput
(
'
TOPTYPE
'
)
.
setCheck
(
'
Type
'
)
.
appendField
(
'
top type
'
);
this
.
moveInputBefore
(
'
TOPTYPE
'
,
'
COLOUR
'
);
}
}
else
if
(
topExists
)
{
this
.
removeInput
(
'
TOPTYPE
'
);
}
if
(
option
==
'
BOTTOM
'
||
option
==
'
BOTH
'
)
{
if
(
!
bottomExists
)
{
this
.
appendValueInput
(
'
BOTTOMTYPE
'
)
.
setCheck
(
'
Type
'
)
.
appendField
(
'
bottom type
'
);
this
.
moveInputBefore
(
'
BOTTOMTYPE
'
,
'
COLOUR
'
);
}
}
else
if
(
bottomExists
)
{
this
.
removeInput
(
'
BOTTOMTYPE
'
);
}
}
};
...
...
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