function ShopCateCollection(name) { this.name = name; this.length = 0; this.add = addShopCate; return this; } function addShopCate(object) { this.length++; this[this.length] = object } function ShopCateNode(id,name) { this.id = id; this.name = name; return this; } function extractShopCateChildrenOf(node,arr) { var children = new ShopCateCollection(node); var currentIndex = 1; while (currentIndex <= arr.length) { //arr[currentIndex].id.startWith(node) && if (arr[currentIndex].id.substring(0,node.length)==node && arr[currentIndex].id.length==(node.length+2) ) { children.add(arr[currentIndex]) } currentIndex++ } return children; } shopcates=new ShopCateCollection("C"); shopcates.add(new ShopCateNode("C060109","玩具车")); shopcates.add(new ShopCateNode("C060108","益智玩具")); shopcates.add(new ShopCateNode("C060107","助学玩具")); shopcates.add(new ShopCateNode("C060106","模型玩具")); shopcates.add(new ShopCateNode("C060105","电子玩具")); shopcates.add(new ShopCateNode("C060104","电动玩具")); shopcates.add(new ShopCateNode("C060103","塑胶玩具")); shopcates.add(new ShopCateNode("C060102","木制玩具")); shopcates.add(new ShopCateNode("C060101","绒毛玩具")); shopcates.add(new ShopCateNode("C0601","大众玩具")); shopcates.add(new ShopCateNode("C050203","广告礼品")); shopcates.add(new ShopCateNode("C050202","纪念品")); shopcates.add(new ShopCateNode("C050201","时尚配饰")); shopcates.add(new ShopCateNode("C050109","仿古工艺")); shopcates.add(new ShopCateNode("C050108","竹木工艺")); shopcates.add(new ShopCateNode("C050107","植物编织")); shopcates.add(new ShopCateNode("C050106","民间工艺")); shopcates.add(new ShopCateNode("C050105","雕刻工艺")); shopcates.add(new ShopCateNode("C050104","陶瓷工艺")); shopcates.add(new ShopCateNode("C050103","金属工艺")); shopcates.add(new ShopCateNode("C050102","水晶工艺")); shopcates.add(new ShopCateNode("C050101","玻璃工艺")); shopcates.add(new ShopCateNode("C0502","礼品饰品")); shopcates.add(new ShopCateNode("C0501","工艺品")); shopcates.add(new ShopCateNode("C020103","保健食品")); shopcates.add(new ShopCateNode("C020102","旅游食品")); shopcates.add(new ShopCateNode("C020101","家庭零食")); shopcates.add(new ShopCateNode("C0201","大众食品")); shopcates.add(new ShopCateNode("C0401","大众保健")); shopcates.add(new ShopCateNode("C030103","酒类")); shopcates.add(new ShopCateNode("C030102","软饮")); shopcates.add(new ShopCateNode("C030101","茶品")); shopcates.add(new ShopCateNode("C0301","大众饮品")); shopcates.add(new ShopCateNode("C040106","保健器具")); shopcates.add(new ShopCateNode("C040105","延缓衰老")); shopcates.add(new ShopCateNode("C040104","医疗器械")); shopcates.add(new ShopCateNode("C040103","科学保健")); shopcates.add(new ShopCateNode("C040102","保健食品")); shopcates.add(new ShopCateNode("C040101","成人用品")); shopcates.add(new ShopCateNode("C010206","宠物用品")); shopcates.add(new ShopCateNode("C010205","餐厨用品")); shopcates.add(new ShopCateNode("C010204","居家装饰")); shopcates.add(new ShopCateNode("C010203","厨房电器")); shopcates.add(new ShopCateNode("C010202","小家电")); shopcates.add(new ShopCateNode("C010201","家庭影院")); shopcates.add(new ShopCateNode("C010106","洗浴清洁")); shopcates.add(new ShopCateNode("C010105","宠物用品")); shopcates.add(new ShopCateNode("C010104","餐厨用品")); shopcates.add(new ShopCateNode("C010103","婴幼用品")); shopcates.add(new ShopCateNode("C010102","床上用品")); shopcates.add(new ShopCateNode("C010101","居家装饰")); shopcates.add(new ShopCateNode("C0102","居家生活")); shopcates.add(new ShopCateNode("C0101","日用百货")); shopcates.add(new ShopCateNode("C070306","清洁器具")); shopcates.add(new ShopCateNode("C070305","电热器具")); shopcates.add(new ShopCateNode("C070304","厨房电器")); shopcates.add(new ShopCateNode("C070303","小家电")); shopcates.add(new ShopCateNode("C070302","家庭影院")); shopcates.add(new ShopCateNode("C070301","随身视听")); shopcates.add(new ShopCateNode("C070205","相机附件")); shopcates.add(new ShopCateNode("C070204","摄像机")); shopcates.add(new ShopCateNode("C070203","相机镜头")); shopcates.add(new ShopCateNode("C070202","数码相机")); shopcates.add(new ShopCateNode("C070201","光学相机")); shopcates.add(new ShopCateNode("C070106","硬盘")); shopcates.add(new ShopCateNode("C070105","台式机")); shopcates.add(new ShopCateNode("C070104","游戏")); shopcates.add(new ShopCateNode("C070103","网络")); shopcates.add(new ShopCateNode("C070102","存储")); shopcates.add(new ShopCateNode("C070101","鼠标")); shopcates.add(new ShopCateNode("C0703","家用电器")); shopcates.add(new ShopCateNode("C0702","摄影摄像")); shopcates.add(new ShopCateNode("C0701","电脑办公")); shopcates.add(new ShopCateNode("C08","游戏产品")); shopcates.add(new ShopCateNode("C07","电子产品")); shopcates.add(new ShopCateNode("C06","玩具")); shopcates.add(new ShopCateNode("C05","工艺品")); shopcates.add(new ShopCateNode("C04","保健品")); shopcates.add(new ShopCateNode("C03","饮品")); shopcates.add(new ShopCateNode("C02","食品")); shopcates.add(new ShopCateNode("C01","日用品"));