Skip to content

Instantly share code, notes, and snippets.

@JogoShugh
Last active April 8, 2019 20:32
Show Gist options
  • Save JogoShugh/9aefefcb0fa5182237115de6e4a552d2 to your computer and use it in GitHub Desktop.
Save JogoShugh/9aefefcb0fa5182237115de6e4a552d2 to your computer and use it in GitHub Desktop.
V1 TeamRoom Hacks
$('.advisory').each((index, elm) => {
const el = $(elm);
const story = el.parents('.story-card');
const text = el.text().trim().replace(/\s+|\r|\n+/gmi, ' ');
const matches = text.match(/\d+/gi);
let total = 0;
let color = '';
if (matches) {
matches[0]+='d';
if (matches.length>1) matches[1]+='c';
const aging = `<span title='${text}'>${matches.join(', ')}</span>`;
el.parents('.aging').html(aging);
total = parseInt(matches[0]);
if (matches.length>1) total += parseInt(matches[1]);
} else {
total = 1;
el.parents('.aging').html(`<span class='new-card' title='${text}'>new</span>`);
}
const ageMarkers = [3,10,15,25];
const oldestColor = 'deeppink';
const colorAgeMap = {
'3': 'darkgreen',
'10': 'darkblue',
'15': 'darkgoldenrod',
'25': 'darkred'
};
for(const marker of ageMarkers) {
if (total <= marker) {
color = colorAgeMap[String(marker)];
break;
}
}
if (color === '') color = oldestColor;
const ageColor = `background-color: ${color} !important`;
story.attr('style', ageColor);
});
$('.advisory').each((index, elm) => {
const el = $(elm);
const text = el.text().trim().replace(/\s+|\r|\n+/gmi, '');
const matches = text.match(/\d+/gi);
if (matches) {
matches[0]+='d';
if (matches.length>1) matches[1]+='c';
const aging = `<span title='${text}'>${matches.join(', ')}</span>`;
const story = el.parents('.story-card');
el.parents('.aging').html(aging);
let total = parseInt(matches[0]);
if (matches.length>1) total += parseInt(matches[1]);
console.log("Total: ", total);
let opacity = total / 28;
if (opacity > 1) opacity = 1.0;
if (opacity < 0.1) opacity = 0.1;
opacity = String(opacity);
const ageShade = `background-color: rgba(255, 0, 0, ${opacity}) !important`;
console.log("Opacity:" + opacity);
story.attr('style', ageShade);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment