Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions appengine/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ BlocklyStorage.link = function(opt_workspace) {
var xml = Blockly.Xml.workspaceToDom(workspace, true);
// Remove x/y coordinates from XML if there's only one block stack.
// There's no reason to store this, removing it helps with anonymity.
if (workspace.getTopBlocks(false).length == 1 && xml.querySelector) {
if (workspace.getTopBlocks(false).length === 1 && xml.querySelector) {
var block = xml.querySelector('block');
if (block) {
block.removeAttribute('x');
Expand Down Expand Up @@ -116,17 +116,17 @@ BlocklyStorage.makeRequest_ = function(url, name, content, workspace) {
* @private
*/
BlocklyStorage.handleRequest_ = function() {
if (BlocklyStorage.httpRequest_.readyState == 4) {
if (BlocklyStorage.httpRequest_.status != 200) {
if (BlocklyStorage.httpRequest_.readyState === 4) {
if (BlocklyStorage.httpRequest_.status !== 200) {
BlocklyStorage.alert(BlocklyStorage.HTTPREQUEST_ERROR + '\n' +
'httpRequest_.status: ' + BlocklyStorage.httpRequest_.status);
} else {
var data = BlocklyStorage.httpRequest_.responseText.trim();
if (BlocklyStorage.httpRequest_.name == 'xml') {
if (BlocklyStorage.httpRequest_.name === 'xml') {
window.location.hash = data;
BlocklyStorage.alert(BlocklyStorage.LINK_ALERT.replace('%1',
window.location.href));
} else if (BlocklyStorage.httpRequest_.name == 'key') {
} else if (BlocklyStorage.httpRequest_.name === 'key') {
if (!data.length) {
BlocklyStorage.alert(BlocklyStorage.HASH_ERROR.replace('%1',
window.location.hash));
Expand All @@ -153,7 +153,7 @@ BlocklyStorage.monitorChanges_ = function(workspace) {
function change() {
var xmlDom = Blockly.Xml.workspaceToDom(workspace);
var xmlText = Blockly.Xml.domToText(xmlDom);
if (startXmlText != xmlText) {
if (startXmlText !== xmlText) {
window.location.hash = '';
workspace.removeChangeListener(change);
}
Expand Down
54 changes: 27 additions & 27 deletions blocks/lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Blockly.Blocks['lists_create_with'] = {
// Disconnect any children that don't belong.
for (var i = 0; i < this.itemCount_; i++) {
var connection = this.getInput('ADD' + i).connection.targetConnection;
if (connection && connections.indexOf(connection) == -1) {
if (connection && connections.indexOf(connection) === -1) {
connection.disconnect();
}
}
Expand Down Expand Up @@ -245,7 +245,7 @@ Blockly.Blocks['lists_create_with'] = {
if (!this.getInput('ADD' + i)) {
var input = this.appendValueInput('ADD' + i)
.setAlign(Blockly.ALIGN_RIGHT);
if (i == 0) {
if (i === 0) {
input.appendField(Blockly.Msg['LISTS_CREATE_WITH_INPUT_WITH']);
}
}
Expand Down Expand Up @@ -341,7 +341,7 @@ Blockly.Blocks['lists_getIndex'] = {
this.setHelpUrl(Blockly.Msg['LISTS_GET_INDEX_HELPURL']);
this.setStyle('list_blocks');
var modeMenu = new Blockly.FieldDropdown(MODE, function(value) {
var isStatement = (value == 'REMOVE');
var isStatement = (value === 'REMOVE');
this.getSourceBlock().updateStatement_(isStatement);
});
this.appendValueInput('VALUE')
Expand Down Expand Up @@ -405,8 +405,8 @@ Blockly.Blocks['lists_getIndex'] = {
tooltip = Blockly.Msg['LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM'];
break;
}
if (where == 'FROM_START' || where == 'FROM_END') {
var msg = (where == 'FROM_START') ?
if (where === 'FROM_START' || where === 'FROM_END') {
var msg = (where === 'FROM_START') ?
Blockly.Msg['LISTS_INDEX_FROM_START_TOOLTIP'] :
Blockly.Msg['LISTS_INDEX_FROM_END_TOOLTIP'];
tooltip += ' ' + msg.replace('%1',
Expand All @@ -425,7 +425,7 @@ Blockly.Blocks['lists_getIndex'] = {
var container = Blockly.utils.xml.createElement('mutation');
var isStatement = !this.outputConnection;
container.setAttribute('statement', isStatement);
var isAt = this.getInput('AT').type == Blockly.INPUT_VALUE;
var isAt = this.getInput('AT').type === Blockly.INPUT_VALUE;
container.setAttribute('at', isAt);
return container;
},
Expand All @@ -437,9 +437,9 @@ Blockly.Blocks['lists_getIndex'] = {
domToMutation: function(xmlElement) {
// Note: Until January 2013 this block did not have mutations,
// so 'statement' defaults to false and 'at' defaults to true.
var isStatement = (xmlElement.getAttribute('statement') == 'true');
var isStatement = (xmlElement.getAttribute('statement') === 'true');
this.updateStatement_(isStatement);
var isAt = (xmlElement.getAttribute('at') != 'false');
var isAt = (xmlElement.getAttribute('at') !== 'false');
this.updateAt_(isAt);
},

Expand All @@ -457,7 +457,7 @@ Blockly.Blocks['lists_getIndex'] = {
*/
updateStatement_: function(newStatement) {
var oldStatement = !this.outputConnection;
if (newStatement != oldStatement) {
if (newStatement !== oldStatement) {
this.unplug(true, true);
if (newStatement) {
this.setOutput(false);
Expand Down Expand Up @@ -491,9 +491,9 @@ Blockly.Blocks['lists_getIndex'] = {
this.appendDummyInput('AT');
}
var menu = new Blockly.FieldDropdown(this.WHERE_OPTIONS, function(value) {
var newAt = (value == 'FROM_START') || (value == 'FROM_END');
var newAt = (value === 'FROM_START') || (value === 'FROM_END');
// The 'isAt' variable is available due to this function being a closure.
if (newAt != isAt) {
if (newAt !== isAt) {
var block = this.getSourceBlock();
block.updateAt_(newAt);
// This menu has been destroyed and replaced. Update the replacement.
Expand Down Expand Up @@ -578,7 +578,7 @@ Blockly.Blocks['lists_setIndex'] = {
tooltip = Blockly.Msg['LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM'];
break;
}
if (where == 'FROM_START' || where == 'FROM_END') {
if (where === 'FROM_START' || where === 'FROM_END') {
tooltip += ' ' + Blockly.Msg['LISTS_INDEX_FROM_START_TOOLTIP']
.replace('%1',
thisBlock.workspace.options.oneBasedIndex ? '#1' : '#0');
Expand All @@ -593,7 +593,7 @@ Blockly.Blocks['lists_setIndex'] = {
*/
mutationToDom: function() {
var container = Blockly.utils.xml.createElement('mutation');
var isAt = this.getInput('AT').type == Blockly.INPUT_VALUE;
var isAt = this.getInput('AT').type === Blockly.INPUT_VALUE;
container.setAttribute('at', isAt);
return container;
},
Expand All @@ -605,7 +605,7 @@ Blockly.Blocks['lists_setIndex'] = {
domToMutation: function(xmlElement) {
// Note: Until January 2013 this block did not have mutations,
// so 'at' defaults to true.
var isAt = (xmlElement.getAttribute('at') != 'false');
var isAt = (xmlElement.getAttribute('at') !== 'false');
this.updateAt_(isAt);
},

Expand Down Expand Up @@ -635,9 +635,9 @@ Blockly.Blocks['lists_setIndex'] = {
this.appendDummyInput('AT');
}
var menu = new Blockly.FieldDropdown(this.WHERE_OPTIONS, function(value) {
var newAt = (value == 'FROM_START') || (value == 'FROM_END');
var newAt = (value === 'FROM_START') || (value === 'FROM_END');
// The 'isAt' variable is available due to this function being a closure.
if (newAt != isAt) {
if (newAt !== isAt) {
var block = this.getSourceBlock();
block.updateAt_(newAt);
// This menu has been destroyed and replaced. Update the replacement.
Expand Down Expand Up @@ -697,9 +697,9 @@ Blockly.Blocks['lists_getSublist'] = {
*/
mutationToDom: function() {
var container = Blockly.utils.xml.createElement('mutation');
var isAt1 = this.getInput('AT1').type == Blockly.INPUT_VALUE;
var isAt1 = this.getInput('AT1').type === Blockly.INPUT_VALUE;
container.setAttribute('at1', isAt1);
var isAt2 = this.getInput('AT2').type == Blockly.INPUT_VALUE;
var isAt2 = this.getInput('AT2').type === Blockly.INPUT_VALUE;
container.setAttribute('at2', isAt2);
return container;
},
Expand All @@ -709,8 +709,8 @@ Blockly.Blocks['lists_getSublist'] = {
* @this {Blockly.Block}
*/
domToMutation: function(xmlElement) {
var isAt1 = (xmlElement.getAttribute('at1') == 'true');
var isAt2 = (xmlElement.getAttribute('at2') == 'true');
var isAt1 = (xmlElement.getAttribute('at1') === 'true');
var isAt2 = (xmlElement.getAttribute('at2') === 'true');
this.updateAt_(1, isAt1);
this.updateAt_(2, isAt2);
},
Expand Down Expand Up @@ -745,10 +745,10 @@ Blockly.Blocks['lists_getSublist'] = {
}
var menu = new Blockly.FieldDropdown(this['WHERE_OPTIONS_' + n],
function(value) {
var newAt = (value == 'FROM_START') || (value == 'FROM_END');
var newAt = (value === 'FROM_START') || (value === 'FROM_END');
// The 'isAt' variable is available due to this function being a
// closure.
if (newAt != isAt) {
if (newAt !== isAt) {
var block = this.getSourceBlock();
block.updateAt_(n, newAt);
// This menu has been destroyed and replaced.
Expand All @@ -759,7 +759,7 @@ Blockly.Blocks['lists_getSublist'] = {
});
this.getInput('AT' + n)
.appendField(menu, 'WHERE' + n);
if (n == 1) {
if (n === 1) {
this.moveInputBefore('AT1', 'AT2');
if (this.getInput('ORDINAL1')) {
this.moveInputBefore('ORDINAL1', 'AT2');
Expand Down Expand Up @@ -839,9 +839,9 @@ Blockly.Blocks['lists_split'] = {
this.setOutput(true, 'Array');
this.setTooltip(function() {
var mode = thisBlock.getFieldValue('MODE');
if (mode == 'SPLIT') {
if (mode === 'SPLIT') {
return Blockly.Msg['LISTS_SPLIT_TOOLTIP_SPLIT'];
} else if (mode == 'JOIN') {
} else if (mode === 'JOIN') {
return Blockly.Msg['LISTS_SPLIT_TOOLTIP_JOIN'];
}
throw Error('Unknown mode: ' + mode);
Expand All @@ -855,7 +855,7 @@ Blockly.Blocks['lists_split'] = {
*/
updateType_: function(newMode) {
var mode = this.getFieldValue('MODE');
if (mode != newMode) {
if (mode !== newMode) {
var inputConnection = this.getInput('INPUT').connection;
inputConnection.setShadowDom(null);
var inputBlock = inputConnection.targetBlock();
Expand All @@ -868,7 +868,7 @@ Blockly.Blocks['lists_split'] = {
}
}
}
if (newMode == 'SPLIT') {
if (newMode === 'SPLIT') {
this.outputConnection.setCheck('Array');
this.getInput('INPUT').setCheck('String');
} else {
Expand Down
2 changes: 1 addition & 1 deletion blocks/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ Blockly.Constants.Logic.LOGIC_TERNARY_ONCHANGE_MIXIN = {
// Disconnect blocks that existed prior to this change if they don't match.
if ((blockA || blockB) && parentConnection) {
for (var i = 0; i < 2; i++) {
var block = (i == 1) ? blockA : blockB;
var block = (i === 1) ? blockA : blockB;
if (block &&
!block.workspace.connectionChecker.doTypeChecks(
block.outputConnection, parentConnection)) {
Expand Down
6 changes: 3 additions & 3 deletions blocks/loops.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ Blockly.Constants.Loops.CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN = {
}
var variable = this.getField('VAR').getVariable();
var varName = variable.name;
if (!this.isCollapsed() && varName != null) {
if (!this.isCollapsed() && varName !== null) {
var option = {enabled: true};
option.text =
Blockly.Msg['VARIABLES_SET_CREATE_GET'].replace('%1', varName);
Expand Down Expand Up @@ -310,7 +310,7 @@ Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN = {
// Is the block nested in a loop?
do {
if (Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN.LOOP_TYPES
.indexOf(block.type) != -1) {
.indexOf(block.type) !== -1) {
return block;
}
block = block.getSurroundParent();
Expand All @@ -329,7 +329,7 @@ Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN = {
// * It's at the start of a drag.
// * It's not a move event.
if (!this.workspace.isDragging || this.workspace.isDragging() ||
e.type != Blockly.Events.BLOCK_MOVE) {
e.type !== Blockly.Events.BLOCK_MOVE) {
return;
}
var enabled = Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN
Expand Down
8 changes: 4 additions & 4 deletions blocks/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ Blockly.Constants.Math.IS_DIVISIBLEBY_MUTATOR_MIXIN = {
*/
mutationToDom: function() {
var container = Blockly.utils.xml.createElement('mutation');
var divisorInput = (this.getFieldValue('PROPERTY') == 'DIVISIBLE_BY');
var divisorInput = (this.getFieldValue('PROPERTY') === 'DIVISIBLE_BY');
container.setAttribute('divisor_input', divisorInput);
return container;
},
Expand All @@ -462,7 +462,7 @@ Blockly.Constants.Math.IS_DIVISIBLEBY_MUTATOR_MIXIN = {
* @this {Blockly.Block}
*/
domToMutation: function(xmlElement) {
var divisorInput = (xmlElement.getAttribute('divisor_input') == 'true');
var divisorInput = (xmlElement.getAttribute('divisor_input') === 'true');
this.updateShape_(divisorInput);
},

Expand Down Expand Up @@ -500,7 +500,7 @@ Blockly.Constants.Math.IS_DIVISIBLEBY_MUTATOR_MIXIN = {
*/
Blockly.Constants.Math.IS_DIVISIBLE_MUTATOR_EXTENSION = function() {
this.getField('PROPERTY').setValidator(function(option) {
var divisorInput = (option == 'DIVISIBLE_BY');
var divisorInput = (option === 'DIVISIBLE_BY');
this.getSourceBlock().updateShape_(divisorInput);
});
};
Expand Down Expand Up @@ -530,7 +530,7 @@ Blockly.Constants.Math.LIST_MODES_MUTATOR_MIXIN = {
* @this {Blockly.Block}
*/
updateType_: function(newOp) {
if (newOp == 'MODE') {
if (newOp === 'MODE') {
this.outputConnection.setCheck('Array');
} else {
this.outputConnection.setCheck('Number');
Expand Down
Loading