Prev | Current Page 779 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

createDocument();
var colors = Xml.createElement(???colors???);
xml.addChild(colors);
for(item in list)
{
var color = Xml.createElement(???color???);
color.set(???name???, item.name);
color.set(???hex???, item.hex);
colors.addChild(color);
}
return xml.toString();
}
public static function filterByName(start : String, list : Iterable < Color > )
{
start = start.toLowerCase();
return Lambda.filter(list, function(c)
{
return StringTools.startsWith(c.name.toLowerCase(), start);
});
}
}
The server script is also very simple and resembles the QuotationService from the previous
example. The ColorsService reads a list of color names and hex definitions from a text file and filters
the result using the optional parameter start .
import neko.io.File;
class ColorsService
{
public static function main()
{
var start = neko.Web.getParams().get(???start???);
if(start == null)
start = ?????™;
var colors = loadColors();
neko.Lib.print(ColorsUtil.toXml(ColorsUtil.filterByName(start, colors)));
}
private static function loadColors()
{
var c = File.


Pages:
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791