diff --git a/core/block.js b/core/block.js index 6a20efaf9..b33fe7bb4 100644 --- a/core/block.js +++ b/core/block.js @@ -84,7 +84,8 @@ Blockly.Block = function(workspace, prototypeName, opt_id) { */ this.childBlocks_ = []; - /** @type {boolean} + /** + * @type {boolean} * @private */ this.deletable_ = true; @@ -222,13 +223,13 @@ Blockly.Block.prototype.dispose = function(healStack) { } // Then dispose of myself. // Dispose of all inputs and their fields. - for (var j = 0, input; input = this.inputList[j]; j++) { + for (var i = 0, input; input = this.inputList[i]; i++) { input.dispose(); } this.inputList.length = 0; // Dispose of any remaining connections (next/previous/output). var connections = this.getConnections_(true); - for (i = 0; i < connections.length; i++) { + for (var i = 0; i < connections.length; i++) { var connection = connections[i]; if (connection.isConnected()) { connection.disconnect(); @@ -586,7 +587,7 @@ Blockly.Block.prototype.setConnectionsHidden = function(hidden) { for (var i = 0, connection; connection = myConnections[i]; i++) { connection.setHidden(hidden); if (connection.isSuperior()) { - child = connection.targetBlock(); + var child = connection.targetBlock(); if (child) { child.setConnectionsHidden(hidden); } @@ -843,7 +844,7 @@ Blockly.Block.prototype.getInputsInline = function() { return false; } } - for (i = 1; i < this.inputList.length; i++) { + for (var i = 1; i < this.inputList.length; i++) { if (this.inputList[i - 1].type == Blockly.INPUT_VALUE && this.inputList[i].type == Blockly.DUMMY_INPUT) { // Dummy input after a value input. Inline them. @@ -1063,7 +1064,7 @@ Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) { }; // Populate block with inputs and fields. var fieldStack = []; - for (i = 0; i < elements.length; i++) { + for (var i = 0; i < elements.length; i++) { var element = elements[i]; if (typeof element == 'string') { fieldStack.push([element, undefined]); diff --git a/core/block_svg.js b/core/block_svg.js index f0fea7f56..7bdccb58e 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -119,7 +119,7 @@ Blockly.BlockSvg.prototype.initSvg = function() { input.init(); } var icons = this.getIcons(); - for (i = 0; i < icons.length; i++) { + for (var i = 0; i < icons.length; i++) { icons[i].createIcon(); } this.updateColour(); @@ -447,7 +447,7 @@ Blockly.BlockSvg.prototype.setCollapsed = function(collapsed) { var COLLAPSED_INPUT_NAME = '_TEMP_COLLAPSED_INPUT'; if (collapsed) { var icons = this.getIcons(); - for (i = 0; i < icons.length; i++) { + for (var i = 0; i < icons.length; i++) { icons[i].setVisible(false); } var text = this.toString(Blockly.COLLAPSE_CHARS); @@ -464,7 +464,7 @@ Blockly.BlockSvg.prototype.setCollapsed = function(collapsed) { renderList[0] = this; } if (this.rendered) { - for (var j = 0, block; block = renderList[j]; j++) { + for (var i = 0, block; block = renderList[i]; i++) { block.render(); } // Don't bump neighbours. @@ -497,7 +497,7 @@ Blockly.BlockSvg.prototype.tab = function(start, forward) { } } } - i = list.indexOf(start); + var i = list.indexOf(start); if (i == -1) { // No start location, start at the beginning or end. i = forward ? -1 : list.length; @@ -792,12 +792,12 @@ Blockly.BlockSvg.prototype.moveConnections_ = function(dx, dy) { myConnections[i].moveBy(dx, dy); } var icons = this.getIcons(); - for (i = 0; i < icons.length; i++) { + for (var i = 0; i < icons.length; i++) { icons[i].computeIconLocation(); } // Recurse through all blocks attached under this one. - for (i = 0; i < this.childBlocks_.length; i++) { + for (var i = 0; i < this.childBlocks_.length; i++) { this.childBlocks_[i].moveConnections_(dx, dy); } }; @@ -862,7 +862,7 @@ Blockly.BlockSvg.prototype.onMouseMove_ = function(e) { if (Blockly.dragMode_ == Blockly.DRAG_FREE) { // Unrestricted dragging. var dxy = goog.math.Coordinate.difference(oldXY, this.dragStartXY_); - group = this.getSvgRoot(); + var group = this.getSvgRoot(); group.translate_ = 'translate(' + newXY.x + ',' + newXY.y + ')'; group.setAttribute('transform', group.translate_ + group.skew_); // Drag all the nested bubbles. @@ -878,7 +878,7 @@ Blockly.BlockSvg.prototype.onMouseMove_ = function(e) { var closestConnection = null; var localConnection = null; var radiusConnection = Blockly.SNAP_RADIUS; - for (i = 0; i < myConnections.length; i++) { + for (var i = 0; i < myConnections.length; i++) { var myConnection = myConnections[i]; var neighbour = myConnection.closest(radiusConnection, dxy); if (neighbour.connection) { diff --git a/core/blockly.js b/core/blockly.js index 2f2d196b7..0536332d8 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -462,10 +462,10 @@ Blockly.getMainWorkspaceMetrics_ = function() { var bottomEdge = Math.max(contentY + contentHeight + viewHeight / 2, contentY + viewHeight); } else { - leftEdge = blockBox.x; - rightEdge = leftEdge + blockBox.width; - topEdge = blockBox.y; - bottomEdge = topEdge + blockBox.height; + var leftEdge = blockBox.x; + var rightEdge = leftEdge + blockBox.width; + var topEdge = blockBox.y; + var bottomEdge = topEdge + blockBox.height; } var absoluteLeft = 0; if (!this.RTL && this.toolbox_) { diff --git a/core/events.js b/core/events.js index cd6880dd8..bc4299e55 100644 --- a/core/events.js +++ b/core/events.js @@ -161,7 +161,7 @@ Blockly.Events.filter = function(queueIn, forward) { } } // Remove null events. - for (i = queue.length - 1; i >= 0; i--) { + for (var i = queue.length - 1; i >= 0; i--) { if (queue[i].isNull()) { queue.splice(i, 1); } @@ -172,7 +172,7 @@ Blockly.Events.filter = function(queueIn, forward) { } // Move mutation events to the top of the queue. // Intentionally skip first event. - for (var k = 1, event; event = queue[k]; k++) { + for (var i = 1, event; event = queue[i]; i++) { if (event.type == Blockly.Events.CHANGE && event.element == 'mutation') { queue.unshift(queue.splice(i, 1)[0]); @@ -254,7 +254,7 @@ Blockly.Events.getDescendantIds_ = function(block) { * Decode the JSON into an event. * @param {!Object} json JSON representation. * @param {!Blockly.Workspace} workspace Target workspace for event. - * @return {!Blockly.Events.Abstract} the event represented by the json. + * @return {!Blockly.Events.Abstract} The event represented by the JSON. */ Blockly.Events.fromJson = function(json, workspace) { var event; diff --git a/core/field.js b/core/field.js index 302ffb996..305ecd6d6 100644 --- a/core/field.js +++ b/core/field.js @@ -254,11 +254,11 @@ Blockly.Field.prototype.render_ = function() { var width = Blockly.Field.cacheWidths_[key]; } else { try { - width = this.textElement_.getComputedTextLength(); + var width = this.textElement_.getComputedTextLength(); } catch (e) { // MSIE 11 is known to throw "Unexpected call to method or property // access." if Blockly is hidden. - width = this.textElement_.textContent.length * 8; + var width = this.textElement_.textContent.length * 8; } if (Blockly.Field.cacheWidths_) { Blockly.Field.cacheWidths_[key] = width; @@ -269,7 +269,7 @@ Blockly.Field.prototype.render_ = function() { width + Blockly.BlockSvg.SEP_SPACE_X); } } else { - width = 0; + var width = 0; } this.size_.width = width; }; diff --git a/core/field_angle.js b/core/field_angle.js index 5eb49a2dd..b5ca196ce 100644 --- a/core/field_angle.js +++ b/core/field_angle.js @@ -66,7 +66,7 @@ Blockly.FieldAngle.prototype.setValidator = function(handler) { if (v1 === undefined) { v1 = value; } - v2 = Blockly.FieldAngle.angleValidator.call(this, v1); + var v2 = Blockly.FieldAngle.angleValidator.call(this, v1); if (v2 === undefined) { v2 = v1; } diff --git a/core/field_variable.js b/core/field_variable.js index 421f9ea08..8e5bac966 100644 --- a/core/field_variable.js +++ b/core/field_variable.js @@ -64,7 +64,7 @@ Blockly.FieldVariable.prototype.setValidator = function(handler) { if (v1 === undefined) { v1 = value; } - v2 = Blockly.FieldVariable.dropdownChange.call(this, v1); + var v2 = Blockly.FieldVariable.dropdownChange.call(this, v1); if (v2 === undefined) { v2 = v1; } @@ -128,7 +128,7 @@ Blockly.FieldVariable.dropdownCreate = function() { var variableList = Blockly.Variables.allVariables(this.sourceBlock_.workspace); } else { - variableList = []; + var variableList = []; } // Ensure that the currently selected variable is an option. var name = this.getText(); diff --git a/core/inject.js b/core/inject.js index fb3cd82d8..4f84b24a3 100644 --- a/core/inject.js +++ b/core/inject.js @@ -211,26 +211,27 @@ Blockly.createMainWorkspace_ = function(svg, options) { var blockXY = block.getRelativeToSurfaceXY(); var blockHW = block.getHeightWidth(); // Bump any block that's above the top back inside. - var overflow = edgeTop + MARGIN - blockHW.height - blockXY.y; - if (overflow > 0) { - block.moveBy(0, overflow); + var overflowTop = edgeTop + MARGIN - blockHW.height - blockXY.y; + if (overflowTop > 0) { + block.moveBy(0, overflowTop); } // Bump any block that's below the bottom back inside. - overflow = edgeTop + metrics.viewHeight - MARGIN - blockXY.y; - if (overflow < 0) { - block.moveBy(0, overflow); + var overflowBottom = + edgeTop + metrics.viewHeight - MARGIN - blockXY.y; + if (overflowBottom < 0) { + block.moveBy(0, overflowBottom); } // Bump any block that's off the left back inside. - overflow = MARGIN + edgeLeft - + var overflowLeft = MARGIN + edgeLeft - blockXY.x - (options.RTL ? 0 : blockHW.width); - if (overflow > 0) { - block.moveBy(overflow, 0); + if (overflowLeft > 0) { + block.moveBy(overflowLeft, 0); } // Bump any block that's off the right back inside. - overflow = edgeLeft + metrics.viewWidth - MARGIN - + var overflowRight = edgeLeft + metrics.viewWidth - MARGIN - blockXY.x + (options.RTL ? blockHW.width : 0); - if (overflow < 0) { - block.moveBy(overflow, 0); + if (overflowRight < 0) { + block.moveBy(overflowRight, 0); } } } diff --git a/core/mutator.js b/core/mutator.js index 50586e082..a53babfd9 100644 --- a/core/mutator.js +++ b/core/mutator.js @@ -115,7 +115,7 @@ Blockly.Mutator.prototype.createEditor_ = function() { quarkXml.appendChild(goog.dom.createDom('block', {'type': quarkName})); } } else { - quarkXml = null; + var quarkXml = null; } var workspaceOptions = { languageTree: quarkXml, @@ -223,8 +223,8 @@ Blockly.Mutator.prototype.setVisible = function(visible) { var margin = this.workspace_.flyout_.CORNER_RADIUS * 2; var x = this.workspace_.flyout_.width_ + margin; } else { - margin = 16; - x = margin; + var margin = 16; + var x = margin; } if (this.block_.RTL) { x = -x; @@ -283,7 +283,7 @@ Blockly.Mutator.prototype.workspaceChanged_ = function() { // When the mutator's workspace changes, update the source block. if (this.rootBlock_.workspace == this.workspace_) { Blockly.Events.setGroup(true); - block = this.block_; + var block = this.block_; var oldMutationDom = block.mutationToDom(); var oldMutation = oldMutationDom && Blockly.Xml.domToText(oldMutationDom); // Switch off rendering while the source block is rebuilt. diff --git a/core/options.js b/core/options.js index 41e4edc3f..57ff21f0a 100644 --- a/core/options.js +++ b/core/options.js @@ -45,26 +45,26 @@ Blockly.Options = function(options) { var hasDisable = false; var hasSounds = false; } else { - languageTree = Blockly.Options.parseToolboxTree(options['toolbox']); - hasCategories = Boolean(languageTree && + var languageTree = Blockly.Options.parseToolboxTree(options['toolbox']); + var hasCategories = Boolean(languageTree && languageTree.getElementsByTagName('category').length); - hasTrashcan = options['trashcan']; + var hasTrashcan = options['trashcan']; if (hasTrashcan === undefined) { hasTrashcan = hasCategories; } - hasCollapse = options['collapse']; + var hasCollapse = options['collapse']; if (hasCollapse === undefined) { hasCollapse = hasCategories; } - hasComments = options['comments']; + var hasComments = options['comments']; if (hasComments === undefined) { hasComments = hasCategories; } - hasDisable = options['disable']; + var hasDisable = options['disable']; if (hasDisable === undefined) { hasDisable = hasCategories; } - hasSounds = options['sounds']; + var hasSounds = options['sounds']; if (hasSounds === undefined) { hasSounds = true; } diff --git a/core/toolbox.js b/core/toolbox.js index 32a10f177..2d765da6e 100644 --- a/core/toolbox.js +++ b/core/toolbox.js @@ -285,7 +285,7 @@ Blockly.Toolbox.prototype.addColour_ = function(opt_tree) { if (this.hasColours_) { var border = '8px solid ' + (child.hexColour || '#ddd'); } else { - border = 'none'; + var border = 'none'; } if (this.workspace_.RTL) { element.style.borderRight = border; @@ -321,7 +321,7 @@ Blockly.Toolbox.prototype.getClientRect = function() { return new goog.math.Rect(toolboxRect.left, -BIG_NUM, width, BIG_NUM * 2); } // LTR - width = BIG_NUM + toolboxRect.width + toolboxRect.left; + var width = BIG_NUM + toolboxRect.width + toolboxRect.left; return new goog.math.Rect(-BIG_NUM, -BIG_NUM, width, BIG_NUM * 2); }; diff --git a/core/tooltip.js b/core/tooltip.js index 86da01d65..6e520e65b 100644 --- a/core/tooltip.js +++ b/core/tooltip.js @@ -317,7 +317,7 @@ Blockly.Tooltip.wrap_ = function(text, limit) { // Seed the list with evenly spaced linebreaks. var steps = words.length / lineCount; var insertedBreaks = 1; - for (i = 0; i < words.length - 1; i++) { + for (var i = 0; i < words.length - 1; i++) { if (insertedBreaks < (i + 1.5) / steps) { insertedBreaks++; wordBreaks[i] = true; @@ -358,7 +358,7 @@ Blockly.Tooltip.wrapScore_ = function(words, wordBreaks, limit) { var maxLength = Math.max.apply(Math, lineLengths); var score = 0; - for (i = 0; i < lineLengths.length; i++) { + for (var i = 0; i < lineLengths.length; i++) { // Optimize for width. // -2 points per char over limit (scaled to the power of 1.5). score -= Math.pow(Math.abs(limit - lineLengths[i]), 1.5) * 2; diff --git a/core/trashcan.js b/core/trashcan.js index a192deb81..429d613c6 100644 --- a/core/trashcan.js +++ b/core/trashcan.js @@ -167,7 +167,7 @@ Blockly.Trashcan.prototype.createDom = function() { body.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', this.workspace_.options.pathToMedia + Blockly.SPRITE.url); - clip = Blockly.createSvgElement('clipPath', + var clip = Blockly.createSvgElement('clipPath', {'id': 'blocklyTrashLidClipPath' + rnd}, this.svgGroup_); Blockly.createSvgElement('rect', diff --git a/core/utils.js b/core/utils.js index a53256867..08961e235 100644 --- a/core/utils.js +++ b/core/utils.js @@ -104,7 +104,7 @@ Blockly.bindEvent_ = function(node, name, thisObject, func) { func.call(thisObject, e); }; } else { - wrapFunc = func; + var wrapFunc = func; } node.addEventListener(name, wrapFunc, false); var bindData = [[node, name, wrapFunc]]; @@ -374,8 +374,8 @@ Blockly.commonWordPrefix = function(array, opt_shortest) { wordPrefix = len + 1; } } - for (i = 1; i < array.length; i++) { - letter = array[i][len]; + for (var i = 1; i < array.length; i++) { + var letter = array[i][len]; if (letter && letter != ' ') { return wordPrefix; } @@ -409,8 +409,8 @@ Blockly.commonWordSuffix = function(array, opt_shortest) { wordPrefix = len + 1; } } - for (i = 1; i < array.length; i++) { - letter = array[i].charAt(array[i].length - len - 1); + for (var i = 1; i < array.length; i++) { + var letter = array[i].charAt(array[i].length - len - 1); if (letter && letter != ' ') { return wordPrefix; } @@ -478,7 +478,7 @@ Blockly.tokenizeInterpolation = function(message) { } } } - text = buffer.join(''); + var text = buffer.join(''); if (text) { tokens.push(text); } diff --git a/core/variables.js b/core/variables.js index e4048a995..12b8eeb06 100644 --- a/core/variables.js +++ b/core/variables.js @@ -123,12 +123,12 @@ Blockly.Variables.flyoutCategory = function(workspace) { // // item // - block = goog.dom.createDom('block'); + var block = goog.dom.createDom('block'); block.setAttribute('type', 'variables_get'); if (Blockly.Blocks['variables_set']) { block.setAttribute('gap', 24); } - field = goog.dom.createDom('field', null, variableList[i]); + var field = goog.dom.createDom('field', null, variableList[i]); field.setAttribute('name', 'VAR'); block.appendChild(field); xmlList.push(block); diff --git a/core/workspace.js b/core/workspace.js index 66a49ea99..e67fbe564 100644 --- a/core/workspace.js +++ b/core/workspace.js @@ -235,7 +235,7 @@ Blockly.Workspace.prototype.undo = function(redo) { } events = Blockly.Events.filter(events, redo); Blockly.Events.recordUndo = false; - for (i = 0; event = events[i]; i++) { + for (var i = 0, event; event = events[i]; i++) { event.run(redo); } Blockly.Events.recordUndo = true; diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 12e52cba3..3c62acac1 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -486,7 +486,7 @@ Blockly.WorkspaceSvg.prototype.paste = function(xmlBlock) { if (!collide) { // Check for blocks in snap range to any of its connections. var connections = block.getConnections_(false); - for (var j = 0, connection; connection = connections[j]; j++) { + for (var i = 0, connection; connection = connections[i]; i++) { var neighbour = connection.closest(Blockly.SNAP_RADIUS, new goog.math.Coordinate(blockX, blockY)); if (neighbour.connection) { @@ -808,7 +808,7 @@ Blockly.WorkspaceSvg.prototype.showContextMenu_ = function(e) { } } } - for (i = 0; i < topBlocks.length; i++) { + for (var i = 0; i < topBlocks.length; i++) { addDeletableBlocks(topBlocks[i]); } var deleteOption = { diff --git a/core/xml.js b/core/xml.js index 5f4d9a987..e2651e025 100644 --- a/core/xml.js +++ b/core/xml.js @@ -109,7 +109,7 @@ Blockly.Xml.blockToDom = function(block) { element.appendChild(dataElement); } - for (i = 0; input = block.inputList[i]; i++) { + for (var i = 0, input; input = block.inputList[i]; i++) { var container; var empty = true; if (input.type == Blockly.DUMMY_INPUT) { @@ -156,11 +156,11 @@ Blockly.Xml.blockToDom = function(block) { var nextBlock = block.getNextBlock(); if (nextBlock) { - container = goog.dom.createDom('next', null, + var container = goog.dom.createDom('next', null, Blockly.Xml.blockToDom(nextBlock)); element.appendChild(container); } - shadow = block.nextConnection && block.nextConnection.getShadowDom(); + var shadow = block.nextConnection && block.nextConnection.getShadowDom(); if (shadow && (!nextBlock || !nextBlock.isShadow())) { container.appendChild(Blockly.Xml.cloneShadow_(shadow)); } @@ -337,7 +337,7 @@ Blockly.Xml.domToBlock = function(xmlBlock, workspace) { for (var i = blocks.length - 1; i >= 0; i--) { blocks[i].initSvg(); } - for (i = blocks.length - 1; i >= 0; i--) { + for (var i = blocks.length - 1; i >= 0; i--) { blocks[i].render(false); } // Populating the connection database may be defered until after the blocks diff --git a/core/zoom_controls.js b/core/zoom_controls.js index 31f06fa9b..d50110829 100644 --- a/core/zoom_controls.js +++ b/core/zoom_controls.js @@ -131,7 +131,7 @@ Blockly.ZoomControls.prototype.createDom = function() { zoomoutSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', workspace.options.pathToMedia + Blockly.SPRITE.url); - clip = Blockly.createSvgElement('clipPath', + var clip = Blockly.createSvgElement('clipPath', {'id': 'blocklyZoominClipPath' + rnd}, this.svgGroup_); Blockly.createSvgElement('rect', @@ -147,7 +147,7 @@ Blockly.ZoomControls.prototype.createDom = function() { zoominSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', workspace.options.pathToMedia + Blockly.SPRITE.url); - clip = Blockly.createSvgElement('clipPath', + var clip = Blockly.createSvgElement('clipPath', {'id': 'blocklyZoomresetClipPath' + rnd}, this.svgGroup_); Blockly.createSvgElement('rect',