From 6eb652cf708017df4458c338cad642463ebe5554 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Mon, 29 Feb 2016 15:02:05 -0800 Subject: [PATCH] Fix persistence of logging in playground. --- core/variables.js | 18 +++++++----------- msg/messages.js | 6 +++--- tests/playground.html | 2 +- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/core/variables.js b/core/variables.js index db506fb9c..46deb7619 100644 --- a/core/variables.js +++ b/core/variables.js @@ -56,14 +56,12 @@ Blockly.Variables.allVariables = function(root) { var variableHash = Object.create(null); // Iterate through every block and add each variable to the hash. for (var x = 0; x < blocks.length; x++) { - if (blocks[x].getVars) { - var blockVariables = blocks[x].getVars(); - for (var y = 0; y < blockVariables.length; y++) { - var varName = blockVariables[y]; - // Variable name may be null if the block is only half-built. - if (varName) { - variableHash[varName.toLowerCase()] = varName; - } + var blockVariables = blocks[x].getVars(); + for (var y = 0; y < blockVariables.length; y++) { + var varName = blockVariables[y]; + // Variable name may be null if the block is only half-built. + if (varName) { + variableHash[varName.toLowerCase()] = varName; } } } @@ -85,9 +83,7 @@ Blockly.Variables.renameVariable = function(oldName, newName, workspace) { var blocks = workspace.getAllBlocks(); // Iterate through every block. for (var i = 0; i < blocks.length; i++) { - if (blocks[i].renameVar) { - blocks[i].renameVar(oldName, newName); - } + blocks[i].renameVar(oldName, newName); } }; diff --git a/msg/messages.js b/msg/messages.js index 6467ca968..7e4a3dddd 100644 --- a/msg/messages.js +++ b/msg/messages.js @@ -43,9 +43,9 @@ goog.require('Blockly.Msg'); */ /** - * Tip: Generate URLs for read-only blocks by creating the blocks in the Code app, - * then evaluating this in the console: - * 'http://blockly-demo.appspot.com/static/apps/code/readonly.html?lang=en&xml=' + encodeURIComponent(Blockly.Xml.domToText(Blockly.Xml.workspaceToDom(Blockly.mainWorkspace)).slice(5, -6)) + * Each message is preceded with a tripple-slash comment that becomes the + * message descriptor. The build process extracts these descriptors, adds + * them to msg/json/qqq.json, and they show up in the translation console. */ /// default name - A simple, general default name for a variable, preferably short. diff --git a/tests/playground.html b/tests/playground.html index 2f3d98167..e0a225b2b 100644 --- a/tests/playground.html +++ b/tests/playground.html @@ -89,7 +89,7 @@ function start() { taChange(); // Restore event logging state. var state = sessionStorage.getItem('logEvents'); - logEvents(Boolean(state)); + logEvents(Boolean(Number(state))); } function toXml() {