githubpoints/githubpoints-projects.js

33 lines
1.2 KiB
JavaScript

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, '');
link.innerHTML = link.text.replace(/^\(\d+\)/, '<span class="issue-points">' + points + '</span>');
}
};
};
var updatePoints = function () {
calculateIssuePoints();
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');
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) {
column_points[0].innerHTML = total;
} else {
header.innerHTML = '<span class="column-points">' + total + '</span>' + header.innerHTML;
}
};
};
window.setInterval(updatePoints, 2000);