Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
appinventor-sources
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
appinventor-sources
Commits
77d9970b
Commit
77d9970b
authored
Feb 16, 2020
by
Beka Westberg
Committed by
Evan W. Patton
Feb 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Translate global variable typeblock names
parent
c93be3f6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
46 deletions
+29
-46
appinventor/blocklyeditor/src/typeblock.js
appinventor/blocklyeditor/src/typeblock.js
+29
-46
No files found.
appinventor/blocklyeditor/src/typeblock.js
View file @
77d9970b
...
@@ -401,55 +401,38 @@ Blockly.TypeBlock.prototype.loadProcedures_ = function(){
...
@@ -401,55 +401,38 @@ Blockly.TypeBlock.prototype.loadProcedures_ = function(){
* example of how to call this function.
* example of how to call this function.
*/
*/
Blockly
.
TypeBlock
.
prototype
.
loadGlobalVariables_
=
function
()
{
Blockly
.
TypeBlock
.
prototype
.
loadGlobalVariables_
=
function
()
{
//clean up any previous procedures in the list
// Remove any global vars from the list so that we can re-add them.
this
.
TBOptions_
=
goog
.
object
.
filter
(
this
.
TBOptions_
,
this
.
TBOptions_
=
goog
.
object
.
filter
(
this
.
TBOptions_
,
function
(
option
)
{
function
(
opti
){
return
!
opti
.
isGlobalvar
;});
return
!
option
.
isGlobalvar
;
var
globalVarNames
=
createTypeBlockForVariables_
.
call
(
this
);
var
self
=
this
;
goog
.
array
.
forEach
(
globalVarNames
,
function
(
varName
){
var
canonicalN
;
if
(
varName
.
translatedName
.
substring
(
0
,
3
)
===
'
get
'
)
canonicalN
=
'
lexical_variable_get
'
;
else
canonicalN
=
'
lexical_variable_set
'
;
self
.
TBOptions_
[
varName
.
translatedName
]
=
{
canonicName
:
canonicalN
,
dropDown
:
varName
.
dropDown
,
isGlobalvar
:
true
};
});
});
/**
var
globalVarNames
=
Blockly
.
FieldLexicalVariable
.
getGlobalNames
();
* Create TypeBlock options for global variables (a setter and a getter for each).
goog
.
array
.
forEach
(
globalVarNames
,
function
(
varName
)
{
* @returns {Array} array of global var options
var
prefixedName
=
Blockly
.
Msg
.
LANG_VARIABLES_GLOBAL_PREFIX
+
*/
'
'
+
varName
;
function
createTypeBlockForVariables_
()
{
var
translatedGet
=
Blockly
.
Msg
.
LANG_VARIABLES_GET_TITLE_GET
+
var
options
=
[];
'
'
+
prefixedName
;
var
varNames
=
Blockly
.
FieldLexicalVariable
.
getGlobalNames
();
// We can leave 'global' as 'global' inside the value property because
// Make a setter and a getter for each of the names
// (I believe) the FieldLexicalVariable translates that later.
goog
.
array
.
forEach
(
varNames
,
function
(
varName
){
this
.
TBOptions_
[
translatedGet
]
=
{
options
.
push
(
canonicName
:
'
lexical_variable_get
'
,
{
translatedName
:
'
get global
'
+
varName
,
dropDown
:
{
dropDown
:
{
titleName
:
'
VAR
'
,
titleName
:
'
VAR
'
,
value
:
'
global
'
+
varName
value
:
'
global
'
+
varName
}
},
}
isGlobalvar
:
true
);
};
options
.
push
(
var
translatedSet
=
Blockly
.
Msg
.
LANG_VARIABLES_SET_TITLE_SET
+
{
'
'
+
prefixedName
;
translatedName
:
'
set global
'
+
varName
,
this
.
TBOptions_
[
translatedSet
]
=
{
canonicName
:
'
lexical_variable_set
'
,
dropDown
:
{
dropDown
:
{
titleName
:
'
VAR
'
,
titleName
:
'
VAR
'
,
value
:
'
global
'
+
varName
value
:
'
global
'
+
varName
},
isGlobalvar
:
true
}
}
}
}.
bind
(
this
));
);
});
return
options
;
}
};
};
/**
/**
...
...
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