Skip to content

Instantly share code, notes, and snippets.

@wowkin2
Created December 8, 2020 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wowkin2/7001096d35ac0f8d8b091ad9b0d89fbf to your computer and use it in GitHub Desktop.
Save wowkin2/7001096d35ac0f8d8b091ad9b0d89fbf to your computer and use it in GitHub Desktop.
Highlight Python test coverage with color (for percent row)
$('.right').each(function(a, b){
var value = $(this).html();
if (value !== undefined) {
var red = 255 - parseInt(value.slice(0, -1)) * 2;
var green = 0 + parseInt(value.slice(0, -1)) * 2;
var color = 'rgb(' + red + ', ' + green + ', 0)';
$(this).css('background', color);
console.log(value, color);
}
});
@wowkin2
Copy link
Author

wowkin2 commented Jul 15, 2022

if jQuery is missing:

var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type (or see below for non wait option)
jQuery.noConflict();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment