e.forEach(function(item) { var element = document.createElement("a"); element.href="typica://script/" + item.dbid var colordiv; if(item.completion >= 1) { colordiv = '
'; } else { colordiv = '
'; } if(item.completion < 0.6) { colordiv = '
'; } if(item.completion < 0.3) { colordiv = '
'; } element.innerHTML = '
' + colordiv + '' + item.title + '' + Math.floor(item.completion * 100) + '%' + item.detail + '
'; document.body.appendChild(element); })