Lint corrections.

This commit is contained in:
Neil Fraser
2015-06-17 13:05:24 -07:00
parent b37fb2bf8c
commit edd3e3bf33
24 changed files with 190 additions and 176 deletions

View File

@@ -1,5 +1,5 @@
// Do not edit this file; automatically generated by build.py.
"use strict";
'use strict';
var COMPILED=!0,goog=goog||{};goog.global=this;goog.isDef=function(a){return void 0!==a};goog.exportPath_=function(a,b,c){a=a.split(".");c=c||goog.global;a[0]in c||!c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)!a.length&&goog.isDef(b)?c[d]=b:c=c[d]?c[d]:c[d]={}};
goog.define=function(a,b){var c=b;COMPILED||(goog.global.CLOSURE_UNCOMPILED_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_UNCOMPILED_DEFINES,a)?c=goog.global.CLOSURE_UNCOMPILED_DEFINES[a]:goog.global.CLOSURE_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_DEFINES,a)&&(c=goog.global.CLOSURE_DEFINES[a]));goog.exportPath_(a,c)};goog.DEBUG=!0;goog.LOCALE="en";goog.TRUSTED_SITE=!0;goog.STRICT_MODE_COMPATIBLE=!1;goog.DISALLOW_TEST_ONLY_CODE=COMPILED&&!goog.DEBUG;
@@ -1341,7 +1341,7 @@ a.viewLeft:e)||a.contentLeft+a.contentWidth>(b.RTL?a.viewWidth:a.viewWidth+e))fo
Blockly.init_=function(a){var b=a.options,c=a.options.svg;Blockly.bindEvent_(c,"contextmenu",null,function(a){Blockly.isTargetInput_(a)||a.preventDefault()});Blockly.bindEvent_(c,"touchstart",null,function(a){Blockly.longStart_(a,null)});Blockly.bindEvent_(window,"resize",null,function(){Blockly.svgResize(a)});Blockly.documentEventsBound_||(Blockly.bindEvent_(document,"keydown",null,Blockly.onKeyDown_),Blockly.bindEvent_(document,"touchend",null,Blockly.longStop_),Blockly.bindEvent_(document,"touchcancel",
null,Blockly.longStop_),document.addEventListener("mouseup",Blockly.onMouseUp_,!1),goog.userAgent.IPAD&&Blockly.bindEvent_(window,"orientationchange",document,function(){Blockly.fireUiEvent(window,"resize")}),Blockly.documentEventsBound_=!0);b.languageTree&&(a.toolbox_?a.toolbox_.init(a):a.flyout_&&(a.flyout_.init(a),a.flyout_.show(b.languageTree.childNodes),a.scrollX=a.flyout_.width_,b.RTL&&(a.scrollX*=-1),c="translate("+a.scrollX+", 0)",a.getCanvas().setAttribute("transform",c),a.getBubbleCanvas().setAttribute("transform",
c)));b.hasScrollbars&&(a.scrollbar=new Blockly.ScrollbarPair(a),a.scrollbar.resize());if(b.hasSounds){a.loadAudio_([b.pathToMedia+"click.mp3",b.pathToMedia+"click.wav",b.pathToMedia+"click.ogg"],"click");a.loadAudio_([b.pathToMedia+"delete.mp3",b.pathToMedia+"delete.ogg",b.pathToMedia+"delete.wav"],"delete");var d=[],b=function(){for(;d.length;)Blockly.unbindEvent_(d.pop());a.preloadAudio_()};d.push(Blockly.bindEvent_(document,"mousemove",null,b));d.push(Blockly.bindEvent_(document,"touchstart",null,
b))}};Blockly.updateToolbox=function(a,b){console.warn("Deprecated call to Blockly.updateToolbox, use workspace.updateToolbox instead.");Blockly.getMainWorkspace().updateToolbox(a)};
b))}};Blockly.updateToolbox=function(a){console.warn("Deprecated call to Blockly.updateToolbox, use workspace.updateToolbox instead.");Blockly.getMainWorkspace().updateToolbox(a)};
// Copyright 2012 Google Inc. Apache License 2.0
Blockly.utils={};Blockly.addClass_=function(a,b){var c=a.getAttribute("class")||"";-1==(" "+c+" ").indexOf(" "+b+" ")&&(c&&(c+=" "),a.setAttribute("class",c+b))};Blockly.removeClass_=function(a,b){var c=a.getAttribute("class");if(-1!=(" "+c+" ").indexOf(" "+b+" ")){for(var c=c.split(/\s+/),d=0;d<c.length;d++)c[d]&&c[d]!=b||(c.splice(d,1),d--);c.length?a.setAttribute("class",c.join(" ")):a.removeAttribute("class")}};
Blockly.hasClass_=function(a,b){return-1!=(" "+a.getAttribute("class")+" ").indexOf(" "+b+" ")};Blockly.bindEvent_=function(a,b,c,d){var e=c?function(a){d.call(c,a)}:d;a.addEventListener(b,e,!1);var f=[[a,b,e]];if(b in Blockly.bindEvent_.TOUCH_MAP)for(var e=function(a){if(1==a.changedTouches.length){var b=a.changedTouches[0];a.clientX=b.clientX;a.clientY=b.clientY}d.call(c,a);a.preventDefault()},g=0,h;h=Blockly.bindEvent_.TOUCH_MAP[b][g];g++)a.addEventListener(h,e,!1),f.push([a,h,e]);return f};

View File

