Home Remote forum plugin - List of latest posts

Can’t get enough of THR? What to check the latest news?
This plugin builds a table listing the newest postings of this very forum.
It outputs html that must be bound to a webbrowser.

function onPoll() {
    console.log("polling");
    var posts = 4;   
    var mainDevice = plugin.Devices["forum"];   
    var http = new HTTPClient();
    var response = http.get("https://community.thehomeremote.com/posts.json" );
    var json = response.data.latest_posts.slice(0,posts); 
    var json2 = new Array();	
    for (var i = 0; i < json.length; i++) {
        var temp_item = json[i];
        json2.push({
        	"Date"    : new Date(temp_item.updated_at).toLocaleString(),
        	"Author"  : temp_item.username,
        	"Subject" : temp_item.topic_title
    	});
    }
   mainDevice.out = json2table(json2);  
   
  function json2table(json) {
    var cols = Object.keys(json[0]);
    var BkgCol = '#F2F2F2';
    var BrdCol = 'C0C0C0';
    var CelCol = 'FFFFFF';
    var BrdWid = '4';
    var headerRow = '';
    var bodyRows = '';
    function capitalizeFirstLetter(string) {     return string.charAt(0).toUpperCase() + string.slice(1);   }
    cols.map(function(col) {     headerRow += '<th style="border: '+ BrdWid+'px solid #'+BrdCol+';">' + capitalizeFirstLetter(col) + '</th>';   });
    json.map(function(row) {
         bodyRows += '<tr>';
         cols.map(function(colName) {   bodyRows += '<td style="border: '+ BrdWid+'px solid #'+BrdCol+';">' + row[colName] + '</td>';      })
         bodyRows += '</tr>';
  });
  return '<body style="background-color:'+BkgCol+'"><table style="background-color: #'+CelCol+';border: '+ BrdWid+'px solid #'+BrdCol+';border-collapse: collapse"><thead><tr>' +     headerRow +
         '</tr></thead><tbody>' +    bodyRows +
         '</tbody></table>';
} // end json2table function
  
} //end onPoll