js/utils.js
//Use HTML for tables, so ensure support for newlines etc
Use HTML for tables, so ensure support for newlines etc
Use HTML for tables so ensure support for newlines etc
function htmlTableFromArray(content, header, columnWidths, alignment) {
	if (content.length < 1) {
		console.log("Invalid parameters - need at least one row");
		return "";
	}
	var table = "<table>";
	if (columnWidths) {
		for (var i = 0; i < columnWidths.length; i++) {
			table += "<col width=\"" + columnWidths[i] + "%\">";
		}
	}
	if (header) {
		table += "<tr>";
		for (var i = 0; i < content[0].length; i++) {
			table += "<th>" + content[0][i] + "</th>\n";
		}
		table += "</tr>";
	}
	for (var i = (header ? 1 : 0); i < content.length; i++) {
		table += "<tr>";
		for (var j = 0; j < content[i].length; j++) {
			if (alignment) table += "<td align=\"" + alignment[j] + "\">" + content[i][j] + "</td>";
			else table += "<td>" + content[i][j] + "</td>";
		}
		table += "</tr>";
	}
	table += "</table>";
	return table;
}
function htmlTableFromArray ( content , header , columnWidths , alignment ) { if ( content . length < 1 ) { console . log ( "Invalid parameters - need at least one row" ) ; return "" ; } var table = "<table>" ; if ( columnWidths ) { for ( var i = 0 ; i < columnWidths . length ; i ++ ) { table += "<col width=\"" + columnWidths [ i ] + "%\">" ; } } if ( header ) { table += "<tr>" ; for ( var i = 0 ; i < content [ 0 ] . length ; i ++ ) { table += "<th>" + content [ 0 ] [ i ] + "</th>\n" ; } table += "</tr>" ; } for ( var i = ( header ? 1 : 0 ) ; i < content . length ; i ++ ) { table += "<tr>" ; for ( var j = 0 ; j < content [ i ] . length ; j ++ ) { if ( alignment ) table += "<td align=\"" + alignment [ j ] + "\">" + content [ i ] [ j ] + "</td>" ; else table += "<td>" + content [ i ] [ j ] + "</td>" ; } table += "</tr>" ; } table += "</table>" ; return table ; }
Use HTML for tables, so ensure support for newlines etc
Use HTML for tables so ensure support for newlines etc