Skip to content

Commit

Permalink
It might be brain-dead Javascript written by a clueless newbie, but i…
Browse files Browse the repository at this point in the history
…t does _work_.
  • Loading branch information
Frank Shearar committed Oct 19, 2012
1 parent a9db298 commit 8083cf2
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions src/add-numeric-tags.js
@@ -1,11 +1,28 @@
var labels = document.getElementsByClassName("filter-item");
var labels = document.getElementsByClassName('filter-item');
var total = 0.0;
labels.forEach(function(element, index, array) {
var n = parseFloat(labels.body);
if (!n.isNan()) {
total += n;
}
});
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;
}
}
}
}

// the bodies of spans with class "label" that are numbers
var display = document.createElement('span')
display.innerHTML = "| Total estimate: " + total.toString();
display.className = 'open';
console.log("1");
document.querySelector('.info-secondary').appendChild(display);
console.log("2");

0 comments on commit 8083cf2

Please sign in to comment.