From 027a3feedfe39de42b78630d5d913e2ef8b74f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Cuevas?= Date: Mon, 29 Apr 2019 12:43:52 +0200 Subject: [PATCH] Added a bar counting the points --- githubpoints-projects.js | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/githubpoints-projects.js b/githubpoints-projects.js index 641cbbd..25d86c3 100644 --- a/githubpoints-projects.js +++ b/githubpoints-projects.js @@ -10,13 +10,46 @@ var calculateIssuePoints = function () { }; }; +var drawProgressBars = function(to_do, doing, done) { + let total = to_do + doing + done; + + let doing_percent = (doing / total) * 100; + let done_percent = (done / total) * 100; + + 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 = `
+
+
+ +   +   + +
+
`; + + barsPlace.innerHTML += pointBarHTML; +} + var updatePoints = function () { calculateIssuePoints(); + var to_do = 0; + var doing = 0; + var done = 0; let columns = document.getElementsByClassName('project-column'); + for (let count = 0; count < columns.length; count++) { let total = 0; let column = columns[count]; let point_marks = column.getElementsByClassName('issue-points'); + let column_name = column.getElementsByClassName('js-project-column-name')[0].innerHTML; for (let j = 0; j < point_marks.length; j++) { total += parseInt(point_marks[j].textContent); } @@ -27,7 +60,18 @@ var updatePoints = function () { } else { header.innerHTML = '' + total + '' + header.innerHTML; } + switch (column_name) { + case 'To do': + to_do = total; + break; + case 'In progress': + doing = total; + break; + case 'Done': + done = total; + } }; + drawProgressBars(to_do, doing, done); }; window.setInterval(updatePoints, 2000);