2023-06-22 09:41:37 +00:00
|
|
|
let userOffset;
|
2020-03-29 21:15:32 +00:00
|
|
|
|
2020-11-18 09:11:12 +00:00
|
|
|
/* global moment:false */
|
|
|
|
/**
|
2020-03-29 21:15:32 +00:00
|
|
|
* @class Revision
|
2023-08-25 12:42:32 +00:00
|
|
|
* @param {Object} data - Containing keys `id`, `size`, `parsedcomment`, `timestamp`, `user` and `minor`
|
2020-11-18 09:11:12 +00:00
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
function Revision( data ) {
|
|
|
|
this.id = data.revid;
|
|
|
|
this.size = data.size;
|
|
|
|
this.timestamp = data.timestamp;
|
|
|
|
this.minor = !!data.minor || data.minor === '';
|
|
|
|
|
|
|
|
// Comments, tags, and users can be suppressed thus we must check if they exist
|
2023-08-25 12:42:32 +00:00
|
|
|
this.parsedComment = data.parsedcomment || '';
|
|
|
|
this.tags = data.tags || [];
|
|
|
|
this.user = data.user || '';
|
|
|
|
this.userGender = data.userGender || '';
|
2020-11-18 09:11:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$.extend( Revision.prototype, {
|
2016-06-17 13:06:12 +00:00
|
|
|
/**
|
2020-11-18 09:11:12 +00:00
|
|
|
* @type {number}
|
2016-06-17 13:06:12 +00:00
|
|
|
*/
|
2020-11-18 09:11:12 +00:00
|
|
|
id: 0,
|
2016-07-14 21:20:46 +00:00
|
|
|
|
2020-11-18 09:11:12 +00:00
|
|
|
/**
|
|
|
|
* @type {number}
|
|
|
|
*/
|
|
|
|
size: 0,
|
2016-04-28 10:18:52 +00:00
|
|
|
|
2020-11-18 09:11:12 +00:00
|
|
|
/**
|
|
|
|
* @type {string[]}
|
|
|
|
*/
|
|
|
|
tags: [],
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
minor: false,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
parsedComment: '',
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
timestamp: '',
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
user: '',
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {string}
|
|
|
|
*/
|
|
|
|
userGender: '',
|
|
|
|
|
|
|
|
/**
|
2023-10-24 14:08:50 +00:00
|
|
|
* @type {number} Warning, only set for Revision objects that are part of a RevisionList
|
2020-11-18 09:11:12 +00:00
|
|
|
*/
|
|
|
|
relativeSize: 0,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {number}
|
|
|
|
*/
|
|
|
|
getId: function () {
|
|
|
|
return this.id;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {number}
|
|
|
|
*/
|
|
|
|
getSize: function () {
|
|
|
|
return this.size;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {boolean}
|
|
|
|
*/
|
|
|
|
isMinor: function () {
|
|
|
|
return this.minor;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {string}
|
|
|
|
*/
|
|
|
|
getParsedComment: function () {
|
|
|
|
return this.parsedComment;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {string[]}
|
|
|
|
*/
|
|
|
|
getTags: function () {
|
|
|
|
return this.tags;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Uses moment.js to format the date
|
|
|
|
*
|
|
|
|
* @return {string}
|
|
|
|
*/
|
|
|
|
getFormattedDate: function () {
|
2023-11-29 11:55:18 +00:00
|
|
|
const offset = parseInt( userOffset );
|
|
|
|
return moment( this.timestamp ).utcOffset( offset ).format( 'LLL' );
|
2020-11-18 09:11:12 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {string}
|
|
|
|
*/
|
|
|
|
getUser: function () {
|
|
|
|
return this.user;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {string}
|
|
|
|
*/
|
|
|
|
getUserGender: function () {
|
|
|
|
return this.userGender;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {number} size
|
|
|
|
*/
|
|
|
|
setRelativeSize: function ( size ) {
|
|
|
|
this.relativeSize = size;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return {number}
|
|
|
|
*/
|
|
|
|
getRelativeSize: function () {
|
|
|
|
return this.relativeSize;
|
|
|
|
}
|
|
|
|
} );
|
2016-04-28 10:18:52 +00:00
|
|
|
|
2020-03-29 21:15:32 +00:00
|
|
|
module.exports = {
|
|
|
|
Revision: Revision,
|
2023-11-24 09:14:15 +00:00
|
|
|
setUserOffset: function ( offset ) {
|
|
|
|
userOffset = offset;
|
|
|
|
}
|
2020-03-29 21:15:32 +00:00
|
|
|
};
|