kopia lustrzana https://github.com/backface/turtlestitch
Add a 'get current DATE' block with various options, add some translations to FR and DE
rodzic
e9020b4ed3
commit
faa8b4fe22
24
blocks.js
24
blocks.js
|
@ -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':
|
||||
|
|
43
lang-de.js
43
lang-de.js
|
@ -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';
|
||||
};
|
||||
|
|
46
lang-fr.js
46
lang-fr.js
|
@ -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';
|
||||
|
||||
};
|
||||
|
|
12
objects.js
12
objects.js
|
@ -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: ///////////////
|
||||
|
||||
|
|
58
threads.js
58
threads.js
|
@ -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()]);
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue