Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
Additional color-coding for EOL versions (implements #25)
Browse files Browse the repository at this point in the history
  • Loading branch information
colinodell committed Feb 1, 2018
1 parent 433226d commit 5fbdead
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
3 changes: 3 additions & 0 deletions _sass/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,9 @@ article.hosts {
.good-version {
color: #0c0;
}
.eol-version {
color: #ea0;
}
.bad-version {
color: #c00;
}
Expand Down
20 changes: 15 additions & 5 deletions js/versions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
var eolVersions = {
'5.4': new Date('2015-09-03T23:59:59'),
'5.5': new Date('2016-07-21T23:59:59'),
'5.6': new Date('2018-12-31T23:59:59'),
'7.0': new Date('2018-12-03T23:59:59'),
'7.1': new Date('2019-12-01T23:59:59'),
'7.2': new Date('2020-11-30T23:59:59')
};

// Simple function for comparing x.y.z versions
function cmpVersions (a, b) {
var i, l, d;
Expand Down Expand Up @@ -65,6 +74,7 @@ function getFixedVersions(callback) {
// Only execute this code on pages which have version tables
if (document.getElementsByClassName('tables').length > 0) {
getFixedVersions(function (fixedVersions) {
var now = new Date();
var versionCells = document.querySelectorAll('.tables .version');
Array.prototype.forEach.call(versionCells, function (el) {
var version = el.textContent.trim();
Expand All @@ -82,12 +92,12 @@ if (document.getElementsByClassName('tables').length > 0) {
var fullVersion = version[0];
var minorVersion = version[1];

if (typeof fixedVersions[minorVersion] === 'undefined') {
el.classList.add('good-version');
} else if (cmpVersions(fullVersion, fixedVersions[minorVersion]) >= 0) {
el.classList.add('good-version');
} else {
if (typeof fixedVersions[minorVersion] !== 'undefined' && cmpVersions(fullVersion, fixedVersions[minorVersion]) < 0) {
el.classList.add('bad-version');
} else if (typeof eolVersions[minorVersion] !== 'undefined' && eolVersions[minorVersion] < now) {
el.classList.add('eol-version');
} else {
el.classList.add('good-version');
}
});
});
Expand Down

0 comments on commit 5fbdead

Please sign in to comment.