mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-15 11:40:43 +00:00
139368093e
The first revision was previously not included because revision size was calculated by subtracting the size in bytes of a revision from the size of the previous revision which lead to a problem with the first revision. The first revision's relative size is now equal to its actual size. Bug: T135003 Change-Id: I71441ed33673b06407be0fc566c96c3955dddbf9
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
( function ( mw, $ ) {
|
|
var SectionLegend = function ( revisionList ) {
|
|
this.revisionList = revisionList;
|
|
};
|
|
|
|
$.extend( SectionLegend.prototype, {
|
|
/**
|
|
* @type {RevisionList}
|
|
*/
|
|
revisionList: null,
|
|
|
|
getSectionColorMap: function () {
|
|
var sectionMap = [],
|
|
revisions = this.revisionList.getRevisions(),
|
|
section, i;
|
|
|
|
for ( i = 0; i < revisions.length; i++ ) {
|
|
section = revisions[ i ].getSection();
|
|
if ( section.length > 0 && !( section in sectionMap ) ) {
|
|
sectionMap[ section ] = '';
|
|
}
|
|
}
|
|
|
|
i = 0;
|
|
for ( section in sectionMap ) {
|
|
sectionMap[ section ] = mw.libs.revisionSlider.rainbow( Object.keys( sectionMap ).length, i );
|
|
i++;
|
|
}
|
|
|
|
return sectionMap;
|
|
},
|
|
|
|
getHtml: function () {
|
|
var sectionMap = this.getSectionColorMap(),
|
|
html = '<div class="revisions-legend">',
|
|
sectionName;
|
|
for ( sectionName in sectionMap ) {
|
|
html += '<span class="rvslider-legend-box" style="color:' + sectionMap[ sectionName ] + ';"> ■</span>' + sectionName;
|
|
}
|
|
return html + '</div>';
|
|
}
|
|
} );
|
|
|
|
mw.libs.revisionSlider = mw.libs.revisionSlider || {};
|
|
mw.libs.revisionSlider.SectionLegend = SectionLegend;
|
|
}( mediaWiki, jQuery ) );
|