2019-04-15 14:37:05 +02:00
|
|
|
var calculateIssuePoints = function () {
|
|
|
|
let links = document.getElementsByClassName('js-project-card-issue-link');
|
|
|
|
for (let count = 0; count < links.length; count++) {
|
|
|
|
let link = links[count];
|
|
|
|
let points_mark = link.text.match(/^\(\d+\)*/);
|
|
|
|
if (points_mark) {
|
|
|
|
let points = points_mark[0].replace(/\(|\)/g, '');
|
2019-04-15 15:12:42 +02:00
|
|
|
link.innerHTML = link.text.replace(/^\(\d+\)/, '<span class="issue-points">' + points + '</span>');
|
2019-04-15 14:37:05 +02:00
|
|
|
}
|
2019-04-12 12:55:20 +02:00
|
|
|
};
|
2019-04-15 14:37:05 +02:00
|
|
|
};
|
|
|
|
|
2019-04-29 12:43:52 +02:00
|
|
|
var drawProgressBars = function(to_do, doing, done) {
|
|
|
|
let total = to_do + doing + done;
|
2019-05-07 11:36:06 +02:00
|
|
|
|
|
|
|
let doing_percent = 0;
|
|
|
|
let done_percent = 0;
|
2019-04-29 12:43:52 +02:00
|
|
|
|
2019-05-07 11:36:06 +02:00
|
|
|
if (total > 0) {
|
2019-05-07 14:27:25 +02:00
|
|
|
doing_percent = (doing / total) * 100;
|
|
|
|
done_percent = (done / total) * 100;
|
2019-05-07 11:36:06 +02:00
|
|
|
}
|
2019-04-29 12:43:52 +02:00
|
|
|
|
|
|
|
let pointsBarElement = document.getElementById('pointsBar');
|
|
|
|
|
|
|
|
if (pointsBarElement) {
|
|
|
|
pointsBarElement.parentNode.removeChild(pointsBarElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
let header = document.getElementsByClassName('project-header')[0];
|
|
|
|
let barsPlace = header.getElementsByClassName('f5')[0];
|
|
|
|
|
|
|
|
let pointBarHTML = `<div id="pointsBar" class="ml-3 d-inline-block">
|
|
|
|
<div style="width: 100px">
|
|
|
|
<div class="tooltipped tooltipped-s" aria-label="${done} done / ${doing} in progress / ${to_do} to do">
|
|
|
|
<span class="progress-bar progress-bar-small">
|
2019-05-07 14:27:25 +02:00
|
|
|
<span style="width: ${done_percent}%;" class="progress d-inline-block bg-blue"> </span><span style="width: ${doing_percent}%;" class="progress d-inline-block bg-yellow"> </span>
|
2019-04-29 12:43:52 +02:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>`;
|
|
|
|
|
|
|
|
barsPlace.innerHTML += pointBarHTML;
|
|
|
|
}
|
|
|
|
|
2019-04-15 14:37:05 +02:00
|
|
|
var updatePoints = function () {
|
|
|
|
calculateIssuePoints();
|
2019-04-29 12:43:52 +02:00
|
|
|
var to_do = 0;
|
|
|
|
var doing = 0;
|
|
|
|
var done = 0;
|
2019-04-15 14:37:05 +02:00
|
|
|
let columns = document.getElementsByClassName('project-column');
|
2019-04-29 12:43:52 +02:00
|
|
|
|
2019-04-15 14:37:05 +02:00
|
|
|
for (let count = 0; count < columns.length; count++) {
|
|
|
|
let total = 0;
|
|
|
|
let column = columns[count];
|
|
|
|
let point_marks = column.getElementsByClassName('issue-points');
|
2019-04-29 12:43:52 +02:00
|
|
|
let column_name = column.getElementsByClassName('js-project-column-name')[0].innerHTML;
|
2019-04-15 14:37:05 +02:00
|
|
|
for (let j = 0; j < point_marks.length; j++) {
|
|
|
|
total += parseInt(point_marks[j].textContent);
|
|
|
|
}
|
|
|
|
let header = column.getElementsByTagName('h4')[0];
|
|
|
|
let column_points = header.getElementsByClassName('column-points');
|
|
|
|
if (column_points.length > 0) {
|
2019-04-15 14:49:05 +02:00
|
|
|
column_points[0].innerHTML = total;
|
2019-04-15 14:37:05 +02:00
|
|
|
} else {
|
2019-04-15 15:12:42 +02:00
|
|
|
header.innerHTML = '<span class="column-points">' + total + '</span>' + header.innerHTML;
|
2019-04-15 14:37:05 +02:00
|
|
|
}
|
2019-04-29 12:43:52 +02:00
|
|
|
switch (column_name) {
|
|
|
|
case 'To do':
|
|
|
|
to_do = total;
|
|
|
|
break;
|
|
|
|
case 'In progress':
|
|
|
|
doing = total;
|
|
|
|
break;
|
|
|
|
case 'Done':
|
|
|
|
done = total;
|
|
|
|
}
|
2019-04-12 12:55:20 +02:00
|
|
|
};
|
2019-04-29 12:43:52 +02:00
|
|
|
drawProgressBars(to_do, doing, done);
|
2019-04-12 12:55:20 +02:00
|
|
|
};
|
2019-04-15 14:37:05 +02:00
|
|
|
|
|
|
|
window.setInterval(updatePoints, 2000);
|