<!-- Go Board Position Generation 09/19/2000-01/18/2001 --> <!-- ---------------------------------------- 12/07/2000 --> <!-- www.davar.net/GO/POSITION.JS --> <!-- Copyright (C) 2000-2001 by Vladimir Veytsel --> <!-- // Generates HTML table of Go board position presentation to be used // in texts that discuss those positions. Serves merely as a shorthand // to save typing as well as page loading time by eliminating massive // HTML repetitions. // The position description is a straightforward one - each argument // is a string corresponding to one row of Go board elements that are // listed from left to right (delimited by "_") being the data items // of the cells of a table representing required position. // Two types of items are possible: // 1. Simple item: Image // Image is a Foreground occupying the entire cell // 2. Complex item: Image-Foreground[-Alignment] // Image is a Background for the specified Foreground // (Used to mark board elements with symbols, // E.g.: mark stones with move numbers) // Where: Image - Name of JPG file representing required image // E.g.: ETL - Empty Top Left corner of Go board // Note: Though it is not a requirement, it makes // sense to have images in HTML text directory // to avoid specification of their paths. // Foreground - Specification of Foreground to be overlaid // on the Background Image // E.g.: <FONT COLOR=Red><B>5</B></FONT> // Alignment - Specification of horizontal and vertical alignments // of specified Foreground within Image background // (HTML defaults: ALIGN=Right VALIGN=Center) // E.g.: ALIGN=Center to achieve both horizontal and // vertical centering of specified // Foreground over Image background // Note: When both horizontal and vertical alignments // are specified they should be separated by " ". // Note: In a complex item alignment specification is optional, // while foreground should always be present. // E.g.: document.write(POSITION("EL_EC_EC_EC", // "BS_BS_BS_EC", // "WS_WS_BS_EC", // "EBL-<FONT COLOR=Red>A</FONT>-ALIGN=Center_WS_BS_EB", // "RB_RB_RB_RB")) // Notes: // - Each argument describes position row; it should be contained // within ONE line of HTML text. // - Symbols "_" and "-" are reserved as delimiters within an argument. // The returned value is the HTML text of a table representing Go position // to be used in the "document.write". function POSITION(Pos) {// Pos - Go board position description (multiple arguments) Pos_Table="<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>" for (i=0;i<arguments.length;i++) {Pos_Table=Pos_Table+"<TR>" Pos_Row =arguments[i] Item =Pos_Row.split("_") for (j=0;j<Item.length;j++) {if (Item[j].length<4) Image=Item[j] else {// Parse complex Item: Image-Foreground[-Alignment] Complex =Item[j].split("-") Image =Complex[0] Foreground=Complex[1] Alignment ="" if (Complex.length>2) Alignment=Complex[2] } // Form values of Width and Height of element Image Width=33; Height=33 if ((Image=="RTL")|| (Image=="RTR")|| (Image=="RBR")|| (Image=="RBL")) {Width=8; Height=8} if ((Image=="RT")|| (Image=="RB")) Height=8 if ((Image=="RL")|| (Image=="RR")) Width=8 // Form table data cell (simple/complex) if (Item[j].length<4) Pos_Table=Pos_Table+"<TD><IMG SRC='"+Image+ ".JPG' WIDTH="+Width+" HEIGHT="+Height+"></TD>" else Pos_Table=Pos_Table+"<TD BACKGROUND='"+Image+ ".JPG' WIDTH="+Width+" HEIGHT="+Height+ " "+Alignment+">"+Foreground+"</TD>" } Pos_Table=Pos_Table+"</TR>" } Pos_Table=Pos_Table+"</TABLE>" return Pos_Table } //-->