2016-04-28 10:18:52 +00:00
|
|
|
( function ( mw, $ ) {
|
|
|
|
|
|
|
|
var Revision = function ( data ) {
|
2016-05-06 13:46:28 +00:00
|
|
|
this.id = data.revid;
|
2016-04-28 10:18:52 +00:00
|
|
|
this.size = data.size;
|
|
|
|
this.comment = data.comment;
|
|
|
|
this.parsedComment = data.parsedcomment;
|
|
|
|
this.timestamp = data.timestamp;
|
|
|
|
this.user = data.user;
|
2016-05-12 12:00:00 +00:00
|
|
|
this.minor = data.hasOwnProperty( 'minor' ) && ( data.minor || data.minor === '' );
|
2016-04-28 10:18:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
$.extend( Revision.prototype, {
|
2016-05-06 13:46:28 +00:00
|
|
|
/**
|
|
|
|
* @type {int}
|
|
|
|
*/
|
|
|
|
id: 0,
|
|
|
|
|
2016-04-28 10:18:52 +00:00
|
|
|
/**
|
|
|
|
* @type {int}
|
|
|
|
*/
|
|
|
|
size: 0,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
comment: '',
|
|
|
|
|
2016-05-12 12:00:00 +00:00
|
|
|
/**
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
minor: false,
|
|
|
|
|
2016-04-28 10:18:52 +00:00
|
|
|
/**
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
parsedComment: '',
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
timestamp: '',
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
user: '',
|
|
|
|
|
2016-05-12 13:52:54 +00:00
|
|
|
/**
|
|
|
|
* @type {int}
|
|
|
|
*/
|
|
|
|
relativeSize: 0,
|
|
|
|
|
2016-05-06 13:46:28 +00:00
|
|
|
getId: function () {
|
|
|
|
return this.id;
|
|
|
|
},
|
|
|
|
|
2016-04-28 10:18:52 +00:00
|
|
|
getSize: function () {
|
|
|
|
return this.size;
|
|
|
|
},
|
|
|
|
|
2016-05-12 12:00:00 +00:00
|
|
|
isMinor: function () {
|
|
|
|
return this.minor;
|
|
|
|
},
|
|
|
|
|
2016-04-28 10:18:52 +00:00
|
|
|
getParsedComment: function () {
|
|
|
|
return this.parsedComment;
|
|
|
|
},
|
|
|
|
|
|
|
|
getComment: function () {
|
|
|
|
return this.comment;
|
|
|
|
},
|
|
|
|
|
2016-05-02 10:05:31 +00:00
|
|
|
getSection: function () {
|
|
|
|
var comment = this.getComment();
|
|
|
|
comment = comment.match(
|
|
|
|
new RegExp( '(/\\* [^\\*]* \\*/)', 'gi' )
|
|
|
|
);
|
|
|
|
if ( !comment ) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
return comment[ 0 ].replace(
|
|
|
|
new RegExp( ' \\*/|/\\* ', 'gi' ),
|
|
|
|
''
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
2016-04-28 10:18:52 +00:00
|
|
|
formatDate: function ( rawDate ) {
|
|
|
|
var MONTHS = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec' ],
|
2016-05-12 16:01:50 +00:00
|
|
|
offset = mw.user.options.values.timecorrection ? mw.user.options.values.timecorrection.split( '|' )[ 1 ] : mw.config.values.extRevisionSliderTimeOffset,
|
|
|
|
f = new Date( ( new Date( rawDate ) ).getTime() + ( offset * 60 * 1000 ) ),
|
2016-04-28 10:18:52 +00:00
|
|
|
fDate = f.getUTCDate(),
|
|
|
|
fMonth = f.getUTCMonth(),
|
|
|
|
fYear = f.getUTCFullYear(),
|
|
|
|
fHours = ( '0' + f.getUTCHours() ).slice( -2 ),
|
|
|
|
fMinutes = ( '0' + f.getUTCMinutes() ).slice( -2 );
|
|
|
|
|
|
|
|
return fHours + ':' + fMinutes + ', ' + fDate + ' ' + MONTHS[ fMonth ] + ' ' + fYear;
|
|
|
|
},
|
|
|
|
|
|
|
|
getFormattedDate: function () {
|
|
|
|
return this.formatDate( this.timestamp );
|
|
|
|
},
|
|
|
|
|
|
|
|
getUser: function () {
|
|
|
|
return this.user;
|
2016-05-12 13:52:54 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setRelativeSize: function ( size ) {
|
|
|
|
this.relativeSize = size;
|
|
|
|
},
|
|
|
|
|
|
|
|
getRelativeSize: function () {
|
|
|
|
return this.relativeSize;
|
2016-04-28 10:18:52 +00:00
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
|
|
|
mw.libs.revisionSlider = mw.libs.revisionSlider || {};
|
|
|
|
mw.libs.revisionSlider.Revision = Revision;
|
|
|
|
}( mediaWiki, jQuery ) );
|