0

我用 google script api 创建了我的第一个网络应用程序(它现在有点像一个网页)。

http://bit.do/WhoKilledWho

根据这次经验,我认为“哇,获取数据很容易”。 urlFetchApp.fetch()

整理数据并不容易,但也不算太糟糕。很多循环等等。

然而,为输出创建我的“表”是可怕的。

  // 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;

有没有JSON.htmltablify(myobject)这样简单的事情?

4

0 回答 0