@@ -1,5 +1,5 @@
// Do not edit this file; automatically generated by build.py.
"use strict";
'use strict';
// 'this' is 'window' in a browser, or 'global' in node.js.
this.BLOCKLY_DIR = (function() {
@@ -26,7 +26,7 @@ if (!this.goog) {
// Build map of all dependencies (used and unused).
var dir = this.BLOCKLY_DIR.match(/[^\/]+$/)[0];
goog.addDependency("../../../" + dir + "/core/block.js", ['Blockly.Block'], ['Blockly.Blocks', 'Blockly.Comment', 'Blockly.Connection', 'Blockly.Input', 'Blockly.Mutator', 'Blockly.Warning', 'Blockly.Workspace', 'Blockly.Xml', 'goog.array', 'goog.asserts', 'goog.math.Coordinate', 'goog.string']);
goog.addDependency("../../../" + dir + "/core/block_svg.js", ['Blockly.BlockSvg'], ['Blockly.Block', 'Blockly.ContextMenu', 'goog.asserts', 'goog.dom', 'goog.math.Coordinate', 'goog.Timer']);
goog.addDependency("../../../" + dir + "/core/block_svg.js", ['Blockly.BlockSvg'], ['Blockly.Block', 'Blockly.ContextMenu', 'goog.Timer', 'goog.asserts', 'goog.dom', 'goog.math.Coordinate']);
goog.addDependency("../../../" + dir + "/core/blockly.js", ['Blockly'], ['Blockly.BlockSvg', 'Blockly.FieldAngle', 'Blockly.FieldCheckbox', 'Blockly.FieldColour', 'Blockly.FieldDropdown', 'Blockly.FieldImage', 'Blockly.FieldTextInput', 'Blockly.FieldVariable', 'Blockly.Generator', 'Blockly.Msg', 'Blockly.Procedures', 'Blockly.Realtime', 'Blockly.Toolbox', 'Blockly.WidgetDiv', 'Blockly.WorkspaceSvg', 'Blockly.inject', 'Blockly.utils', 'goog.color']);
goog.addDependency("../../../" + dir + "/core/blocks.js", ['Blockly.Blocks'], ['goog.asserts']);
goog.addDependency("../../../" + dir + "/core/bubble.js", ['Blockly.Bubble'], ['Blockly.Workspace', 'goog.dom', 'goog.math', 'goog.userAgent']);
@@ -37,8 +37,8 @@ goog.addDependency("../../../" + dir + "/core/css.js", ['Blockly.Css'], ['goog.c
goog.addDependency("../../../" + dir + "/core/field.js", ['Blockly.Field'], ['goog.asserts', 'goog.dom', 'goog.math.Size', 'goog.style', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/field_angle.js", ['Blockly.FieldAngle'], ['Blockly.FieldTextInput', 'goog.math', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/field_checkbox.js", ['Blockly.FieldCheckbox'], ['Blockly.Field']);
goog.addDependency("../../../" + dir + "/core/field_colour.js", ['Blockly.FieldColour'], ['Blockly.Field', 'goog.dom', 'goog.events', 'goog.ui.ColorPicker', 'goog.style']);
goog.addDependency("../../../" + dir + "/core/field_date.js", ['Blockly.FieldDate'], ['Blockly.Field', 'goog.date', 'goog.dom', 'goog.events', 'goog.ui.DatePicker', 'goog.style', 'goog.i18n.DateTimeSymbols', 'goog.i18n.DateTimeSymbols_he']);
goog.addDependency("../../../" + dir + "/core/field_colour.js", ['Blockly.FieldColour'], ['Blockly.Field', 'goog.dom', 'goog.events', 'goog.style', 'goog.ui.ColorPicker']);
goog.addDependency("../../../" + dir + "/core/field_date.js", ['Blockly.FieldDate'], ['Blockly.Field', 'goog.date', 'goog.dom', 'goog.events', 'goog.i18n.DateTimeSymbols', 'goog.i18n.DateTimeSymbols_he', 'goog.style', 'goog.ui.DatePicker']);
goog.addDependency("../../../" + dir + "/core/field_dropdown.js", ['Blockly.FieldDropdown'], ['Blockly.Field', 'goog.dom', 'goog.events', 'goog.style', 'goog.ui.Menu', 'goog.ui.MenuItem', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/field_image.js", ['Blockly.FieldImage'], ['Blockly.Field', 'goog.dom', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/field_label.js", ['Blockly.FieldLabel'], ['Blockly.Field', 'Blockly.Tooltip', 'goog.dom', 'goog.math.Size']);
@@ -50,7 +50,7 @@ goog.addDependency("../../../" + dir + "/core/icon.js", ['Blockly.Icon'], ['goog
goog.addDependency("../../../" + dir + "/core/inject.js", ['Blockly.inject'], ['Blockly.Css', 'Blockly.WorkspaceSvg', 'goog.dom', 'goog.ui.Component', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/input.js", ['Blockly.Input'], ['Blockly.Connection', 'Blockly.FieldLabel', 'goog.asserts']);
goog.addDependency("../../../" + dir + "/core/msg.js", ['Blockly.Msg'], []);
goog.addDependency("../../../" + dir + "/core/mutator.js", ['Blockly.Mutator'], ['Blockly.Bubble', 'Blockly.Icon', 'Blockly.WorkspaceSvg', 'goog.dom', 'goog.Timer']);
goog.addDependency("../../../" + dir + "/core/mutator.js", ['Blockly.Mutator'], ['Blockly.Bubble', 'Blockly.Icon', 'Blockly.WorkspaceSvg', 'goog.Timer', 'goog.dom']);
goog.addDependency("../../../" + dir + "/core/names.js", ['Blockly.Names'], []);
goog.addDependency("../../../" + dir + "/core/procedures.js", ['Blockly.Procedures'], ['Blockly.Field', 'Blockly.Names', 'Blockly.Workspace']);
goog.addDependency("../../../" + dir + "/core/realtime-client-utils.js", ['rtclient'], []);

View File

@@ -29,6 +29,9 @@ goog.provide('Blockly.Blocks.colour');
goog.require('Blockly.Blocks');
/**
* Common HSV hue for all blocks in this category.
*/
Blockly.Blocks.colour.HUE = 20;
Blockly.Blocks['colour_picker'] = {

View File

@@ -29,6 +29,9 @@ goog.provide('Blockly.Blocks.lists');
goog.require('Blockly.Blocks');
/**
* Common HSV hue for all blocks in this category.
*/
Blockly.Blocks.lists.HUE = 260;
Blockly.Blocks['lists_create_empty'] = {

View File

@@ -29,6 +29,9 @@ goog.provide('Blockly.Blocks.logic');
goog.require('Blockly.Blocks');
/**
* Common HSV hue for all blocks in this category.
*/
Blockly.Blocks.logic.HUE = 210;
Blockly.Blocks['controls_if'] = {

View File

@@ -29,6 +29,9 @@ goog.provide('Blockly.Blocks.loops');
goog.require('Blockly.Blocks');
/**
* Common HSV hue for all blocks in this category.
*/
Blockly.Blocks.loops.HUE = 120;
Blockly.Blocks['controls_repeat'] = {
@@ -38,20 +41,12 @@ Blockly.Blocks['controls_repeat'] = {
*/
init: function() {
this.jsonInit({
"message": Blockly.Msg.CONTROLS_REPEAT_TITLE + " %2 " +
Blockly.Msg.CONTROLS_REPEAT_INPUT_DO + " %3",
"message": Blockly.Msg.CONTROLS_REPEAT_TITLE,
"args": [
{
"type": "field_input",
"name": "TIMES",
"text": "10"
},
{
"type": "input_dummy"
},
{
"type": "input_statement",
"name": "DO"
}
],
"previousStatement": null,
@@ -60,6 +55,8 @@ Blockly.Blocks['controls_repeat'] = {
"tooltip": Blockly.Msg.CONTROLS_REPEAT_TOOLTIP,
"helpUrl": Blockly.Msg.CONTROLS_REPEAT_HELPURL
});
this.appendStatementInput('DO')
.appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO);
this.getField_('TIMES').setChangeHandler(
Blockly.FieldTextInput.nonnegativeIntegerValidator);
}
@@ -72,20 +69,12 @@ Blockly.Blocks['controls_repeat_ext'] = {
*/
init: function() {
this.jsonInit({
"message": Blockly.Msg.CONTROLS_REPEAT_TITLE + " %2 " +
Blockly.Msg.CONTROLS_REPEAT_INPUT_DO + " %3",
"message": Blockly.Msg.CONTROLS_REPEAT_TITLE,
"args": [
{
"type": "input_value",
"name": "TIMES",
"check": "Number"
},
{
"type": "input_dummy"
},
{
"type": "input_statement",
"name": "DO"
}
],
"previousStatement": null,
@@ -94,6 +83,8 @@ Blockly.Blocks['controls_repeat_ext'] = {
"tooltip": Blockly.Msg.CONTROLS_REPEAT_TOOLTIP,
"helpUrl": Blockly.Msg.CONTROLS_REPEAT_HELPURL
});
this.appendStatementInput('DO')
.appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO);
}
};

View File

@@ -29,6 +29,9 @@ goog.provide('Blockly.Blocks.math');
goog.require('Blockly.Blocks');
/**
* Common HSV hue for all blocks in this category.
*/
Blockly.Blocks.math.HUE = 230;
Blockly.Blocks['math_number'] = {

View File

@@ -29,6 +29,9 @@ goog.provide('Blockly.Blocks.procedures');
goog.require('Blockly.Blocks');
/**
* Common HSV hue for all blocks in this category.
*/
Blockly.Blocks.procedures.HUE = 290;
Blockly.Blocks['procedures_defnoreturn'] = {

View File

@@ -29,6 +29,9 @@ goog.provide('Blockly.Blocks.texts');
goog.require('Blockly.Blocks');
/**
* Common HSV hue for all blocks in this category.
*/
Blockly.Blocks.texts.HUE = 160;
Blockly.Blocks['text'] = {

View File

@@ -29,6 +29,9 @@ goog.provide('Blockly.Blocks.variables');
goog.require('Blockly.Blocks');
/**
* Common HSV hue for all blocks in this category.
*/
Blockly.Blocks.variables.HUE = 330;
Blockly.Blocks['variables_get'] = {

View File

@@ -1,5 +1,5 @@
// Do not edit this file; automatically generated by build.py.
"use strict";
'use strict';
// Copyright 2012 Google Inc. Apache License 2.0
@@ -56,8 +56,8 @@ Blockly.Blocks.logic_null={init:function(){this.setHelpUrl(Blockly.Msg.LOGIC_NUL
Blockly.Blocks.logic_ternary={init:function(){this.setHelpUrl(Blockly.Msg.LOGIC_TERNARY_HELPURL);this.setColour(Blockly.Blocks.logic.HUE);this.appendValueInput("IF").setCheck("Boolean").appendField(Blockly.Msg.LOGIC_TERNARY_CONDITION);this.appendValueInput("THEN").appendField(Blockly.Msg.LOGIC_TERNARY_IF_TRUE);this.appendValueInput("ELSE").appendField(Blockly.Msg.LOGIC_TERNARY_IF_FALSE);this.setOutput(!0);this.setTooltip(Blockly.Msg.LOGIC_TERNARY_TOOLTIP);this.prevParentConnection_=null},onchange:function(){if(this.workspace){var a=
this.getInputTargetBlock("THEN"),b=this.getInputTargetBlock("ELSE"),c=this.outputConnection.targetConnection;if((a||b)&&c)for(var d=0;2>d;d++){var e=1==d?a:b;e&&!e.outputConnection.checkType_(c)&&(c===this.prevParentConnection_?(this.setParent(null),c.sourceBlock_.bumpNeighbours_()):(e.setParent(null),e.bumpNeighbours_()))}this.prevParentConnection_=c}}};
// Copyright 2012 Google Inc. Apache License 2.0
Blockly.Blocks.loops={};Blockly.Blocks.loops.HUE=120;Blockly.Blocks.controls_repeat={init:function(){this.jsonInit({message:Blockly.Msg.CONTROLS_REPEAT_TITLE+" %2 "+Blockly.Msg.CONTROLS_REPEAT_INPUT_DO+" %3",args:[{type:"field_input",name:"TIMES",text:"10"},{type:"input_dummy"},{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,colour:Blockly.Blocks.loops.HUE,tooltip:Blockly.Msg.CONTROLS_REPEAT_TOOLTIP,helpUrl:Blockly.Msg.CONTROLS_REPEAT_HELPURL});this.getField_("TIMES").setChangeHandler(Blockly.FieldTextInput.nonnegativeIntegerValidator)}};
Blockly.Blocks.controls_repeat_ext={init:function(){this.jsonInit({message:Blockly.Msg.CONTROLS_REPEAT_TITLE+" %2 "+Blockly.Msg.CONTROLS_REPEAT_INPUT_DO+" %3",args:[{type:"input_value",name:"TIMES",check:"Number"},{type:"input_dummy"},{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,colour:Blockly.Blocks.loops.HUE,tooltip:Blockly.Msg.CONTROLS_REPEAT_TOOLTIP,helpUrl:Blockly.Msg.CONTROLS_REPEAT_HELPURL})}};
Blockly.Blocks.loops={};Blockly.Blocks.loops.HUE=120;Blockly.Blocks.controls_repeat={init:function(){this.jsonInit({message:Blockly.Msg.CONTROLS_REPEAT_TITLE,args:[{type:"field_input",name:"TIMES",text:"10"}],previousStatement:null,nextStatement:null,colour:Blockly.Blocks.loops.HUE,tooltip:Blockly.Msg.CONTROLS_REPEAT_TOOLTIP,helpUrl:Blockly.Msg.CONTROLS_REPEAT_HELPURL});this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO);this.getField_("TIMES").setChangeHandler(Blockly.FieldTextInput.nonnegativeIntegerValidator)}};
Blockly.Blocks.controls_repeat_ext={init:function(){this.jsonInit({message:Blockly.Msg.CONTROLS_REPEAT_TITLE,args:[{type:"input_value",name:"TIMES",check:"Number"}],previousStatement:null,nextStatement:null,colour:Blockly.Blocks.loops.HUE,tooltip:Blockly.Msg.CONTROLS_REPEAT_TOOLTIP,helpUrl:Blockly.Msg.CONTROLS_REPEAT_HELPURL});this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO)}};
Blockly.Blocks.controls_whileUntil={init:function(){var a=[[Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE,"WHILE"],[Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL,"UNTIL"]];this.setHelpUrl(Blockly.Msg.CONTROLS_WHILEUNTIL_HELPURL);this.setColour(Blockly.Blocks.loops.HUE);this.appendValueInput("BOOL").setCheck("Boolean").appendField(new Blockly.FieldDropdown(a),"MODE");this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_WHILEUNTIL_INPUT_DO);this.setPreviousStatement(!0);this.setNextStatement(!0);
var b=this;this.setTooltip(function(){var a=b.getFieldValue("MODE");return{WHILE:Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE,UNTIL:Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}[a]})}};
Blockly.Blocks.controls_for={init:function(){this.jsonInit({message:Blockly.Msg.CONTROLS_FOR_TITLE,args:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",name:"FROM",check:"Number",align:"RIGHT"},{type:"input_value",name:"TO",align:"RIGHT"},{type:"input_value",name:"BY",check:"Number",align:"RIGHT"}],inputsInline:!0,previousStatement:null,nextStatement:null,colour:Blockly.Blocks.loops.HUE,helpUrl:Blockly.Msg.CONTROLS_FOR_HELPURL});this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_FOR_INPUT_DO);

244
build.py
View File

@@ -62,8 +62,8 @@ def import_path(fullpath):
return module
HEADER = ('// Do not edit this file; automatically generated by build.py.\n'
'"use strict";\n')
HEADER = ("// Do not edit this file; automatically generated by build.py.\n"
"'use strict';\n")
class Gen_uncompressed(threading.Thread):
@@ -75,8 +75,8 @@ class Gen_uncompressed(threading.Thread):
self.search_paths = search_paths
def run(self):
target_filename = 'blockly_uncompressed.js'
f = open(target_filename, 'w')
target_filename = "blockly_uncompressed.js"
f = open(target_filename, "w")
f.write(HEADER)
f.write("""
// 'this' is 'window' in a browser, or 'global' in node.js.
@@ -108,24 +108,24 @@ var dir = this.BLOCKLY_DIR.match(/[^\\/]+$/)[0];
base_path = calcdeps.FindClosureBasePath(self.search_paths)
for dep in calcdeps.BuildDependenciesFromFiles(self.search_paths):
add_dependency.append(calcdeps.GetDepsLine(dep, base_path))
add_dependency = '\n'.join(add_dependency)
add_dependency = "\n".join(add_dependency)
# Find the Blockly directory name and replace it with a JS variable.
# This allows blockly_uncompressed.js to be compiled on one computer and be
# used on another, even if the directory name differs.
m = re.search('[\\/]([^\\/]+)[\\/]core[\\/]blockly.js', add_dependency)
add_dependency = re.sub('([\\/])' + re.escape(m.group(1)) +
'([\\/]core[\\/])', '\\1" + dir + "\\2', add_dependency)
f.write(add_dependency + '\n')
m = re.search("[\\/]([^\\/]+)[\\/]core[\\/]blockly.js", add_dependency)
add_dependency = re.sub("([\\/])" + re.escape(m.group(1)) +
"([\\/]core[\\/])", '\\1" + dir + "\\2', add_dependency)
f.write(add_dependency + "\n")
provides = []
for dep in calcdeps.BuildDependenciesFromFiles(self.search_paths):
if not dep.filename.startswith(os.pardir + os.sep): # '../'
if not dep.filename.startswith(os.pardir + os.sep): # "../"
provides.extend(dep.provides)
provides.sort()
f.write('\n')
f.write('// Load Blockly.\n')
f.write("\n")
f.write("// Load Blockly.\n")
for provide in provides:
f.write('goog.require(\'%s\');\n' % provide)
f.write("goog.require('%s');\n" % provide)
f.write("""
delete this.BLOCKLY_DIR;
@@ -145,7 +145,7 @@ document.write('<script src="' + this.BLOCKLY_DIR +
document.write('<script>this.BLOCKLY_BOOT()</script>');
""")
f.close()
print('SUCCESS: ' + target_filename)
print("SUCCESS: " + target_filename)
class Gen_compressed(threading.Thread):
@@ -161,95 +161,95 @@ class Gen_compressed(threading.Thread):
def run(self):
self.gen_core()
self.gen_blocks()
self.gen_generator('javascript')
self.gen_generator('python')
self.gen_generator('php')
self.gen_generator('dart')
self.gen_generator("javascript")
self.gen_generator("python")
self.gen_generator("php")
self.gen_generator("dart")
def gen_core(self):
target_filename = 'blockly_compressed.js'
target_filename = "blockly_compressed.js"
# Define the parameters for the POST request.
params = [
('compilation_level', 'SIMPLE_OPTIMIZATIONS'),
('use_closure_library', 'true'),
('output_format', 'json'),
('output_info', 'compiled_code'),
('output_info', 'warnings'),
('output_info', 'errors'),
('output_info', 'statistics'),
("compilation_level", "SIMPLE_OPTIMIZATIONS"),
("use_closure_library", "true"),
("output_format", "json"),
("output_info", "compiled_code"),
("output_info", "warnings"),
("output_info", "errors"),
("output_info", "statistics"),
]
# Read in all the source files.
filenames = calcdeps.CalculateDependencies(self.search_paths,
[os.path.join('core', 'blockly.js')])
[os.path.join("core", "blockly.js")])
for filename in filenames:
# Filter out the Closure files (the compiler will add them).
if filename.startswith(os.pardir + os.sep): # '../'
continue
f = open(filename)
params.append(('js_code', ''.join(f.readlines())))
params.append(("js_code", "".join(f.readlines())))
f.close()
self.do_compile(params, target_filename, filenames, '')
self.do_compile(params, target_filename, filenames, "")
def gen_blocks(self):
target_filename = 'blocks_compressed.js'
target_filename = "blocks_compressed.js"
# Define the parameters for the POST request.
params = [
('compilation_level', 'SIMPLE_OPTIMIZATIONS'),
('output_format', 'json'),
('output_info', 'compiled_code'),
('output_info', 'warnings'),
('output_info', 'errors'),
('output_info', 'statistics'),
("compilation_level", "SIMPLE_OPTIMIZATIONS"),
("output_format", "json"),
("output_info", "compiled_code"),
("output_info", "warnings"),
("output_info", "errors"),
("output_info", "statistics"),
]
# Read in all the source files.
# Add Blockly.Blocks to be compatible with the compiler.
params.append(('js_code', 'goog.provide(\'Blockly.Blocks\');'))
filenames = glob.glob(os.path.join('blocks', '*.js'))
params.append(("js_code", "goog.provide('Blockly.Blocks');"))
filenames = glob.glob(os.path.join("blocks", "*.js"))
for filename in filenames:
f = open(filename)
params.append(('js_code', ''.join(f.readlines())))
params.append(("js_code", "".join(f.readlines())))
f.close()
# Remove Blockly.Blocks to be compatible with Blockly.
remove = 'var Blockly={Blocks:{}};'
remove = "var Blockly={Blocks:{}};"
self.do_compile(params, target_filename, filenames, remove)
def gen_generator(self, language):
target_filename = language + '_compressed.js'
target_filename = language + "_compressed.js"
# Define the parameters for the POST request.
params = [
('compilation_level', 'SIMPLE_OPTIMIZATIONS'),
('output_format', 'json'),
('output_info', 'compiled_code'),
('output_info', 'warnings'),
('output_info', 'errors'),
('output_info', 'statistics'),
("compilation_level", "SIMPLE_OPTIMIZATIONS"),
("output_format", "json"),
("output_info", "compiled_code"),
("output_info", "warnings"),
("output_info", "errors"),
("output_info", "statistics"),
]
# Read in all the source files.
# Add Blockly.Generator to be compatible with the compiler.
params.append(('js_code', 'goog.provide(\'Blockly.Generator\');'))
params.append(("js_code", "goog.provide('Blockly.Generator');"))
filenames = glob.glob(
os.path.join('generators', language, '*.js'))
filenames.insert(0, os.path.join('generators', language + '.js'))
os.path.join("generators", language, "*.js"))
filenames.insert(0, os.path.join("generators", language + ".js"))
for filename in filenames:
f = open(filename)
params.append(('js_code', ''.join(f.readlines())))
params.append(("js_code", "".join(f.readlines())))
f.close()
filenames.insert(0, '[goog.provide]')
filenames.insert(0, "[goog.provide]")
# Remove Blockly.Generator to be compatible with Blockly.
remove = 'var Blockly={Generator:{}};'
remove = "var Blockly={Generator:{}};"
self.do_compile(params, target_filename, filenames, remove)
def do_compile(self, params, target_filename, filenames, remove):
# Send the request to Google.
headers = {'Content-type': 'application/x-www-form-urlencoded'}
conn = httplib.HTTPConnection('closure-compiler.appspot.com')
conn.request('POST', '/compile', urllib.urlencode(params), headers)
headers = {"Content-type": "application/x-www-form-urlencoded"}
conn = httplib.HTTPConnection("closure-compiler.appspot.com")
conn.request("POST", "/compile", urllib.urlencode(params), headers)
response = conn.getresponse()
json_str = response.read()
conn.close()
@@ -258,46 +258,46 @@ class Gen_compressed(threading.Thread):
json_data = json.loads(json_str)
def file_lookup(name):
if not name.startswith('Input_'):
return '???'
if not name.startswith("Input_"):
return "???"
n = int(name[6:]) - 1
return filenames[n]
if json_data.has_key('serverErrors'):
errors = json_data['serverErrors']
if json_data.has_key("serverErrors"):
errors = json_data["serverErrors"]
for error in errors:
print('SERVER ERROR: %s' % target_filename)
print(error['error'])
elif json_data.has_key('errors'):
errors = json_data['errors']
print("SERVER ERROR: %s" % target_filename)
print(error["error"])
elif json_data.has_key("errors"):
errors = json_data["errors"]
for error in errors:
print('FATAL ERROR')
print(error['error'])
if error['file']:
print('%s at line %d:' % (
file_lookup(error['file']), error['lineno']))
print(error['line'])
print((' ' * error['charno']) + '^')
print("FATAL ERROR")
print(error["error"])
if error["file"]:
print("%s at line %d:" % (
file_lookup(error["file"]), error["lineno"]))
print(error["line"])
print((" " * error["charno"]) + "^")
sys.exit(1)
else:
if json_data.has_key('warnings'):
warnings = json_data['warnings']
if json_data.has_key("warnings"):
warnings = json_data["warnings"]
for warning in warnings:
print('WARNING')
print(warning['warning'])
if warning['file']:
print('%s at line %d:' % (
file_lookup(warning['file']), warning['lineno']))
print(warning['line'])
print((' ' * warning['charno']) + '^')
print("WARNING")
print(warning["warning"])
if warning["file"]:
print("%s at line %d:" % (
file_lookup(warning["file"]), warning["lineno"]))
print(warning["line"])
print((" " * warning["charno"]) + "^")
print()
if not json_data.has_key('compiledCode'):
print('FATAL ERROR: Compiler did not return compiledCode.')
if not json_data.has_key("compiledCode"):
print("FATAL ERROR: Compiler did not return compiledCode.")
sys.exit(1)
code = HEADER + '\n' + json_data['compiledCode']
code = code.replace(remove, '')
code = HEADER + "\n" + json_data["compiledCode"]
code = code.replace(remove, "")
# Trim down Google's Apache licences.
LICENSE = re.compile("""/\\*
@@ -319,24 +319,24 @@ class Gen_compressed(threading.Thread):
See the License for the specific language governing permissions and
limitations under the License.
\\*/""")
code = re.sub(LICENSE, r'\n// \1 Apache License 2.0', code)
code = re.sub(LICENSE, r"\n// \1 Apache License 2.0", code)
stats = json_data['statistics']
original_b = stats['originalSize']
compressed_b = stats['compressedSize']
stats = json_data["statistics"]
original_b = stats["originalSize"]
compressed_b = stats["compressedSize"]
if original_b > 0 and compressed_b > 0:
f = open(target_filename, 'w')
f = open(target_filename, "w")
f.write(code)
f.close()
original_kb = int(original_b / 1024 + 0.5)
compressed_kb = int(compressed_b / 1024 + 0.5)
ratio = int(float(compressed_b) / float(original_b) * 100 + 0.5)
print('SUCCESS: ' + target_filename)
print('Size changed from %d KB to %d KB (%d%%).' % (
print("SUCCESS: " + target_filename)
print("Size changed from %d KB to %d KB (%d%%)." % (
original_kb, compressed_kb, ratio))
else:
print('UNKNOWN ERROR')
print("UNKNOWN ERROR")
class Gen_langfiles(threading.Thread):
@@ -358,30 +358,30 @@ class Gen_langfiles(threading.Thread):
if e.errno == errno.ENOENT:
# If it was a source file, we can't proceed.
if e.filename in srcs:
print('Source file missing: ' + e.filename)
print("Source file missing: " + e.filename)
sys.exit(1)
else:
# If a destination file was missing, rebuild.
return True
else:
print('Error checking file creation times: ' + e)
print("Error checking file creation times: " + e)
def run(self):
# The files msg/json/{en,qqq,synonyms}.json depend on msg/messages.js.
if self._rebuild([os.path.join('msg', 'messages.js')],
[os.path.join('msg', 'json', f) for f in
['en.json', 'qqq.json', 'synonyms.json']]):
if self._rebuild([os.path.join("msg", "messages.js")],
[os.path.join("msg", "json", f) for f in
["en.json", "qqq.json", "synonyms.json"]]):
try:
subprocess.check_call([
'python',
os.path.join('i18n', 'js_to_json.py'),
'--input_file', 'msg/messages.js',
'--output_dir', 'msg/json/',
'--quiet'])
"python",
os.path.join("i18n", "js_to_json.py"),
"--input_file", "msg/messages.js",
"--output_dir", "msg/json/",
"--quiet"])
except (subprocess.CalledProcessError, OSError) as e:
# Documentation for subprocess.check_call says that CalledProcessError
# will be raised on failure, but I found that OSError is also possible.
print('Error running i18n/js_to_json.py: ', e)
print("Error running i18n/js_to_json.py: ", e)
sys.exit(1)
# Checking whether it is necessary to rebuild the js files would be a lot of
@@ -390,38 +390,38 @@ class Gen_langfiles(threading.Thread):
try:
# Use create_messages.py to create .js files from .json files.
cmd = [
'python',
os.path.join('i18n', 'create_messages.py'),
'--source_lang_file', os.path.join('msg', 'json', 'en.json'),
'--source_synonym_file', os.path.join('msg', 'json', 'synonyms.json'),
'--key_file', os.path.join('msg', 'json', 'keys.json'),
'--output_dir', os.path.join('msg', 'js'),
'--quiet']
json_files = glob.glob(os.path.join('msg', 'json', '*.json'))
"python",
os.path.join("i18n", "create_messages.py"),
"--source_lang_file", os.path.join("msg", "json", "en.json"),
"--source_synonym_file", os.path.join("msg", "json", "synonyms.json"),
"--key_file", os.path.join("msg", "json", "keys.json"),
"--output_dir", os.path.join("msg", "js"),
"--quiet"]
json_files = glob.glob(os.path.join("msg", "json", "*.json"))
json_files = [file for file in json_files if not
(file.endswith(('keys.json', 'synonyms.json', 'qqq.json')))]
(file.endswith(("keys.json", "synonyms.json", "qqq.json")))]
cmd.extend(json_files)
subprocess.check_call(cmd)
except (subprocess.CalledProcessError, OSError) as e:
print('Error running i18n/create_messages.py: ', e)
print("Error running i18n/create_messages.py: ", e)
sys.exit(1)
# Output list of .js files created.
for f in json_files:
# This assumes the path to the current directory does not contain 'json'.
f = f.replace('json', 'js')
# This assumes the path to the current directory does not contain "json".
f = f.replace("json", "js")
if os.path.isfile(f):
print('SUCCESS: ' + f)
print("SUCCESS: " + f)
else:
print('FAILED to create ' + f)
print("FAILED to create " + f)
if __name__ == '__main__':
if __name__ == "__main__":
try:
calcdeps = import_path(os.path.join(os.path.pardir,
'closure-library', 'closure', 'bin', 'calcdeps.py'))
calcdeps = import_path(os.path.join(
os.path.pardir, "closure-library", "closure", "bin", "calcdeps.py"))
except ImportError:
if os.path.isdir(os.path.join(os.path.pardir, 'closure-library-read-only')):
if os.path.isdir(os.path.join(os.path.pardir, "closure-library-read-only")):
# Dir got renamed when Closure moved from Google Code to GitHub in 2014.
print("Error: Closure directory needs to be renamed from"
"'closure-library-read-only' to 'closure-library'.\n"
@@ -431,7 +431,7 @@ if __name__ == '__main__':
https://developers.google.com/blockly/hacking/closure""")
sys.exit(1)
search_paths = calcdeps.ExpandDirectories(
['core', os.path.join(os.path.pardir, 'closure-library')])
["core", os.path.join(os.path.pardir, "closure-library")])
# Run both tasks in parallel threads.
# Uncompressed is limited by processor speed.

View File

@@ -28,10 +28,10 @@ goog.provide('Blockly.BlockSvg');
goog.require('Blockly.Block');
goog.require('Blockly.ContextMenu');
goog.require('goog.Timer');
goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.math.Coordinate');
goog.require('goog.Timer');
/**

View File

@@ -29,8 +29,8 @@ goog.provide('Blockly.FieldColour');
goog.require('Blockly.Field');
goog.require('goog.dom');
goog.require('goog.events');
goog.require('goog.ui.ColorPicker');
goog.require('goog.style');
goog.require('goog.ui.ColorPicker');
/**

View File

@@ -30,10 +30,10 @@ goog.require('Blockly.Field');
goog.require('goog.date');
goog.require('goog.dom');
goog.require('goog.events');
goog.require('goog.ui.DatePicker');
goog.require('goog.style');
goog.require('goog.i18n.DateTimeSymbols');
goog.require('goog.i18n.DateTimeSymbols_he');
goog.require('goog.style');
goog.require('goog.ui.DatePicker');
/**
@@ -198,6 +198,9 @@ Blockly.FieldDate.loadLanguage_ = function() {
}
};
/**
* CSS for date picker. See css.js for use.
*/
Blockly.FieldDate.CSS = [
/* Copied from: goog/css/datepicker.css */
/*

View File

@@ -386,7 +386,7 @@ Blockly.createMainWorkspace_ = function(svg, options) {
// The SVG is now fully assembled.
Blockly.svgResize(mainWorkspace);
Blockly.WidgetDiv.createDom();
Blockly.Tooltip.createDom()
Blockly.Tooltip.createDom();
return mainWorkspace;
};
@@ -489,7 +489,7 @@ Blockly.init_ = function(mainWorkspace) {
* Modify the block tree on the existing toolbox.
* @param {Node|string} tree DOM tree of blocks, or text representation of same.
*/
Blockly.updateToolbox = function(tree, workspace) {
Blockly.updateToolbox = function(tree) {
console.warn('Deprecated call to Blockly.updateToolbox, ' +
'use workspace.updateToolbox instead.');
Blockly.getMainWorkspace().updateToolbox(tree);

View File

@@ -30,8 +30,8 @@ goog.provide('Blockly.Mutator');
goog.require('Blockly.Bubble');
goog.require('Blockly.Icon');
goog.require('Blockly.WorkspaceSvg');
goog.require('goog.dom');
goog.require('goog.Timer');
goog.require('goog.dom');
/**

View File

@@ -1,5 +1,5 @@
// Do not edit this file; automatically generated by build.py.
"use strict";
'use strict';
// Copyright 2014 Google Inc. Apache License 2.0

View File

@@ -40,7 +40,8 @@ Blockly.PHP['colour_random'] = function(block) {
var functionName = Blockly.PHP.provideFunction_(
'colour_random',
[ 'function ' + Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_ + '() {',
' return \'#\' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, \'0\', STR_PAD_LEFT);',
' return \'#\' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), ' +
'6, \'0\', STR_PAD_LEFT);',
'}']);
var code = functionName + '()';
return [code, Blockly.PHP.ORDER_FUNCTION_CALL];

View File

@@ -148,8 +148,7 @@ Blockly.PHP['math_constant'] = function(block) {
var CONSTANTS = {
'PI': ['M_PI', Blockly.PHP.ORDER_ATOMIC],
'E': ['M_E', Blockly.PHP.ORDER_ATOMIC],
'GOLDEN_RATIO':
['(1 + sqrt(5)) / 2', Blockly.PHP.ORDER_DIVISION],
'GOLDEN_RATIO': ['(1 + sqrt(5)) / 2', Blockly.PHP.ORDER_DIVISION],
'SQRT2': ['M_SQRT2', Blockly.PHP.ORDER_ATOMIC],
'SQRT1_2': ['M_SQRT1_2', Blockly.PHP.ORDER_ATOMIC],
'INFINITY': ['INF', Blockly.PHP.ORDER_ATOMIC]

View File

@@ -97,11 +97,11 @@ Blockly.PHP['text_indexOf'] = function(block) {
var code = operator + '(' + argument1 + ', ' + argument0 + ') + 1';
var functionName = Blockly.PHP.provideFunction_(
block.getFieldValue('END')=='FIRST'?'text_indexOf':'text_lastIndexOf',
block.getFieldValue('END') == 'FIRST'?'text_indexOf':'text_lastIndexOf',
[ 'function ' + Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_ +
'($text, $search) {',
' $pos = ' + operator + '($text, $search);',
' return $pos===false?0:$pos+1;',
' return $pos === false ? 0 : $pos + 1;',
'}']);
code = functionName + '(' + argument1 + ', ' + argument0 + ')';
return [code, Blockly.PHP.ORDER_FUNCTION_CALL];
@@ -119,7 +119,7 @@ Blockly.PHP['text_charAt'] = function(block) {
var code = text + '[0]';
return [code, Blockly.PHP.ORDER_FUNCTION_CALL];
case 'LAST':
var code = 'substr(' + text + ',-1,1)';
var code = 'substr(' + text + ', -1, 1)';
return [code, Blockly.PHP.ORDER_FUNCTION_CALL];
case 'FROM_START':
// Blockly uses one-based indicies.
@@ -138,9 +138,8 @@ Blockly.PHP['text_charAt'] = function(block) {
case 'RANDOM':
var functionName = Blockly.PHP.provideFunction_(
'text_random_letter',
[ 'function ' + Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_ +
'($text) {',
' return $text[rand(0, strlen($text)-1)];',
[ 'function ' + Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_ + '($text) {',
' return $text[rand(0, strlen($text) - 1)];',
'}']);
code = functionName + '(' + text + ')';
return [code, Blockly.PHP.ORDER_FUNCTION_CALL];
@@ -194,15 +193,15 @@ Blockly.PHP['text_getSubstring'] = function(block) {
Blockly.PHP['text_changeCase'] = function(block) {
// Change capitalization.
var code;
if (block.getFieldValue('CASE')=='UPPERCASE') {
if (block.getFieldValue('CASE') == 'UPPERCASE') {
var argument0 = Blockly.PHP.valueToCode(block, 'TEXT',
Blockly.PHP.ORDER_FUNCTION_CALL) || '\'\'';
code = 'strtoupper(' + argument0 + ')';
} else if (block.getFieldValue('CASE')=='LOWERCASE') {
} else if (block.getFieldValue('CASE') == 'LOWERCASE') {
var argument0 = Blockly.PHP.valueToCode(block, 'TEXT',
Blockly.PHP.ORDER_FUNCTION_CALL) || '\'\'';
code = 'strtolower(' + argument0 + ')';
} else if (block.getFieldValue('CASE')=='TITLECASE') {
} else if (block.getFieldValue('CASE') == 'TITLECASE') {
var argument0 = Blockly.PHP.valueToCode(block, 'TEXT',
Blockly.PHP.ORDER_FUNCTION_CALL) || '\'\'';
code = 'ucwords(strtolower(' + argument0 + '))';

View File

@@ -1,5 +1,5 @@
// Do not edit this file; automatically generated by build.py.
"use strict";
'use strict';
// Copyright 2012 Google Inc. Apache License 2.0

View File

@@ -1,5 +1,5 @@
// Do not edit this file; automatically generated by build.py.
"use strict";
'use strict';
// Copyright 2015 Google Inc. Apache License 2.0
@@ -77,10 +77,10 @@ Blockly.PHP.texts={};Blockly.PHP.text=function(a){return[Blockly.PHP.quote_(a.ge
Blockly.PHP.text_join=function(a){var b;if(0==a.itemCount_)return["''",Blockly.PHP.ORDER_ATOMIC];if(1==a.itemCount_)return b=Blockly.PHP.valueToCode(a,"ADD0",Blockly.PHP.ORDER_NONE)||"''",[b,Blockly.PHP.ORDER_FUNCTION_CALL];if(2==a.itemCount_)return b=Blockly.PHP.valueToCode(a,"ADD0",Blockly.PHP.ORDER_NONE)||"''",a=Blockly.PHP.valueToCode(a,"ADD1",Blockly.PHP.ORDER_NONE)||"''",[b+" . "+a,Blockly.PHP.ORDER_ADDITION];b=Array(a.itemCount_);for(var c=0;c<a.itemCount_;c++)b[c]=Blockly.PHP.valueToCode(a,
"ADD"+c,Blockly.PHP.ORDER_COMMA)||"''";b="implode('', array("+b.join(",")+"))";return[b,Blockly.PHP.ORDER_FUNCTION_CALL]};Blockly.PHP.text_append=function(a){var b=Blockly.PHP.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE);a=Blockly.PHP.valueToCode(a,"TEXT",Blockly.PHP.ORDER_NONE)||"''";return b+" .= "+a+";\n"};Blockly.PHP.text_length=function(a){return["strlen("+(Blockly.PHP.valueToCode(a,"VALUE",Blockly.PHP.ORDER_FUNCTION_CALL)||"''")+")",Blockly.PHP.ORDER_FUNCTION_CALL]};
Blockly.PHP.text_isEmpty=function(a){return["empty("+(Blockly.PHP.valueToCode(a,"VALUE",Blockly.PHP.ORDER_FUNCTION_CALL)||"''")+")",Blockly.PHP.ORDER_FUNCTION_CALL]};
Blockly.PHP.text_indexOf=function(a){var b="FIRST"==a.getFieldValue("END")?"strpos":"strrpos",c=Blockly.PHP.valueToCode(a,"FIND",Blockly.PHP.ORDER_FUNCTION_CALL)||"''",d=Blockly.PHP.valueToCode(a,"VALUE",Blockly.PHP.ORDER_FUNCTION_CALL)||"''",e=b+"("+d+", "+c+") + 1",e=Blockly.PHP.provideFunction_("FIRST"==a.getFieldValue("END")?"text_indexOf":"text_lastIndexOf",["function "+Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($text, $search) {"," $pos = "+b+"($text, $search);"," return $pos===false?0:$pos+1;",
Blockly.PHP.text_indexOf=function(a){var b="FIRST"==a.getFieldValue("END")?"strpos":"strrpos",c=Blockly.PHP.valueToCode(a,"FIND",Blockly.PHP.ORDER_FUNCTION_CALL)||"''",d=Blockly.PHP.valueToCode(a,"VALUE",Blockly.PHP.ORDER_FUNCTION_CALL)||"''",e=b+"("+d+", "+c+") + 1",e=Blockly.PHP.provideFunction_("FIRST"==a.getFieldValue("END")?"text_indexOf":"text_lastIndexOf",["function "+Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($text, $search) {"," $pos = "+b+"($text, $search);"," return $pos === false ? 0 : $pos + 1;",
"}"])+"("+d+", "+c+")";return[e,Blockly.PHP.ORDER_FUNCTION_CALL]};
Blockly.PHP.text_charAt=function(a){var b=a.getFieldValue("WHERE")||"FROM_START",c=Blockly.PHP.valueToCode(a,"AT",Blockly.PHP.ORDER_FUNCTION_CALL)||"0";a=Blockly.PHP.valueToCode(a,"VALUE",Blockly.PHP.ORDER_FUNCTION_CALL)||"''";switch(b){case "FIRST":return[a+"[0]",Blockly.PHP.ORDER_FUNCTION_CALL];case "LAST":return["substr("+a+",-1,1)",Blockly.PHP.ORDER_FUNCTION_CALL];case "FROM_START":return c=Blockly.isNumber(c)?parseFloat(c)-1:c+" - 1",["substr("+a+", "+c+", 1)",Blockly.PHP.ORDER_FUNCTION_CALL];
case "FROM_END":return["substr("+a+", -"+c+", 1)",Blockly.PHP.ORDER_FUNCTION_CALL];case "RANDOM":return b=Blockly.PHP.provideFunction_("text_random_letter",["function "+Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($text) {"," return $text[rand(0, strlen($text)-1)];","}"])+"("+a+")",[b,Blockly.PHP.ORDER_FUNCTION_CALL]}throw"Unhandled option (text_charAt).";};
Blockly.PHP.text_charAt=function(a){var b=a.getFieldValue("WHERE")||"FROM_START",c=Blockly.PHP.valueToCode(a,"AT",Blockly.PHP.ORDER_FUNCTION_CALL)||"0";a=Blockly.PHP.valueToCode(a,"VALUE",Blockly.PHP.ORDER_FUNCTION_CALL)||"''";switch(b){case "FIRST":return[a+"[0]",Blockly.PHP.ORDER_FUNCTION_CALL];case "LAST":return["substr("+a+", -1, 1)",Blockly.PHP.ORDER_FUNCTION_CALL];case "FROM_START":return c=Blockly.isNumber(c)?parseFloat(c)-1:c+" - 1",["substr("+a+", "+c+", 1)",Blockly.PHP.ORDER_FUNCTION_CALL];
case "FROM_END":return["substr("+a+", -"+c+", 1)",Blockly.PHP.ORDER_FUNCTION_CALL];case "RANDOM":return b=Blockly.PHP.provideFunction_("text_random_letter",["function "+Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($text) {"," return $text[rand(0, strlen($text) - 1)];","}"])+"("+a+")",[b,Blockly.PHP.ORDER_FUNCTION_CALL]}throw"Unhandled option (text_charAt).";};
Blockly.PHP.text_getSubstring=function(a){var b=Blockly.PHP.valueToCode(a,"STRING",Blockly.PHP.ORDER_FUNCTION_CALL)||"''",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2"),e=Blockly.PHP.valueToCode(a,"AT1",Blockly.PHP.ORDER_FUNCTION_CALL)||"0";a=Blockly.PHP.valueToCode(a,"AT2",Blockly.PHP.ORDER_FUNCTION_CALL)||"0";return["FIRST"==c&&"LAST"==d?b:Blockly.PHP.provideFunction_("text_get_substring",["function "+Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($text, $where1, $at1, $where2, $at2) {"," if ($where2 == 'FROM_START') {",
" $at2--;"," } else if ($where2 == 'FROM_END') {"," $at2 = $at2 - $at1;"," } else if ($where2 == 'FIRST') {"," $at2 = 0;"," } else if ($where2 == 'LAST') {"," $at2 = strlen($text);"," } else { $at2 = 0; }"," if ($where1 == 'FROM_START') {"," $at1--;"," } else if ($where1 == 'FROM_END') {"," $at1 = strlen($text) - $at1;"," } else if ($where1 == 'FIRST') {"," $at1 = 0;"," } else if ($where1 == 'LAST') {"," $at1 = strlen($text) - 1;"," } else { $at1 = 0; }",
" return substr($text, $at1, $at2);","}"])+"("+b+", '"+c+"', "+e+", '"+d+"', "+a+")",Blockly.PHP.ORDER_FUNCTION_CALL]};

View File

@@ -1,5 +1,5 @@
// Do not edit this file; automatically generated by build.py.
"use strict";
'use strict';
// Copyright 2012 Google Inc. Apache License 2.0