'new Date' is subject to clock drift etc.
mw.now() uses performance.now() when available, which will always
increase at a constant rate independent of the system clock.
Change-Id: Ib653103bf6116544f35c930fb33421f1bb362c7d
*/
// jscs:enable checkParamNames
*/
// jscs:enable checkParamNames
var hasOwn = Object.hasOwnProperty;
var hasOwn = Object.hasOwnProperty;
context.data.prevText = val;
// Try cache first
if ( context.config.cache && hasOwn.call( cache, val ) ) {
context.data.prevText = val;
// Try cache first
if ( context.config.cache && hasOwn.call( cache, val ) ) {
- if ( +new Date() - cache[ val ].timestamp < context.config.cacheMaxAge ) {
+ if ( mw.now() - cache[ val ].timestamp < context.config.cacheMaxAge ) {
context.data.$textbox.suggestions( 'suggestions', cache[ val ].suggestions );
if ( typeof context.config.update.after === 'function' ) {
context.config.update.after.call( context.data.$textbox, cache[ val ].metadata );
context.data.$textbox.suggestions( 'suggestions', cache[ val ].suggestions );
if ( typeof context.config.update.after === 'function' ) {
context.config.update.after.call( context.data.$textbox, cache[ val ].metadata );
cache[ val ] = {
suggestions: suggestions,
metadata: metadata,
cache[ val ] = {
suggestions: suggestions,
metadata: metadata,
* @mixins jQuery.plugin.suggestions
*/
* @mixins jQuery.plugin.suggestions
*/
+}( jQuery, mediaWiki ) );
*/
mw.Upload.BookletLayout.prototype.uploadFile = function () {
var deferred = $.Deferred(),
*/
mw.Upload.BookletLayout.prototype.uploadFile = function () {
var deferred = $.Deferred(),
- startTime = new Date(),
layout = this,
file = this.getFile();
layout = this,
file = this.getFile();
deferred.reject( errorMessage );
} );
}, function ( progress ) {
deferred.reject( errorMessage );
} );
}, function ( progress ) {
- var elapsedTime = new Date() - startTime,
+ var elapsedTime = mw.now() - startTime,
estimatedTotalTime = ( 1 / progress ) * elapsedTime,
estimatedRemainingTime = moment.duration( estimatedTotalTime - elapsedTime );
layout.emit( 'fileUploadProgress', progress, estimatedRemainingTime );
estimatedTotalTime = ( 1 / progress ) * elapsedTime,
estimatedRemainingTime = moment.duration( estimatedTotalTime - elapsedTime );
layout.emit( 'fileUploadProgress', progress, estimatedRemainingTime );