eddi: Tabelle als Karte aus md. Array.

Beitrag lesen

Hallo,

  
// Cardsystems.js created by Ggriever  
var posx=0,posy=0;  
var karte = [];  
for(var i=0;i<5;i++){  
   karte[i]=[];  
   for(var j=0;j<6;j++)  
      karte[i][j]=["#00DF00",false,""];  
}  
  
var f = window.open("about:blank");  
f.document.write("<table cellspacing=0 cellpadding=0 border=0 style='table-layout:fixed;' id=\"js_table\">")  
for(var i = 0;i<karte.length;i++)  
{  
  f.document.write("<tr>")  
  if(karte[posx-(i-2)] && karte[posx-(i-2)][posy-2])  
     f.document.write("<td style=\"background:"+karte[posx-(i-2)][posy-2][0]+"\">&nbsp;</td>");  
  else  
     f.document.write("<td>&nbsp;</td>");  
  
  if(karte[posx-(i-2)] && karte[posx-(i-2)][posy-1])  
     f.document.write("<td style=\"background:"+karte[posx-(i-2)][posy-1][0]+"\">&nbsp;</td>");  
  else  
     f.document.write("<td>&nbsp;</td>");  
  
  if(karte[posx-(i-2)] && karte[posx-(i-2)][posy])  
     f.document.write("<td style=\"background:"+karte[posx-(i-2)][posy][0]+"\">&nbsp;</td>");  
  else  
     f.document.write("<td>&nbsp;</td>");  
  
  if(karte[posx-(i-2)] && karte[posx-(i-2)][(posy+1)])  
     f.document.write("<td style=\"background:"+karte[posx-(i-2)][(posy+1)][0]+"\">&nbsp;</td>");  
  else  
     f.document.write("<td>&nbsp;</td>");  
  
  if(karte[posx-(i-2)] && karte[posx-(i-2)][(posy+2)])  
     f.document.write("<td style=\"background:"+karte[posx-(i-2)][(posy+2)][0]+"\">&nbsp;</td>");  
  else  
     f.document.write("<td>&nbsp;</td>");  
  
  f.document.write("</tr>")  
}  
f.document.write("</table>")  

  
table#id_table td {width:12px;height:12px;background:#000}  

Gruß aus Berlin!
eddi