Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Condense the code a bit.

  • Loading branch information...
commit 72bbda6702863225e969185d632a08947a0e2f83 1 parent e48c563
@frankshearar authored
Showing with 14 additions and 17 deletions.
  1. +1 −1  manifest.json
  2. +13 −16 src/add-numeric-tags.js
View
2  manifest.json
@@ -2,7 +2,7 @@
"name": "GitHub Planning Helper",
"version": "1.0",
"manifest_version": 1,
- "description": "Add all numeric tags when viewing GitHub issues.",
+ "description": "Display the total estimate for your GitHub milestones.",
"content_scripts": [
{
"matches": [
View
29 src/add-numeric-tags.js
@@ -1,23 +1,20 @@
+// Find all the labels
var labels = document.getElementsByClassName('filter-item');
var total = 0.0;
for (var i = 0; i < labels.length; i++) {
- element = labels[i];
- var scale = element.querySelector('.name');
- if (scale) {
- scale = scale.innerHTML;
-
- var count = element.querySelector('.count');
-
- if (count) {
- count = count.innerHTML;
-
- scale = parseFloat(scale);
- count = parseInt(count);
- if (!isNaN(scale) && !isNaN(count)) {
- total += scale * count;
- }
- }
+ var element = labels[i];
+ var scale = element.querySelector('.name');
+ var count = element.querySelector('.count');
+ if (scale && count) {
+ scale = parseFloat(scale.innerHTML);
+ count = parseInt(count.innerHTML);
+ // Filter out any non-numeric labels.
+ // Also, protect against with non-numeric counts (which shouldn't
+ // happen, but...).
+ if (!isNaN(scale) && !isNaN(count)) {
+ total += scale * count;
}
+ }
}
var hangPoint = document.querySelector('.info-secondary');
Please sign in to comment.
Something went wrong with that request. Please try again.