javascript - I am trying to modify server side js. which takes an json file as input and render the data to produce html file. -
attached code takes json input , trying render data using script comes in proper format.
we need modify "json html.txt" server-side js, output in html input json .
attached image shows output @ right side.this output must in format.
<!doctype html> <html> <body> <p id="demo"></p> <script> var statement, i, j, x = ""; statement = { "financial statement:": ["netincomeloss = ","- netincomelossattributabletononcontrollinginterest","+ profitloss = "," + incomelossfromdiscontinuedoperationsneto..."," + incomelossfromcontinuingoperationsinclud... = "," + apd_incomelossfromcontinuingoperationsbeforetaxes = "," + operatingincomeloss = "," + salesrevenuenet"," - costofgoodsandservicessold"," - sellinggeneralandadministrativeexpense"," - researchanddevelopmentexpense"," - restructuringcharges"," + apd_otherincomeexpensenet"," + incomelossfromequitymethodinvestments"," - interestexpense"," - incometaxexpensebenefit","earningspersharebasic = ","+ incomelossfromcontinuingoperationsperbasicshare","+ incomelossfromdiscontinuedoperationsnetoftaxperbasicshare","earningspersharediluted = ","+ incomelossfromcontinuingoperationsperdilutedshare","+ incomelossfromdiscontinuedoperationsneto..."], "2009-12-31":[251.8,5,256.8,0,256.8,340.3,345,2173.5,1568.6,244.1,27.2,0,11.4,26.9,31.6,83.5,1.19e-06,1.19e-06,0,1.16e-06,1.16e-06,0],"2008-12-31":[68.6,5,73.6,-21.4,95,102.1,114.1,2195.3,1629.7,247,33.2,174.2,2.9,24.5,36.5,7.1,3.3e-07,4.3e-07,-1e-07,3.2e-07,4.2e-07,-1e-07] } var spacecount=[]; var financialstatement=[]; var othercolumns = []; var output = '<table class="table" style="width:100%;"><tr>'; object.keys(statement).foreach(function (key, i) { output += '<th><pre>' + key + '</pre></th>'; if (i > 0){ othercolumns.push(key); } }); output += '</tr>'; statement[object.keys(statement)[0]].foreach(function(val, i){ var total = false; if (val.indexof('=') > -1){ total = true; } var printvalue = '<td><pre>' + val + '</pre></td>'; if (total){ printvalue = '<td><pre style="font-weight: bold;text-decoration: underline;">' + val + '</pre></td>'; } othercolumns.foreach(function(key, j){ if (total){ printvalue += '<td><pre style="font-weight: bold;text-decoration: underline;">' + statement[key][i] + '</pre></td>'; } else { printvalue += '<td><pre>' + statement[key][i] + '</pre></td>'; } }); output += printvalue + '</tr>'; }); output += '</table>'; document.getelementbyid("demo").innerhtml = output; </script> </body> </html>
Comments
Post a Comment