Created
July 29, 2020 11:10
-
-
Save edgabaldi/28b3b7d8c8328f85cdd5b4ba9f182986 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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