Skip to content

Instantly share code, notes, and snippets.

@StabbyMcDuck
Forked from anonymous/colorCodeTag
Last active February 7, 2018 20:51
Show Gist options
  • Save StabbyMcDuck/2ef6c7b33fd05afb605375adc32f65ca to your computer and use it in GitHub Desktop.
Save StabbyMcDuck/2ef6c7b33fd05afb605375adc32f65ca to your computer and use it in GitHub Desktop.
<script>
function colorCodeTags(){
var classTitle = document.getElementsByClassName("ms-vb-title"); // find all tags in the title column
var colorCode = document.getElementsByTagName("td");// finding all the TD tags
var i = 0;
var j = 0;
for (i = 0; i < colorCode.length; i += 1) {
var colorCell = colorCode[i];
var innerText = colorCell.innerText
if (!colorCell.classList.contains("ms-vb-title")) {
var innerText = colorCell.innerText
if (colorCode[i].innerText === "Blue"){
colorCode[i].innerHTML = "<style>img {height: 20px; width: 20px; display: block; margin-left: auto; margin-right: auto; }</style><img src = 'https://collaboration.merck.com/sites/ngppm-uat/Style%20Library/Images/blue.png'/>";
} else if (colorCode[i].innerText === "Green"){
colorCode[i].innerHTML = "<style>img {height: 20px; width: 20px; display: block; margin-left: auto; margin-right: auto; }</style><img src = 'https://collaboration.merck.com/sites/ngppm-uat/Style%20Library/Images/Green.png'/>";
} else if (colorCode[i].innerText === "Yellow"){
colorCode[i].innerHTML = "<style>img {height: 20px; width: 20px; display: block; margin-left: auto; margin-right: auto; }</style><img src = 'https://collaboration.merck.com/sites/ngppm-uat/Style%20Library/Images/Yellow.png'/>";
} else if (colorCode[i].innerText === "Red"){
colorCode[i].innerHTML = "<style>img {height: 20px; width: 20px; display: block; margin-left: auto; margin-right: auto; }</style><img src = 'https://collaboration.merck.com/sites/ngppm-uat/Style%20Library/Images/Red.png'/>";
}
}
}
}
setInterval(colorCodeTags, 100);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment