How to use init method in Testcafe

Best JavaScript code snippet using testcafe

Run Testcafe automation tests on LambdaTest cloud grid

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

main.js

Source: main.js Github

copy
1/*! main.js | Bulkit | CSS Ninja */
2
3/* ==========================================================================
4Website core JS file (see function.js for complete function reference)
5========================================================================== */
6"use strict";
7
8initPageLoader();
9$(document).ready(function ($) {
10  var el = document.querySelectorAll('[data-lazy-load]');
11  var observer = lozad(el, {
12    loaded: function loaded(el) {
13      // Custom implementation on a loaded element
14      el.parentNode.classList.add('loaded');
15    }
16  });
17  observer.observe(); //Global functions
18
19  if (env === 'development') {
20    changeDemoImages();
21  }
22
23  initThemeSwitcher();
24  initSlider();
25  initBackgroundImages(); //Layout functions
26
27  initNavbar();
28  initLandingNavbar();
29  initMobileMenu();
30  initLandingMobileMenu();
31  initNavbarDropdown();
32  initSidebar();
33  feather.replace(); //Tabs
34
35  initTabsNav();
36  initNavigationTabs();
37  initVerticalTabs(); //Cards
38
39  initMediaCards();
40  initTiltCards(); //Form controls
41
42  initDatepicker();
43  initTimepicker();
44  initDatepickerAlt();
45  initChosenSelects();
46  initMaterialSelect();
47  initAutocompletes();
48  initFileInputs();
49  initRangeInput();
50  initRangeInputs();
51  initJqueryTagInput();
52  initBulmaTags();
53  initBulmaSteps();
54  initBulmaIconpicker();
55  initBulmaCalendar();
56  initComboBox();
57  initImageComboBox();
58  initStackedComboBox(); //4. Popups
59
60  initPopovers();
61  initTooltips();
62  initModals(); //5. Carousels
63
64  initBasicCarousel();
65  initVerticalCarousel();
66  initFlatCarousel();
67  initImageCarousel();
68  initSingleImageCarousel();
69  initMultipleImagesCarousel(); //6. Video
70
71  initVideoEmbed();
72  initBackgroundVideo();
73  initPlayers(); //7. Counters
74
75  initCounters(); //8. Accordions
76
77  initSimpleAccordion();
78  initAccordions(); //9. File uploader
79
80  initFileUploader(); //10. Toasts
81
82  initToasts(); //11. Demo
83
84  initDemo();
85  initScrollspyNav();
86  initParallax();
87  initBackToTop(); //12. Utility functions
88
89  initGitem();
90  initAnchorScroll();
91  initQuickview();
92  initScrollReveal(); //13. Landing pages functions
93
94  initMockup();
95  initClientsCarousel();
96  initPeopleCarousel();
97  initCustomCarousel();
98  initCarousel();
99  initLandingCarousel();
100  initTestimonials();
101  initCharacterTestimonials();
102  initPricing();
103  initPricingCarousel();
104  initTabbedPricing();
105  initFreelancerPricing();
106  initSwitchPricing();
107  initBoxedPricing();
108  initOnePagePricing();
109  initBlog();
110  initSearchBox();
111  initNavigationDots();
112  initFaq();
113  initAuth();
114  initAnimations();
115  initCanvas();
116  initParticles();
117  initAnimatedSvg();
118  initChatWidget();
119  initContactToggler();
120  initMapBox();
121  initCodeTabs();
122});
Full Screen

Card.jsx

Source: Card.jsx Github

copy
1import React,{useEffect,useState} from 'react'
2import Avatar from '@material-ui/core/Avatar';
3import DoneIcon from '@material-ui/icons/Done'
4import Grid from "@material-ui/core/Grid"
5import firebaseDb from './firebase';
6import ProductCarousel from "./ProductCarousel"
7import {useHistory} from "react-router-dom";
8import {makeStyles} from '@material-ui/core/styles';
9
10
11
12const useStyles = makeStyles((theme) => ({
13    gridy: {
14    [theme.breakpoints.down('sm')]: {
15       margin:'20px 0 0 50%',
16       transform:"translate(-50%,0)"
17          },
18          "&:hover": {
19            transform:"scale(1.001)",
20            transition:"all 0.5s"
21          },
22        }
23  }));
24
25  
26
27export default function Card(props) {
28    const classes = useStyles();
29    const history=useHistory();
30    const[init,upda]=useState({});
31
32    useEffect(()=>{
33        firebaseDb.child('products').on("value",snapshot=>{
34      
35            if(snapshot.val() !=null){
36                    // upda({...snapshot.val()})
37                    // setOpen(true);
38                    
39                     upda({...snapshot.val()});                      
40            }
41    })
42
43    },[props.categoryAction])
44
45    // click event
46
47    const clicki=(a)=>{
48            a.valll="products"
49            history.push("/insideproduct",a);
50    }
51
52    // slider arr
53
54
55
56
57    return (
58        <>
59        <Grid container style={{marginBottom:"50px",paddingLeft:"20px"}}>
60
61        
62
63{/* ternary start */}
64        {
65            Object.keys(init) && Object.keys(init).length > 0 && Array.isArray(Object.keys(init))?
66
67
68
69            props.categoryAction == "LowHigh" ?
70
71
72//ternary start
73              Object.keys(init).sort((a, b) => init[a].price - init[b].price).map((row) => (
74
75                <>
76        <Grid className={classes.gridy} item lg={3} md={4} xs={12} style={{marginBottom:"20px"}}>
77        <div style={{width:"300px"}}>
78        <div style={{backgroundColor:"rgb(240, 240, 240)",height:"355px",width:"290px",overflow:"hidden"}}>
79
80         <div style={{height:"50px",marginBottom:"8px"}}>
81{
82        ( 100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0)) ) > 0 ?
83         <Avatar style={{position:"relative",top:"6px",left:"20px",backgroundColor:"red"}}><span style={{fontSize:"12px"}}>-{100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0))}% </span></Avatar>
84         :
85         <></>
86}         
87         </div>
88
89        <div style={{position:"relative",right:"28px"}}>
90        <ProductCarousel
91        width="220px!important"
92     image1={init[row].image}
93     image2={init[row].image2}
94
95     />
96        </div>
97        <p onClick={()=>clicki({
98        id:row,
99        image:init[row].image,
100        image2:init[row].image2,
101        item:init[row].item,
102        writer:init[row].writer,
103        price: init[row].price,
104        off:init[row].off,
105        description:init[row].description,
106        author:init[row].author
107        })} className="jjj" style={{margin:"16px 0 0 0",cursor:"pointer"}}>{init[row].item}</p>
108
109       </div>   
110        <span style={{color:"silver",marginTop:"0px"}}>{init[row].writer}</span>
111        <h3 style={{color:"#B12704",margin:"10px 0 0 0px"}}><sup>₹</sup>{init[row].price} <span style={{color:"silver",fontSize:"16px",textDecoration:"line-through"}}>  ₹{Number(init[row].price)+Number(init[row].off)}  </span> <span style={{color:"silver",fontSize:"16px",textDecoration:"none",marginLeft:"10px"}}> save({init[row].off}) {100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0))}%</span></h3>
112<p style={{marginTop:"10px"}}> <DoneIcon style={{color:"#B12704"}}/> <span  style={{color:"#B12704"}}><b>Express</b></span> Get it by Tomorrow, <b> April {new Date().getDate()+1}</b> </p>
113
114    <span style={{color:"silver",marginTop:"0px"}}>FREE Delivery over ₹499.Fulfilled by PerfectLegal.</span>
115        </div>
116        </Grid>
117
118                </>
119              ))
120
121
122        :
123
124//trenery Start
125
126props.categoryAction == "HighLow" ?
127
128        Object.keys(init).sort((a, b) => init[a].price - init[b].price).reverse().map((row) => (
129
130<>
131<Grid className={classes.gridy} item lg={3} md={4} xs={12} style={{marginBottom:"20px"}}>
132<div style={{width:"300px"}}>
133<div style={{backgroundColor:"rgb(240, 240, 240)",height:"355px",width:"290px",overflow:"hidden"}}>
134
135<div style={{height:"50px",marginBottom:"8px"}}>
136{
137        ( 100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0)) ) > 0 ?
138         <Avatar style={{position:"relative",top:"6px",left:"20px",backgroundColor:"red"}}><span style={{fontSize:"12px"}}>-{100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0))}% </span></Avatar>
139         :
140         <></>
141}         
142</div>
143
144<div style={{position:"relative",right:"28px"}}>
145<ProductCarousel
146width="220px!important"
147image1={init[row].image}
148image2={init[row].image2}
149
150/>
151</div>
152<p onClick={()=>clicki({
153id:row,
154image:init[row].image,
155image2:init[row].image2,
156item:init[row].item,
157writer:init[row].writer,
158price: init[row].price,
159off:init[row].off,
160description:init[row].description,
161author:init[row].author
162})} className="jjj" style={{margin:"16px 0 0 0",cursor:"pointer"}}>{init[row].item}</p>
163
164</div>   
165<span style={{color:"silver",marginTop:"0px"}}>{init[row].writer}</span>
166<h3 style={{color:"#B12704",margin:"10px 0 0 0px"}}><sup>₹</sup>{init[row].price} <span style={{color:"silver",fontSize:"16px",textDecoration:"line-through"}}>  ₹{Number(init[row].price)+Number(init[row].off)}  </span> <span style={{color:"silver",fontSize:"16px",textDecoration:"none",marginLeft:"10px"}}> save({init[row].off}) {100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0))}%</span></h3>
167<p style={{marginTop:"10px"}}> <DoneIcon style={{color:"#B12704"}}/> <span  style={{color:"#B12704"}}><b>Express</b></span> Get it by Tomorrow, <b> April {new Date().getDate()+1}</b> </p>
168
169<span style={{color:"silver",marginTop:"0px"}}>FREE Delivery over ₹499.Fulfilled by PerfectLegal.</span>
170</div>
171</Grid>
172
173</>
174))
175
176:
177//trenery Start
178
179props.categoryAction == "OlderFirst" ?
180
181Object.keys(init).map((row) => (
182
183<>
184<Grid className={classes.gridy} item lg={3} md={4} xs={12} style={{marginBottom:"20px"}}>
185<div style={{width:"300px"}}>
186<div style={{backgroundColor:"rgb(240, 240, 240)",height:"355px",width:"290px",overflow:"hidden"}}>
187
188<div style={{height:"50px",marginBottom:"8px"}}>
189{
190        ( 100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0)) ) > 0 ?
191         <Avatar style={{position:"relative",top:"6px",left:"20px",backgroundColor:"red"}}><span style={{fontSize:"12px"}}>-{100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0))}% </span></Avatar>
192         :
193         <></>
194}         
195</div>
196
197<div style={{position:"relative",right:"28px"}}>
198<ProductCarousel
199width="220px!important"
200image1={init[row].image}
201image2={init[row].image2}
202
203/>
204</div>
205<p onClick={()=>clicki({
206id:row,
207image:init[row].image,
208image2:init[row].image2,
209item:init[row].item,
210writer:init[row].writer,
211price: init[row].price,
212off:init[row].off,
213description:init[row].description,
214author:init[row].author
215})} className="jjj" style={{margin:"16px 0 0 0",cursor:"pointer"}}>{init[row].item}</p>
216
217</div>   
218<span style={{color:"silver",marginTop:"0px"}}>{init[row].writer}</span>
219<h3 style={{color:"#B12704",margin:"10px 0 0 0px"}}><sup>₹</sup>{init[row].price} <span style={{color:"silver",fontSize:"16px",textDecoration:"line-through"}}>  ₹{Number(init[row].price)+Number(init[row].off)}  </span> <span style={{color:"silver",fontSize:"16px",textDecoration:"none",marginLeft:"10px"}}> save({init[row].off}) {100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0))}%</span></h3>
220<p style={{marginTop:"10px"}}> <DoneIcon style={{color:"#B12704"}}/> <span  style={{color:"#B12704"}}><b>Express</b></span> Get it by Tomorrow, <b> April {new Date().getDate()+1}</b> </p>
221
222<span style={{color:"silver",marginTop:"0px"}}>FREE Delivery over ₹499.Fulfilled by PerfectLegal.</span>
223</div>
224</Grid>
225
226</>
227))
228
229:
230
231// TERNARY START
232
233props.categoryAction == "NewerFirst" ?
234
235
236
237
238
239Object.keys(init).reverse().map((row) => (
240
241<>
242<Grid className={classes.gridy} item lg={3} md={4} xs={12} style={{marginBottom:"20px"}}>
243<div style={{width:"300px"}}>
244<div style={{backgroundColor:"rgb(240, 240, 240)",height:"355px",width:"290px",overflow:"hidden"}}>
245
246<div style={{height:"50px",marginBottom:"8px"}}>
247{
248        ( 100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0)) ) > 0 ?
249         <Avatar style={{position:"relative",top:"6px",left:"20px",backgroundColor:"red"}}><span style={{fontSize:"12px"}}>-{100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0))}% </span></Avatar>
250         :
251         <></>
252}         
253</div>
254
255<div style={{position:"relative",right:"28px"}}>
256<ProductCarousel
257width="220px!important"
258image1={init[row].image}
259image2={init[row].image2}
260
261/>
262</div>
263<p onClick={()=>clicki({
264id:row,
265image:init[row].image,
266image2:init[row].image2,
267item:init[row].item,
268writer:init[row].writer,
269price: init[row].price,
270off:init[row].off,
271description:init[row].description,
272author:init[row].author
273})} className="jjj" style={{margin:"16px 0 0 0",cursor:"pointer"}}>{init[row].item}</p>
274
275</div>   
276<span style={{color:"silver",marginTop:"0px"}}>{init[row].writer}</span>
277<h3 style={{color:"#B12704",margin:"10px 0 0 0px"}}><sup>₹</sup>{init[row].price} <span style={{color:"silver",fontSize:"16px",textDecoration:"line-through"}}>  ₹{Number(init[row].price)+Number(init[row].off)}  </span> <span style={{color:"silver",fontSize:"16px",textDecoration:"none",marginLeft:"10px"}}> save({init[row].off}) {100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0))}%</span></h3>
278<p style={{marginTop:"10px"}}> <DoneIcon style={{color:"#B12704"}}/> <span  style={{color:"#B12704"}}><b>Express</b></span> Get it by Tomorrow, <b> April {new Date().getDate()+1}</b> </p>
279
280<span style={{color:"silver",marginTop:"0px"}}>FREE Delivery over ₹499.Fulfilled by PerfectLegal.</span>
281</div>
282</Grid>
283
284</>
285))
286
287
288
289
290:
291
292console.log("false")
293
294
295     :
296             "Loading Items..."
297        }
298
299
300</Grid>
301        </>
302    )
303}
304
Full Screen

ClothesCard.jsx

Source: ClothesCard.jsx Github

copy
1import React,{useEffect,useState} from 'react'
2import Avatar from '@material-ui/core/Avatar';
3import DoneIcon from '@material-ui/icons/Done'
4import Grid from "@material-ui/core/Grid"
5import firebaseDb from './firebase';
6import ProductCarousel from "./ProductCarousel"
7import {useHistory} from "react-router-dom";
8import {makeStyles} from '@material-ui/core/styles';
9
10
11
12const useStyles = makeStyles((theme) => ({
13    gridy: {
14    [theme.breakpoints.down('sm')]: {
15       margin:'20px 0 0 50%',
16       transform:"translate(-50%,0)"
17          },
18          "&:hover": {
19            transform:"scale(1.001)",
20            transition:"all 0.5s"
21          },
22        }
23  }));
24
25
26export default function ClothesCard(props) {
27    const classes = useStyles();
28
29    const history=useHistory();
30
31
32    const[init,upda]=useState({});
33
34
35    useEffect(()=>{
36        firebaseDb.child('Cothes').on("value",snapshot=>{
37      
38            if(snapshot.val() !=null){
39                    // upda({...snapshot.val()})
40                    // setOpen(true);
41                    
42                     upda({...snapshot.val()});                      
43            }
44    })
45
46},[])
47
48
49        const clicki=(a)=>{
50            a.valll="Cothes"
51            history.push("/insideproduct",a);
52        }
53
54
55    return (
56        <>
57        <Grid container style={{marginBottom:"50px",paddingLeft:"20px"}}>
58
59        
60
61       
62
63    
64
65{/* ternary start */}
66{
67            Object.keys(init) && Object.keys(init).length > 0 && Array.isArray(Object.keys(init))?
68
69
70
71            props.categoryAction == "LowHigh" ?
72
73
74//ternary start
75              Object.keys(init).sort((a, b) => init[a].price - init[b].price).map((row) => (
76
77                <>
78        <Grid className={classes.gridy} item lg={3} md={4} xs={6} style={{marginBottom:"20px"}}>
79        <div style={{width:"300px"}}>
80        <div style={{backgroundColor:"white",height:"355px",width:"290px",overflow:"hidden"}}>
81
82         <div style={{height:"50px",marginBottom:"8px"}}>
83         <Avatar style={{position:"relative",top:"6px",left:"20px",backgroundColor:"red"}}><span style={{fontSize:"12px"}}>-{100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0))}% </span></Avatar>
84         </div>
85
86        <div style={{position:"relative",right:"28px"}}>
87        <ProductCarousel
88        width="220px!important"
89        height="220px"
90     image1={init[row].image}
91     image2={init[row].image2}
92
93     />
94        </div>
95        <p onClick={()=>clicki({
96        id:row,
97        image:init[row].image,
98        image2:init[row].image2,
99        item:init[row].item,
100        sellers:init[row].sellers,
101        price: init[row].price,
102        off:init[row].off,
103        description:init[row].description,
104        about_seller:init[row].about_seller
105        })} className="jjj" style={{margin:"16px 0 0 0",cursor:"pointer"}}>{init[row].item}</p>
106
107       </div>   
108        <span style={{color:"silver",marginTop:"0px"}}>{init[row].sellers}</span>
109        <h3 style={{color:"#B12704",margin:"10px 0 0 0px"}}><sup>₹</sup>{init[row].price} <span style={{color:"silver",fontSize:"16px",textDecoration:"line-through"}}>  ₹{Number(init[row].price)+Number(init[row].off)}  </span> <span style={{color:"silver",fontSize:"16px",textDecoration:"none",marginLeft:"10px"}}> save({init[row].off}) {100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0))}%</span></h3>
110<p style={{marginTop:"10px"}}> <DoneIcon style={{color:"#B12704"}}/> <span  style={{color:"#B12704"}}><b>Express</b></span> Get it by Tomorrow, <b> March {new Date().getDate()+1}</b> </p>
111
112    <span style={{color:"silver",marginTop:"0px"}}>FREE Delivery over ₹499.Fulfilled by PerfectLegal.</span>
113        </div>
114        </Grid>
115
116                </>
117              ))
118
119
120        :
121
122//trenery Start
123
124props.categoryAction == "HighLow" ?
125
126        Object.keys(init).sort((a, b) => init[a].price - init[b].price).reverse().map((row) => (
127
128<>
129<Grid className={classes.gridy} item lg={3} md={4} xs={6} style={{marginBottom:"20px"}}>
130<div style={{width:"300px"}}>
131<div style={{backgroundColor:"white",height:"355px",width:"290px",overflow:"hidden"}}>
132
133<div style={{height:"50px",marginBottom:"8px"}}>
134<Avatar style={{position:"relative",top:"6px",left:"20px",backgroundColor:"red"}}><span style={{fontSize:"12px"}}>-{100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0))}% </span></Avatar>
135</div>
136
137<div style={{position:"relative",right:"28px"}}>
138<ProductCarousel
139width="220px!important"
140height="220px"
141image1={init[row].image}
142image2={init[row].image2}
143
144/>
145</div>
146<p onClick={()=>clicki({
147id:row,
148image:init[row].image,
149image2:init[row].image2,
150item:init[row].item,
151sellers:init[row].sellers,
152price: init[row].price,
153off:init[row].off,
154description:init[row].description,
155about_seller:init[row].about_seller
156})} className="jjj" style={{margin:"16px 0 0 0",cursor:"pointer"}}>{init[row].item}</p>
157
158</div>   
159<span style={{color:"silver",marginTop:"0px"}}>{init[row].sellers}</span>
160<h3 style={{color:"#B12704",margin:"10px 0 0 0px"}}><sup>₹</sup>{init[row].price} <span style={{color:"silver",fontSize:"16px",textDecoration:"line-through"}}>  ₹{Number(init[row].price)+Number(init[row].off)}  </span> <span style={{color:"silver",fontSize:"16px",textDecoration:"none",marginLeft:"10px"}}> save({init[row].off}) {100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0))}%</span></h3>
161<p style={{marginTop:"10px"}}> <DoneIcon style={{color:"#B12704"}}/> <span  style={{color:"#B12704"}}><b>Express</b></span> Get it by Tomorrow, <b> March {new Date().getDate()+1}</b> </p>
162
163<span style={{color:"silver",marginTop:"0px"}}>FREE Delivery over ₹499.Fulfilled by PerfectLegal.</span>
164</div>
165</Grid>
166
167</>
168))
169
170:
171//trenery Start
172
173props.categoryAction == "OlderFirst" ?
174
175Object.keys(init).map((row) => (
176
177<>
178<Grid className={classes.gridy} item lg={3} md={4} xs={6} style={{marginBottom:"20px"}}>
179<div style={{width:"300px"}}>
180<div style={{backgroundColor:"white",height:"355px",width:"290px",overflow:"hidden"}}>
181
182<div style={{height:"50px",marginBottom:"8px"}}>
183<Avatar style={{position:"relative",top:"6px",left:"20px",backgroundColor:"red"}}><span style={{fontSize:"12px"}}>-{100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0))}% </span></Avatar>
184</div>
185
186<div style={{position:"relative",right:"28px"}}>
187<ProductCarousel
188width="220px!important"
189height="220px"
190image1={init[row].image}
191image2={init[row].image2}
192
193/>
194</div>
195<p onClick={()=>clicki({
196id:row,
197image:init[row].image,
198image2:init[row].image2,
199item:init[row].item,
200sellers:init[row].sellers,
201price: init[row].price,
202off:init[row].off,
203description:init[row].description,
204about_seller:init[row].about_seller
205})} className="jjj" style={{margin:"16px 0 0 0",cursor:"pointer"}}>{init[row].item}</p>
206
207</div>   
208<span style={{color:"silver",marginTop:"0px"}}>{init[row].sellers}</span>
209<h3 style={{color:"#B12704",margin:"10px 0 0 0px"}}><sup>₹</sup>{init[row].price} <span style={{color:"silver",fontSize:"16px",textDecoration:"line-through"}}>  ₹{Number(init[row].price)+Number(init[row].off)}  </span> <span style={{color:"silver",fontSize:"16px",textDecoration:"none",marginLeft:"10px"}}> save({init[row].off}) {100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0))}%</span></h3>
210<p style={{marginTop:"10px"}}> <DoneIcon style={{color:"#B12704"}}/> <span  style={{color:"#B12704"}}><b>Express</b></span> Get it by Tomorrow, <b> March {new Date().getDate()+1}</b> </p>
211
212<span style={{color:"silver",marginTop:"0px"}}>FREE Delivery over ₹499.Fulfilled by PerfectLegal.</span>
213</div>
214</Grid>
215
216</>
217))
218
219:
220
221// TERNARY START
222
223props.categoryAction == "NewerFirst" ?
224
225
226
227
228
229Object.keys(init).reverse().map((row) => (
230
231<>
232<Grid className={classes.gridy} item lg={3} md={4} xs={6} style={{marginBottom:"20px"}}>
233<div style={{width:"300px"}}>
234<div style={{backgroundColor:"white",height:"355px",width:"290px",overflow:"hidden"}}>
235
236<div style={{height:"50px",marginBottom:"8px"}}>
237<Avatar style={{position:"relative",top:"6px",left:"20px",backgroundColor:"red"}}><span style={{fontSize:"12px"}}>-{100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0))}% </span></Avatar>
238</div>
239
240<div style={{position:"relative",right:"28px"}}>
241<ProductCarousel
242width="220px!important"
243height="220px"
244image1={init[row].image}
245image2={init[row].image2}
246
247/>
248</div>
249<p onClick={()=>clicki({
250id:row,
251image:init[row].image,
252image2:init[row].image2,
253item:init[row].item,
254sellers:init[row].sellers,
255price: init[row].price,
256off:init[row].off,
257description:init[row].description,
258about_seller:init[row].about_seller
259})} className="jjj" style={{margin:"16px 0 0 0",cursor:"pointer"}}>{init[row].item}</p>
260
261</div>   
262<span style={{color:"silver",marginTop:"0px"}}>{init[row].sellers}</span>
263<h3 style={{color:"#B12704",margin:"10px 0 0 0px"}}><sup>₹</sup>{init[row].price} <span style={{color:"silver",fontSize:"16px",textDecoration:"line-through"}}>  ₹{Number(init[row].price)+Number(init[row].off)}  </span> <span style={{color:"silver",fontSize:"16px",textDecoration:"none",marginLeft:"10px"}}> save({init[row].off}) {100-((Number(init[row].price)/(Number(init[row].price)+Number(init[row].off))*100).toFixed(0))}%</span></h3>
264<p style={{marginTop:"10px"}}> <DoneIcon style={{color:"#B12704"}}/> <span  style={{color:"#B12704"}}><b>Express</b></span> Get it by Tomorrow, <b> March {new Date().getDate()+1}</b> </p>
265
266<span style={{color:"silver",marginTop:"0px"}}>FREE Delivery over ₹499.Fulfilled by PerfectLegal.</span>
267</div>
268</Grid>
269
270</>
271))
272
273
274
275
276:
277
278
279alert("select some category")
280
281
282     :
283
284     "Loading Items..."
285
286        }
287
288
289</Grid>
290        </>
291    )
292}
293
Full Screen

init-events.js

Source: init-events.js Github

copy
1description("This tests the init functions for all the event DOM classes that have them.");
2
3function testInitEvent(prefix, argumentString)
4{
5    var event = document.createEvent(prefix + "Event");
6    var initExpression = "event.init" + prefix + "Event(" + argumentString + ")";
7    eval(initExpression);
8    return event;
9}
10
11var event = document.createEvent("Event");
12
13event.initEvent("type", false, false);
14
15shouldBe("testInitEvent('', '\"a\", false, false').type", "'a'");
16shouldBe("testInitEvent('', 'null, false, false').type", "'null'");
17shouldBe("testInitEvent('', '\"a\", false, false').bubbles", "false");
18shouldBe("testInitEvent('', '\"a\", true, false').bubbles", "true");
19shouldBe("testInitEvent('', '\"a\", false, false').cancelable", "false");
20shouldBe("testInitEvent('', '\"a\", false, true').cancelable", "true");
21
22shouldBe("testInitEvent('Keyboard', '\"a\", false, false, window, \"b\", 1001, false, false, false, false, false').type", "'a'");
23shouldBe("testInitEvent('Keyboard', 'null, false, false, window, \"b\", 1001, false, false, false, false, false').type", "'null'");
24shouldBe("testInitEvent('Keyboard', '\"a\", false, false, window, \"b\", 1001, false, false, false, false, false').bubbles", "false");
25shouldBe("testInitEvent('Keyboard', '\"a\", true, false, window, \"b\", 1001, false, false, false, false, false').bubbles", "true");
26shouldBe("testInitEvent('Keyboard', '\"a\", false, false, window, \"b\", 1001, false, false, false, false, false').cancelable", "false");
27shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').cancelable", "true");
28shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').view", "window");
29shouldBe("testInitEvent('Keyboard', '\"a\", false, true, null, \"b\", 1001, false, false, false, false, false').view", "null");
30shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').keyIdentifier", "'b'");
31shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, null, 1001, false, false, false, false, false').keyIdentifier", "'null'");
32shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').keyLocation", "1001");
33shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').ctrlKey", "false");
34shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, true, false, false, false, false').ctrlKey", "true");
35shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').altKey", "false");
36shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, true, false, false, false').altKey", "true");
37shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').shiftKey", "false");
38shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, true, false, false').shiftKey", "true");
39shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').metaKey", "false");
40shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, true, false').metaKey", "true");
41shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').altGraphKey", "false");
42shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, true').altGraphKey", "true");
43shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, true').detail", "0");
44shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').keyCode", "0");
45shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').charCode", "0");
46shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').layerX", "0");
47shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').layerY", "0");
48shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').pageX", "0");
49shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').pageY", "0");
50shouldBe("testInitEvent('Keyboard', '\"a\", false, true, window, \"b\", 1001, false, false, false, false, false').which", "0");
51
52shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, null').type", "'a'");
53shouldBe("testInitEvent('Message', 'null, false, false, \"b\", \"c\", \"d\", window, null').type", "'null'");
54shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, null').bubbles", "false");
55shouldBe("testInitEvent('Message', '\"a\", true, false, \"b\", \"c\", \"d\", window, null').bubbles", "true");
56shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, null').cancelable", "false");
57shouldBe("testInitEvent('Message', '\"a\", false, true, \"b\", \"c\", \"d\", window, null').cancelable", "true");
58shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, null').data", "'b'");
59shouldBe("testInitEvent('Message', '\"a\", false, false, null, \"c\", \"d\", window, null').data", "null");
60shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, null').origin", "'c'");
61shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", null, \"d\", window, null').origin", "'null'");
62shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, null').lastEventId", "'d'");
63shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", null, window, null').lastEventId", "'null'");
64shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", window, null').source", "window");
65shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", null, null').source", "null");
66var channel = new MessageChannel;
67var channelArray = [channel.port1, channel.port2];
68shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", null, channelArray').ports[0]", "channel.port1");
69shouldBe("testInitEvent('Message', '\"a\", false, false, \"b\", \"c\", \"d\", null, channelArray').ports[1]", "channel.port2");
70
71shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').type", "'a'");
72shouldBe("testInitEvent('Mouse', 'null, false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').type", "'null'");
73shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').bubbles", "false");
74shouldBe("testInitEvent('Mouse', '\"a\", true, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').bubbles", "true");
75shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').cancelable", "false");
76shouldBe("testInitEvent('Mouse', '\"a\", false, true, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').cancelable", "true");
77shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').view", "window");
78shouldBe("testInitEvent('Mouse', '\"a\", false, false, null, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').view", "null");
79shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').detail", "1001");
80shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').screenX", "1002");
81shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').screenY", "1003");
82shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').clientX", "1004");
83shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').clientY", "1005");
84shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').ctrlKey", "false");
85shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, true, false, false, false, 1006, null').ctrlKey", "true");
86shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').altKey", "false");
87shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, true, false, false, 1006, null').altKey", "true");
88shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').shiftKey", "false");
89shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, true, false, 1006, null').shiftKey", "true");
90shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').metaKey", "false");
91shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, true, 1006, null').metaKey", "true");
92shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').button", "1006");
93shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').relatedTarget", "null");
94shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, document').relatedTarget", "document");
95shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').offsetX", "1004");
96shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').offsetY", "1005");
97shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').x", "1004");
98shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').y", "1005");
99shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').fromElement", "null");
100shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, document').fromElement", "document");
101shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').toElement", "null");
102shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').dataTransfer", "null");
103shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').keyCode", "0");
104shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').charCode", "0");
105shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').layerX", "1004");
106shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').layerY", "1005");
107shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').pageX", "1004");
108shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').pageY", "1005");
109shouldBe("testInitEvent('Mouse', '\"a\", false, false, window, 1001, 1002, 1003, 1004, 1005, false, false, false, false, 1006, null').which", "1007");
110
111shouldBe("testInitEvent('Mutation', '\"a\", false, false, null, \"b\", \"c\", \"d\", 1001').type", "'a'");
112shouldBe("testInitEvent('Mutation', 'null, false, false, null, \"b\", \"c\", \"d\", 1001').type", "'null'");
113shouldBe("testInitEvent('Mutation', '\"a\", false, false, null, \"b\", \"c\", \"d\", 1001').bubbles", "false");
114shouldBe("testInitEvent('Mutation', '\"a\", true, false, null, \"b\", \"c\", \"d\", 1001').bubbles", "true");
115shouldBe("testInitEvent('Mutation', '\"a\", false, false, null, \"b\", \"c\", \"d\", 1001').cancelable", "false");
116shouldBe("testInitEvent('Mutation', '\"a\", false, true, null, \"b\", \"c\", \"d\", 1001').cancelable", "true");
117shouldBe("testInitEvent('Mutation', '\"a\", false, false, null, \"b\", \"c\", \"d\", 1001').relatedNode", "null");
118shouldBe("testInitEvent('Mutation', '\"a\", false, false, document, \"b\", \"c\", \"d\", 1001').relatedNode", "document");
119shouldBe("testInitEvent('Mutation', '\"a\", false, false, null, \"b\", \"c\", \"d\", 1001').prevValue", "'b'");
120shouldBe("testInitEvent('Mutation', '\"a\", false, false, null, null, \"c\", \"d\", 1001').prevValue", "'null'");
121shouldBe("testInitEvent('Mutation', '\"a\", false, false, null, \"b\", \"c\", \"d\", 1001').newValue", "'c'");
122shouldBe("testInitEvent('Mutation', '\"a\", false, false, null, \"b\", null, \"d\", 1001').newValue", "'null'");
123shouldBe("testInitEvent('Mutation', '\"a\", false, false, null, \"b\", \"c\", \"d\", 1001').attrName", "'d'");
124shouldBe("testInitEvent('Mutation', '\"a\", false, false, null, \"b\", \"c\", null, 1001').attrName", "'null'");
125shouldBe("testInitEvent('Mutation', '\"a\", false, false, null, \"b\", \"c\", \"d\", 1001').attrChange", "1001");
126
127// initOverflowEvent has an interface that has an design that's inconsistent with the init functions from other events.
128shouldBe("testInitEvent('Overflow', '1001, false, false').type", "'overflowchanged'");
129shouldBe("testInitEvent('Overflow', '1001, false, false').bubbles", "false");
130shouldBe("testInitEvent('Overflow', '1001, false, false').cancelable", "false");
131shouldBe("testInitEvent('Overflow', '1001, false, false').orient", "1001");
132shouldBe("testInitEvent('Overflow', '1001, false, false').horizontalOverflow", "false");
133shouldBe("testInitEvent('Overflow', '1001, true, false').horizontalOverflow", "true");
134shouldBe("testInitEvent('Overflow', '1001, false, false').verticalOverflow", "false");
135shouldBe("testInitEvent('Overflow', '1001, false, true').verticalOverflow", "true");
136
137shouldBe("testInitEvent('Progress', '\"a\", false, false, false, 1001, 1002').type", "'a'");
138shouldBe("testInitEvent('Progress', 'null, false, false, false, 1001, 1002').type", "'null'");
139shouldBe("testInitEvent('Progress', '\"a\", false, false, false, 1001, 1002').bubbles", "false");
140shouldBe("testInitEvent('Progress', '\"a\", true, false, false, 1001, 1002').bubbles", "true");
141shouldBe("testInitEvent('Progress', '\"a\", false, false, false, 1001, 1002').cancelable", "false");
142shouldBe("testInitEvent('Progress', '\"a\", false, true, false, 1001, 1002').cancelable", "true");
143shouldBe("testInitEvent('Progress', '\"a\", false, false, false, 1001, 1002').lengthComputable", "false");
144shouldBe("testInitEvent('Progress', '\"a\", false, false, true, 1001, 1002').lengthComputable", "true");
145shouldBe("testInitEvent('Progress', '\"a\", false, false, false, 1001, 1002').loaded", "1001");
146shouldBe("testInitEvent('Progress', '\"a\", false, false, false, 1001, 1002').total", "1002");
147
148shouldBe("testInitEvent('Storage', '\"a\", false, false, \"b\", \"c\", \"d\", \"e\"').type", "'a'");
149shouldBe("testInitEvent('Storage', 'null, false, false, \"b\", \"c\", \"d\", \"e\"').type", "'null'");
150shouldBe("testInitEvent('Storage', '\"a\", false, false, \"b\", \"c\", \"d\", \"e\"').bubbles", "false");
151shouldBe("testInitEvent('Storage', '\"a\", true, false, \"b\", \"c\", \"d\", \"e\"').bubbles", "true");
152shouldBe("testInitEvent('Storage', '\"a\", false, false, \"b\", \"c\", \"d\", \"e\"').cancelable", "false");
153shouldBe("testInitEvent('Storage', '\"a\", false, true, \"b\", \"c\", \"d\", \"e\"').cancelable", "true");
154shouldBe("testInitEvent('Storage', '\"a\", false, false, \"b\", \"c\", \"d\", \"e\"').key", "'b'");
155shouldBe("testInitEvent('Storage', '\"a\", false, false, null, \"c\", \"d\", \"e\"').key", "'null'");
156shouldBe("testInitEvent('Storage', '\"a\", false, false, \"b\", \"c\", \"d\", \"e\"').oldValue", "'c'");
157shouldBe("testInitEvent('Storage', '\"a\", false, false, \"b\", null, \"d\", \"e\"').oldValue", "null");
158shouldBe("testInitEvent('Storage', '\"a\", false, false, \"b\", \"c\", \"d\", \"e\"').newValue", "'d'");
159shouldBe("testInitEvent('Storage', '\"a\", false, false, \"b\", \"c\", null, \"e\"').newValue", "null");
160shouldBe("testInitEvent('Storage', '\"a\", false, false, \"b\", \"c\", \"d\", \"e\"').url", "'e'");
161shouldBe("testInitEvent('Storage', '\"a\", false, false, \"b\", \"c\", \"d\", null').url", "'null'");
162
163shouldBe("testInitEvent('Text', '\"a\", false, false, window, \"b\"').type", "'a'");
164shouldBe("testInitEvent('Text', 'null, false, false, window, \"b\"').type", "'null'");
165shouldBe("testInitEvent('Text', '\"a\", false, false, window, \"b\"').bubbles", "false");
166shouldBe("testInitEvent('Text', '\"a\", true, false, window, \"b\"').bubbles", "true");
167shouldBe("testInitEvent('Text', '\"a\", false, false, window, \"b\"').cancelable", "false");
168shouldBe("testInitEvent('Text', '\"a\", false, true, window, \"b\"').cancelable", "true");
169shouldBe("testInitEvent('Text', '\"a\", false, false, window, \"b\"').view", "window");
170shouldBe("testInitEvent('Text', '\"a\", false, false, null, \"b\"').view", "null");
171shouldBe("testInitEvent('Text', '\"a\", false, false, window, \"b\"').data", "'b'");
172shouldBe("testInitEvent('Text', '\"a\", false, false, window, null').data", "'null'");
173shouldBe("testInitEvent('Text', '\"a\", false, false, window, \"b\"').detail", "0");
174shouldBe("testInitEvent('Text', '\"a\", false, false, window, \"b\"').keyCode", "0");
175shouldBe("testInitEvent('Text', '\"a\", false, false, window, \"b\"').charCode", "0");
176shouldBe("testInitEvent('Text', '\"a\", false, false, window, \"b\"').layerX", "0");
177shouldBe("testInitEvent('Text', '\"a\", false, false, window, \"b\"').layerY", "0");
178shouldBe("testInitEvent('Text', '\"a\", false, false, window, \"b\"').pageX", "0");
179shouldBe("testInitEvent('Text', '\"a\", false, false, window, \"b\"').pageY", "0");
180shouldBe("testInitEvent('Text', '\"a\", false, false, window, \"b\"').which", "0");
181
182shouldBe("testInitEvent('UI', '\"a\", false, false, window, 1001').type", "'a'");
183shouldBe("testInitEvent('UI', 'null, false, false, window, 1001').type", "'null'");
184shouldBe("testInitEvent('UI', '\"a\", false, false, window, 1001').bubbles", "false");
185shouldBe("testInitEvent('UI', '\"a\", true, false, window, 1001').bubbles", "true");
186shouldBe("testInitEvent('UI', '\"a\", false, false, window, 1001').cancelable", "false");
187shouldBe("testInitEvent('UI', '\"a\", false, true, window, 1001').cancelable", "true");
188shouldBe("testInitEvent('UI', '\"a\", false, false, window, 1001').view", "window");
189shouldBe("testInitEvent('UI', '\"a\", false, false, null, 1001').view", "null");
190shouldBe("testInitEvent('UI', '\"a\", false, false, window, 1001').detail", "1001");
191shouldBe("testInitEvent('UI', '\"a\", false, false, window, 1001').keyCode", "0");
192shouldBe("testInitEvent('UI', '\"a\", false, false, window, 1001').charCode", "0");
193shouldBe("testInitEvent('UI', '\"a\", false, false, window, 1001').layerX", "0");
194shouldBe("testInitEvent('UI', '\"a\", false, false, window, 1001').layerY", "0");
195shouldBe("testInitEvent('UI', '\"a\", false, false, window, 1001').pageX", "0");
196shouldBe("testInitEvent('UI', '\"a\", false, false, window, 1001').pageY", "0");
197shouldBe("testInitEvent('UI', '\"a\", false, false, window, 1001').which", "0");
198
199shouldBe("testInitEvent('WebKitAnimation', '\"a\", false, false, \"b\", 1001').type", "'a'");
200shouldBe("testInitEvent('WebKitAnimation', 'null, false, false, \"b\", 1001').type", "'null'");
201shouldBe("testInitEvent('WebKitAnimation', '\"a\", false, false, \"b\", 1001').bubbles", "false");
202shouldBe("testInitEvent('WebKitAnimation', '\"a\", true, false, \"b\", 1001').bubbles", "true");
203shouldBe("testInitEvent('WebKitAnimation', '\"a\", false, false, \"b\", 1001').cancelable", "false");
204shouldBe("testInitEvent('WebKitAnimation', '\"a\", false, true, \"b\", 1001').cancelable", "true");
205shouldBe("testInitEvent('WebKitAnimation', '\"a\", false, false, \"b\", 1001').animationName", "'b'");
206shouldBe("testInitEvent('WebKitAnimation', '\"a\", false, false, null, 1001').animationName", "'null'");
207shouldBe("testInitEvent('WebKitAnimation', '\"a\", false, false, \"b\", 1001').elapsedTime", "1001");
208
209shouldBe("testInitEvent('WebKitTransition', '\"a\", false, false, \"b\", 1001').type", "'a'");
210shouldBe("testInitEvent('WebKitTransition', 'null, false, false, \"b\", 1001').type", "'null'");
211shouldBe("testInitEvent('WebKitTransition', '\"a\", false, false, \"b\", 1001').bubbles", "false");
212shouldBe("testInitEvent('WebKitTransition', '\"a\", true, false, \"b\", 1001').bubbles", "true");
213shouldBe("testInitEvent('WebKitTransition', '\"a\", false, false, \"b\", 1001').cancelable", "false");
214shouldBe("testInitEvent('WebKitTransition', '\"a\", false, true, \"b\", 1001').cancelable", "true");
215shouldBe("testInitEvent('WebKitTransition', '\"a\", false, false, \"b\", 1001').propertyName", "'b'");
216shouldBe("testInitEvent('WebKitTransition', '\"a\", false, false, null, 1001').propertyName", "'null'");
217shouldBe("testInitEvent('WebKitTransition', '\"a\", false, false, \"b\", 1001').elapsedTime", "1001");
218
219// WheelEvent has no init function yet; roughly speaking, we are waiting for that part of DOM 3 to stabilize.
220
221var successfullyParsed = true;
222
Full Screen

api_gen.bzl

Source: api_gen.bzl Github

copy
1"""Targets for generating TensorFlow Python API __init__.py files."""
2
3# keep sorted
4TENSORFLOW_API_INIT_FILES = [
5    # BEGIN GENERATED FILES
6    "__init__.py",
7    "app/__init__.py",
8    "bitwise/__init__.py",
9    "compat/__init__.py",
10    "data/__init__.py",
11    "debugging/__init__.py",
12    "distributions/__init__.py",
13    "distributions/bijectors/__init__.py",
14    "dtypes/__init__.py",
15    "errors/__init__.py",
16    "feature_column/__init__.py",
17    "gfile/__init__.py",
18    "graph_util/__init__.py",
19    "image/__init__.py",
20    "io/__init__.py",
21    "initializers/__init__.py",
22    "keras/__init__.py",
23    "keras/activations/__init__.py",
24    "keras/applications/__init__.py",
25    "keras/applications/densenet/__init__.py",
26    "keras/applications/inception_resnet_v2/__init__.py",
27    "keras/applications/inception_v3/__init__.py",
28    "keras/applications/mobilenet/__init__.py",
29    "keras/applications/nasnet/__init__.py",
30    "keras/applications/resnet50/__init__.py",
31    "keras/applications/vgg16/__init__.py",
32    "keras/applications/vgg19/__init__.py",
33    "keras/applications/xception/__init__.py",
34    "keras/backend/__init__.py",
35    "keras/callbacks/__init__.py",
36    "keras/constraints/__init__.py",
37    "keras/datasets/__init__.py",
38    "keras/datasets/boston_housing/__init__.py",
39    "keras/datasets/cifar10/__init__.py",
40    "keras/datasets/cifar100/__init__.py",
41    "keras/datasets/fashion_mnist/__init__.py",
42    "keras/datasets/imdb/__init__.py",
43    "keras/datasets/mnist/__init__.py",
44    "keras/datasets/reuters/__init__.py",
45    "keras/estimator/__init__.py",
46    "keras/initializers/__init__.py",
47    "keras/layers/__init__.py",
48    "keras/losses/__init__.py",
49    "keras/metrics/__init__.py",
50    "keras/models/__init__.py",
51    "keras/optimizers/__init__.py",
52    "keras/preprocessing/__init__.py",
53    "keras/preprocessing/image/__init__.py",
54    "keras/preprocessing/sequence/__init__.py",
55    "keras/preprocessing/text/__init__.py",
56    "keras/regularizers/__init__.py",
57    "keras/utils/__init__.py",
58    "keras/wrappers/__init__.py",
59    "keras/wrappers/scikit_learn/__init__.py",
60    "layers/__init__.py",
61    "linalg/__init__.py",
62    "logging/__init__.py",
63    "losses/__init__.py",
64    "manip/__init__.py",
65    "math/__init__.py",
66    "metrics/__init__.py",
67    "nn/__init__.py",
68    "nn/rnn_cell/__init__.py",
69    "profiler/__init__.py",
70    "python_io/__init__.py",
71    "quantization/__init__.py",
72    "resource_loader/__init__.py",
73    "strings/__init__.py",
74    "saved_model/__init__.py",
75    "saved_model/builder/__init__.py",
76    "saved_model/constants/__init__.py",
77    "saved_model/loader/__init__.py",
78    "saved_model/main_op/__init__.py",
79    "saved_model/signature_constants/__init__.py",
80    "saved_model/signature_def_utils/__init__.py",
81    "saved_model/tag_constants/__init__.py",
82    "saved_model/utils/__init__.py",
83    "sets/__init__.py",
84    "sparse/__init__.py",
85    "spectral/__init__.py",
86    "summary/__init__.py",
87    "sysconfig/__init__.py",
88    "test/__init__.py",
89    "train/__init__.py",
90    "train/queue_runner/__init__.py",
91    "user_ops/__init__.py",
92    # END GENERATED FILES
93]
94
95# keep sorted
96ESTIMATOR_API_INIT_FILES = [
97    # BEGIN GENERATED ESTIMATOR FILES
98    "__init__.py",
99    "estimator/__init__.py",
100    "estimator/export/__init__.py",
101    "estimator/inputs/__init__.py",
102    # END GENERATED ESTIMATOR FILES
103]
104
105# Creates a genrule that generates a directory structure with __init__.py
106# files that import all exported modules (i.e. modules with tf_export
107# decorators).
108#
109# Args:
110#   name: name of genrule to create.
111#   output_files: List of __init__.py files that should be generated.
112#     This list should include file name for every module exported using
113#     tf_export. For e.g. if an op is decorated with
114#     @tf_export('module1.module2', 'module3'). Then, output_files should
115#     include module1/module2/__init__.py and module3/__init__.py.
116#   root_init_template: Python init file that should be used as template for
117#     root __init__.py file. "# API IMPORTS PLACEHOLDER" comment inside this
118#     template will be replaced with root imports collected by this genrule.
119#   srcs: genrule sources. If passing root_init_template, the template file
120#     must be included in sources.
121#   api_name: Name of the project that you want to generate API files for
122#     (e.g. "tensorflow" or "estimator").
123#   package: Python package containing the @tf_export decorators you want to
124#     process
125#   package_dep: Python library target containing your package.
126
127def gen_api_init_files(
128        name,
129        output_files = TENSORFLOW_API_INIT_FILES,
130        root_init_template = None,
131        srcs = [],
132        api_name = "tensorflow",
133        package = "tensorflow.python",
134        package_dep = "//tensorflow/python:no_contrib"):
135    root_init_template_flag = ""
136    if root_init_template:
137      root_init_template_flag = "--root_init_template=$(location " + root_init_template + ")"
138
139    api_gen_binary_target = "create_" + package + "_api"
140    native.py_binary(
141        name = "create_" + package + "_api",
142        srcs = ["//tensorflow/tools/api/generator:create_python_api.py"],
143        main = "//tensorflow/tools/api/generator:create_python_api.py",
144        srcs_version = "PY2AND3",
145        visibility = ["//visibility:public"],
146        deps = [
147            package_dep,
148            "//tensorflow/tools/api/generator:doc_srcs",
149        ],
150    )
151
152    native.genrule(
153        name = name,
154        outs = output_files,
155        cmd = (
156            "$(location :" + api_gen_binary_target + ") " +
157            root_init_template_flag + " --apidir=$(@D) --apiname=" + api_name + " --package=" + package + " $(OUTS)"),
158        srcs = srcs,
159        tools = [":" + api_gen_binary_target ],
160        visibility = ["//tensorflow:__pkg__"],
161    )
162
Full Screen

class_test.py

Source: class_test.py Github

copy
1class Place(object):
2    def __init__(self, place_name, place_type=None):
3        self.name = place_name
4        self.type = place_type
5
6
7class Dining(Place):
8    def __init__(self, dining_name, place_type="dining"):
9        super().__init__(dining_name)
10        self.type = place_type
11
12
13class Restaurant(Dining):
14    def __init__(self, restaurant_name):
15        super().__init__(restaurant_name)
16        self.type = "restaurant"
17
18
19class Cafe(Dining):
20    def __init__(self, cafe_name):
21        super().__init__(cafe_name)
22        self.type = "cafe"
23
24
25class Takeout(Dining):
26    def __init__(self, meal_takeaway_name):
27        super().__init__(meal_takeaway_name)
28        self.type = "meal_takeaway"
29
30
31class Bakery(Dining):
32    def __init__(self, bakery_name):
33        super().__init__(bakery_name)
34        self.type = "bakery"
35
36
37class Nightlife(Place):
38    def __init__(self, nightlife_name, place_type="nightlife"):
39        super().__init__(nightlife_name)
40        self.type = place_type
41
42
43class Nightclub(Nightlife):
44    def __init__(self, night_club_name):
45        super().__init__(night_club_name)
46        self.type = "night_club"
47
48
49class Bar(Nightlife):
50    def __init__(self, bar_name):
51        super().__init__(bar_name)
52        self.type = "bar"
53
54
55class Art(Place):
56    def __init__(self, art_name):
57        super().__init__(art_name)
58
59
60class Gallery(Place):
61    def __init__(self, gallery_name):
62        super().__init__(gallery_name)
63        self.type = "art_gallery"
64
65
66class Museum(Place):
67    def __init__(self, museum_name):
68        super().__init__(museum_name)
69        self.type = "museum"
70
71
72class MovieTheater(Place):
73    def __init__(self, theater_name):
74        super().__init__(theater_name)
75        self.type = "movie_theater"
76
77
78class Religious(Place):
79    def __init__(self, religious_name, place_type="religious"):
80        super().__init__(religious_name)
81        self.type = place_type
82
83
84class Church(Religious):
85    def __init__(self, church_name):
86        super().__init__(church_name)
87        self.type = "church"
88
89
90class Temple(Religious):
91    def __init__(self, temple_name):
92        super().__init__(temple_name)
93        self.type = "hindu_temple"
94
95
96class Mosque(Religious):
97    def __init__(self, mosque_name):
98        super().__init__(mosque_name)
99        self.type = "mosque"
100
101
102class Synagogue(Religious):
103    def __init__(self, synagogue_name):
104        super().__init__(synagogue_name)
105        self.type = "synagogue"
106
107
108class Transport(Place):
109    def __init__(self, transportation_name, place_type="transportation"):
110        super().__init__(transportation_name)
111        self.type = place_type
112
113
114class Parking(Transport):
115    def __init__(self, parking_name):
116        super().__init__(parking_name)
117        self.type = "parking"
118
119
120class BusStation(Transport):
121    def __init__(self, bus_station_name):
122        super().__init__(bus_station_name)
123        self.type = "bus_station"
124
125
126class SubwayStation(Transport):
127    def __init__(self, subway_station_name):
128        super().__init__(subway_station_name)
129        self.type = "subway_station"
130
131
132class Athletic(Place):
133    def __init__(self, athletic_name, place_type="athletic"):
134        super().__init__(athletic_name)
135        self.type = place_type
136
137
138class BowlingAlley(Athletic):
139    def __init__(self, bowling_alley_name):
140        super().__init__(bowling_alley_name)
141        self.type = "bowling_alley"
142
143
144class Stadium(Athletic):
145    def __init__(self, stadium_name):
146        super().__init__(stadium_name)
147        self.type = "stadium"
148
149
150class Outdoor(Place):
151    def __init__(self, park_name, place_type="park"):
152        super().__init__(park_name)
153        self.type = place_type
154
155
156class AmusementPark(Outdoor):
157    def __init__(self, amusement_park_name):
158        super().__init__(amusement_park_name)
159        self.type = "amusement_park"
160
161
162class Aquarium(Outdoor):
163    def __init__(self, aquarium_name):
164        super().__init__(aquarium_name)
165        self.type = "aquarium"
166
167
168class Zoo(Outdoor):
169    def __init__(self, zoo_name):
170        super().__init__(zoo_name)
171        self.type = "zoo"
172
173
174class Park(Outdoor):
175    def __init__(self, park_name):
176        super().__init__(park_name)
177        self.type = "park"
178
179
180places = [Church("Churches"),
181          Temple("Hindu Temple"),
182          Mosque("Mosques"),
183          Synagogue("Synagogue"),
184
185          AmusementPark("Amusement Parks"),
186          Aquarium("Aquariums"),
187          Park("Parks"),
188          Zoo("Zoos"),
189
190          Nightclub("Night Clubs"),
191          Bar("Bars"),
192
193          Gallery("Art Galleries"),
194          MovieTheater("Movie Theaters"),
195          Museum("Museums"),
196
197          Bakery("Bakeries"),
198          Restaurant("Restaurant"),
199          Cafe("Cafes"),
200          Takeout("Takeout Restaurants"),
201
202          BowlingAlley("Bowling Alleys"),
203          Stadium("Stadiums"),
204
205          Parking("Parking"),
206          BusStation("Bus Stations"),
207          SubwayStation("Subway Stations")
208          ]
209
210print(places)
Full Screen

