Add a 'get current DATE' block with various options, add some translations to FR and DE

pull/3/merge
Michael Ball 2013-12-27 18:49:56 -08:00
rodzic e9020b4ed3
commit faa8b4fe22
5 zmienionych plików z 184 dodań i 9 usunięć

Wyświetl plik

@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph, Costume*/
// Global stuff ////////////////////////////////////////////////////////
modules.blocks = '2013-November-26';
modules.blocks = '2013-December-27';
var SyntaxElementMorph;
var BlockMorph;
@ -812,6 +812,27 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
true // read-only
);
break;
case '%dates':
part = new InputSlotMorph(
null, // text
false, // non-numeric
{
'Date' : ['Date'],
'Month' : ['Month'],
'Day of Month' : ['Day of Month'],
'Year' : ['Year'],
'Day of Week' : ['Day of Week'],
'Time' : ['Time'],
'Hour' : ['Hour'],
'Minute' : ['Minute'],
'Second' : ['Second'],
'Time in Milliseconds' : ['Time in Milliseconds'],
'UTC Time' : ['UTC Time'],
},
true // read-only
);
part.setContents('Date')
break;
case '%delim':
part = new InputSlotMorph(
null, // text
@ -1166,7 +1187,6 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
);
break;
// symbols:
case '%turtle':
@ -6147,7 +6167,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:

Wyświetl plik

@ -1246,4 +1246,47 @@ SnapTranslator.dict.de = {
'letztes',
'any':
'beliebiges'
// Date reporter dropdowns
'Month':
'Monat',
// Months of the Year
'January':
'Januar',
'February':
'Februar',
'March':
'März',
'April':
'April';
'May':
'Mai',
'June':
'Juni',
'July':
'Juli';
'August':
'August',
'September':
'September',
'October':
'Oktober';
'November':
'November',
'December':
'Dezember',
'Sunday':
'Sonntag';
'Monday':
'Montag',
'Tuesday':
'Dienstag',
'Wednesday':
'Mittwoch';
'Thursday':
'Donnerstag',
'Friday':
'Freitag',
'Saturday':
'Samstag';
};

Wyświetl plik

@ -716,7 +716,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':
@ -731,7 +731,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',
@ -956,7 +956,7 @@ SnapTranslator.dict.fr = {
'tabulations',
'cr':
'retours de ligne',
// About Snap
'About Snap':
'A propos de Snap',
@ -1160,5 +1160,49 @@ SnapTranslator.dict.fr = {
'last':
'dernier',
'any':
'n\u0027importe quel'
'n\u0027importe quel',
// Date reporter dropdowns
'Month':
'mois',
// Months of the Year
'January':
'janvier',
'February':
'février',
'March':
'mars',
'April':
'avril';
'May':
'mai',
'June':
'juin',
'July':
'juillet';
'August':
'août',
'September':
'septembre',
'October':
'octobre';
'November':
'novembre',
'December':
'decembre',
'Sunday':
'dimanche';
'Monday':
'lundi',
'Tuesday':
'mardi',
'Wednesday':
'mercredi';
'Thursday':
'jedui',
'Friday':
'vendredi',
'Saturday':
'samedi';
};

Wyświetl plik

@ -124,7 +124,7 @@ PrototypeHatBlockMorph*/
// Global stuff ////////////////////////////////////////////////////////
modules.objects = '2013-December-19';
modules.objects = '2013-December-27';
var SpriteMorph;
var StageMorph;
@ -786,6 +786,12 @@ SpriteMorph.prototype.initBlocks = function () {
category: 'sensing',
spec: 'set turbo mode to %b'
},
reportDate: {
type: 'reporter',
category: 'sensing',
spec: 'get current %dates',
},
// Operators
reifyScript: {
@ -1700,6 +1706,8 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push('-');
blocks.push(block('reportIsFastTracking'));
blocks.push(block('doSetFastTracking'));
blocks.push('-');
blocks.push(block('reportDate'));
// for debugging: ///////////////
@ -4398,6 +4406,8 @@ StageMorph.prototype.blockTemplates = function (category) {
blocks.push('-');
blocks.push(block('reportIsFastTracking'));
blocks.push(block('doSetFastTracking'));
blocks.push('-');
blocks.push(block('reportDate'));
// for debugging: ///////////////
@ -5147,7 +5157,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,

Wyświetl plik

@ -2474,6 +2474,34 @@ Process.prototype.reportTimer = function () {
return 0;
};
// Process Dates and times in Snap
Process.prototype.reportDate = function (datefn) {
// Map block options to built-in functions
var dateMap = { 'Date' : 'toLocaleDateString',
'Time' : 'toLocaleTimeString',
'Month' : 'getMonthName', // return a name, not a number
'Day of Week' : 'getDayName', // return a name, not a number
'Day of Month': 'getDate',
'Year' : 'getFullYear',
'Hour' : 'getHours',
'Minute' : 'getMinutes',
'Second' : 'getSeconds',
'Milliseconds' : 'getMilliseconds',
'Time in Milliseconds' : 'getTime',
'UTC Time' : 'toUTCString' };
if (!dateMap[datefn]) {
return '';
}
currDate = new Date();
func = dateMap[datefn]
return currDate[func]();
}
// Process code mapping
/*
@ -3068,3 +3096,33 @@ UpvarReference.prototype.toString = function () {
UpvarReference.prototype.names = VariableFrame.prototype.names;
UpvarReference.prototype.allNames = VariableFrame.prototype.allNames;
UpvarReference.prototype.allNamesDict = VariableFrame.prototype.allNamesDict;
// Date Utilities (for the 'reportDate' block)
Date.prototype.getMonthName = function () {
mons = ['January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'];
return localize(mons[this.getMonth()]);
}
Date.prototype.getDayName = function () {
days = ['Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'];
return localize(days[this.getDay()]);
}