Created
July 18, 2012 08:15
-
-
Save suhajdab/3134992 to your computer and use it in GitHub Desktop.
overview bookmarklet for ProData Hour Reporting page
This file contains hidden or 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
var contracthours=165,hourrate=123,sum=0,now=new Date,firstday=1,nextday=now.getDate()-(now.getHours()<15?1:0),lastday=(new Date((new Date).setFullYear(now.getFullYear(),now.getMonth()+1,0))).getDate(),workdaysdone=0,workdaysleft=0,msg;for(var d=firstday;d<=lastday;d++){var day=new Date((new Date).setFullYear(now.getFullYear(),now.getMonth(),d)),weekday=day.getDay();if(weekday!==0&&weekday!==6){if(d<=nextday)workdaysdone++;else workdaysleft++}}[].slice.apply(document.querySelectorAll('span[id*="lblTimer"]')).forEach(function(a){sum+=parseFloat(a.innerText)||0});msg=contracthours+" total hours\n"+sum+" hours ("+Math.round(sum/workdaysdone*10)/10+" hours / workday) worked so far.\n"+(contracthours-sum)+" hours ("+Math.round((contracthours-sum)/workdaysleft*10)/10+" hours / workday) to go.\n"+Math.floor(sum*hourrate)+" dkk earned so far";alert(msg) |
This file contains hidden or 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
165 total hours | |
99.5 hours (5.5 hours / workday) worked so far. | |
65.5 hours (16.4 hours / workday) to go. | |
12345 dkk earned so far |
This file contains hidden or 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
var contracthours = 165, | |
hourrate = 123, | |
sum = 0, | |
now = new Date, | |
firstday = 1, | |
nextday = now.getDate() - (now.getHours() < 15 ? 1 : 0), | |
lastday = new Date((new Date).setFullYear(now.getFullYear(), now.getMonth() + 1, 0)).getDate(), | |
workdaysdone = 0, | |
workdaysleft = 0, | |
msg; | |
for (var d = firstday; d <= lastday; d++) { | |
var day = new Date((new Date).setFullYear(now.getFullYear(), now.getMonth(), d)), | |
weekday = day.getDay(); | |
if (weekday !== 0 && weekday !== 6) { | |
if (d <= nextday) workdaysdone++; | |
else workdaysleft++; | |
} | |
}; | |
[ ].slice.apply(document.querySelectorAll('span[id*="lblTimer"]')).forEach(function (el) { | |
sum += (parseFloat(el.innerText) || 0) | |
}); | |
msg = contracthours + ' total hours\n' | |
+ sum + ' hours (' + Math.round(sum / workdaysdone * 10) / 10 + ' hours / workday) worked so far.\n' | |
+ (contracthours - sum) + ' hours (' + Math.round((contracthours - sum) / workdaysleft * 10) / 10 + ' hours / workday) to go.\n' | |
+ Math.floor(sum * hourrate) + ' dkk earned so far'; | |
alert(msg); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment