Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It might be brain-dead Javascript written by a clueless newbie, but i…
…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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); |