0

I've created my first web app (it's now kinda a web page) with the google script api.

http://bit.do/WhoKilledWho

From this experience I thought "wow getting the data is easy". urlFetchApp.fetch()

Collating the data was not so easy, but not too bad. Lots of loops etc.

However creating my "table" for output was horrendous.

  // Blue team Output
  output = "<table class='gradienttable' width = '60%'><tr><th>Blue Team</th>"
  for (p in players) {
    if (players[p].team != 100) {
      output = output + "<th width = '14%'>" + players[p].pname + "<br>(" + players[p].cname + ")</th>";}
  }

  for (p in players) {
    //output = output + "<tr>";
    i = 1;
    for (k in players){
      if (players[p].team == 100) {
        if (i==1) { output = output + "<tr><th  width = '14%'>" + players[p].pname + "<br>(" + players[p].cname + " " +players[p].kda +")</th>"; }
        if (players[k].team != players[p].team) {
          output = output + "<td>" + players[p].killed[k] + "</td>";}
        i++;
      }
    }
    output = output + "</tr>";
  }
  output = output + "</table>";
  return output;

Is there's no JSON.htmltablify(myobject) or something easy like that?

Reenen
  • 128
  • 9
  • Hava a look at d3.js. – isnot2bad May 21 '15 at 04:55
  • Wow, it looks spectacular. I must still find a way to incorporate it into my document (in google scripts api), but it looks like something that will be well worth the effort to learn how to use. – Reenen May 21 '15 at 06:37
  • Please note that d3.js is a client library, so it runs in the browser, not on the server. Depending on where you get your data from, you can either query it in the browser via ajax or - as you did right now - fetch it on server side and generate some json structure into your html that is later used by d3.js on the client. – isnot2bad May 21 '15 at 07:04

0 Answers0