1
0
mirror of https://github.com/psychopy/psychojs.git synced 2025-05-11 16:18:10 +00:00

Merge branch 'psychopy:main' into master

This commit is contained in:
Alain Pitiot 2021-06-15 16:15:46 +02:00
commit 7a9cdcfd27
5 changed files with 47 additions and 24 deletions

14
package-lock.json generated
View File

@ -11,7 +11,6 @@
"dependencies": {
"howler": "^2.2.1",
"log4javascript": "github:Ritzlgrmft/log4javascript",
"moment": "^2.29.1",
"pako": "^1.0.10",
"pixi.js-legacy": "^6.0.4",
"seedrandom": "^3.0.5",
@ -1799,14 +1798,6 @@
"node": ">=10"
}
},
"node_modules/moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==",
"engines": {
"node": "*"
}
},
"node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@ -3881,11 +3872,6 @@
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"dev": true
},
"moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",

View File

@ -28,7 +28,6 @@
"dependencies": {
"howler": "^2.2.1",
"log4javascript": "github:Ritzlgrmft/log4javascript",
"moment": "^2.29.1",
"pako": "^1.0.10",
"pixi.js-legacy": "^6.0.4",
"seedrandom": "^3.0.5",

View File

@ -7,8 +7,6 @@
* @license Distributed under the terms of the MIT License
*/
import moment from 'moment';
/**
* <p>MonotonicClock offers a convenient way to keep track of time during experiments. An experiment can have as many independent clocks as needed, e.g. one to time responses, another one to keep track of stimuli, etc.</p>
@ -69,20 +67,58 @@ export class MonotonicClock
/**
* Get the clock's current time as a formatted string.
* Get the current timestamp with language-sensitive formatting rules applied.
*
* <p>Note: this is mostly used as an appendix to the name of the keys save to the server.</p>
* <p>Note: This is just a convenience wrapper around `Intl.DateTimeFormat()`.</p>
*
* @name module:util.MonotonicClock.getDate
* @function
* @public
* @static
* @param {string|array.string} locales - A string with a BCP 47 language tag, or an array of such strings.
* @param {object} options - An object with detailed date and time styling information.
* @return {string} The current timestamp in the chosen format.
*/
static getDate(locales = 'en-CA', optionsMaybe)
{
const date = new Date();
const options = Object.assign({
hour12: false,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
fractionalSecondDigits: 3
}, optionsMaybe);
const dateTimeFormat = new Intl.DateTimeFormat(locales, options);
return dateTimeFormat.format(date);
}
/**
* Get the clock's current time in the default format filtering out file name unsafe characters.
*
* <p>Note: This is mostly used as an appendix to the name of the keys save to the server.</p>
*
* @name module:util.MonotonicClock.getDateStr
* @function
* @public
* @static
* @param {string} [format= 'YYYY-MM-DD_HH[h]mm.ss.SSS'] - the format for the string (see [momentjs.com]{@link https://momentjs.com/docs/#/parsing/string-format/} for details)
* @return {string} a string representing the current time in the given format
* @return {string} A string representing the current time formatted as YYYY-MM-DD_HH[h]mm.ss.sss
*/
static getDateStr(format = 'YYYY-MM-DD_HH[h]mm.ss.SSS')
static getDateStr()
{
return moment().format(format);
// yyyy-mm-dd, hh:mm:ss.sss
return MonotonicClock.getDate()
// yyyy-mm-dd_hh:mm:ss.sss
.replace(', ', '_')
// yyyy-mm-dd_hh[h]mm:ss.sss
.replace(':', 'h')
// yyyy-mm-dd_hh[h]mm.ss.sss
.replace(':', '.');
}
}

View File

@ -319,6 +319,7 @@ export class TextBox extends util.mix(VisualStim).with(ColorMixin)
padding: padding_px + 'px',
multiline,
text: this._text,
height: multiline ? (height_px - 2 * padding_px) + 'px' : undefined,
width: (width_px - 2 * padding_px) + 'px'
},

View File

@ -22,6 +22,7 @@ export class TextInput extends PIXI.Container
background: 'none',
border: 'none',
outline: 'none',
text: '',
transformOrigin: '0 0',
lineHeight: '1'
},
@ -56,7 +57,7 @@ export class TextInput extends PIXI.Container
this._selection = [0, 0];
this._restrict_value = '';
this._createDOMInput();
this.substituteText = false;
this.substituteText = !this._multiline;
this._setState('DEFAULT');
}