-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheavp3_eav_divyield.js
More file actions
49 lines (43 loc) · 1.57 KB
/
eavp3_eav_divyield.js
File metadata and controls
49 lines (43 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
jQuery(document).ready(function($) {
if ($('span.eavdivyield').length == 0) {
var currency = $('#eavtitle div.price span.currency');
var price = $('a', currency).html().trim();
var dividend;
var divamt;
try {
dividend = $('#nmp-stats div:first > span:last > span:first > a').html().trim();
divamt = $('#nmp-stats div:first > span:first > span:first > a').html().trim();
} catch(e) {
// If at first you don't succeed, try/catch again
try {
dividend = $('#nmp-stats div:nth-child(4) > span:last > span:first > a').html().trim();
divamt = $('#nmp-stats div:nth-child(4) > span:first > span:first > a').html().trim();
} catch(e) {
return; // Give it up already
}
}
divamt = divamt.replace(/\,/g, '');
var divyield = dividend / price;
var divyieldp = parseFloat((divyield * 100).toFixed(2));
if (divamt >= 150000) {
divyieldp += 0.2;
}
var color;
if (divyieldp <= 0.65) {
color = "#CC0033";
} else if(divyieldp >= 0.75 && divyieldp < 1.00) {
color = "#FFBB00";
} else if (divyieldp >= 1.00 && divyieldp < 2.00) {
color = "#009900";
} else if (divyieldp >= 2.00) {
color = "#0075F5";
} else {
color = "#000";
}
if (divamt >= 150000) {
divyieldp -= 0.2;
}
currency.append('<br/><span class="eavdivyield" style="float:left;font-size: 12px;display:none;margin-top:5px;">Current Dividend Yield: <span style="color:' + color + ';">' + divyieldp.toFixed(2) + '%</span></span>');
$('span.eavdivyield').fadeIn();
}
});