summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--blocks.js24
-rw-r--r--lang-de.js7
-rw-r--r--lang-fr.js13
-rw-r--r--objects.js11
-rw-r--r--threads.js29
5 files changed, 74 insertions, 10 deletions
diff --git a/blocks.js b/blocks.js
index 0ce1478..1cfd2c2 100644
--- a/blocks.js
+++ b/blocks.js
@@ -155,7 +155,8 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/
// Global stuff ////////////////////////////////////////////////////////
-modules.blocks = '2014-January-09';
+modules.blocks = '2014-February-04';
+
var SyntaxElementMorph;
var BlockMorph;
@@ -812,6 +813,24 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
true // read-only
);
break;
+ case '%dates':
+ part = new InputSlotMorph(
+ null, // text
+ false, // non-numeric
+ {
+ 'year' : ['year'],
+ 'month' : ['month'],
+ 'date' : ['date'],
+ 'day of week' : ['day of week'],
+ 'hour' : ['hour'],
+ 'minute' : ['minute'],
+ 'second' : ['second'],
+ 'time in milliseconds' : ['time in milliseconds'],
+ },
+ true // read-only
+ );
+ part.setContents('date');
+ break;
case '%delim':
part = new InputSlotMorph(
null, // text
@@ -1192,7 +1211,6 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
);
break;
-
// symbols:
case '%turtle':
@@ -6174,7 +6192,7 @@ CSlotMorph.prototype.drawBottomEdge = function (context) {
I am an editable text input slot. I can be either rectangular or
rounded, and can have an optional drop-down menu. If I'm set to
read-only I must have a drop-down menu and will assume a darker
- shade of my parent's color.
+ shade of my parent's color.
my most important public attributes and accessors are:
diff --git a/lang-de.js b/lang-de.js
index 8b71902..c68cf4b 100644
--- a/lang-de.js
+++ b/lang-de.js
@@ -1257,5 +1257,10 @@ SnapTranslator.dict.de = {
'last':
'letztes',
'any':
- 'beliebiges'
+ 'beliebiges',
+
+ // Date reporter dropdowns
+ 'month':
+ 'monat',
+
};
diff --git a/lang-fr.js b/lang-fr.js
index 4198bf7..ecb585a 100644
--- a/lang-fr.js
+++ b/lang-fr.js
@@ -718,7 +718,7 @@ SnapTranslator.dict.fr = {
'check for alternative\nGUI design':
'Cocher pour un style d\interface alternatif',
'uncheck for default\nGUI design':
- 'D\u00E9cocher pour le style classique d\interface',
+ 'D\u00E9cocher pour le style classique d\interface',
'Thread safe scripts':
'Scripts réentrants',
'check to disallow\nscript reentrance':
@@ -733,7 +733,7 @@ SnapTranslator.dict.fr = {
'D\u00E9cocher pour une vitesse\nd\'animation maximale (mais variable)',
'check for smooth, predictable\nanimations across computers':
'Cocher pour une vitesse d\'animation\nfixe et identique sur tous les ordinateurs',
-
+
// inputs
'with inputs':
'avec entr\u00E9es',
@@ -958,7 +958,7 @@ SnapTranslator.dict.fr = {
'tabulations',
'cr':
'retours de ligne',
-
+
// About Snap
'About Snap':
'A propos de Snap',
@@ -1162,5 +1162,10 @@ SnapTranslator.dict.fr = {
'last':
'dernier',
'any':
- 'n\u0027importe quel'
+ 'n\u0027importe quel',
+
+ // Date reporter dropdowns
+ 'month':
+ 'mois'
+
};
diff --git a/objects.js b/objects.js
index 52126e2..1d37a4e 100644
--- a/objects.js
+++ b/objects.js
@@ -804,6 +804,11 @@ SpriteMorph.prototype.initBlocks = function () {
category: 'sensing',
spec: 'set turbo mode to %b'
},
+ reportDate: {
+ type: 'reporter',
+ category: 'sensing',
+ spec: 'get current %dates'
+ },
// Operators
reifyScript: {
@@ -1740,6 +1745,8 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push('-');
blocks.push(block('reportIsFastTracking'));
blocks.push(block('doSetFastTracking'));
+ blocks.push('-');
+ blocks.push(block('reportDate'));
// for debugging: ///////////////
@@ -4448,6 +4455,8 @@ StageMorph.prototype.blockTemplates = function (category) {
blocks.push('-');
blocks.push(block('reportIsFastTracking'));
blocks.push(block('doSetFastTracking'));
+ blocks.push('-');
+ blocks.push(block('reportDate'));
// for debugging: ///////////////
@@ -5197,7 +5206,7 @@ Costume.prototype.shrinkWrap = function () {
};
Costume.prototype.boundingBox = function () {
- // answer the rectangle surrounding my contents' non-transparent pixels
+ // answer the rectangle surrounding my contents' non-transparent pixels
var row,
col,
pic = this.contents,
diff --git a/threads.js b/threads.js
index 93931c1..7b46f70 100644
--- a/threads.js
+++ b/threads.js
@@ -111,7 +111,7 @@ function snapEquals(a, b) {
y = b;
}
- // handle text comparision text-insensitive.
+ // handle text comparision case-insensitive.
if (isString(x) && isString(y)) {
return x.toLowerCase() === y.toLowerCase();
}
@@ -2536,6 +2536,33 @@ Process.prototype.reportTimer = function () {
return 0;
};
+// 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) {
+ if (!dateMap[datefn]) { return ''; }
+
+ currDate = new Date();
+ func = dateMap[datefn];
+ result = currDate[func]();
+
+ // Show months as 1-12 and days as 1-7
+ if (datefn === 'month' || datefn === 'day of week') {
+ result += 1;
+ }
+
+ return result;
+}
+
// Process code mapping
/*