Created
February 11, 2016 10:05
-
-
Save rayburgemeestre/fbbe2816906fec967e7a to your computer and use it in GitHub Desktop.
tampermonkey_kanbanflow_time_spent_per_day.js
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
// ==UserScript== | |
// @name Add time spent per day in "Done" column Kanbanflow. | |
// @namespace http://cppse.nl/ | |
// @version 0.1 | |
// @description Add time spent per day in "Done" column Kanbanflow. | |
// @match https://kanbanflow.com/board/* | |
// @copyright 2012+, Ray Burgemeestre | |
// @updateURL http://cppse.nl/public/tampermonkey_kanbanflow_time_spent_per_day-meta.js | |
// @downloadURL http://cppse.nl/public/tampermonkey_kanbanflow_time_spent_per_day.js | |
// ==/UserScript== | |
function kanbanflow_check_fun() { | |
var groups = document.querySelectorAll('.task-group'), g; | |
for (g=0; g<groups.length; g++) { | |
(function (group) { | |
var times = group.querySelectorAll('.task-time'), t, total = 0; | |
for (t=0; t<times.length; t++) { | |
var s = times[t].innerHTML.split('/'), | |
spent = s.shift().trim(), | |
estimate = s.shift(); | |
estimate = estimate ? estimate.trim() : 0; | |
function normalize(timestr) | |
{ | |
var c = timestr.split(' '), i, s, total = 0; | |
for (i=0; i<c.length; i++) { | |
var s = c[i].trim(); | |
if (s[s.length - 1] === 'h') { | |
total += parseInt(s) * 60; | |
} | |
else if (s[s.length - 1] === 'm') { | |
total += parseInt(s) * 1; | |
} | |
} | |
return total; | |
} | |
total += normalize(spent); | |
} | |
var html = '' + group.querySelector('.task-groupLabel').innerHTML.split('==>')[0]; | |
group.querySelector('.task-groupLabel').innerHTML = html + ' ==> ' + | |
Math.round((total / 60) * 100) / 100; | |
})(groups[g]); | |
// break; | |
} | |
setTimeout( kanbanflow_check_fun, 1000); | |
} | |
setTimeout( kanbanflow_check_fun, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment