forked from kleampa/not-paid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnot-paid.js
24 lines (20 loc) · 799 Bytes
/
not-paid.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Next time use letsdeel.com to make sure you get paid
(function(){
/* change these variables as you wish */
var due_date = new Date('2017-02-27');
var days_deadline = 60;
/* stop changing here */
var current_date = new Date();
var utc1 = Date.UTC(due_date.getFullYear(), due_date.getMonth(), due_date.getDate());
var utc2 = Date.UTC(current_date.getFullYear(), current_date.getMonth(), current_date.getDate());
var days = Math.floor((utc2 - utc1) / (1000 * 60 * 60 * 24));
if(days > 0) {
var days_late = days_deadline-days;
var opacity = (days_late*100/days_deadline)/100;
opacity = (opacity < 0) ? 0 : opacity;
opacity = (opacity > 1) ? 1 : opacity;
if(opacity >= 0 && opacity <= 1) {
document.getElementsByTagName("BODY")[0].style.opacity = opacity;
}
}
})()