diff --git a/blocks.js b/blocks.js index f8289d84..b00510a8 100644 --- a/blocks.js +++ b/blocks.js @@ -149,7 +149,7 @@ isSnapObject, copy, PushButtonMorph, SpriteIconMorph, Process, AlignmentMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2016-December-19'; +modules.blocks = '2016-December-27'; var SyntaxElementMorph; var BlockMorph; @@ -246,52 +246,52 @@ SyntaxElementMorph.uber = Morph.prototype; outline: - corner - radius of command block rounding + corner - radius of command block rounding rounding - radius of reporter block rounding edge - width of 3D-ish shading box - hatHeight - additional top space for hat blocks + hatHeight - additional top space for hat blocks hatWidth - minimum width for hat blocks rfBorder - pixel width of reification border (grey outline) minWidth - minimum width for any syntax element's contents jigsaw shape: - inset - distance from indentation to left edge + inset - distance from indentation to left edge dent - width of indentation bottom paddings: - bottomPadding - adds to the width of the bottom most c-slot + bottomPadding - adds to the width of the bottom most c-slot cSlotPadding - adds to the width of the open "C" in c-slots - typeInPadding - adds pixels between text and edge in input slots + typeInPadding - adds pixels between text and edge in input slots labelPadding - adds left/right pixels to block labels label: - labelFontName - specific font family name - labelFontStyle - generic font family name, cascaded - fontSize - duh - embossing - offset for embossing effect - labelWidth - column width, used for word wrapping - labelWordWrap - if true labels can break after each word - dynamicInputLabels - if true inputs can have dynamic labels + labelFontName - specific font family name + labelFontStyle - generic font family name, cascaded + fontSize - duh + embossing - offset for embossing effect + labelWidth - column width, used for word wrapping + labelWordWrap - if true labels can break after each word + dynamicInputLabels - if true inputs can have dynamic labels snapping: - feedbackColor - for displaying drop feedbacks - feedbackMinHeight - height of white line for command block snaps - minSnapDistance - threshold when commands start snapping - reporterDropFeedbackPadding - increases reporter drop feedback + feedbackColor - for displaying drop feedbacks + feedbackMinHeight - height of white line for command block snaps + minSnapDistance - threshold when commands start snapping + reporterDropFeedbackPadding - increases reporter drop feedback color gradients: contrast - 3D-ish shading gradient contrast - labelContrast - 3D-ish label shading contrast - activeHighlight - for stack highlighting when active - errorHighlight - for error highlighting - activeBlur - shadow for blurred activeHighlight + labelContrast - 3D-ish label shading contrast + activeHighlight - for stack highlighting when active + errorHighlight - for error highlighting + activeBlur - shadow for blurred activeHighlight activeBorder - unblurred activeHighlight - rfColor - for reified outlines and slot backgrounds + rfColor - for reified outlines and slot backgrounds */ SyntaxElementMorph.prototype.setScale = function (num) { @@ -1120,7 +1120,8 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { part = new InputSlotMorph( null, false, - { color: ['color'], + { + color: ['color'], fisheye: ['fisheye'], whirl: ['whirl'], pixelate: ['pixelate'], @@ -2020,14 +2021,14 @@ SyntaxElementMorph.prototype.endLayout = function () { SyntaxElementMorph my most important attributes and public accessors are: - selector - (string) name of method to be triggered - receiver() - answer the object (sprite) to which I apply - inputs() - answer an array with my arg slots and nested reporters - defaults - an optional Array containing default input values - topBlock() - answer the top block of the stack I'm attached to - blockSpec - a formalized description of my label parts - setSpec() - force me to change my label structure - evaluate() - answer the result of my evaluation + selector - (string) name of method to be triggered + receiver() - answer the object (sprite) to which I apply + inputs() - answer an array with my arg slots and nested reporters + defaults - an optional Array containing default input values + topBlock() - answer the top block of the stack I'm attached to + blockSpec - a formalized description of my label parts + setSpec() - force me to change my label structure + evaluate() - answer the result of my evaluation isUnevaluated() - answer whether I am part of a special form Zebra coloring provides a mechanism to alternate brightness of nested, @@ -2101,28 +2102,28 @@ SyntaxElementMorph.prototype.endLayout = function () { arity: multiple - %mult%x - where %x stands for any of the above single inputs - %inputs - for an additional text label 'with inputs' - %words - for an expandable list of default 2 (used in JOIN) - %exp - for a static expandable list of minimum 0 (used in LIST) - %scriptVars - for an expandable list of variable reporter templates - %parms - for an expandable list of formal parameters - %ringparms - the same for use inside Rings + %mult%x - where %x stands for any of the above single inputs + %inputs - for an additional text label 'with inputs' + %words - for an expandable list of default 2 (used in JOIN) + %exp - for a static expandable list of minimum 0 (used in LIST) + %scriptVars - for an expandable list of variable reporter templates + %parms - for an expandable list of formal parameters + %ringparms - the same for use inside Rings special form: upvar - %upvar - same as %t (inline variable reporter template) + %upvar - same as %t (inline variable reporter template) special form: input name - %inputName - variable blob (used in input type dialog) + %inputName - variable blob (used in input type dialog) examples: 'if %b %c else %c' - creates Scratch's If/Else block - 'set pen color to %clr' - creates Scratch's Pen color block + 'set pen color to %clr' - creates Scratch's Pen color block 'list %mult%s' - creates BYOB's list reporter block - 'call %n %inputs' - creates BYOB's Call block + 'call %n %inputs' - creates BYOB's Call block 'the script %parms %c' - creates BYOB's THE SCRIPT block */ @@ -2349,7 +2350,7 @@ BlockMorph.prototype.userMenu = function () { menu.addItem( "script pic with result...", function () { - top.ExportResultPic(); + top.exportResultPic(); }, 'open a new window\n' + 'with a picture of both\nthis script and its result', @@ -4909,7 +4910,7 @@ ReporterBlockMorph.prototype.mouseClickLeft = function (pos) { // ReporterBlock exporting picture with result bubble -ReporterBlockMorph.prototype.ExportResultPic = function () { +ReporterBlockMorph.prototype.exportResultPic = function () { var top = this.topBlock(), receiver = top.receiver(), stage; @@ -4923,7 +4924,6 @@ ReporterBlockMorph.prototype.ExportResultPic = function () { } }; - // ReporterBlockMorph deleting ReporterBlockMorph.prototype.userDestroy = function () { @@ -8620,19 +8620,18 @@ TemplateSlotMorph.prototype.unflash = function () { I am a diamond-shaped argument slot. My block spec is - %b - Boolean + %b - Boolean %boolUE - Boolean unevaluated I can be directly edited. When the user clicks on me I toggle between , and values. - evaluate returns my value. + evaluate() returns my value. my most important public attributes and accessors are: - value - user editable contents (Boolean or null) + value - user editable contents (Boolean or null) setContents(Boolean/null) - display the argument (Boolean or null) - */ // BooleanSlotMorph inherits from ArgMorph: @@ -10848,7 +10847,7 @@ function BlockHighlightMorph() { evaluation is handles by the interpreter */ -// MultiArgMorph inherits from ArgMorph: +// MultiArgMorph inherits from ArgMorph: MultiArgMorph.prototype = new ArgMorph(); MultiArgMorph.prototype.constructor = MultiArgMorph; @@ -11256,10 +11255,9 @@ MultiArgMorph.prototype.mappedCode = function (definitions) { // MultiArgMorph arity evaluating: MultiArgMorph.prototype.evaluate = function () { -/* - this is usually overridden by the interpreter. This method is only - called (and needed) for the variables menu. -*/ + // this is usually overridden by the interpreter. This method is only + // called (and needed) for the variables menu. + var result = []; this.inputs().forEach(function (slot) { result.push(slot.evaluate()); @@ -11285,7 +11283,7 @@ MultiArgMorph.prototype.isEmptySlot = function () { input's value along. */ -// ArgLabelMorph inherits from ArgMorph: +// ArgLabelMorph inherits from ArgMorph: ArgLabelMorph.prototype = new ArgMorph(); ArgLabelMorph.prototype.constructor = ArgLabelMorph; @@ -11395,10 +11393,9 @@ ArgLabelMorph.prototype.reactToGrabOf = function () { // ArgLabelMorph evaluating: ArgLabelMorph.prototype.evaluate = function () { -/* - this is usually overridden by the interpreter. This method is only - called (and needed) for the variables menu. -*/ + // this is usually overridden by the interpreter. This method is only + // called (and needed) for the variables menu. + return this.argMorph().evaluate(); }; @@ -11410,7 +11407,7 @@ ArgLabelMorph.prototype.isEmptySlot = function () { /* I am an unevaluated, non-editable, rf-colored, rounded or diamond - input slot. My current (only) use is in the THE BLOCK block. + input slot. My current (only) use is in the THE BLOCK block. My command spec is %f */ diff --git a/byob.js b/byob.js index d56ed8d5..f7b8e55e 100644 --- a/byob.js +++ b/byob.js @@ -2,7 +2,7 @@ byob.js - "build your own blocks" for SNAP! + "build your own blocks" for Snap! based on morphic.js, widgets.js blocks.js, threads.js and objects.js inspired by Scratch @@ -108,7 +108,7 @@ WatcherMorph, Variable*/ // Global stuff //////////////////////////////////////////////////////// -modules.byob = '2016-September-27'; +modules.byob = '2016-December-27'; // Declarations diff --git a/gui.js b/gui.js index ed1381e6..d7f5c778 100644 --- a/gui.js +++ b/gui.js @@ -72,7 +72,7 @@ isRetinaSupported, SliderMorph, Animation*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2016-December-19'; +modules.gui = '2016-December-27'; // Declarations @@ -1358,6 +1358,7 @@ IDE_Morph.prototype.createSpriteEditor = function () { this.spriteEditor.contents.acceptsDrops = true; scripts.scrollFrame = this.spriteEditor; + scripts.updateUndropControls(); this.add(this.spriteEditor); this.spriteEditor.scrollX(this.spriteEditor.padding); this.spriteEditor.scrollY(this.spriteEditor.padding); @@ -2410,6 +2411,20 @@ IDE_Morph.prototype.settingsMenu = function () { ); } menu.addLine(); + /* + addPreference( + 'JavaScript', + function () { + Process.prototype.enableJS = !Process.prototype.enableJS; + myself.currentSprite.blocksCache.operators = null; + myself.currentSprite.paletteCache.operators = null; + myself.refreshPalette(); + }, + Process.prototype.enableJS, + 'uncheck to disable support for\nnative JavaScript functions', + 'check to support\nnative JavaScript functions' + ); + */ if (isRetinaSupported()) { addPreference( 'Retina display support', @@ -2485,7 +2500,7 @@ IDE_Morph.prototype.settingsMenu = function () { 'Execute on slider change', 'toggleSliderExecute', ArgMorph.prototype.executeOnSliderEdit, - 'uncheck to supress\nrunning scripts\nwhen moving the slider', + 'uncheck to suppress\nrunning scripts\nwhen moving the slider', 'check to run\nthe edited script\nwhen moving the slider' ); } @@ -4475,6 +4490,8 @@ IDE_Morph.prototype.toggleAppMode = function (appMode) { } }); } + // update undrop controls + this.currentSprite.scripts.updateUndropControls(); } this.setExtent(this.world().extent()); // resume trackChanges }; diff --git a/history.txt b/history.txt index 901af8f5..097ab1bf 100755 --- a/history.txt +++ b/history.txt @@ -3206,6 +3206,24 @@ http://snap.berkeley.edu/run#cloud:Username=jens&ProjectName=rotation ------ * Objects: added Boolean operators to “reporterize” +161222 +------ +* Objects: simplified reporterize>>blockFromAST +* Threads: prevented color slots from flashing. Good catch, thanks, Joan! + +161223 +------ +* Objects: tweaked reporterize infixParser + +161225 +------ +* GUI: update undrop controls when switching sprites and display modes + +161227 +------ +* GUI, Threads, Objects, Store: Disable JS-Functions, to protect users from malicious scripts, commented out for now + + == v4.10 === (in development) Features: diff --git a/lang-ca.js b/lang-ca.js index a5d5934a..7c972725 100644 --- a/lang-ca.js +++ b/lang-ca.js @@ -846,7 +846,7 @@ SnapTranslator.dict.ca = { 'uncheck for round ends of lines': 'desmarqueu per fer que\nels extrems de les línies\ndel llapis siguin arrodonides', 'Inheritance support': - 'Suport per a herència', + 'Suport a l\'herència d\'objectes', // inputs 'with inputs': @@ -1122,9 +1122,9 @@ SnapTranslator.dict.ca = { 'Command\n(C-shape)': 'Comanda\n(en forma de C)', 'Any\n(unevaluated)': - 'Qualsevol\n(sense evaluar)', + 'Qualsevol\n(sense avaluar)', 'Boolean\n(unevaluated)': - 'Booleà\n(sense evaluar)', + 'Booleà\n(sense avaluar)', 'Single input.': 'Entrada única.', 'Default Value:': @@ -1904,8 +1904,6 @@ SnapTranslator.dict.ca = { 'desmarqueu per deshabilitar\nel suport a l\'edició per teclat', 'check to enable\nkeyboard editing support': 'marqueu per habilitar\nel suport a l\'edició per teclat', - 'Inheritance support': - 'Suport a l\'herència d\'objectes', 'uncheck to disable\nsprite inheritance features': 'desmarqueu per deshabilitar les\nfuncionalitats relatives a l\'herència d\'objectes', 'check for sprite\ninheritance features': @@ -1924,8 +1922,6 @@ SnapTranslator.dict.ca = { 'captura de pantalla', 'stage image': 'imatge de l\'escenari', - 'frames': - 'frames', 'processes': 'processos', 'map %repRing over %l': diff --git a/lang-pt.js b/lang-pt.js index b9d4a11f..15c6abf1 100755 --- a/lang-pt.js +++ b/lang-pt.js @@ -1909,8 +1909,6 @@ SnapTranslator.dict.pt = { 'Desassinalar para desactivar\na edição usando o teclado.', 'check to enable\nkeyboard editing support': 'Assinalar para activar\na edição usando o teclado.', - 'Inheritance support': - 'Suporte para herança', 'uncheck to disable\nsprite inheritance features': 'Desassinalar para desactivar\nfuncionalidades de herança de actores.', 'check for sprite\ninheritance features': diff --git a/lang-zh.js b/lang-zh_CN.js similarity index 99% rename from lang-zh.js rename to lang-zh_CN.js index d6bdb6a6..2e91b246 100644 --- a/lang-zh.js +++ b/lang-zh_CN.js @@ -1,6 +1,6 @@ /* - lang-zh.js + lang-zh_CN.js Simplified Chinese translation for SNAP! @@ -166,7 +166,7 @@ /*global SnapTranslator*/ -SnapTranslator.dict.zh = { +SnapTranslator.dict.zh_CN = { /* Special characters: (see ) diff --git a/lang-tw.js b/lang-zh_TW.js similarity index 95% rename from lang-tw.js rename to lang-zh_TW.js index aea55857..5e7420e2 100644 --- a/lang-tw.js +++ b/lang-zh_TW.js @@ -1,6 +1,6 @@ /* - lang-tw.js + lang-zh_TW.js Traditional Chinese translation for SNAP! SNAP 繁體中文翻譯版 @@ -167,7 +167,7 @@ /*global SnapTranslator*/ -SnapTranslator.dict.tw = { +SnapTranslator.dict.zh_TW = { /* Special characters: (see ) diff --git a/libraries/try-catch.xml b/libraries/try-catch.xml new file mode 100644 index 00000000..ee989ca3 --- /dev/null +++ b/libraries/try-catch.xml @@ -0,0 +1 @@ +
return
\ No newline at end of file diff --git a/locale.js b/locale.js index 37331c57..dc167c1c 100644 --- a/locale.js +++ b/locale.js @@ -42,7 +42,7 @@ /*global modules, contains*/ -modules.locale = '2016-December-09'; +modules.locale = '2016-December-27'; // Global stuff @@ -229,7 +229,7 @@ SnapTranslator.dict.cs = { '2015-11-16' }; -SnapTranslator.dict.zh = { +SnapTranslator.dict.zh_CN = { 'language_name': '简体中文', 'language_translator': @@ -317,7 +317,7 @@ SnapTranslator.dict.pl = { '2016-11-14' }; -SnapTranslator.dict.tw = { +SnapTranslator.dict.zh_TW = { 'language_name': '繁體中文', 'language_translator': diff --git a/morphic.js b/morphic.js index fdd2d099..60561149 100644 --- a/morphic.js +++ b/morphic.js @@ -1136,7 +1136,7 @@ /*global window, HTMLCanvasElement, FileReader, Audio, FileList*/ -var morphicVersion = '2016-December-12'; +var morphicVersion = '2016-December-27'; var modules = {}; // keep track of additional loaded modules var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug @@ -3849,9 +3849,7 @@ Morph.prototype.perish = function (msecs, onComplete) { // Morph utilities: -Morph.prototype.nop = function () { - nop(); -}; +Morph.prototype.nop = nop; Morph.prototype.resize = function () { this.world().activeHandle = new HandleMorph(this); @@ -4122,7 +4120,7 @@ Morph.prototype.developersMenu = function () { menu.addItem( "pick up", 'pickUp', - 'disattach and put \ninto the hand' + 'detach and put \ninto the hand' ); menu.addItem( "attach...", @@ -6310,9 +6308,7 @@ SliderButtonMorph.prototype.init = function (orientation) { SliderButtonMorph.uber.init.call(this, orientation); }; -SliderButtonMorph.prototype.autoOrientation = function () { - nop(); -}; +SliderButtonMorph.prototype.autoOrientation = nop; SliderButtonMorph.prototype.drawNew = function () { var colorBak = this.color.copy(); @@ -6548,9 +6544,7 @@ SliderMorph.prototype.init = function ( // this.drawNew(); }; -SliderMorph.prototype.autoOrientation = function () { - nop(); -}; +SliderMorph.prototype.autoOrientation = nop; SliderMorph.prototype.rangeSize = function () { return this.stop - this.start; @@ -9833,9 +9827,7 @@ ScrollFrameMorph.prototype.scrollY = function (steps) { } }; -ScrollFrameMorph.prototype.step = function () { - nop(); -}; +ScrollFrameMorph.prototype.step = nop; ScrollFrameMorph.prototype.mouseDownLeft = function (pos) { if (!this.isScrollingByDragging) { @@ -10026,7 +10018,6 @@ ScrollFrameMorph.prototype.developersMenu = function () { return menu; }; - ScrollFrameMorph.prototype.toggleTextLineWrapping = function () { this.isTextLineWrapping = !this.isTextLineWrapping; }; @@ -11447,21 +11438,13 @@ WorldMorph.prototype.initEventListeners = function () { }; }; -WorldMorph.prototype.mouseDownLeft = function () { - nop(); -}; +WorldMorph.prototype.mouseDownLeft = nop; -WorldMorph.prototype.mouseClickLeft = function () { - nop(); -}; +WorldMorph.prototype.mouseClickLeft = nop; -WorldMorph.prototype.mouseDownRight = function () { - nop(); -}; +WorldMorph.prototype.mouseDownRight = nop; -WorldMorph.prototype.mouseClickRight = function () { - nop(); -}; +WorldMorph.prototype.mouseClickRight = nop; WorldMorph.prototype.wantsDropOf = function () { // allow handle drops if any drops are allowed @@ -11538,7 +11521,7 @@ WorldMorph.prototype.contextMenu = function () { menu.addItem( "fill page...", 'fillPage', - 'let the World automatically\nadjust to browser resizings' + 'let the World automatically\nadjust to browser resizing' ); if (useBlurredShadows) { menu.addItem( diff --git a/objects.js b/objects.js index df32b857..54482b4e 100644 --- a/objects.js +++ b/objects.js @@ -82,7 +82,7 @@ SpeechBubbleMorph, RingMorph, isNil, FileReader, TableDialogMorph, BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize, TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph*/ -modules.objects = '2016-December-21'; +modules.objects = '2016-December-27'; var SpriteMorph; var StageMorph; @@ -2027,8 +2027,11 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('reportIsA')); blocks.push(block('reportIsIdentical')); - blocks.push('-'); - blocks.push(block('reportJSFunction')); + + if (true) { // (Process.prototype.enableJS) { + blocks.push('-'); + blocks.push(block('reportJSFunction')); + } // for debugging: /////////////// @@ -2641,8 +2644,8 @@ SpriteMorph.prototype.reporterize = function (expressionString) { var ast; function parseInfix(expression, operator, already) { - // very basic binary infix parser for arithmetic expressions - // with strict left-to-right operator precedence (like in Smalltalk) + // very basic diadic infix parser for arithmetic expressions + // with strict left-to-right operator precedence (as in Smalltalk) // which can be overriden by - nested - parentheses. // assumes well-formed expressions, no graceful error handling yet. @@ -2702,13 +2705,17 @@ SpriteMorph.prototype.reporterize = function (expressionString) { case '&': case '|': if (!operator && !inputs[0].length) { - inputs[0] += ch; + inputs[0] = ch; } else if (operator) { - return parseInfix( - expression.slice(idx), - ch, - [operator, already, format(inputs[1])] - ); + if (!inputs[1].length) { + inputs[1] = ch; + } else { + return parseInfix( + expression.slice(idx), + ch, + [operator, already, format(inputs[1])] + ); + } } else { operator = ch; already = format(inputs[0]); @@ -2725,7 +2732,8 @@ SpriteMorph.prototype.reporterize = function (expressionString) { } function blockFromAST(ast) { - var block, selectors, monads, alias, key, sel, i, inps; + var block, selectors, monads, alias, key, sel, i, inps, + off = 1; selectors = { '+': 'reportSum', '-': 'reportDifference', @@ -2747,60 +2755,40 @@ SpriteMorph.prototype.reporterize = function (expressionString) { '!' : 'not' }; key = alias[ast[0]] || ast[0]; - if (contains(monads, key)) { + if (contains(monads, key)) { // monadic sel = selectors[key]; - if (sel) { + if (sel) { // single input block = SpriteMorph.prototype.blockForSelector(sel); inps = block.inputs(); - i = 0; - } else { + } else { // two inputs, first is function name block = SpriteMorph.prototype.blockForSelector('reportMonadic'); inps = block.inputs(); inps[0].setContents([key]); - i = 1; + off = 0; } - if (ast[1] instanceof Array) { - block.silentReplaceInput(inps[i], blockFromAST(ast[1])); - } else if (isString(ast[1])) { - if (contains(['true', 'false'], ast[1])) { + } else { // diadic + block = SpriteMorph.prototype.blockForSelector(selectors[key]); + inps = block.inputs(); + } + for (i = 1; i < ast.length; i += 1) { + if (ast[i] instanceof Array) { + block.silentReplaceInput(inps[i - off], blockFromAST(ast[i])); + } else if (isString(ast[i])) { + if (contains(['true', 'false'], ast[i])) { block.silentReplaceInput( - inps[i], + inps[i - off], SpriteMorph.prototype.blockForSelector( - ast[1] === 'true' ? 'reportTrue' : 'reportFalse' + ast[i] === 'true' ? 'reportTrue' : 'reportFalse' ) ); - } else if (ast[1] !== '_') { + } else if (ast[i] !== '_') { block.silentReplaceInput( - inps[i], - SpriteMorph.prototype.variableBlock(ast[1]) + inps[i - off], + SpriteMorph.prototype.variableBlock(ast[i]) ); } } else { // number - inps[i].setContents(ast[1]); - } - } else { // diadic - block = SpriteMorph.prototype.blockForSelector(selectors[ast[0]]); - inps = block.inputs(); - for (i = 1; i < 3; i += 1) { - if (ast[i] instanceof Array) { - block.silentReplaceInput(inps[i - 1], blockFromAST(ast[i])); - } else if (isString(ast[i])) { - if (contains(['true', 'false'], ast[i])) { - block.silentReplaceInput( - inps[i - 1], - SpriteMorph.prototype.blockForSelector( - ast[i] === 'true' ? 'reportTrue' : 'reportFalse' - ) - ); - } else if (ast[i] !== '_') { - block.silentReplaceInput( - inps[i - 1], - SpriteMorph.prototype.variableBlock(ast[i]) - ); - } - } else { // number - inps[i - 1].setContents(ast[i]); - } + inps[i - off].setContents(ast[i]); } } block.isDraggable = true; @@ -6248,8 +6236,11 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('reportIsA')); blocks.push(block('reportIsIdentical')); - blocks.push('-'); - blocks.push(block('reportJSFunction')); + + if (true) { // (Process.prototype.enableJS) { + blocks.push('-'); + blocks.push(block('reportJSFunction')); + } // for debugging: /////////////// diff --git a/store.js b/store.js index 3764b24f..659d1e17 100644 --- a/store.js +++ b/store.js @@ -61,7 +61,7 @@ normalizeCanvas*/ // Global stuff //////////////////////////////////////////////////////// -modules.store = '2016-November-24'; +modules.store = '2016-December-27'; // XML_Serializer /////////////////////////////////////////////////////// @@ -1017,6 +1017,16 @@ SnapSerializer.prototype.loadBlock = function (model, isReporter) { model.attributes['var'] ); } + /* + if (model.attributes.s === 'reportJSFunction' && + !Process.prototype.enableJS) { + if (window.confirm('enable JavaScript?')) { + Process.prototype.enableJS = true; + } else { + throw new Error('JavaScript is not enabled'); + } + } + */ block = SpriteMorph.prototype.blockForSelector(model.attributes.s); } else if (model.tag === 'custom-block') { isGlobal = model.attributes.scope ? false : true; diff --git a/threads.js b/threads.js index f19773f8..302b7286 100644 --- a/threads.js +++ b/threads.js @@ -59,9 +59,9 @@ degrees, detect, nop, radians, ReporterSlotMorph, CSlotMorph, RingMorph, IDE_Morph, ArgLabelMorph, localize, XML_Element, hex_sha512, TableDialogMorph, StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy, isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph, -TableFrameMorph, isSnapObject*/ +TableFrameMorph, ColorSlotMorph, isSnapObject*/ -modules.threads = '2016-October-27'; +modules.threads = '2016-December-27'; var ThreadManager; var Process; @@ -473,6 +473,7 @@ Process.prototype.isCatchingErrors = true; Process.prototype.enableLiveCoding = false; // experimental Process.prototype.enableSingleStepping = false; // experimental Process.prototype.flashTime = 0; // experimental +// Process.prototype.enableJS = false; function Process(topBlock, onComplete, rightAway) { this.topBlock = topBlock || null; @@ -1000,6 +1001,11 @@ Process.prototype.evaluate = function ( ) { if (!context) {return null; } if (context instanceof Function) { + /* + if (!this.enableJS) { + throw new Error('JavaScript is not enabled'); + } + */ return context.apply( this.blockReceiver(), args.asArray().concat([this]) @@ -3357,7 +3363,8 @@ Process.prototype.flashContext = function () { expr instanceof SyntaxElementMorph && !(expr instanceof CommandSlotMorph) && !this.context.isFlashing && - expr.world()) { + expr.world() && + !(expr instanceof ColorSlotMorph)) { this.unflash(); expr.flash(); this.context.isFlashing = true;