BUILD

Source: BUILD Github

copy
1# Description:
2#   Contains the Keras API (internal TensorFlow version).
3#   Note that tf.contrib.keras has been deprecated in favor of tf.keras.
4
5licenses(["notice"])  # Apache 2.0
6
7exports_files(["LICENSE"])
8
9package(default_visibility = ["//tensorflow:__subpackages__"])
10
11py_library(
12    name = "keras",
13    srcs = [
14        "__init__.py",
15        "api/__init__.py",
16        "api/keras/__init__.py",
17        "api/keras/activations/__init__.py",
18        "api/keras/applications/__init__.py",
19        "api/keras/applications/inception_v3/__init__.py",
20        "api/keras/applications/mobilenet/__init__.py",
21        "api/keras/applications/resnet50/__init__.py",
22        "api/keras/applications/vgg16/__init__.py",
23        "api/keras/applications/vgg19/__init__.py",
24        "api/keras/applications/xception/__init__.py",
25        "api/keras/backend/__init__.py",
26        "api/keras/callbacks/__init__.py",
27        "api/keras/constraints/__init__.py",
28        "api/keras/datasets/__init__.py",
29        "api/keras/datasets/boston_housing/__init__.py",
30        "api/keras/datasets/cifar10/__init__.py",
31        "api/keras/datasets/cifar100/__init__.py",
32        "api/keras/datasets/imdb/__init__.py",
33        "api/keras/datasets/mnist/__init__.py",
34        "api/keras/datasets/reuters/__init__.py",
35        "api/keras/initializers/__init__.py",
36        "api/keras/layers/__init__.py",
37        "api/keras/losses/__init__.py",
38        "api/keras/metrics/__init__.py",
39        "api/keras/models/__init__.py",
40        "api/keras/optimizers/__init__.py",
41        "api/keras/preprocessing/__init__.py",
42        "api/keras/preprocessing/image/__init__.py",
43        "api/keras/preprocessing/sequence/__init__.py",
44        "api/keras/preprocessing/text/__init__.py",
45        "api/keras/regularizers/__init__.py",
46        "api/keras/utils/__init__.py",
47        "api/keras/wrappers/__init__.py",
48        "api/keras/wrappers/scikit_learn/__init__.py",
49    ],
50    srcs_version = "PY2AND3",
51    deps = [
52        "//tensorflow/python/keras",
53    ],
54)
55
Full Screen