Iterate Columns + Rows
For Loop Mastery
by dixalex
JavaScript
if ($('div.dashTable').length > 0) {
var tdIndex = $("th:contains('Reward')").index();
console.log("TD Index is: " + tdIndex);
for (i = 0; i <= 5; i++) {
var clonedRow = $('div.dashTable table tr:eq(1)').clone();
clonedRow.appendTo($('div.dashTable table'));
}
for (i = 0; i <= $('div.dashTable table tr').length; i++) {
for (a = 0; a <= $('div.dashTable table tr td').length; a++) {
var targetTD = $('div.dashTable table tr:eq(' + i + ') td:eq(' + tdIndex + ')');
var points = parseInt($('div.dashTable table tr:eq(' + i + ') td:eq(' + tdIndex + ')').text(), 10),
conversion = 20,
currency = Math.round(points * 100.0 / conversion) / 100;
}
if (currency === 0 || isNaN(currency)) {
targetTD.css("color", "green").css("font-weight", "bold").text("$" + "0" + ".00").css("text-align", "center");
};
targetTD.css("color", "green").css("font-weight", "bold").text("$" + currency + ".00").css("text-align", "center");
console.log("Make Blue: " + targetTD.text());
}
console.log("Row Count: " + $('div.dashTable table tr').length);
}
//Currency conversion for Mobile
var dashUL = $('div.dashTable ul li');
if ($('div.dashTable ul li').length > 0) {
dashUL.each(function() {
$(this).find("p:contains('Dollars:') span:eq(0)").addClass('pointerDIV');
$(this).find("p:contains('Reward:') span:eq(0)").addClass('pointerDIV');
$(this).find("p:contains('Dollars:')").append("<div style='position: relative; font-size: 12px;' class='currencyDiv'></div>");
$(this).find("p:contains('Reward:')").append("<div style='position: relative; font-size: 12px;' class='currencyDiv'></div>");
});
var pointCnt = $('.pointerDIV').length;
$('.pointerDIV').each(function() {
var points = parseInt($(this).text(), 10),
conversion = 20,
currency = Math.round(points * 100.0 / conversion) / 100;
if (currency === 0 || isNaN(currency)) {
$(this).css("display", "none").css("visibility",...