From c67a13b7bda166591a1b9f572e5113b31aa20f21 Mon Sep 17 00:00:00 2001 From: Brian Broll Date: Tue, 19 May 2015 15:48:17 -0500 Subject: Fixed typo in Process constructor Changed Process.prototype.contructor to Process.prototype.constructor --- threads.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'threads.js') diff --git a/threads.js b/threads.js index 165ad0e..df67b2c 100644 --- a/threads.js +++ b/threads.js @@ -339,7 +339,7 @@ ThreadManager.prototype.findProcess = function (block) { */ Process.prototype = {}; -Process.prototype.contructor = Process; +Process.prototype.constructor = Process; Process.prototype.timeout = 500; // msecs after which to force yield Process.prototype.isCatchingErrors = true; -- cgit v1.3.1 From e21a872b0dcbca2e7ea8311d9b54f709876d1848 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 15 Jun 2015 17:19:25 -0700 Subject: Implement log10 and 10^x math functions --- blocks.js | 6 +++--- threads.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'threads.js') diff --git a/blocks.js b/blocks.js index 67324ca..1ef322c 100644 --- a/blocks.js +++ b/blocks.js @@ -1111,9 +1111,9 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { acos : ['acos'], atan : ['atan'], ln : ['ln'], - // log : 'log', - 'e^' : ['e^'] - // '10^' : '10^' + log : ['log'], + 'e^' : ['e^'], + '10^' : ['10^'] }, true ); diff --git a/threads.js b/threads.js index 165ad0e..61b5722 100644 --- a/threads.js +++ b/threads.js @@ -2122,14 +2122,14 @@ Process.prototype.reportMonadic = function (fname, n) { case 'ln': result = Math.log(x); break; - case 'log': - result = 0; + case 'log': // base 10 + result = Math.log(x) / Math.LN10; break; case 'e^': result = Math.exp(x); break; case '10^': - result = 0; + result = Math.pow(10, x); break; default: nop(); -- cgit v1.3.1 From 93d67ed386bba4862ac00eb55dcf664300ce53c7 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 15 Jun 2015 18:49:24 -0700 Subject: Fix Error Handing in the DATE block For some reason the function wasnt properly catching errors and was instead rasing native JS errors. This fixes that bug, so the function will now report nothing when it doesnt know what to do. In addition, moving the variable `dateMap` inside the function reduces a global variable, which shouldnt affect anything other than keeping the code clean. :) --- threads.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'threads.js') diff --git a/threads.js b/threads.js index 165ad0e..efe9ba4 100644 --- a/threads.js +++ b/threads.js @@ -2640,26 +2640,26 @@ Process.prototype.reportTimer = function () { }; // Process Dates and times in Snap -// Map block options to built-in functions -var dateMap = { - 'year' : 'getFullYear', - 'month' : 'getMonth', - 'date': 'getDate', - 'day of week' : 'getDay', - 'hour' : 'getHours', - 'minute' : 'getMinutes', - 'second' : 'getSeconds', - 'time in milliseconds' : 'getTime' -}; - Process.prototype.reportDate = function (datefn) { var inputFn = this.inputOption(datefn), - currDate = new Date(), - func = dateMap[inputFn], - result = currDate[func](); + // Map block options to built-in functions + dateMap = { + 'year' : 'getFullYear', + 'month' : 'getMonth', + 'date': 'getDate', + 'day of week' : 'getDay', + 'hour' : 'getHours', + 'minute' : 'getMinutes', + 'second' : 'getSeconds', + 'time in milliseconds' : 'getTime' + }; if (!dateMap[inputFn]) { return ''; } + var currDate = new Date(), + func = dateMap[inputFn], + result = currDate[func](); + // Show months as 1-12 and days as 1-7 if (inputFn === 'month' || inputFn === 'day of week') { result += 1; -- cgit v1.3.1 From f4ff1056eae012b9a257c7dea88af3d007012632 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Thu, 25 Jun 2015 15:30:58 +0200 Subject: update threads.js version --- threads.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'threads.js') diff --git a/threads.js b/threads.js index efe9ba4..edbe2cf 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2015-May-01'; +modules.threads = '2015-June-25'; var ThreadManager; var Process; @@ -2641,7 +2641,8 @@ Process.prototype.reportTimer = function () { // Process Dates and times in Snap Process.prototype.reportDate = function (datefn) { - var inputFn = this.inputOption(datefn), + var currDate, func, result, + inputFn = this.inputOption(datefn), // Map block options to built-in functions dateMap = { 'year' : 'getFullYear', @@ -2655,16 +2656,14 @@ Process.prototype.reportDate = function (datefn) { }; if (!dateMap[inputFn]) { return ''; } - - var currDate = new Date(), - func = dateMap[inputFn], - result = currDate[func](); + currDate = new Date(); + func = dateMap[inputFn]; + result = currDate[func](); // Show months as 1-12 and days as 1-7 if (inputFn === 'month' || inputFn === 'day of week') { result += 1; } - return result; }; -- cgit v1.3.1