How to use list method in molecule

Best Python code snippet using molecule_python

product_search_controller.js

Source:product_search_controller.js Github

copy

Full Screen

1const express = require('express');2const categoryModel = require('../models/product_modle');3const router = express.Router();4const {paginate}=require('../config/default.json');5const menuCategory=require('../models/category-menu.model');6router.get('/keyword/',async function (req, res){7 return res.redirect(req.headers.referer);8})9router.get('/keyword/:txt',async function (req, res){10 const txtSearch=req.params.txt;11 const shopping_list=req.session.shopCart;12 const menuList=await menuCategory.getCateMenu();13 const submenuList=await menuCategory.getCateSubMenu();14 const allListMenu=[];15 const items=req.session.cart;16 const listHot=await categoryModel.all();17 const listNew=await categoryModel.getNewList();18 for (const i of menuList)19 {20 const menu_list=await categoryModel.allById(i.category_id);21 categoryModel.checkIsHaving(items,menu_list);22 if (req.session.authUser!=null)23 {24 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);25 await categoryModel.checkBill(menu_list,listBuy);26 }27 await categoryModel.checkHot(menu_list,listHot);28 await categoryModel.checkNew(menu_list,listNew);29 const item={30 menu: i.category_id,31 name: i.category_name,32 submenu: [],33 top4_course_menu: menu_list34 };35 allListMenu.push(item);36 }37 for (const j of submenuList)38 {39 for (i=0;i<allListMenu.length;i++)40 {41 if (allListMenu[i].menu===j.parent_id)42 {43 allListMenu[i].submenu.push(j);44 }45 }46 }47 //chÆ°a xong48 const page=req.query.page || 1;49 const previousPage=+page-1;50 const nextPage=+page+1;51 if (page<1){52 page=1;53 }54 const total=await categoryModel.countBySearch(txtSearch);55 let nPages=Math.floor(total/paginate.limit);56 if (total %paginate.limit>0)57 {58 nPages++;59 }60 const page_numbers=[];61 for (i=1;i<=nPages;i++)62 {63 page_numbers.push({64 value: i,65 isCurrentPage: i=== +page,66 });67 }68 const offset=(page-1)*paginate.limit;69 const list = await categoryModel.getCateBySearch(txtSearch,offset);70 if (req.session.authUser!=null){71 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);72 await categoryModel.checkBill(list,listBuy);73 await categoryModel.checkisHaving(req.session.cart,list);74 }75 //const listHot=await categoryModel.all();76 await categoryModel.checkHot(list,listHot);77 //const listNew=await categoryModel.getNewList();78 await categoryModel.checkNew(list,listNew);79 res.render('search_site', {80 product_popular: list,81 empty: list.length === 0,82 cateId: {83 Id: txtSearch,84 categoryById: false85 },86 page_numbers,87 previousPage,88 nextPage,89 checkNextPage: nextPage<=nPages,90 checkPreviousPage: previousPage>0,91 shopping_list,92 items,93 menuList: menuList,94 empty_menu: menuList.length!==0,95 allListMenu: allListMenu,96 layout: "search-item.hbs",97 });98})99router.post('/',async function (req, res,next){100 const link='/search/keyword/'+req.body.contentSearch;101 res.redirect(link);102})103router.get('/:id', async function (req, res) {104 const shopping_list=req.session.shopCart;105 const menuList=await menuCategory.getCateMenu();106 const submenuList=await menuCategory.getCateSubMenu();107 const allListMenu=[];108 const items=req.session.cart;109 const listHot=await categoryModel.all();110 const listNew=await categoryModel.getNewList();111 for (const i of menuList)112 {113 const menu_list=await categoryModel.allById(i.category_id);114 categoryModel.checkIsHaving(items,menu_list);115 if (req.session.authUser!=null)116 {117 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);118 await categoryModel.checkBill(menu_list,listBuy);119 }120 await categoryModel.checkHot(menu_list,listHot);121 await categoryModel.checkNew(menu_list,listNew);122 const item={123 menu: i.category_id,124 name: i.category_name,125 submenu: [],126 top4_course_menu: menu_list127 };128 allListMenu.push(item);129 }130 for (const j of submenuList)131 {132 for (i=0;i<allListMenu.length;i++)133 {134 if (allListMenu[i].menu===j.parent_id)135 {136 allListMenu[i].submenu.push(j);137 }138 }139 }140 const catId=req.params.id;141 const page=req.query.page || 1;142 const previousPage=+page-1;143 const nextPage=+page+1;144 if (page<1){145 page=1;146 }147 const total=await categoryModel.countByCat(catId);148 let nPages=Math.floor(total/paginate.limit);149 if (total %paginate.limit>0)150 {151 nPages++;152 }153 const page_numbers=[];154 for (i=1;i<=nPages;i++)155 {156 page_numbers.push({157 value: i,158 isCurrentPage: i=== +page,159 });160 }161 const offset=(page-1)*paginate.limit;162 const list = await categoryModel.getCateListByPage(catId,offset);163 if (req.session.authUser!=null){164 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);165 await categoryModel.checkBill(list,listBuy);166 await categoryModel.checkisHaving(req.session.cart,list);167 }168 //const listHot=await categoryModel.all();169 await categoryModel.checkHot(list,listHot);170 //const listNew=await categoryModel.getNewList();171 await categoryModel.checkNew(list,listNew);172 res.render('search_site', {173 product_popular: list,174 empty: list.length === 0,175 cateId: {176 Id:catId,177 categoryById: true178 },179 page_numbers,180 previousPage,181 nextPage,182 shopping_list,183 items,184 menuList: menuList,185 empty_menu: menuList.length!==0,186 allListMenu: allListMenu,187 checkNextPage: nextPage<=nPages,188 checkPreviousPage: previousPage>0,189 layout: "search-item.hbs",190 });191})192router.get('/sub/:id', async function (req, res) {193 const shopping_list=req.session.shopCart;194 const menuList=await menuCategory.getCateMenu();195 const submenuList=await menuCategory.getCateSubMenu();196 const allListMenu=[];197 const items=req.session.cart;198 const listHot=await categoryModel.all();199 const listNew=await categoryModel.getNewList();200 for (const i of menuList)201 {202 const menu_list=await categoryModel.allById(i.category_id);203 categoryModel.checkIsHaving(items,menu_list);204 if (req.session.authUser!=null)205 {206 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);207 await categoryModel.checkBill(menu_list,listBuy);208 }209 await categoryModel.checkHot(menu_list,listHot);210 await categoryModel.checkNew(menu_list,listNew);211 const item={212 menu: i.category_id,213 name: i.category_name,214 submenu: [],215 top4_course_menu: menu_list216 };217 allListMenu.push(item);218 }219 for (const j of submenuList)220 {221 for (i=0;i<allListMenu.length;i++)222 {223 if (allListMenu[i].menu===j.parent_id)224 {225 allListMenu[i].submenu.push(j);226 }227 }228 }229 const catId=req.params.id;230 const page=req.query.page || 1;231 const previousPage=+page-1;232 const nextPage=+page+1;233 if (page<1){234 page=1;235 }236 const total=await categoryModel.countByCatSub(catId);237 let nPages=Math.floor(total/paginate.limit);238 if (total %paginate.limit>0)239 {240 nPages++;241 }242 const page_numbers=[];243 for (i=1;i<=nPages;i++)244 {245 page_numbers.push({246 value: i,247 isCurrentPage: i=== +page,248 });249 }250 const offset=(page-1)*paginate.limit;251 const list = await categoryModel.getCateListBySub(catId,offset);252 if (req.session.authUser!=null){253 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);254 await categoryModel.checkBill(list,listBuy);255 await categoryModel.checkisHaving(req.session.cart,list);256 }257 //const listHot=await categoryModel.all();258 await categoryModel.checkHot(list,listHot);259 //const listNew=await categoryModel.getNewList();260 await categoryModel.checkNew(list,listNew);261 res.render('search_site', {262 product_popular: list,263 empty: list.length === 0,264 cateId: {265 Id:catId,266 categoryByIdSub: true267 },268 page_numbers,269 previousPage,270 nextPage,271 shopping_list,272 items,273 menuList: menuList,274 empty_menu: menuList.length!==0,275 allListMenu: allListMenu,276 checkNextPage: nextPage<=nPages,277 checkPreviousPage: previousPage>0,278 layout: "search-item.hbs",279 });280})281router.get('/:id/:condition', async function (req, res) {282 let cd="";283 const condition=req.params.condition;284 var active_5=true;285 var active_up_4= true;286 var active_up_3= true;287 var active_down_3= true;288 if (condition==="rating-5")289 {290 cd="=5";291 active_5=true;292 active_up_4= false;293 active_up_3= false;294 active_down_3= false;295 }296 if (condition==="rating-up-4")297 {298 cd=">=4";299 active_5=false;300 active_up_4= true;301 active_up_3= false;302 active_down_3= false;303 }304 if (condition==="rating-up-3")305 {306 cd=">=3";307 active_5=false;308 active_up_4= false;309 active_up_3= true;310 active_down_3= false;311 }312 if (condition==="rating-down-3")313 {314 cd="<3";315 active_5=false;316 active_up_4= false;317 active_up_3= false;318 active_down_3= true;319 }320 const at_5=active_5;321 const at_up_4=active_up_4;322 const at_up_3=active_up_3;323 const at_down_3=active_down_3;324 const shopping_list=req.session.shopCart;325 const menuList=await menuCategory.getCateMenu();326 const submenuList=await menuCategory.getCateSubMenu();327 const allListMenu=[];328 const items=req.session.cart;329 const listHot=await categoryModel.all();330 const listNew=await categoryModel.getNewList();331 for (const i of menuList)332 {333 const menu_list=await categoryModel.allById(i.category_id);334 categoryModel.checkIsHaving(items,menu_list);335 if (req.session.authUser!=null)336 {337 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);338 await categoryModel.checkBill(menu_list,listBuy);339 }340 await categoryModel.checkHot(menu_list,listHot);341 await categoryModel.checkNew(menu_list,listNew);342 const item={343 menu: i.category_id,344 name: i.category_name,345 submenu: [],346 top4_course_menu: menu_list347 };348 allListMenu.push(item);349 }350 for (const j of submenuList)351 {352 for (i=0;i<allListMenu.length;i++)353 {354 if (allListMenu[i].menu===j.parent_id)355 {356 allListMenu[i].submenu.push(j);357 }358 }359 }360 const catId=req.params.id;361 const page=req.query.page || 1;362 const previousPage=+page-1;363 const nextPage=+page+1;364 if (page<1){365 page=1;366 }367 const total=await categoryModel.countByCatCondition(catId,cd);368 let nPages=Math.floor(total/paginate.limit);369 if (total %paginate.limit>0)370 {371 nPages++;372 }373 const page_numbers=[];374 for (i=1;i<=nPages;i++)375 {376 page_numbers.push({377 value: i,378 isCurrentPage: i=== +page,379 });380 }381 const offset=(page-1)*paginate.limit;382 383 const list = await categoryModel.getStarCourseCondition(catId,offset,cd);384 if (req.session.authUser!=null){385 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);386 await categoryModel.checkBill(list,listBuy);387 await categoryModel.checkisHaving(req.session.cart,list);388 }389 //const listHot=await categoryModel.all();390 await categoryModel.checkHot(list,listHot);391 //const listNew=await categoryModel.getNewList();392 await categoryModel.checkNew(list,listNew);393 res.render('search_site', {394 product_popular: list,395 empty: list.length === 0,396 cateId: {397 Id:catId,398 categoryById: true,399 active_5:at_5,400 active_up_4:at_up_4,401 active_up_3:at_up_3,402 active_down_3:at_down_3403 },404 page_numbers,405 previousPage,406 nextPage,407 shopping_list,408 items,409 menuList: menuList,410 empty_menu: menuList.length!==0,411 allListMenu: allListMenu,412 checkNextPage: nextPage<=nPages,413 checkPreviousPage: previousPage>0,414 layout: "search-item.hbs",415 });416})417router.get('/sub/:id/:condition', async function (req, res) {418 let cd="";419 const condition=req.params.condition;420 var active_5=true;421 var active_up_4= true;422 var active_up_3= true;423 var active_down_3= true;424 if (condition==="rating-5")425 {426 cd="=5";427 active_5=true;428 active_up_4= false;429 active_up_3= false;430 active_down_3= false;431 }432 if (condition==="rating-up-4")433 {434 cd=">=4";435 active_5=false;436 active_up_4= true;437 active_up_3= false;438 active_down_3= false;439 }440 if (condition==="rating-up-3")441 {442 cd=">=3";443 active_5=false;444 active_up_4= false;445 active_up_3= true;446 active_down_3= false;447 }448 if (condition==="rating-down-3")449 {450 cd="<3";451 active_5=false;452 active_up_4= false;453 active_up_3= false;454 active_down_3= true;455 }456 const at_5=active_5;457 const at_up_4=active_up_4;458 const at_up_3=active_up_3;459 const at_down_3=active_down_3;460 const shopping_list=req.session.shopCart;461 const menuList=await menuCategory.getCateMenu();462 const submenuList=await menuCategory.getCateSubMenu();463 const allListMenu=[];464 const items=req.session.cart;465 const listHot=await categoryModel.all();466 const listNew=await categoryModel.getNewList();467 for (const i of menuList)468 {469 const menu_list=await categoryModel.allById(i.category_id);470 categoryModel.checkIsHaving(items,menu_list);471 if (req.session.authUser!=null)472 {473 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);474 await categoryModel.checkBill(menu_list,listBuy);475 }476 await categoryModel.checkHot(menu_list,listHot);477 await categoryModel.checkNew(menu_list,listNew);478 const item={479 menu: i.category_id,480 name: i.category_name,481 submenu: [],482 top4_course_menu: menu_list483 };484 allListMenu.push(item);485 }486 for (const j of submenuList)487 {488 for (i=0;i<allListMenu.length;i++)489 {490 if (allListMenu[i].menu===j.parent_id)491 {492 allListMenu[i].submenu.push(j);493 }494 }495 }496 const catId=req.params.id;497 const page=req.query.page || 1;498 const previousPage=+page-1;499 const nextPage=+page+1;500 if (page<1){501 page=1;502 }503 const total=await categoryModel.countByCatConditionSub(catId,cd);504 let nPages=Math.floor(total/paginate.limit);505 if (total %paginate.limit>0)506 {507 nPages++;508 }509 const page_numbers=[];510 for (i=1;i<=nPages;i++)511 {512 page_numbers.push({513 value: i,514 isCurrentPage: i=== +page,515 });516 }517 const offset=(page-1)*paginate.limit;518 519 const list = await categoryModel.getStarCourseConditionSub(catId,offset,cd);520 if (req.session.authUser!=null){521 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);522 await categoryModel.checkBill(list,listBuy);523 await categoryModel.checkisHaving(req.session.cart,list);524 }525 //const listHot=await categoryModel.all();526 await categoryModel.checkHot(list,listHot);527 //const listNew=await categoryModel.getNewList();528 await categoryModel.checkNew(list,listNew);529 res.render('search_site', {530 product_popular: list,531 empty: list.length === 0,532 cateId: {533 Id:catId,534 categoryByIdSub: true,535 active_5:at_5,536 active_up_4:at_up_4,537 active_up_3:at_up_3,538 active_down_3:at_down_3539 },540 page_numbers,541 previousPage,542 nextPage,543 shopping_list,544 items,545 menuList: menuList,546 empty_menu: menuList.length!==0,547 allListMenu: allListMenu,548 checkNextPage: nextPage<=nPages,549 checkPreviousPage: previousPage>0,550 layout: "search-item.hbs",551 });552})553router.get('/keyword/:id/:condition', async function (req, res) {554 let cd="";555 const condition=req.params.condition;556 var active_5=true;557 var active_up_4= true;558 var active_up_3= true;559 var active_down_3= true;560 if (condition==="rating-5")561 {562 cd="=5";563 active_5=true;564 active_up_4= false;565 active_up_3= false;566 active_down_3= false;567 }568 if (condition==="rating-up-4")569 {570 cd=">=4";571 active_5=false;572 active_up_4= true;573 active_up_3= false;574 active_down_3= false;575 }576 if (condition==="rating-up-3")577 {578 cd=">=3";579 active_5=false;580 active_up_4= false;581 active_up_3= true;582 active_down_3= false;583 }584 if (condition==="rating-down-3")585 {586 cd="<3";587 active_5=false;588 active_up_4= false;589 active_up_3= false;590 active_down_3= true;591 }592 const at_5=active_5;593 const at_up_4=active_up_4;594 const at_up_3=active_up_3;595 const at_down_3=active_down_3;596 const shopping_list=req.session.shopCart;597 const menuList=await menuCategory.getCateMenu();598 const submenuList=await menuCategory.getCateSubMenu();599 const allListMenu=[];600 const items=req.session.cart;601 const listHot=await categoryModel.all();602 const listNew=await categoryModel.getNewList();603 for (const i of menuList)604 {605 const menu_list=await categoryModel.allById(i.category_id);606 categoryModel.checkIsHaving(items,menu_list);607 if (req.session.authUser!=null)608 {609 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);610 await categoryModel.checkBill(menu_list,listBuy);611 }612 await categoryModel.checkHot(menu_list,listHot);613 await categoryModel.checkNew(menu_list,listNew);614 const item={615 menu: i.category_id,616 name: i.category_name,617 submenu: [],618 top4_course_menu: menu_list619 };620 allListMenu.push(item);621 }622 for (const j of submenuList)623 {624 for (i=0;i<allListMenu.length;i++)625 {626 if (allListMenu[i].menu===j.parent_id)627 {628 allListMenu[i].submenu.push(j);629 }630 }631 }632 const catId=req.params.id;633 const page=req.query.page || 1;634 const previousPage=+page-1;635 const nextPage=+page+1;636 if (page<1){637 page=1;638 }639 const total=await categoryModel.countByCatSearchCondition(catId,cd);640 let nPages=Math.floor(total/paginate.limit);641 if (total %paginate.limit>0)642 {643 nPages++;644 }645 const page_numbers=[];646 for (i=1;i<=nPages;i++)647 {648 page_numbers.push({649 value: i,650 isCurrentPage: i=== +page,651 });652 }653 const offset=(page-1)*paginate.limit;654 655 const list = await categoryModel.getStarCourseSearchCondition(catId,offset,cd);656 if (req.session.authUser!=null){657 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);658 await categoryModel.checkBill(list,listBuy);659 await categoryModel.checkisHaving(req.session.cart,list);660 }661 //const listHot=await categoryModel.all();662 await categoryModel.checkHot(list,listHot);663 //const listNew=await categoryModel.getNewList();664 await categoryModel.checkNew(list,listNew);665 res.render('search_site', {666 product_popular: list,667 empty: list.length === 0,668 cateId: {669 Id:catId,670 categoryById: false,671 active_5:at_5,672 active_up_4:at_up_4,673 active_up_3:at_up_3,674 active_down_3:at_down_3675 },676 page_numbers,677 previousPage,678 nextPage,679 shopping_list,680 items,681 menuList: menuList,682 empty_menu: menuList.length!==0,683 allListMenu: allListMenu,684 checkNextPage: nextPage<=nPages,685 checkPreviousPage: previousPage>0,686 layout: "search-item.hbs",687 });688})689router.get('/:id/mode/:condition', async function (req, res) {690 const condition=req.params.condition;691 let cd=""692 let mode="";693 let ms=false;694 let mo=false;695 let pd=false;696 let pa=false;697 let n=false698 if (condition==="most-study")699 {700 cd="number_student";701 mode="DESC"702 ms=true;703 mo=false;704 pd=false;705 pa=false;706 n=false707 }708 if (condition==="most-overall")709 {710 cd="overall_star";711 mode="DESC"712 ms=false;713 mo=true;714 pd=false;715 pa=false;716 n=false717 }718 if (condition==="price-descend")719 {720 cd="reduce_price";721 mode="DESC"722 ms=false;723 mo=false;724 pd=true;725 pa=false;726 n=false727 }728 if (condition==="price-ascend")729 {730 cd="reduce_price";731 mode="ASC"732 ms=false;733 mo=false;734 pd=false;735 pa=true;736 n=false737 }738 if (condition==="newest")739 {740 cd="create_date";741 mode="DESC"742 ms=false;743 mo=false;744 pd=false;745 pa=false;746 n=true;747 }748 const mosts=ms;749 const mosto=mo;750 const priced=pd;751 const pricea=pa;752 const ne=n;753 const shopping_list=req.session.shopCart;754 const menuList=await menuCategory.getCateMenu();755 const submenuList=await menuCategory.getCateSubMenu();756 const allListMenu=[];757 const items=req.session.cart;758 const listHot=await categoryModel.all();759 const listNew=await categoryModel.getNewList();760 for (const i of menuList)761 {762 const menu_list=await categoryModel.allById(i.category_id);763 categoryModel.checkIsHaving(items,menu_list);764 if (req.session.authUser!=null)765 {766 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);767 await categoryModel.checkBill(menu_list,listBuy);768 }769 await categoryModel.checkHot(menu_list,listHot);770 await categoryModel.checkNew(menu_list,listNew);771 const item={772 menu: i.category_id,773 name: i.category_name,774 submenu: [],775 top4_course_menu: menu_list776 };777 allListMenu.push(item);778 }779 for (const j of submenuList)780 {781 for (i=0;i<allListMenu.length;i++)782 {783 if (allListMenu[i].menu===j.parent_id)784 {785 allListMenu[i].submenu.push(j);786 }787 }788 }789 const catId=req.params.id;790 const page=req.query.page || 1;791 const previousPage=+page-1;792 const nextPage=+page+1;793 if (page<1){794 page=1;795 }796 const total=await categoryModel.countByCat(catId);797 let nPages=Math.floor(total/paginate.limit);798 if (total %paginate.limit>0)799 {800 nPages++;801 }802 const page_numbers=[];803 for (i=1;i<=nPages;i++)804 {805 page_numbers.push({806 value: i,807 isCurrentPage: i=== +page,808 });809 }810 const offset=(page-1)*paginate.limit;811 const list = await categoryModel.mostByCatIDCondition(catId, offset,cd,mode);812 if (req.session.authUser!=null){813 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);814 await categoryModel.checkBill(list,listBuy);815 await categoryModel.checkisHaving(req.session.cart,list);816 }817 //const listHot=await categoryModel.all();818 await categoryModel.checkHot(list,listHot);819 //const listNew=await categoryModel.getNewList();820 await categoryModel.checkNew(list,listNew);821 res.render('search_site', {822 product_popular: list,823 empty: list.length === 0,824 cateId: {825 Id:catId,826 categoryById: true,827 active_m_st: mosts,828 active_m_ov: mosto,829 active_new: ne,830 active_m_dp: priced,831 active_m_ap: pricea,832 },833 page_numbers,834 previousPage,835 nextPage,836 shopping_list,837 items,838 menuList: menuList,839 empty_menu: menuList.length!==0,840 allListMenu: allListMenu,841 checkNextPage: nextPage<=nPages,842 checkPreviousPage: previousPage>0,843 layout: "search-item.hbs",844 });845})846router.get('/sub/:id/mode/:condition', async function (req, res) {847 const condition=req.params.condition;848 let cd=""849 let mode="";850 let ms=false;851 let mo=false;852 let pd=false;853 let pa=false;854 let n=false855 if (condition==="most-study")856 {857 cd="number_student";858 mode="DESC"859 ms=true;860 mo=false;861 pd=false;862 pa=false;863 n=false864 }865 if (condition==="most-overall")866 {867 cd="overall_star";868 mode="DESC"869 ms=false;870 mo=true;871 pd=false;872 pa=false;873 n=false874 }875 if (condition==="price-descend")876 {877 cd="reduce_price";878 mode="DESC"879 ms=false;880 mo=false;881 pd=true;882 pa=false;883 n=false884 }885 if (condition==="price-ascend")886 {887 cd="reduce_price";888 mode="ASC"889 ms=false;890 mo=false;891 pd=false;892 pa=true;893 n=false894 }895 if (condition==="newest")896 {897 cd="create_date";898 mode="DESC"899 ms=false;900 mo=false;901 pd=false;902 pa=false;903 n=true;904 }905 const mosts=ms;906 const mosto=mo;907 const priced=pd;908 const pricea=pa;909 const ne=n;910 const shopping_list=req.session.shopCart;911 const menuList=await menuCategory.getCateMenu();912 const submenuList=await menuCategory.getCateSubMenu();913 const allListMenu=[];914 const items=req.session.cart;915 const listHot=await categoryModel.all();916 const listNew=await categoryModel.getNewList();917 for (const i of menuList)918 {919 const menu_list=await categoryModel.allById(i.category_id);920 categoryModel.checkIsHaving(items,menu_list);921 if (req.session.authUser!=null)922 {923 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);924 await categoryModel.checkBill(menu_list,listBuy);925 }926 await categoryModel.checkHot(menu_list,listHot);927 await categoryModel.checkNew(menu_list,listNew);928 const item={929 menu: i.category_id,930 name: i.category_name,931 submenu: [],932 top4_course_menu: menu_list933 };934 allListMenu.push(item);935 }936 for (const j of submenuList)937 {938 for (i=0;i<allListMenu.length;i++)939 {940 if (allListMenu[i].menu===j.parent_id)941 {942 allListMenu[i].submenu.push(j);943 }944 }945 }946 const catId=req.params.id;947 const page=req.query.page || 1;948 const previousPage=+page-1;949 const nextPage=+page+1;950 if (page<1){951 page=1;952 }953 const total=await categoryModel.countByCatSub(catId);954 let nPages=Math.floor(total/paginate.limit);955 if (total %paginate.limit>0)956 {957 nPages++;958 }959 const page_numbers=[];960 for (i=1;i<=nPages;i++)961 {962 page_numbers.push({963 value: i,964 isCurrentPage: i=== +page,965 });966 }967 const offset=(page-1)*paginate.limit;968 const list = await categoryModel.mostByCatIDConditionSub(catId, offset,cd,mode);969 if (req.session.authUser!=null){970 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);971 await categoryModel.checkBill(list,listBuy);972 await categoryModel.checkisHaving(req.session.cart,list);973 }974 //const listHot=await categoryModel.all();975 await categoryModel.checkHot(list,listHot);976 //const listNew=await categoryModel.getNewList();977 await categoryModel.checkNew(list,listNew);978 res.render('search_site', {979 product_popular: list,980 empty: list.length === 0,981 cateId: {982 Id:catId,983 categoryByIdSub: true,984 active_m_st: mosts,985 active_m_ov: mosto,986 active_new: ne,987 active_m_dp: priced,988 active_m_ap: pricea,989 },990 page_numbers,991 previousPage,992 nextPage,993 shopping_list,994 items,995 menuList: menuList,996 empty_menu: menuList.length!==0,997 allListMenu: allListMenu,998 checkNextPage: nextPage<=nPages,999 checkPreviousPage: previousPage>0,1000 layout: "search-item.hbs",1001 });1002})1003router.get('/keyword/:id/mode/:condition', async function (req, res) {1004 const condition=req.params.condition;1005 let cd=""1006 let mode="";1007 let ms=false;1008 let mo=false;1009 let pd=false;1010 let pa=false;1011 let n=false1012 if (condition==="most-study")1013 {1014 cd="number_student";1015 mode="DESC"1016 ms=true;1017 mo=false;1018 pd=false;1019 pa=false;1020 n=false1021 }1022 if (condition==="most-overall")1023 {1024 cd="overall_star";1025 mode="DESC"1026 ms=false;1027 mo=true;1028 pd=false;1029 pa=false;1030 n=false1031 }1032 if (condition==="price-descend")1033 {1034 cd="reduce_price";1035 mode="DESC"1036 ms=false;1037 mo=false;1038 pd=true;1039 pa=false;1040 n=false1041 }1042 if (condition==="price-ascend")1043 {1044 cd="reduce_price";1045 mode="ASC"1046 ms=false;1047 mo=false;1048 pd=false;1049 pa=true;1050 n=false1051 }1052 if (condition==="newest")1053 {1054 cd="create_date";1055 mode="DESC"1056 ms=false;1057 mo=false;1058 pd=false;1059 pa=false;1060 n=true;1061 }1062 const mosts=ms;1063 const mosto=mo;1064 const priced=pd;1065 const pricea=pa;1066 const ne=n;1067 const shopping_list=req.session.shopCart;1068 const menuList=await menuCategory.getCateMenu();1069 const submenuList=await menuCategory.getCateSubMenu();1070 const allListMenu=[];1071 const items=req.session.cart;1072 const listHot=await categoryModel.all();1073 const listNew=await categoryModel.getNewList();1074 for (const i of menuList)1075 {1076 const menu_list=await categoryModel.allById(i.category_id);1077 categoryModel.checkIsHaving(items,menu_list);1078 if (req.session.authUser!=null)1079 {1080 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);1081 await categoryModel.checkBill(menu_list,listBuy);1082 }1083 await categoryModel.checkHot(menu_list,listHot);1084 await categoryModel.checkNew(menu_list,listNew);1085 const item={1086 menu: i.category_id,1087 name: i.category_name,1088 submenu: [],1089 top4_course_menu: menu_list1090 };1091 allListMenu.push(item);1092 }1093 for (const j of submenuList)1094 {1095 for (i=0;i<allListMenu.length;i++)1096 {1097 if (allListMenu[i].menu===j.parent_id)1098 {1099 allListMenu[i].submenu.push(j);1100 }1101 }1102 }1103 const catId=req.params.id;1104 const page=req.query.page || 1;1105 const previousPage=+page-1;1106 const nextPage=+page+1;1107 if (page<1){1108 page=1;1109 }1110 const total=await categoryModel.countBySearch(catId);1111 let nPages=Math.floor(total/paginate.limit);1112 if (total %paginate.limit>0)1113 {1114 nPages++;1115 }1116 const page_numbers=[];1117 for (i=1;i<=nPages;i++)1118 {1119 page_numbers.push({1120 value: i,1121 isCurrentPage: i=== +page,1122 });1123 }1124 const offset=(page-1)*paginate.limit;1125 const list = await categoryModel.mostMenuChooseSearch(catId, offset,cd,mode);1126 if (req.session.authUser!=null){1127 const listBuy=await categoryModel.getBuyList(req.session.authUser.user_id);1128 await categoryModel.checkBill(list,listBuy);1129 await categoryModel.checkisHaving(req.session.cart,list);1130 }1131 //const listHot=await categoryModel.all();1132 await categoryModel.checkHot(list,listHot);1133 //const listNew=await categoryModel.getNewList();1134 await categoryModel.checkNew(list,listNew);1135 res.render('search_site', {1136 product_popular: list,1137 empty: list.length === 0,1138 cateId: {1139 Id:catId,1140 categoryById: false,1141 active_m_st: mosts,1142 active_m_ov: mosto,1143 active_new: ne,1144 active_m_dp: priced,1145 active_m_ap: pricea,1146 },1147 page_numbers,1148 previousPage,1149 nextPage,1150 shopping_list,1151 items,1152 menuList: menuList,1153 empty_menu: menuList.length!==0,1154 allListMenu: allListMenu,1155 checkNextPage: nextPage<=nPages,1156 checkPreviousPage: previousPage>0,1157 layout: "search-item.hbs",1158 });1159})...

Full Screen

Full Screen

app.routing.js

Source:app.routing.js Github

copy

Full Screen

1System.register(["@angular/router", "./Home/home.component", "./Color/color/color-edit.component", "./Color/color-list/color-list.component", "./Color/color/color-add.component", "./FabricsCategory/fabricscategory-list/fabricscategory-list.component", "./FabricsProductName/fabricsproductname-list/fabricsproductname-list.component", "./FabricsFibreContent/fabricsfibrecontent-list/fabricsfibrecontent-list.component", "./FabricsFinishing/fabricsfinishing-list/fabricsfinishing-list.component", "./FabricWeight/fabricweight-list/fabricweight-list.component", "./FabricsYarnCount/fabricsyarncount-list/fabricsyarncount-list.component", "./FabricProductType/fabricproducttype-list/fabricproducttype-list.component", "./GraphicType/graphictype-list/graphictype-list.component", "./GraphicCategory/graphiccategory-list/graphiccategory-list.component", "./GraphicProductName/graphicproductname-list/graphicproductname-list.component", "./POM/pom-list/pom-list.component", "./Shipping/shipping-list/shipping-list.component", "./Shipping/shipping/shipping-add.component", "./Shipping/shipping/shipping-edit.component", "./Graphic/graphic-list/graphic-list.component", "./Graphic/graphic/graphic-add.component", "./Graphic/graphic/graphic-edit.component", "./FabricsType/fabricstype-list/fabricstype-list.component", "./Division/division-list/division-list.component", "./Brand/brand-list/brand-list.component", "./AccessoryType/accessorytype-list/accessorytype-list.component", "./ReasonForAbortingProject/reasonforabortingproject-list/reasonforabortingproject-list.component", "./Season/season-list/season-list.component", "./Training/training-list/training-list.component", "./TrainingItem/trainingitem-list/trainingitem-list.component", "./ShippingType/shippingtype-list/shippingtype-list.component", "./SizeRange/sizerange-list/sizerange-list.component", "./SizeRange/sizerange/sizerange-add.component", "./SizeRange/sizerange/sizerange-edit.component", "./WashCategory/washcategory-list/washcategory-list.component", "./WashProductName/washproductname-list/washproductname-list.component", "./WashType/washtype-list/washtype-list.component", "./Year/year-list/year-list.component", "./Wash/wash-list/wash-list.component", "./Wash/wash/wash-add.component", "./Wash/wash/wash-edit.component", "./Application/application-list/application-list.component", "./Application/application/application-add.component", "./Application/application/application-edit.component", "./AccessoryCategory/accessorycategory-list/accessorycategory-list.component", "./AccessoryProductName/accessoryproductname-list/accessoryproductname-list.component", "./Department/department-list/department-list.component", "./EndBuyer/endbuyer-list/endbuyer-list.component", "./Accessories/accessories-list/accessories-list.component", "./Accessories/accessories/accessories-add.component", "./Accessories/accessories/accessories-edit.component", "./Fabrics/fabrics-list/fabrics-list.component", "./Fabrics/fabrics/fabrics-add.component", "./Fabrics/fabrics/fabrics-edit.component", "./Login/login.component", "./User/User/User-Add.component", "./User/User/User-Edit.component", "./User/User-List/User-List.component", "./Spec/spec-list/spec-list.component", "./Spec/spec/spec-add.component", "./UserRole/UserRole/UserRole-Add.component", "./UserRole/UserRole/UserRole-Edit.component", "./UserRole/UserRole-List/UserRole-List.component", "./VendorType/VendorType/VendorType-Add.component", "./VendorType/VendorType/VendorType-Edit.component", "./VendorType/VendorType-List/VendorType-List.component", "./VendorProductType/VendorProductType/VendorProductType-Add.component", "./VendorProductType/VendorProductType/VendorProductType-Edit.component", "./VendorProductType/VendorProductType-List/VendorProductType-List.component", "./Vendor/Vendor/Vendor-Add.component", "./Vendor/Vendor-List/Vendor-List.component", "./PageNotFound/page-not-found.component"], function (exports_1, context_1) {2 "use strict";3 var __moduleName = context_1 && context_1.id;4 var router_1, home_component_1, color_edit_component_1, color_list_component_1, color_add_component_1, fabricscategory_list_component_1, fabricsproductname_list_component_1, fabricsfibrecontent_list_component_1, fabricsfinishing_list_component_1, fabricweight_list_component_1, fabricsyarncount_list_component_1, fabricproducttype_list_component_1, graphictype_list_component_1, graphiccategory_list_component_1, graphicproductname_list_component_1, pom_list_component_1, shipping_list_component_1, shipping_add_component_1, shipping_edit_component_1, graphic_list_component_1, graphic_add_component_1, graphic_edit_component_1, fabricstype_list_component_1, division_list_component_1, brand_list_component_1, accessorytype_list_component_1, reasonforabortingproject_list_component_1, season_list_component_1, training_list_component_1, trainingitem_list_component_1, shippingtype_list_component_1, sizerange_list_component_1, sizerange_add_component_1, sizerange_edit_component_1, washcategory_list_component_1, washproductname_list_component_1, washtype_list_component_1, year_list_component_1, wash_list_component_1, wash_add_component_1, wash_edit_component_1, application_list_component_1, application_add_component_1, application_edit_component_1, accessorycategory_list_component_1, accessoryproductname_list_component_1, department_list_component_1, endbuyer_list_component_1, accessories_list_component_1, accessories_add_component_1, accessories_edit_component_1, fabrics_list_component_1, fabrics_add_component_1, fabrics_edit_component_1, login_component_1, User_Add_component_1, User_Edit_component_1, User_List_component_1, spec_list_component_1, spec_add_component_1, UserRole_Add_component_1, UserRole_Edit_component_1, UserRole_List_component_1, VendorType_Add_component_1, VendorType_Edit_component_1, VendorType_List_component_1, VendorProductType_Add_component_1, VendorProductType_Edit_component_1, VendorProductType_List_component_1, Vendor_Add_component_1, Vendor_List_component_1, page_not_found_component_1, appRoutes, AppRoutingProviders, AppRouting;5 return {6 setters: [7 function (router_1_1) {8 router_1 = router_1_1;9 },10 function (home_component_1_1) {11 home_component_1 = home_component_1_1;12 },13 function (color_edit_component_1_1) {14 color_edit_component_1 = color_edit_component_1_1;15 },16 function (color_list_component_1_1) {17 color_list_component_1 = color_list_component_1_1;18 },19 function (color_add_component_1_1) {20 color_add_component_1 = color_add_component_1_1;21 },22 function (fabricscategory_list_component_1_1) {23 fabricscategory_list_component_1 = fabricscategory_list_component_1_1;24 },25 function (fabricsproductname_list_component_1_1) {26 fabricsproductname_list_component_1 = fabricsproductname_list_component_1_1;27 },28 function (fabricsfibrecontent_list_component_1_1) {29 fabricsfibrecontent_list_component_1 = fabricsfibrecontent_list_component_1_1;30 },31 function (fabricsfinishing_list_component_1_1) {32 fabricsfinishing_list_component_1 = fabricsfinishing_list_component_1_1;33 },34 function (fabricweight_list_component_1_1) {35 fabricweight_list_component_1 = fabricweight_list_component_1_1;36 },37 function (fabricsyarncount_list_component_1_1) {38 fabricsyarncount_list_component_1 = fabricsyarncount_list_component_1_1;39 },40 function (fabricproducttype_list_component_1_1) {41 fabricproducttype_list_component_1 = fabricproducttype_list_component_1_1;42 },43 function (graphictype_list_component_1_1) {44 graphictype_list_component_1 = graphictype_list_component_1_1;45 },46 function (graphiccategory_list_component_1_1) {47 graphiccategory_list_component_1 = graphiccategory_list_component_1_1;48 },49 function (graphicproductname_list_component_1_1) {50 graphicproductname_list_component_1 = graphicproductname_list_component_1_1;51 },52 function (pom_list_component_1_1) {53 pom_list_component_1 = pom_list_component_1_1;54 },55 function (shipping_list_component_1_1) {56 shipping_list_component_1 = shipping_list_component_1_1;57 },58 function (shipping_add_component_1_1) {59 shipping_add_component_1 = shipping_add_component_1_1;60 },61 function (shipping_edit_component_1_1) {62 shipping_edit_component_1 = shipping_edit_component_1_1;63 },64 function (graphic_list_component_1_1) {65 graphic_list_component_1 = graphic_list_component_1_1;66 },67 function (graphic_add_component_1_1) {68 graphic_add_component_1 = graphic_add_component_1_1;69 },70 function (graphic_edit_component_1_1) {71 graphic_edit_component_1 = graphic_edit_component_1_1;72 },73 function (fabricstype_list_component_1_1) {74 fabricstype_list_component_1 = fabricstype_list_component_1_1;75 },76 function (division_list_component_1_1) {77 division_list_component_1 = division_list_component_1_1;78 },79 function (brand_list_component_1_1) {80 brand_list_component_1 = brand_list_component_1_1;81 },82 function (accessorytype_list_component_1_1) {83 accessorytype_list_component_1 = accessorytype_list_component_1_1;84 },85 function (reasonforabortingproject_list_component_1_1) {86 reasonforabortingproject_list_component_1 = reasonforabortingproject_list_component_1_1;87 },88 function (season_list_component_1_1) {89 season_list_component_1 = season_list_component_1_1;90 },91 function (training_list_component_1_1) {92 training_list_component_1 = training_list_component_1_1;93 },94 function (trainingitem_list_component_1_1) {95 trainingitem_list_component_1 = trainingitem_list_component_1_1;96 },97 function (shippingtype_list_component_1_1) {98 shippingtype_list_component_1 = shippingtype_list_component_1_1;99 },100 function (sizerange_list_component_1_1) {101 sizerange_list_component_1 = sizerange_list_component_1_1;102 },103 function (sizerange_add_component_1_1) {104 sizerange_add_component_1 = sizerange_add_component_1_1;105 },106 function (sizerange_edit_component_1_1) {107 sizerange_edit_component_1 = sizerange_edit_component_1_1;108 },109 function (washcategory_list_component_1_1) {110 washcategory_list_component_1 = washcategory_list_component_1_1;111 },112 function (washproductname_list_component_1_1) {113 washproductname_list_component_1 = washproductname_list_component_1_1;114 },115 function (washtype_list_component_1_1) {116 washtype_list_component_1 = washtype_list_component_1_1;117 },118 function (year_list_component_1_1) {119 year_list_component_1 = year_list_component_1_1;120 },121 function (wash_list_component_1_1) {122 wash_list_component_1 = wash_list_component_1_1;123 },124 function (wash_add_component_1_1) {125 wash_add_component_1 = wash_add_component_1_1;126 },127 function (wash_edit_component_1_1) {128 wash_edit_component_1 = wash_edit_component_1_1;129 },130 function (application_list_component_1_1) {131 application_list_component_1 = application_list_component_1_1;132 },133 function (application_add_component_1_1) {134 application_add_component_1 = application_add_component_1_1;135 },136 function (application_edit_component_1_1) {137 application_edit_component_1 = application_edit_component_1_1;138 },139 function (accessorycategory_list_component_1_1) {140 accessorycategory_list_component_1 = accessorycategory_list_component_1_1;141 },142 function (accessoryproductname_list_component_1_1) {143 accessoryproductname_list_component_1 = accessoryproductname_list_component_1_1;144 },145 function (department_list_component_1_1) {146 department_list_component_1 = department_list_component_1_1;147 },148 function (endbuyer_list_component_1_1) {149 endbuyer_list_component_1 = endbuyer_list_component_1_1;150 },151 function (accessories_list_component_1_1) {152 accessories_list_component_1 = accessories_list_component_1_1;153 },154 function (accessories_add_component_1_1) {155 accessories_add_component_1 = accessories_add_component_1_1;156 },157 function (accessories_edit_component_1_1) {158 accessories_edit_component_1 = accessories_edit_component_1_1;159 },160 function (fabrics_list_component_1_1) {161 fabrics_list_component_1 = fabrics_list_component_1_1;162 },163 function (fabrics_add_component_1_1) {164 fabrics_add_component_1 = fabrics_add_component_1_1;165 },166 function (fabrics_edit_component_1_1) {167 fabrics_edit_component_1 = fabrics_edit_component_1_1;168 },169 function (login_component_1_1) {170 login_component_1 = login_component_1_1;171 },172 function (User_Add_component_1_1) {173 User_Add_component_1 = User_Add_component_1_1;174 },175 function (User_Edit_component_1_1) {176 User_Edit_component_1 = User_Edit_component_1_1;177 },178 function (User_List_component_1_1) {179 User_List_component_1 = User_List_component_1_1;180 },181 function (spec_list_component_1_1) {182 spec_list_component_1 = spec_list_component_1_1;183 },184 function (spec_add_component_1_1) {185 spec_add_component_1 = spec_add_component_1_1;186 },187 function (UserRole_Add_component_1_1) {188 UserRole_Add_component_1 = UserRole_Add_component_1_1;189 },190 function (UserRole_Edit_component_1_1) {191 UserRole_Edit_component_1 = UserRole_Edit_component_1_1;192 },193 function (UserRole_List_component_1_1) {194 UserRole_List_component_1 = UserRole_List_component_1_1;195 },196 function (VendorType_Add_component_1_1) {197 VendorType_Add_component_1 = VendorType_Add_component_1_1;198 },199 function (VendorType_Edit_component_1_1) {200 VendorType_Edit_component_1 = VendorType_Edit_component_1_1;201 },202 function (VendorType_List_component_1_1) {203 VendorType_List_component_1 = VendorType_List_component_1_1;204 },205 function (VendorProductType_Add_component_1_1) {206 VendorProductType_Add_component_1 = VendorProductType_Add_component_1_1;207 },208 function (VendorProductType_Edit_component_1_1) {209 VendorProductType_Edit_component_1 = VendorProductType_Edit_component_1_1;210 },211 function (VendorProductType_List_component_1_1) {212 VendorProductType_List_component_1 = VendorProductType_List_component_1_1;213 },214 function (Vendor_Add_component_1_1) {215 Vendor_Add_component_1 = Vendor_Add_component_1_1;216 },217 function (Vendor_List_component_1_1) {218 Vendor_List_component_1 = Vendor_List_component_1_1;219 },220 function (page_not_found_component_1_1) {221 page_not_found_component_1 = page_not_found_component_1_1;222 }223 ],224 execute: function () {225 appRoutes = [226 { path: '', component: home_component_1.HomeComponent },227 { path: "home", redirectTo: "" },228 { path: "color", component: color_list_component_1.ColorListComponent },229 { path: "color/add", component: color_add_component_1.ColorAddComponent },230 { path: "color/edit/:id", component: color_edit_component_1.ColorEditComponent },231 { path: "fabricscategory", component: fabricscategory_list_component_1.FabricsCategoryListComponent },232 { path: "fabricsproductname", component: fabricsproductname_list_component_1.FabricsProductNameListComponent },233 { path: "fabricsfibrecontent", component: fabricsfibrecontent_list_component_1.FabricsFibreContentListComponent },234 { path: "fabricsfinishing", component: fabricsfinishing_list_component_1.FabricsFinishingListComponent },235 { path: "accessories", component: accessories_list_component_1.AccessoriesListComponent },236 { path: "accessories/add", component: accessories_add_component_1.AccessoriesAddComponent },237 { path: "accessories/edit/:id", component: accessories_edit_component_1.AccessoriesEditComponent },238 { path: "graphic", component: graphic_list_component_1.GraphicListComponent },239 { path: "graphic/add", component: graphic_add_component_1.GraphicAddComponent },240 { path: "graphic/edit/:id", component: graphic_edit_component_1.GraphicEditComponent },241 { path: "fabricsyarncount", component: fabricsyarncount_list_component_1.FabricsYarnCountListComponent },242 { path: "fabricproducttype", component: fabricproducttype_list_component_1.FabricProductTypeListComponent },243 { path: "fabricstype", component: fabricstype_list_component_1.FabricsTypeListComponent },244 { path: "fabricweight", component: fabricweight_list_component_1.FabricWeightListComponent },245 { path: "shipping", component: shipping_list_component_1.ShippingListComponent },246 { path: "shipping/add", component: shipping_add_component_1.ShippingAddComponent },247 { path: "shipping/edit/:id", component: shipping_edit_component_1.ShippingEditComponent },248 { path: "pom", component: pom_list_component_1.POMListComponent },249 { path: "accessorytype", component: accessorytype_list_component_1.AccessoryTypeListComponent },250 { path: "accessory/type/:typeid", component: accessories_list_component_1.AccessoriesListComponent },251 { path: "accessory/category/:cateid", component: accessories_list_component_1.AccessoriesListComponent },252 { path: "accessory/productname/:productnameid", component: accessories_list_component_1.AccessoriesListComponent },253 { path: "wash/type/:typeid", component: wash_list_component_1.WashListComponent },254 { path: "wash/category/:cateid", component: wash_list_component_1.WashListComponent },255 { path: "wash/productname/:productnameid", component: wash_list_component_1.WashListComponent },256 { path: "fabrics/type/:typeid", component: fabrics_list_component_1.FabricsListComponent },257 { path: "fabrics/category/:cateid", component: fabrics_list_component_1.FabricsListComponent },258 { path: "fabrics/productname/:productnameid", component: fabrics_list_component_1.FabricsListComponent },259 { path: "graphic/type/:typeid", component: graphic_list_component_1.GraphicListComponent },260 { path: "graphic/category/:cateid", component: graphic_list_component_1.GraphicListComponent },261 { path: "graphic/productname/:productnameid", component: graphic_list_component_1.GraphicListComponent },262 { path: "accessoryproductname", component: accessoryproductname_list_component_1.AccessoryProductNameListComponent },263 { path: "wash", component: wash_list_component_1.WashListComponent },264 { path: "wash/add", component: wash_add_component_1.WashAddComponent },265 { path: "wash/edit/:id", component: wash_edit_component_1.WashEditComponent },266 { path: "reasonforabortingproject", component: reasonforabortingproject_list_component_1.ReasonForAbortingProjectListComponent },267 { path: "season", component: season_list_component_1.SeasonListComponent },268 { path: "training", component: training_list_component_1.TrainingListComponent },269 { path: "trainingitem", component: trainingitem_list_component_1.TrainingItemListComponent },270 { path: "brand", component: brand_list_component_1.BrandListComponent },271 { path: "division", component: division_list_component_1.DivisionListComponent },272 { path: "shippingtype", component: shippingtype_list_component_1.ShippingTypeListComponent },273 { path: "sizerange", component: sizerange_list_component_1.SizeRangeListComponent },274 { path: "sizerange/add", component: sizerange_add_component_1.SizeRangeAddComponent },275 { path: "sizerange/edit/:id", component: sizerange_edit_component_1.SizeRangeEditComponent },276 { path: "washcategory", component: washcategory_list_component_1.WashCategoryListComponent },277 { path: "washproductname", component: washproductname_list_component_1.WashProductNameListComponent },278 { path: "washtype", component: washtype_list_component_1.WashTypeListComponent },279 { path: "graphictype", component: graphictype_list_component_1.GraphicTypeListComponent },280 { path: "graphiccategory", component: graphiccategory_list_component_1.GraphicCategoryListComponent },281 { path: "graphicproductname", component: graphicproductname_list_component_1.GraphicProductNameListComponent },282 { path: "application", component: application_list_component_1.ApplicationListComponent },283 { path: "application/add", component: application_add_component_1.ApplicationAddComponent },284 { path: "application/edit/:id", component: application_edit_component_1.ApplicationEditComponent },285 { path: "year", component: year_list_component_1.YearListComponent },286 { path: "accessorycategory", component: accessorycategory_list_component_1.AccessoryCategoryListComponent },287 { path: "accessoryproductname", component: accessoryproductname_list_component_1.AccessoryProductNameListComponent },288 { path: "department", component: department_list_component_1.DepartmentListComponent },289 { path: "endbuyer", component: endbuyer_list_component_1.EndBuyerListComponent },290 { path: "fabrics", component: fabrics_list_component_1.FabricsListComponent },291 { path: "fabrics/add", component: fabrics_add_component_1.FabricsAddComponent },292 { path: "fabrics/edit/:id", component: fabrics_edit_component_1.FabricsEditComponent },293 { path: "login", component: login_component_1.LoginComponent },294 { path: "userlist", component: User_List_component_1.UserListComponent },295 { path: "userlist/add", component: User_Add_component_1.UserAddComponent },296 { path: "userlist/edit/:id", component: User_Edit_component_1.UserEditComponent },297 { path: "spec", component: spec_list_component_1.SpecListComponent },298 { path: "spec/add", component: spec_add_component_1.SpecAddComponent },299 { path: "userrolelist", component: UserRole_List_component_1.UserRoleListComponent },300 { path: "userrolelist/add", component: UserRole_Add_component_1.UserRoleAddComponent },301 { path: "userrolelist/edit/:id", component: UserRole_Edit_component_1.UserRoleEditComponent },302 { path: "vendortypelist", component: VendorType_List_component_1.VendorTypeListComponent },303 { path: "vendortypelist/add", component: VendorType_Add_component_1.VendorTypeAddComponent },304 { path: "vendortypelist/edit/:id", component: VendorType_Edit_component_1.VendorTypeEditComponent },305 { path: "vendorproducttypelist", component: VendorProductType_List_component_1.VendorProductTypeListComponent },306 { path: "vendorproducttypelist/add", component: VendorProductType_Add_component_1.VendorProductTypeAddComponent },307 { path: "vendorproducttypelist/edit/:id", component: VendorProductType_Edit_component_1.VendorProductTypeEditComponent },308 { path: "vendorlist", component: Vendor_List_component_1.VendorListComponent },309 { path: "vendorlist/add", component: Vendor_Add_component_1.VendorAddComponent },310 //{ path: "vendorlist/edit/:id", component: VendorEditComponent },311 { path: "spec", component: spec_list_component_1.SpecListComponent },312 { path: "spec/add", component: spec_add_component_1.SpecAddComponent },313 { path: '**', component: page_not_found_component_1.PageNotFoundComponent }314 ];315 exports_1("AppRoutingProviders", AppRoutingProviders = []);316 exports_1("AppRouting", AppRouting = router_1.RouterModule.forRoot(appRoutes));317 }318 };...

Full Screen

Full Screen

controllers.js

Source:controllers.js Github

copy

Full Screen

1//======================================================================================================================2// Controllers for List Webble for Webble World v3.0 (2013)3// Created By: truemrwalker4//======================================================================================================================5//=======================================================================================6// WEBBLE CONTROLLER7// This is the Main controller for this Webble Template8//=======================================================================================9wblwrld3App.controller('listCtrl', function($scope, $log, $timeout, Slot, Enum) {10 //=== PROPERTIES ====================================================================11 $scope.stylesToSlots = {12 listGrabber: ['padding', 'background-color', 'border'],13 listContainer: ['font-family', 'font-size', 'color']14 };15 $scope.theList = {16 items: [],17 currentSelected: ''18 };19 $scope.formProps = {20 CBDisplayClass: 'checkbox',21 RBDisplayClass: 'checkbox',22 listHeight: 'auto',23 listOverflow: 'visible',24 listItemMarkerImage: ''25 };26 var selectChangeBlocked = false;27 var fxList;28 //=== EVENT HANDLERS ================================================================29 //=== METHODS & FUNCTIONS ===========================================================30 //===================================================================================31 // Webble template Initialization32 //===================================================================================33 $scope.coreCall_Init = function(theInitWblDef){34 $scope.registerWWEventListener(Enum.availableWWEvents.slotChanged, function(eventData){35 var newVal = eventData.slotValue;36 if(eventData.slotName == 'theList'){37 updateList(newVal);38 }39 else if(eventData.slotName == 'theListType'){40 if(fxList != undefined){ stroll.unbind(fxList); }41 updateList(newVal);42 if(newVal == 6){43 $timeout(function(){fxList = $scope.theView.parent().find("#fxList ul"); stroll.bind(fxList);});44 }45 }46 else if(eventData.slotName == 'theListDirection'){47 if(newVal == 0){48 $scope.formProps.CBDisplayClass = 'checkbox';49 $scope.formProps.RBDisplayClass = 'radio';50 }51 else if(newVal == 1){52 $scope.formProps.CBDisplayClass = 'checkbox-inline';53 $scope.formProps.RBDisplayClass = 'radio-inline';54 }55 }56 else if(eventData.slotName == 'theListContainerHeight'){57 if(newVal != undefined){58 var valParsed = parseInt(newVal);59 if(!isNaN(valParsed)){60 $scope.formProps.listHeight = valParsed + 'px';61 $scope.formProps.listOverflow = 'scroll';62 }63 else{64 $scope.formProps.listHeight = 'auto';65 $scope.formProps.listOverflow = 'visible';66 }67 if($scope.gimme('theListType') == 6){68 if(fxList != undefined){ stroll.unbind(fxList); }69 $timeout(function(){fxList = $scope.theView.parent().find("#fxList ul"); stroll.bind(fxList);});70 }71 }72 }73 else if(eventData.slotName == 'theListItemMarkerImage'){74 if(newVal != undefined){75 $scope.formProps.listItemMarkerImage = 'url(' + newVal + ')';76 }77 }78 else if(eventData.slotName == 'theSelectedName'){79 if(!selectChangeBlocked){80 selectChangeBlocked = true;81 $timeout(function(){selectChangeBlocked = false;}, 100);82 $scope.theList.currentSelected = newVal;83 var count = 0;84 for(var i = 0; i < $scope.theList.items.length; i++){85 if($scope.theList.items[i] == newVal){86 $scope.set('theSelectedIndex', i);87 count++;88 }89 }90 if(count > 1 || (newVal != '' && count == 0)){91 //$scope.set('theSelectedIndex', -2);92 }93 if(newVal == ''){94 $scope.set('theSelectedIndex', -1);95 }96 }97 }98 else if(eventData.slotName == 'theSelectedIndex'){99 if(newVal != -2 && !selectChangeBlocked){100 selectChangeBlocked = true;101 $timeout(function(){selectChangeBlocked = false;}, 100);102 if(newVal < $scope.theList.items.length){103 $scope.theList.currentSelected = $scope.theList.items[parseInt(newVal)];104 $scope.set('theSelectedName', $scope.theList.currentSelected);105 }106 else{107 $scope.set('theSelectedIndex', -1);108 $scope.theList.currentSelected = '';109 $scope.set('theSelectedName', '');110 }111 }112 }113 else if(eventData.slotName == 'removeListItem'){114 if(eventData.slotValue != ''){115 var theListItem = eventData.slotValue;116 var theListStr = $scope.gimme('theList');117 var tempListItems = [], splitChar = '';118 if(theListStr.search(';') != -1){119 tempListItems = theListStr.split(';');120 splitChar = ';';121 }122 else if(theListStr.search(',') != -1){123 tempListItems = theListStr.split(',');124 splitChar = ',';125 }126 else if(theListStr.search(' ') != -1){127 tempListItems = theListStr.split(' ');128 splitChar = ' ';129 }130 else{131 tempListItems.push(theListStr);132 }133 if(!isNaN(theListItem)){134 theListItem = tempListItems[parseInt(theListItem)];135 }136 theListStr = theListStr.replace(theListItem, '').replace(splitChar + splitChar, splitChar);137 if(theListStr[0] == splitChar){theListStr = theListStr.substr(1)}138 if(theListStr[theListStr.length - 1] == splitChar){theListStr = theListStr.substr(0, theListStr.length - 1)}139 $scope.set('removeListItem', '');140 $scope.set('theList', theListStr);141 adjustSelectedItem();142 $timeout(function(){adjustSelectedItem();});143 }144 }145 else if(eventData.slotName == 'addListItem'){146 if(eventData.slotValue != ''){147 var theListStr = $scope.gimme('theList');148 var splitChar = ';';149 if(theListStr.search(',') != -1){ splitChar = ','; }150 else if(theListStr.search(' ') != -1){ splitChar = ' '; }151 theListStr += (splitChar + eventData.slotValue);152 $scope.set('addListItem', '');153 if(fxList != undefined){ stroll.unbind(fxList); }154 $scope.set('theList', theListStr);155 if($scope.gimme('theListType') == 6){156 $timeout(function(){fxList = $scope.theView.parent().find("#fxList ul"); stroll.bind(fxList);});157 }158 adjustSelectedItem();159 }160 }161 else if(eventData.slotName == 'insertListItem'){162 if(eventData.slotValue != ''){163 var theIndex = parseInt($scope.gimme('theSelectedIndex'));164 var newListStr = '';165 if(isNaN(theIndex)){ theIndex = 0; }166 if($scope.theList.items.length > theIndex){167 var theListStr = $scope.gimme('theList');168 var splitChar = ';';169 if(theListStr.search(',') != -1){ splitChar = ','; }170 else if(theListStr.search(' ') != -1){ splitChar = ' '; }171 $scope.theList.items.splice(theIndex, 0, eventData.slotValue);172 for(var i = 0; i < $scope.theList.items.length; i++){173 if(i > 0){ newListStr += splitChar }174 newListStr += $scope.theList.items[i];175 }176 }177 $scope.set('insertListItem', '');178 if(newListStr != ''){179 if(fxList != undefined){ stroll.unbind(fxList); }180 $scope.set('theList', newListStr);181 if($scope.gimme('theListType') == 6){182 $timeout(function(){fxList = $scope.theView.parent().find("#fxList ul"); stroll.bind(fxList);});183 }184 adjustSelectedItem();185 }186 }187 }188 else if(eventData.slotName == 'sortListEnabled'){189 updateList($scope.gimme('theList'));190 }191 });192 $scope.addSlot(new Slot('theList',193 'One Two Three Four Five Six Seven Eight Nine Ten Eleven Twelve Thirteen Fourteen Fifteen Sixteen Seventeen Eighteen Nineteen Twenty Twentyone Twentytwo Twentythree Twentyfour Twentyfive Twentysix Twentyseven Twentyeight Twentynine Thirty Thirtyone Thirtytwo Thirtythree Thirtyfour Thirtyfive Thirtysix Thirtyseven Thirtyeight Thirtynine Forty Fortyone Fortytwo Fortythree Fortyfour Fortyfive Fortysix Fortyseven Fortyeight Fortynine Fifty Fiftyone Fiftytwo Fiftythree Fiftyfour Fiftyfive Fiftysix Fiftyseven Fiftyeight Fiftynine Sixty Sixtyone Sixtytwo Sixtythree Sixtyfour Sixtyfive Sixtysix Sixtyseven Sixtyeight Sixtynine Seventy Seventyone Seventytwo Seventythree Seventyfour Seventyfive Seventysix Seventyseven Seventyeight Seventynine Eighty Eightyone Eightytwo Eightythree Eightyfour Eightyfive Eightysix Eightyseven Eightyeight Eightynine Ninety Ninetyone Ninetytwo Ninetythree Ninetyfour Ninetyfive Ninetysix Ninetyseven Ninetyeight Ninetynine',194 'The List Items',195 'The items of the list (separated by either comma[,], semicolon[;] or space [ ].',196 $scope.theWblMetadata['templateid'],197 {inputType: Enum.aopInputTypes.TextBox},198 undefined199 ));200 $scope.addSlot(new Slot('theSelectedIndex',201 -1,202 'The Selected Index',203 'The index of the selected item of the list (-1 = none slected, -2 = multiple selected)',204 $scope.theWblMetadata['templateid'],205 undefined,206 undefined207 ));208 $scope.getSlot('theSelectedIndex').setDisabledSetting(Enum.SlotDisablingState.PropertyEditing);209 $scope.addSlot(new Slot('theSelectedName',210 '',211 'The Selected Name',212 'The name of the selected item of the list',213 $scope.theWblMetadata['templateid'],214 undefined,215 undefined216 ));217 $scope.getSlot('theSelectedName').setDisabledSetting(Enum.SlotDisablingState.PropertyEditing);218 $scope.addSlot(new Slot('listLength',219 0,220 'List Length',221 'The amount of items in the list',222 $scope.theWblMetadata['templateid'],223 undefined,224 undefined225 ));226 $scope.getSlot('listLength').setDisabledSetting(Enum.SlotDisablingState.PropertyEditing);227 $scope.addSlot(new Slot('theListType',228 6,229 'The Display Type',230 'The type of way the list is being displayed',231 $scope.theWblMetadata['templateid'],232 {inputType: Enum.aopInputTypes.ComboBoxUseIndex, comboBoxContent: ['Undefined', 'Drop Down Box', 'Radio Buttons', 'Multi Select List Box', 'Check Boxes', 'Classic List', 'FX List']},233 undefined234 ));235 $scope.addSlot(new Slot('fxListEffect',236 'twirl',237 'FX List Effect',238 'The effect that will be used when scrolling the fx list. (These CSS Effects was provided by Hakim El Hattab [ @hakimel ])',239 $scope.theWblMetadata['templateid'],240 {inputType: Enum.aopInputTypes.ComboBoxUseValue, comboBoxContent: ['none', 'cards', 'curl', 'fan', 'flip', 'fly', 'fly-reverse', 'fly-simplified', 'grow', 'helix', 'papercut', 'skew', 'tilt', 'twirl', 'wave', 'zipper']},241 undefined242 ));243 $scope.addSlot(new Slot('sortListEnabled',244 false,245 'Sort List Enabled',246 'If checked the list will always be sorted in alphabetic order',247 $scope.theWblMetadata['templateid'],248 undefined,249 undefined250 ));251 $scope.addSlot(new Slot('theListDirection',252 0,253 'The Display Direction',254 'The direction which the list items are displayed (available only for radio and checkbox), vertically or horizontally',255 $scope.theWblMetadata['templateid'],256 {inputType: Enum.aopInputTypes.ComboBoxUseIndex, comboBoxContent: ['Vertical', 'Horizontal']},257 undefined258 ));259 $scope.addSlot(new Slot('theListContainerHeight',260 '300px',261 'The List Display Height',262 'The height of the list to be displayed, [auto] means the height is as long as the list, any size will clip (hide) the part of the list that overflow',263 $scope.theWblMetadata['templateid'],264 undefined,265 undefined266 ));267 $scope.addSlot(new Slot('theListContainerWidth',268 '200px',269 'The List Display Width',270 'The width of the list to be displayed, [auto] means the width is as long as the longest item, any size will clip (hide) the part of the list that overflow',271 $scope.theWblMetadata['templateid'],272 undefined,273 undefined274 ));275 $scope.addSlot(new Slot('multiSelectListSize',276 5,277 'Multi Select List Height',278 'The number of visible items in the multi select list',279 $scope.theWblMetadata['templateid'],280 undefined,281 undefined282 ));283 $scope.addSlot(new Slot('theListItemMarkerStyle',284 'disc',285 'Item Marker Type',286 'When using Classic list, each list item will be marked with a symbol or number, this slot gives you the possibility to change that.',287 $scope.theWblMetadata['templateid'],288 {inputType: Enum.aopInputTypes.ComboBoxUseValue, comboBoxContent: ['none', 'disc', 'armenian', 'circle', 'cjk-ideographic', 'decimal', 'decimal-leading-zero', 'georgian', 'hebrew', 'hiragana', 'hiragana-iroha', 'katakana', 'katakana-iroha', 'lower-alpha', 'lower-greek', 'lower-latin', 'lower-roman', 'square', 'upper-alpha', 'upper-latin', 'upper-roman']},289 undefined290 ));291 $scope.addSlot(new Slot('theListItemMarkerImage',292 'disc',293 'Item Marker Image',294 'When using Classic list, each list item will be marked with a symbol or number, one can even use a custom image by setting this slot.',295 $scope.theWblMetadata['templateid'],296 {inputType: Enum.aopInputTypes.ImagePick},297 undefined298 ));299 $scope.addSlot(new Slot('theListBackgroundColor',300 '#a4a4a4',301 'List Background Color',302 'The background color of the list (not items or the outside padding).',303 $scope.theWblMetadata['templateid'],304 {inputType: Enum.aopInputTypes.ColorPick},305 undefined306 ));307 $scope.addSlot(new Slot('oddItemBkgColor',308 '#ffffff',309 'Odd Item Background Color',310 'The background color of every odd item in the itemized or FX list.',311 $scope.theWblMetadata['templateid'],312 {inputType: Enum.aopInputTypes.ColorPick},313 undefined314 ));315 $scope.addSlot(new Slot('evenItemBkgColor',316 '#d0d0d0',317 'Even Item Background Color',318 'The background color of every even item in the itemized or FX list.',319 $scope.theWblMetadata['templateid'],320 {inputType: Enum.aopInputTypes.ColorPick},321 undefined322 ));323 $scope.addSlot(new Slot('selectedItemBkgColor',324 '#fed1f5',325 'Selected Item Background Color',326 'The background color of the current selected item',327 $scope.theWblMetadata['templateid'],328 {inputType: Enum.aopInputTypes.ColorPick},329 undefined330 ));331 $scope.addSlot(new Slot('itemPadding',332 '10px',333 'List Item Padding',334 'The size of the space surrounding each list item',335 $scope.theWblMetadata['templateid'],336 {inputType: Enum.aopInputTypes.Numeral},337 undefined338 ));339 $scope.addSlot(new Slot('removeListItem',340 '',341 'List Item to Be removed',342 'The name or the index number of a list item to be removed from the list',343 $scope.theWblMetadata['templateid'],344 {inputType: Enum.aopInputTypes.TextBox},345 undefined346 ));347 $scope.addSlot(new Slot('addListItem',348 '',349 'List Item to Be added',350 'The name of an item being added at the end of the list',351 $scope.theWblMetadata['templateid'],352 {inputType: Enum.aopInputTypes.TextBox},353 undefined354 ));355 $scope.addSlot(new Slot('insertListItem',356 '',357 'List Item to Be inserted',358 'The name of an item being inserted at the current selected position. (at the beginning if no item is selected)',359 $scope.theWblMetadata['templateid'],360 {inputType: Enum.aopInputTypes.TextBox},361 undefined362 ));363 $scope.setDefaultSlot('theSelectedName');364 if(BrowserDetect.browser == 'Firefox'){365 $scope.theView.parent().draggable('option', 'cancel', '#listContainer');366 }367 $scope.$watch(function(){return $scope.theList.currentSelected;}, function(newVal, oldVal) {368 if(newVal != oldVal && !selectChangeBlocked){369 selectChangeBlocked = true;370 $timeout(function(){selectChangeBlocked = false;}, 100);371 $scope.set('theSelectedName', newVal);372 var count = 0;373 for(var i = 0; i < $scope.theList.items.length; i++){374 if($scope.theList.items[i] == newVal){375 $scope.set('theSelectedIndex', i);376 count++;377 }378 }379 if(count > 1 || (newVal != '' && count == 0)){380 $scope.set('theSelectedIndex', -2);381 }382 if(newVal == ''){383 $scope.set('theSelectedIndex', -1);384 }385 }386 }, true);387 $timeout(function(){$scope.selectAnItem($scope.gimme('theSelectedIndex'));});388 };389 //===================================================================================390 //========================================================================================391 // Update List392 // Redraws the list according to current setup.393 //========================================================================================394 var updateList = function(newVal){395 if(newVal.search){396 $scope.theList.items = [];397 var workList = [];398 if(newVal.search(';') != -1){399 workList = newVal.split(';');400 }401 else if(newVal.search(',') != -1){402 workList = newVal.split(',');403 }404 else if(newVal.search(' ') != -1){405 workList = newVal.split(' ');406 }407 else{408 workList.push(newVal);409 }410 if(workList.length > 0){411 for(var i = 0; i < workList.length; i++){412 $scope.theList.items.push(workList[i]);413 }414 }415 else{416 $scope.theList.currentSelected = '';417 }418 if($scope.gimme('theSelectedName') != ''){419 $scope.theList.currentSelected = $scope.gimme('theSelectedName');420 }421 }422 else if($.isArray(newVal)){423 $scope.theList.items = [];424 for(var i = 0; i < newVal.length; i++){425 $scope.theList.items.push(newVal[i]);426 }427 }428 if($scope.gimme('sortListEnabled') == true){429 $scope.theList.items.sort();430 }431 if(newVal == ""){432 $scope.set('listLength', 0);433 }434 else{435 $scope.set('listLength', $scope.theList.items.length);436 }437 };438 //========================================================================================439 //========================================================================================440 // Toggle Multi Check Box Selection441 // Toggles the prop item value correctly due to the multi checkbox selections.442 //========================================================================================443 $scope.toggleMultiCheckBoxSelection = function(cbName) {444 if(!$.isArray($scope.theList.currentSelected)){445 $scope.theList.currentSelected = [$scope.theList.currentSelected];446 }447 var idx = $scope.theList.currentSelected.indexOf(cbName);448 // is currently selected449 if (idx > -1) {450 $scope.theList.currentSelected.splice(idx, 1);451 }452 // is newly selected453 else {454 $scope.theList.currentSelected.push(cbName);455 }456 };457 //========================================================================================458 //========================================================================================459 // Adjust Selected Item460 // Make sure that the current selected index and name are the same after list change461 //========================================================================================462 var adjustSelectedItem = function() {463 var currIndex = $scope.gimme('theSelectedIndex');464 if(currIndex != -2){465 selectChangeBlocked = true;466 $timeout(function(){selectChangeBlocked = false;}, 100);467 if(currIndex < $scope.theList.items.length){468 $scope.theList.currentSelected = $scope.theList.items[currIndex];469 $scope.set('theSelectedName', $scope.theList.currentSelected);470 }471 else{472 $scope.set('theSelectedIndex', -1);473 $scope.theList.currentSelected = '';474 $scope.set('theSelectedName', '');475 }476 }477 };478 //========================================================================================479 //========================================================================================480 // Select an Item481 // Make the clicked item selected482 //========================================================================================483 $scope.selectAnItem = function(index) {484 $scope.theList.currentSelected = $scope.theList.items[index];485 };486 //========================================================================================487 //========================================================================================488 // Select an Item489 // Make the clicked item selected490 //========================================================================================491 $scope.getItemBkgColor = function(index) {492 var value = $scope.theList.items[index];493 var isOdd = index % 2;494 if($scope.theList.currentSelected == value){495 return $scope.gimme('selectedItemBkgColor');496 }497 else if(isOdd){498 return $scope.gimme('oddItemBkgColor');499 }500 else{501 return $scope.gimme('evenItemBkgColor');502 }503 };504 //========================================================================================505 //=== CTRL MAIN CODE ======================================================================506});...

Full Screen

Full Screen

Conformance_Expressions.js

Source:Conformance_Expressions.js Github

copy

Full Screen

1/*2Copyright © 2001-2004 World Wide Web Consortium, 3(Massachusetts Institute of Technology, European Research Consortium 4for Informatics and Mathematics, Keio University). All 5Rights Reserved. This work is distributed under the W3C® Software License [1] in the 6hope that it will be useful, but WITHOUT ANY WARRANTY; without even 7the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 8[1] http://www.w3.org/Consortium/Legal/2002/copyright-software-200212319*/10// expose test function names11function exposeTestFunctionNames()12{13return ['Conformance_Expressions'];14}15var docsLoaded = -1000000;16var builder = null;17//18// This function is called by the testing framework before19// running the test suite.20//21// If there are no configuration exceptions, asynchronous22// document loading is started. Otherwise, the status23// is set to complete and the exception is immediately24// raised when entering the body of the test.25//26function setUpPage() {27 setUpPageStatus = 'running';28 try {29 //30 // creates test document builder, may throw exception31 //32 builder = createConfiguredBuilder();33 docsLoaded = 0;34 35 var docRef = null;36 if (typeof(this.doc) != 'undefined') {37 docRef = this.doc;38 }39 docsLoaded += preload(docRef, "doc", "staffNS");40 41 if (docsLoaded == 1) {42 setUpPageStatus = 'complete';43 }44 } catch(ex) {45 catchInitializationError(builder, ex);46 setUpPageStatus = 'complete';47 }48}49//50// This method is called on the completion of 51// each asychronous load started in setUpTests.52//53// When every synchronous loaded document has completed,54// the page status is changed which allows the55// body of the test to be executed.56function loadComplete() {57 if (++docsLoaded == 1) {58 setUpPageStatus = 'complete';59 }60}61/**62* 63 1.3 Conformance - Iterate over a list of strings containing 64 valid XPath expressions, calling XPathEvaluator.createExpression 65 for each. If no expections are thrown and each result is non-null, 66 then the test passes.67 68* @author Bob Clary69* @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#Conformance70* @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvaluator71* @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvaluator-createNSResolver72* @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathEvaluator-createExpression73* @see http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath#XPathNSResolver74*/75function Conformance_Expressions() {76 var success;77 if(checkInitialization(builder, "Conformance_Expressions") != null) return;78 var doc;79 var resolver;80 var evaluator;81 var expression;82 var expressionList = new Array();83 var xpathexpression;84 85 var docRef = null;86 if (typeof(this.doc) != 'undefined') {87 docRef = this.doc;88 }89 doc = load(docRef, "doc", "staffNS");90 evaluator = createXPathEvaluator(doc);91resolver = evaluator.createNSResolver(doc);92 expressionList[expressionList.length] = "/";93expressionList[expressionList.length] = "child::comment()";94expressionList[expressionList.length] = "child::text()";95expressionList[expressionList.length] = "child::processing-instruction()";96expressionList[expressionList.length] = "child::processing-instruction('name')";97expressionList[expressionList.length] = "child::node()";98expressionList[expressionList.length] = "child::*";99expressionList[expressionList.length] = "child::nist:*";100expressionList[expressionList.length] = "child::employee";101expressionList[expressionList.length] = "descendant::comment()";102expressionList[expressionList.length] = "descendant::text()";103expressionList[expressionList.length] = "descendant::processing-instruction()";104expressionList[expressionList.length] = "descendant::processing-instruction('name')";105expressionList[expressionList.length] = "descendant::node()";106expressionList[expressionList.length] = "descendant::*";107expressionList[expressionList.length] = "descendant::nist:*";108expressionList[expressionList.length] = "descendant::employee";109expressionList[expressionList.length] = "parent::comment()";110expressionList[expressionList.length] = "parent::text()";111expressionList[expressionList.length] = "parent::processing-instruction()";112expressionList[expressionList.length] = "parent::processing-instruction('name')";113expressionList[expressionList.length] = "parent::node()";114expressionList[expressionList.length] = "parent::*";115expressionList[expressionList.length] = "parent::nist:*";116expressionList[expressionList.length] = "parent::employee";117expressionList[expressionList.length] = "ancestor::comment()";118expressionList[expressionList.length] = "ancestor::text()";119expressionList[expressionList.length] = "ancestor::processing-instruction()";120expressionList[expressionList.length] = "ancestor::processing-instruction('name')";121expressionList[expressionList.length] = "ancestor::node()";122expressionList[expressionList.length] = "ancestor::*";123expressionList[expressionList.length] = "ancestor::nist:*";124expressionList[expressionList.length] = "ancestor::employee";125expressionList[expressionList.length] = "following-sibling::comment()";126expressionList[expressionList.length] = "following-sibling::text()";127expressionList[expressionList.length] = "following-sibling::processing-instruction()";128expressionList[expressionList.length] = "following-sibling::processing-instruction('name')";129expressionList[expressionList.length] = "following-sibling::node()";130expressionList[expressionList.length] = "following-sibling::*";131expressionList[expressionList.length] = "following-sibling::nist:*";132expressionList[expressionList.length] = "following-sibling::employee";133expressionList[expressionList.length] = "preceding-sibling::comment()";134expressionList[expressionList.length] = "preceding-sibling::text()";135expressionList[expressionList.length] = "preceding-sibling::processing-instruction()";136expressionList[expressionList.length] = "preceding-sibling::processing-instruction('name')";137expressionList[expressionList.length] = "preceding-sibling::node()";138expressionList[expressionList.length] = "preceding-sibling::*";139expressionList[expressionList.length] = "preceding-sibling::nist:*";140expressionList[expressionList.length] = "preceding-sibling::employee";141expressionList[expressionList.length] = "following::comment()";142expressionList[expressionList.length] = "following::text()";143expressionList[expressionList.length] = "following::processing-instruction()";144expressionList[expressionList.length] = "following::processing-instruction('name')";145expressionList[expressionList.length] = "following::node()";146expressionList[expressionList.length] = "following::*";147expressionList[expressionList.length] = "following::nist:*";148expressionList[expressionList.length] = "following::employee";149expressionList[expressionList.length] = "preceding::comment()";150expressionList[expressionList.length] = "preceding::text()";151expressionList[expressionList.length] = "preceding::processing-instruction()";152expressionList[expressionList.length] = "preceding::processing-instruction('name')";153expressionList[expressionList.length] = "preceding::node()";154expressionList[expressionList.length] = "preceding::*";155expressionList[expressionList.length] = "preceding::nist:*";156expressionList[expressionList.length] = "preceding::employee";157expressionList[expressionList.length] = "attribute::comment()";158expressionList[expressionList.length] = "attribute::text()";159expressionList[expressionList.length] = "attribute::processing-instruction()";160expressionList[expressionList.length] = "attribute::processing-instruction('name')";161expressionList[expressionList.length] = "attribute::node()";162expressionList[expressionList.length] = "attribute::*";163expressionList[expressionList.length] = "attribute::nist:*";164expressionList[expressionList.length] = "attribute::employee";165expressionList[expressionList.length] = "namespace::comment()";166expressionList[expressionList.length] = "namespace::text()";167expressionList[expressionList.length] = "namespace::processing-instruction()";168expressionList[expressionList.length] = "namespace::processing-instruction('name')";169expressionList[expressionList.length] = "namespace::node()";170expressionList[expressionList.length] = "namespace::*";171expressionList[expressionList.length] = "namespace::nist:*";172expressionList[expressionList.length] = "namespace::employee";173expressionList[expressionList.length] = "self::comment()";174expressionList[expressionList.length] = "self::text()";175expressionList[expressionList.length] = "self::processing-instruction()";176expressionList[expressionList.length] = "self::processing-instruction('name')";177expressionList[expressionList.length] = "self::node()";178expressionList[expressionList.length] = "self::*";179expressionList[expressionList.length] = "self::nist:*";180expressionList[expressionList.length] = "self::employee";181expressionList[expressionList.length] = "descendant-or-self::comment()";182expressionList[expressionList.length] = "descendant-or-self::text()";183expressionList[expressionList.length] = "descendant-or-self::processing-instruction()";184expressionList[expressionList.length] = "descendant-or-self::processing-instruction('name')";185expressionList[expressionList.length] = "descendant-or-self::node()";186expressionList[expressionList.length] = "descendant-or-self::*";187expressionList[expressionList.length] = "descendant-or-self::nist:*";188expressionList[expressionList.length] = "descendant-or-self::employee";189expressionList[expressionList.length] = "ancestor-or-self::comment()";190expressionList[expressionList.length] = "ancestor-or-self::text()";191expressionList[expressionList.length] = "ancestor-or-self::processing-instruction()";192expressionList[expressionList.length] = "ancestor-or-self::processing-instruction('name')";193expressionList[expressionList.length] = "ancestor-or-self::node()";194expressionList[expressionList.length] = "ancestor-or-self::*";195expressionList[expressionList.length] = "ancestor-or-self::nist:*";196expressionList[expressionList.length] = "ancestor-or-self::employee";197expressionList[expressionList.length] = "comment()";198expressionList[expressionList.length] = "text()";199expressionList[expressionList.length] = "processing-instruction()";200expressionList[expressionList.length] = "processing-instruction('name')";201expressionList[expressionList.length] = "node()";202expressionList[expressionList.length] = "*";203expressionList[expressionList.length] = "nist:*";204expressionList[expressionList.length] = "employee";205expressionList[expressionList.length] = ".//comment()";206expressionList[expressionList.length] = ".//text()";207expressionList[expressionList.length] = ".//processing-instruction()";208expressionList[expressionList.length] = ".//processing-instruction('name')";209expressionList[expressionList.length] = ".//node()";210expressionList[expressionList.length] = ".//*";211expressionList[expressionList.length] = ".//nist:*";212expressionList[expressionList.length] = ".//employee";213expressionList[expressionList.length] = "../comment()";214expressionList[expressionList.length] = "../text()";215expressionList[expressionList.length] = "../processing-instruction()";216expressionList[expressionList.length] = "../processing-instruction('name')";217expressionList[expressionList.length] = "../node()";218expressionList[expressionList.length] = "../*";219expressionList[expressionList.length] = "../nist:*";220expressionList[expressionList.length] = "../employee";221expressionList[expressionList.length] = "@attributename";222expressionList[expressionList.length] = "./comment()";223expressionList[expressionList.length] = "./text()";224expressionList[expressionList.length] = "./processing-instruction()";225expressionList[expressionList.length] = "./processing-instruction('name')";226expressionList[expressionList.length] = "./node()";227expressionList[expressionList.length] = "./*";228expressionList[expressionList.length] = "./nist:*";229expressionList[expressionList.length] = "./employee";230expressionList[expressionList.length] = "comment() | text() | processing-instruction() | node()";231expressionList[expressionList.length] = "employee[address]";232expressionList[expressionList.length] = "employee/address[@street]";233expressionList[expressionList.length] = "employee[position='Computer Specialist']";234expressionList[expressionList.length] = "employee[position!='Computer Specialist']";235expressionList[expressionList.length] = "employee[gender='Male' or gender='Female']";236expressionList[expressionList.length] = "employee[gender!='Male' and gender!='Female']";237expressionList[expressionList.length] = "employee/address[@street='Yes']";238expressionList[expressionList.length] = "employee/address[@street!='Yes']";239expressionList[expressionList.length] = "employee[position()=1]";240expressionList[expressionList.length] = "employee[1]";241expressionList[expressionList.length] = "employee[position()=last()]";242expressionList[expressionList.length] = "employee[last()]";243expressionList[expressionList.length] = "employee[position()>1 and position<last()]";244expressionList[expressionList.length] = "employee[position()>=1 and position<=last()]";245expressionList[expressionList.length] = "employee[count(.)>0]";246expressionList[expressionList.length] = "employee[position() mod 2=0]";247expressionList[expressionList.length] = "employee[position() mod -2=0]";248expressionList[expressionList.length] = "employee[position() div 2=0]";249expressionList[expressionList.length] = "employee[position() div -2=-1]";250expressionList[expressionList.length] = "employee[position() div 2 * 2=position()]";251expressionList[expressionList.length] = "employee[3 > 2 > 1]";252expressionList[expressionList.length] = "id('CANADA')";253expressionList[expressionList.length] = "*[local-name()='employee']";254expressionList[expressionList.length] = "*[local-name(.)='employee']";255expressionList[expressionList.length] = "*[local-name(employee)='employee']";256expressionList[expressionList.length] = "*[local-name()='employee']";257expressionList[expressionList.length] = "*[namespace-uri()='http://www.nist.gov']";258expressionList[expressionList.length] = "*[name()='nist:employee']";259expressionList[expressionList.length] = "*[string()]";260expressionList[expressionList.length] = "*[string(10 div foo)='NaN']";261expressionList[expressionList.length] = "*[concat('a', 'b', 'c')]";262expressionList[expressionList.length] = "*[starts-with('employee', 'emp')]";263expressionList[expressionList.length] = "*[contains('employee', 'emp')]";264expressionList[expressionList.length] = "*[substring-before('employeeId', 'Id')]";265expressionList[expressionList.length] = "*[substring-after('employeeId', 'employee')]";266expressionList[expressionList.length] = "*[substring('employeeId', 4)]";267expressionList[expressionList.length] = "*[substring('employeeId', 4, 5)]";268expressionList[expressionList.length] = "*[string-length()=2]";269expressionList[expressionList.length] = "*[string-length(.)=string-length(normalize-space(.))]";270expressionList[expressionList.length] = "*[translate('bar', 'abc', 'ABC')='BAr']";271expressionList[expressionList.length] = "*[boolean(.)]";272expressionList[expressionList.length] = "*[not(boolean(.))]";273expressionList[expressionList.length] = "*[true()]";274expressionList[expressionList.length] = "*[false()]";275expressionList[expressionList.length] = "*[lang('en')]";276expressionList[expressionList.length] = "*[number()]";277expressionList[expressionList.length] = "*[number('4')]";278expressionList[expressionList.length] = "*[floor(.)]>0";279expressionList[expressionList.length] = "*[ceiling(.)]<1";280expressionList[expressionList.length] = "*[round(number(.))=0]<1";281for(var indexN66388 = 0;indexN66388 < expressionList.length; indexN66388++) {282 expression = expressionList[indexN66388];283 xpathexpression = evaluator.createExpression(expression,resolver);284 285 }286 287}288function runTest() {289 Conformance_Expressions();...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run molecule automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful