# SliTaz package receipt.

PACKED_SIZE="16.0K"
UNPACKED_SIZE="48.0K"
PACKAGE="nanochess"
VERSION="1.0"
CATEGORY="games"
SHORT_DESC="Chess game in javascript (need an unicode aware browser)"
MAINTAINER="pascal.bellard@slitaz.org"
WEB_SITE="http://nanochess.110mb.com/chess4.html"

# Rules to configure and make the package.
compile_rules()
{
	# define colors
	white="#f0f0b0"		# was #f0f0f0
	black="#f05030"		# was #c0c0f0
	gray="#843"		# was #dde
	background="$white"	# was white
	red="blue"	
	
	mkdir -p $src 2> /dev/null
	cp $stuff/index.html $src
	cd $src
	sed -i -e 's/<select/<input type=\\"button\\" value=\\"\&#9818; \&hArr; \&#9812;\\" onclick=\\"yy^=8;Z()\\">&/' \
	  -e 's/><option.*$/>";/' -e "s/ style='font-size:20px'//" \
	  -e 's/50px/"+P+"px/g' -e 's/=60/="+H+"/g' \
	  -e 's|for(a=|H=innerHeight/9;P=H*5/6;|' -e 's/^"<table/for(a=&/' \
	  -e "s/c0c\":\"f0f\")+\"0f0/$white\":\"$black\")+\"/" \
	  -e "s/#dde/$gray/" -e "s/red/$red/" -e 's/bgcolor=#/bgcolor=/' \
	  -e 's|^doc.*|yy=/\\?b/i.test(document.URL)?8:0;for(p=18;++p<23;)a+="<option>\&#9823; \&rarr; \&#98"+p+";</option>";document.write(a);|' \
	  -e "s|<script>|<style>body {background: $background; overflow: hidden;} input,select {background: transparent; -webkit-appearance: none;}</style>\n<title>Toledo chess</title>&|" \
	  -e 's|function Y|function Z(){if(y!=yy)setTimeout("X(0,0,0,21,u,2),X(0,0,0,21,u,1)",250);}\n&|' \
	  -e 's|if(y)set.*|Z();}}Z()|' \
		index.html
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
        mkdir -p $fs/var/www/chess $fs/usr/share/applications
	cp $src/* $fs/var/www/chess
	chown -R 80.80 $fs/var/www/chess
	cat > $fs/usr/share/applications/chess.desktop <<EOT
[Desktop Entry]
Type=Application
Name=Chess
Name[zh_CN]=国际象棋
Exec=sh -c "url=file:///var/www/chess/index.html ; tazweb --notoolbar \$url || browser \$url"
Icon=other
Terminal=false
Categories=Game;
Comment=Chess game
EOT
}

