Best JavaScript code snippet using wpt
LabelDepiction.ts
Source:LabelDepiction.ts
1import { S3Identified, S3Component, S3SubComponent, S3Location, S3SequenceFeature } from "sbolgraph";2import Layout from 'biocad/cad/layout/Layout';3import { VNode } from '@biocad/jfw/vdom';4import Depiction, { Opacity, Orientation, Fade } from 'biocad/cad/layout/Depiction';5import { Matrix, Vec2, Line } from '@biocad/jfw/geom'6import { svg } from '@biocad/jfw/vdom'7import ComponentDepiction from 'biocad/cad/layout/ComponentDepiction';8import { Specifiers } from 'bioterms'9import extend = require('xtend')10import RenderContext from '../RenderContext'11import CircularBackboneDepiction from 'biocad/cad/layout/CircularBackboneDepiction';12import Glyph from "biocad/glyph/Glyph";13export default class LabelDepiction extends Depiction {14 attr:any15 labelFor:Depiction16 constructor(layout:Layout, labelFor:Depiction, parent?:Depiction, uid?:number) {17 super(layout, undefined, undefined, parent, uid);18 this.labelFor = labelFor19 labelFor.label = this20 this.attr = {21 'font-family': 'sans-serif',22 'font-size': (layout.gridSize.x * 0.6) + 'pt'23 }24 }25 isVisible():boolean {26 return this.labelFor.isVisible()27 }28 render(renderContext:RenderContext):VNode {29 const labelFor:Depiction = this.labelFor30 if(labelFor && CircularBackboneDepiction.ancestorOf(labelFor)) {31 return this.renderCircular(renderContext)32 }33 return this.renderLinear(renderContext)34 }35 private renderCircular(renderContext:RenderContext):VNode {36 const layout:Layout = this.layout37 const labelFor:Depiction = this.labelFor38 const depictionOf:S3Identified|undefined = labelFor.depictionOf39 if(depictionOf === undefined)40 throw new Error('???')41 const outmostCircular:Depiction|null = CircularBackboneDepiction.ancestorOf(this)42 if(!outmostCircular) {43 throw new Error('no outmost circular?')44 }45 const centerPoint:Vec2 = outmostCircular.size.multiply(renderContext.layout.gridSize).multiplyScalar(0.5)46 const radius:Vec2 = outmostCircular.size.multiply(renderContext.layout.gridSize).multiplyScalar(0.5)47 var transform:Matrix = Matrix.identity()48 transform = transform.translate(this.absoluteOffset.multiply(renderContext.layout.gridSize))49 if(!this.parent) {50 throw new Error('?????')51 }52 return svg('g', {53 transform: transform.toSVGString()54 }, [55 Glyph.render(56 'plasmid-annotation-label'57 , {58 uri: depictionOf.uri,59 plasmidMetrics: {60 centerPoint: centerPoint,61 radius: radius,62 },63 startPoint: Vec2.fromXY(0, 0),64 endPoint: this.parent.size.multiply(renderContext.layout.gridSize),65 height: 30,66 label: depictionOf.displayName67 })68 ])69 }70 private renderLinear(renderContext:RenderContext):VNode {71 const layout:Layout = this.layout72 /*73 const labelFor:Depiction = this.parent74 const svgAttr = this.attr75 var offset76 77 var cDepiction78 if(labelFor instanceof ComponentDepiction) {79 cDepiction = labelFor as ComponentDepiction80 if(cDepiction.depictionOf.hasRole(Specifiers.SBOL2.Role.CDS)) {81 svgAttr['font-style'] = 'italic'82 }83 offset =84 cDepiction.orientation === Specifiers.Visual.Reverse ?85 labelFor.absoluteInnerOffset.add(Vec2.fromXY(0, labelFor.innerSize.y)).multiply(renderContext.layout.gridSize) :86 labelFor.absoluteOffset.multiply(renderContext.layout.gridSize)87 } else {88 offset = labelFor.absoluteOffset.multiply(renderContext.layout.gridSize)89 }*/90 const labelFor:Depiction = this.labelFor91 const depictionOf:S3Identified|undefined = labelFor.depictionOf92 const svgAttr = this.attr93 var cDepiction94 if(labelFor instanceof ComponentDepiction) {95 cDepiction = labelFor as ComponentDepiction96 }97 var pointer98 if(renderContext.interactive && labelFor.isExpandable) {99 if(labelFor.opacity === Opacity.Blackbox) {100 if(cDepiction && cDepiction.orientation === Orientation.Reverse) {101 //text = String.fromCharCode(0x25c0) + ' ' + text102 pointer = String.fromCharCode(0x25C2) // <103 } else {104 pointer = String.fromCharCode(0x25B8) // >105 }106 } else {107 if(cDepiction && cDepiction.orientation === Orientation.Reverse) {108 pointer = String.fromCharCode(0x25B4) // ^109 } else {110 pointer = String.fromCharCode(0x25BE) // v111 }112 }113 }114 if(labelFor.depictionOf === undefined)115 throw new Error('???')116 const transform = Matrix.translation(this.absoluteOffset.multiply(this.layout.gridSize))117 let dOf = labelFor.depictionOf118 let name = dOf.displayName119 let italic = false120 if(dOf.getBoolProperty('http://biocad.io/terms/untitled') === true) {121 name = 'Untitled part'122 italic = true123 }124 let roles:string[] = []125 if(dOf instanceof S3Component) {126 roles = dOf.soTerms127 } else if(dOf instanceof S3SubComponent) {128 let def = dOf.instanceOf129 roles = def.soTerms130 } else if(dOf instanceof S3SequenceFeature) {131 roles = dOf.soTerms132 } else if(dOf instanceof S3Location) {133 let container = dOf.containingObject134 if(container instanceof S3SequenceFeature) {135 roles = container.soTerms136 }137 if(container instanceof S3SubComponent) {138 let def = container.instanceOf139 roles = def.soTerms140 }141 }142 if(roles.indexOf('SO:0000316') !== -1) {143 italic = true144 }145 if(this.fade === Fade.Full) {146 svgAttr['opacity'] = '0.2'147 } else if(this.fade === Fade.Partial) {148 svgAttr['opacity'] = '0.5'149 }150 let svgText = svg('text', extend(svgAttr, {151 transform: transform.toSVGString(),152 'text-anchor': 'start',153 'alignment-baseline': 'start',154 'dominant-baseline': 'text-before-edge',155 'pointer-events': 'visible',156 'font-style': italic ? 'italic' : 'normal'157 }), [158 svg('tspan', {159 class: 'sf-glyph-expand-icon'160 }, [161 pointer162 ]),163 ' ',164 name165 ])166 let direction = this.boundingBox.center().direction(this.labelFor.boundingBox.center())167 let from = this.boundingBox.edgePointForDirectionVector(direction)168 let to = this.labelFor.boundingBox.edgePointForDirectionVector(Vec2.fromScalar(0.0).subtract(direction))169 let distance = from.distanceTo(to)170 if(false && distance > 2) {171 /*172 let parent = this.parent173 if(!parent) {174 throw new Error('???')175 }176 console.log('dir from to', direction, from, to)177 let line = new Line(from, to)178 let a = parent.absoluteOffset.add(line.a).multiply(this.layout.gridSize)179 let b = parent.absoluteOffset.add(line.b).multiply(this.layout.gridSize)180 let svgArrow = svg('path', {181 d: [182 'M' + a.toPathString(),183 'L' + b.toPathString()184 ].join(''),185 stroke: 'black',186 'stroke-width': '1px'187 })188 return svg('g', [189 svgText,190 svgArrow191 ])*/192 return svg('g', [])193 } else {194 return svgText195 }196 }197 renderThumb(size:Vec2):VNode {198 return svg('g', [])199 }200 isSelectable():boolean {201 return false202 }...
Filters.js
Source:Filters.js
1import React from 'react';2import "./Filters.css";3import { CheckBox } from "./../../assets/Checkbox/CheckBox";4import { withRouter } from 'react-router-dom';5import _ from 'lodash';6class Filters extends React.Component {7 constructor(props) {8 super(props);9 this.state = {10 to: this.props.toDate,11 from: this.props.fromDate,12 city:this.props.city,13 categories: [],14 brand: [],15 fuel: [],16 eng: [],17 seats: [],18 color: [],19 email: JSON.parse(localStorage.getItem("UserEmail")) ? JSON.parse(localStorage.getItem("UserEmail")) : "",20 }21 }22 static getDerivedStateFromProps(props, state) {23 if (props.toDate !== state.to) {24 return {25 to: props.toDate,26 from: props.fromDate,27 city: props.city,28 };29 }30 return null;31 }32 setFilters = () => {33 if (!this.debouncedFn) {34 this.debouncedFn = _.debounce(() => {35 this.props.fetchData(this.state);36 }, 1000);37 }38 this.debouncedFn();39 }40 eventHandler = (e) => {41 if (e.target.className === "categories") {42 if (e.target.checked) {43 this.setState({44 categories: [...this.state.categories, e.target.name]45 }, () => this.setFilters());46 }47 else48 {49 let cat = this.state.categories.filter(item => item !== e.target.name);50 this.setState({51 categories: [...cat]52 }, () => this.setFilters());53 }54 }55 else if (e.target.className === "brand") {56 if (e.target.checked) {57 this.setState({58 brand: [...this.state.brand, e.target.name]59 }, () => this.setFilters());60 }61 else {62 let cat = this.state.brand.filter(item => item !== e.target.name);63 this.setState({64 brand: [...cat]65 }, () => this.setFilters());66 }67 }68 else if (e.target.className === "fuel") {69 if (e.target.checked) {70 this.setState({71 fuel: [...this.state.fuel, e.target.name]72 }, () => this.setFilters());73 }74 else {75 let cat = this.state.fuel.filter(item => item !== e.target.name);76 this.setState({77 fuel: [...cat]78 }, () => this.setFilters());79 }80 }81 else if (e.target.className === "eng") {82 if (e.target.checked) {83 this.setState({84 eng: [...this.state.eng, e.target.name]85 }, () => this.setFilters());86 }87 else {88 let cat = this.state.eng.filter(item => item !== e.target.name);89 this.setState({90 eng: [...cat]91 }, () => this.setFilters());92 }93 }94 else if (e.target.className === "seats") {95 if (e.target.checked) {96 this.setState({97 seats: [...this.state.seats, e.target.name]98 }, () => this.setFilters());99 }100 else {101 let cat = this.state.seats.filter(item => item !== e.target.name);102 this.setState({103 seats: [...cat]104 }, () => this.setFilters());105 }106 }107 else if (e.target.className === "color") {108 if (e.target.checked) {109 this.setState({110 color: [...this.state.color, e.target.name]111 }, () => this.setFilters());112 }113 else {114 let cat = this.state.color.filter(item => item !== e.target.name);115 this.setState({116 color: [...cat]117 }, () => this.setFilters());118 }119 }120 };121 render() {122 return (123 <div className="filters">124 <hr className="hr-text2" data-content="Filters" />125 <div className="categories-filter">126 <h3>Categories</h3>127 <CheckBox labelFor="Hatchback" className="categories" onChange={this.eventHandler} values={false} />128 <CheckBox labelFor="Sedan" className="categories" onChange={this.eventHandler} values={false} />129 <CheckBox labelFor="SUV" className="categories" onChange={this.eventHandler} values={false} />130 <CheckBox labelFor="MUV" className="categories" onChange={this.eventHandler} values={false} />131 </div>132 <div className="brand-filter">133 <h3>Brand</h3>134 <CheckBox labelFor="Hyundai" className="brand" onChange={this.eventHandler} values={false} />135 <CheckBox labelFor="Maruti Suzuki" className="brand" onChange={this.eventHandler} values={false} />136 <CheckBox labelFor="Mahindra" className="brand" onChange={this.eventHandler} values={false} />137 <CheckBox labelFor="Jeep" className="brand" onChange={this.eventHandler} values={false} />138 <CheckBox labelFor="Kia" className="brand" onChange={this.eventHandler} values={false} />139 </div>140 <div className="fuel-filter">141 <h3>Fuel Type</h3>142 <CheckBox labelFor="Diesel" className="fuel" onChange={this.eventHandler} values={false} />143 <CheckBox labelFor="Petrol" className="fuel" onChange={this.eventHandler} values={false} />144 <CheckBox labelFor="Diesel + CNG" className="fuel" onChange={this.eventHandler} values={false} />145 <CheckBox labelFor="Petrol + CNG" className="fuel" onChange={this.eventHandler} values={false} />146 </div>147 <div className="engine-filter">148 <h3>Transmission Type</h3>149 <CheckBox labelFor="Manual" className="eng" onChange={this.eventHandler} values={false} />150 <CheckBox labelFor="Auto" className="eng" onChange={this.eventHandler} values={false} />151 </div>152 <div className="seats-filter">153 <h3>Seating Capacity</h3>154 <CheckBox labelFor="5 seater" className="seats" onChange={this.eventHandler} values={false} />155 <CheckBox labelFor="7 seater" className="seats" onChange={this.eventHandler} values={false} />156 </div>157 <div className="color-filter">158 <h3>Colors</h3>159 <CheckBox labelFor="Crimson Red" className="color" onChange={this.eventHandler} values={false} />160 <CheckBox labelFor="Silver" className="color" onChange={this.eventHandler} values={false} />161 <CheckBox labelFor="White" className="color" onChange={this.eventHandler} values={false} />162 <CheckBox labelFor="Blue" className="color" onChange={this.eventHandler} values={false} />163 <CheckBox labelFor="Black" className="color" onChange={this.eventHandler} values={false} />164 </div>165 </div>166 )167 }168}...
jquery.eventsource.specit.js
Source:jquery.eventsource.specit.js
1function sizeOf(obj) {2 var length = 0;3 for ( var prop in obj ) {4 length++;5 }6 return length;7}8describe("jQuery.EventSource", function() {9 var streams = {}, labelfor, stypeOf;10 before(function() {11 labelfor = "text-event-source";12 stypeOf = window.EventSource ? EventSource : XMLHttpRequest;13 streams = $.eventsource({14 label: labelfor,15 url: "../test-event-sources/event-source-1.php"16 });17 });18 it("$.eventsource streams cache", function() {19 assert($.eventsource("streams")).should(beAn, Object);20 assert(sizeOf($.eventsource("streams"))).should(beLessThanOrEqualTo, 1);21 });22 23 it("$.eventsource stream object", function() {24 assert(streams[labelfor]).should(include, "history");25 assert(streams[labelfor]).should(include, "isHostApi");26 assert(streams[labelfor]).should(include, "lastEventId");27 assert(streams[labelfor]).should(include, "options");28 assert(streams[labelfor]).should(include, "stream");29 });30 31 it("$.eventsource stream object should be", function() {32 33 34 assert(streams[labelfor].isHostApi).should(beA, Boolean);35 assert(streams[labelfor].history).should(beAn, Object);36 assert(streams[labelfor].options).should(beAn, Object);37 //assert(streams[labelfor].stream).should(beA, stypeOf);38 assert(streams[labelfor].lastEventId).should(beA, Number);39 });40 41 42 it("$.eventsource stream options object", function() {43 assert(streams[labelfor].options).should(include, "url");44 assert(streams[labelfor].options).should(include, "label");45 assert(streams[labelfor].options).should(include, "message");46 assert(streams[labelfor].options).should(include, "open");47 }); 48 it("$.eventsource stream options object should be", function() { 49 assert(streams[labelfor].options.url).should(beA, String);50 assert(streams[labelfor].options.label).should(beAn, String);51 //assert(streams[labelfor].options.accepts).should(beAn, Object);52 assert(streams[labelfor].options.message).should(beA, Function);53 assert(streams[labelfor].options.open).should(beA, Function);54 }); 55 it("$.eventsource stream closing", function() { 56 57 $.eventsource("close", labelfor);58 59 assert($.eventsource("streams")).should(beAn, Object);60 assert(sizeOf($.eventsource("streams"))).should(beLessThanOrEqualTo, 0);61 }); 62 after(function() {63 streams = {};64 });...
Using AI Code Generation
1var wptoolkit = require("wptoolkit");2var labelFor = wptoolkit.labelFor;3var wptoolkit = require("wptoolkit");4var labelFor = wptoolkit.labelFor;5var element = labelFor("Username");6console.log(element);7var wptoolkit = require("wptoolkit");8var labelFor = wptoolkit.labelFor;9var element = labelFor("Username");10console.log(element);11var wptoolkit = require("wptoolkit");12var labelFor = wptoolkit.labelFor;13var element = labelFor("Username");14console.log(element);15var wptoolkit = require("wptoolkit");16var labelFor = wptoolkit.labelFor;17var element = labelFor("Username");18console.log(element);19var wptoolkit = require("wptoolkit");20var labelFor = wptoolkit.labelFor;21var element = labelFor("Username");22console.log(element);23var wptoolkit = require("wptoolkit");24var labelFor = wptoolkit.labelFor;25var element = labelFor("Username");26console.log(element);27var wptoolkit = require("wptoolkit");28var labelFor = wptoolkit.labelFor;29var element = labelFor("Username");30console.log(element);31var wptoolkit = require("wptoolkit");32var labelFor = wptoolkit.labelFor;33var element = labelFor("Username");34console.log(element);35var wptoolkit = require("wptoolkit");
Using AI Code Generation
1var wptoolkit = require('wptoolkit');2var labelFor = wptoolkit.labelFor;3var wp = require('webpage');4var page = wp.create();5 var label = labelFor(page, 'input[type="submit"]');6 console.log(label);7 phantom.exit();8});
Using AI Code Generation
1var wptoolkit = require("wptoolkit");2var wptoolkit = require("wptoolkit");3var wptoolkit = require("wptoolkit");4var wptoolkit = require("wptoolkit");5var wptoolkit = require("wptoolkit");6var wptoolkit = require("wptoolkit");7var wptoolkit = require("wptoolkit");8var wptoolkit = require("wptoolkit");9var wptoolkit = require("wptoolkit");10var wptoolkit = require("wptoolkit");
Using AI Code Generation
1var toolbar = document.getElementById("wptoolbar");2var label = toolbar.labelFor("wpSave");3alert(label);4var toolbarbutton = document.getElementById("wpSave");5var label = toolbarbutton.labelFor("wpSave");6alert(label);7a=asa (on behalf of drivers) for checkin to the 1.8 branch8Checking in wptoolbar.js;9new revision: 1.3; previous revision: 1.210Checking in wptoolbar.js;
Using AI Code Generation
1var toolbarbutton = document.getElementById("toolbarbutton");2var label = toolbarbutton.labelFor;3alert(label);4#toolbarbutton[disabled] {5 color: red;6}
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!