Skip to content

Instantly share code, notes, and snippets.

@edgabaldi
Created July 29, 2020 11:10
Show Gist options
  • Save edgabaldi/28b3b7d8c8328f85cdd5b4ba9f182986 to your computer and use it in GitHub Desktop.
Save edgabaldi/28b3b7d8c8328f85cdd5b4ba9f182986 to your computer and use it in GitHub Desktop.
const clean_pcp = (value) => {
new_value = value.replace('%', '').replace(',','.').replace('+','');
return parseFloat(new_value);
}
const circle_icon_green = $('<span class="text-success"><svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-circle-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><circle cx="8" cy="8" r="8"/></svg></span>');
const circle_icon_red = $('<span class="text-danger"><svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-circle-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><circle cx="8" cy="8" r="8"/></svg></span>');
$('.pid-8839-pcp').on('DOMSubtreeModified', function(){
const $this = $(this);
const value = clean_pcp($this.text());
const icon = (value > 0) ? circle_icon_green : circle_icon_red;
$this.append(icon);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment