How to use sibling method in Cypress

Best JavaScript code snippet using cypress

studio2FieldDD.js

Source:studio2FieldDD.js Github

copy

Full Screen

1/*2 * Your installation or use of this SugarCRM file is subject to the applicable3 * terms available at4 * http://support.sugarcrm.com/Resources/Master_Subscription_Agreements/.5 * If you do not agree to all of the applicable terms or do not have the6 * authority to bind the entity as an authorized representative, then do not7 * install or use this SugarCRM file.8 *9 * Copyright (C) SugarCRM Inc. All rights reserved.10 */11Studio2.FieldDD = function(id, sGroup) {12 Studio2.FieldDD.superclass.constructor.call(this, id, sGroup);13};14YAHOO.extend(Studio2.FieldDD, YAHOO.util.DDProxy, {15 startDrag: function(x, y) {16 // make the proxy look like the source element17 var dragEl = this.getDragEl();18 var clickEl = this.getEl();19 dragEl.innerHTML = clickEl.innerHTML;20 dragEl.className = clickEl.className;21 Studio2.copyId = null;22 this.showAnimation = true;23 if (Studio2.isSpecial(clickEl) && (Studio2.establishLocation(clickEl) == 'toolbox')) {24 var copy = Studio2.copyElement(clickEl);25 Studio2.setCopy(copy);26 clickEl.parentNode.insertBefore(copy,clickEl.nextSibling);27 YAHOO.util.Dom.setStyle(clickEl, "display", "none"); // don't want it to take up any space28 } else {29 YAHOO.util.Dom.setStyle(clickEl, "visibility", "hidden"); // want a empty space as we're dragging it away from this place30 }31 Studio2.setScrollObj(this);32 },33 endDrag: function(e) {34 Studio2.clearScrollObj();35 ModuleBuilder.state.markAsDirty();36 var srcEl = this.getEl();37 var proxy = this.getDragEl();38 var proxyid = proxy.id;39 var thisid = this.id;40 if (YAHOO.util.Dom.get(srcEl)) { // if we have a valid srcEl still...hasn't been deleted earlier41 // Show the proxy element and animate it to the src element's location42 YAHOO.util.Dom.setStyle(proxy, "visibility", "");43 YAHOO.util.Dom.setStyle(srcEl, "display", ""); // display!=none for getXY to work44 YAHOO.util.Dom.setStyle(proxyid, "visibility", "hidden");45 if(typeof(YAHOO.util.Dom.get(thisid)) != 'undefined' && YAHOO.util.Dom.get(thisid)!=null) 46 YAHOO.util.Dom.setStyle(thisid, "visibility", "");47 }48 if (Studio2.isSpecial(srcEl) && Studio2.copy()) {49 Studio2.activateCopy(); // activateCopy makes it active, and removes the flag that says there is a copy50 } 51 52 proxy.innerHTML = "";53 },54 onInvalidDrop: function(e) {55 Studio2.clearScrollObj();56 var dragEl = this.getDragEl();57 dragEl.innerHTML = '';58 Studio2.removeCopy();59 YAHOO.util.Dom.setStyle(this.getEl(), "display", "block");60 },61 onDrag: Studio2.onDrag,62 63 onDragDrop: function(e, id) {64 var srcEl = this.getEl();65 var destEl = YAHOO.util.Dom.get(id); // where this element is being dropped66 var srcLocation = Studio2.establishLocation(srcEl);67 var destLocation = Studio2.establishLocation(destEl);68 // CASE1: Trying to delete an item from the toolbox or move fields within the toolbox - don't allow69 if ( ((srcLocation == 'toolbox') && (destLocation == 'delete')) ||70 ((srcLocation == 'toolbox') && (destLocation == 'toolbox'))) {71 Studio2.removeCopy();72 YAHOO.util.Dom.setStyle(srcEl, "display", "block"); // make it visible again - we made special elements invisible in startDrag73 return;74 }75 // CASE2: Delete a panel element76 // if source was in a panel (not toolbox) and destination is delete then remove this element77 if ((srcLocation == 'panels') && (destLocation == 'delete')) {78 if(Studio2.isSpecial(srcEl)) //nsingh- Bug 23057 Disallow deleting a (filler) as it does not make sense to do so.79 return;80 var parent = srcEl.parentNode;81 var sibling = srcEl.previousSibling;82 while(sibling != null) {83 if (sibling.className && (sibling.className.indexOf('le_field') != -1)) {84 break;85 }86 sibling = sibling.previousSibling;87 }88 if (sibling == null) {89 sibling = srcEl.nextSibling;90 while(sibling != null) {91 if (sibling.className && (sibling.className.indexOf('le_field') != -1)) {92 break;93 }94 sibling = sibling.nextSibling;95 }96 }97 Studio2.removeElement(srcEl);98 Studio2.unregisterExpandableField( srcEl );99// this.showAnimation = false; // can't show animation as the source no longer exists100 if (sibling == null) {101 // If we've just deleted the last field from a panel then we need to tidy up102 Studio2.tidyFields(parent);103 } else {104 Studio2.registerExpandableField(sibling);105 }106 return;107 } // end delete108 // CASE3: Simple field swap109 // Either neither one is special, or they're both special and both in panels110 if (( ! Studio2.isSpecial(srcEl) && ! Studio2.isSpecial(destEl)) ||111 ( Studio2.isSpecial(srcEl) && Studio2.isSpecial(destEl) && (srcLocation == 'panels') && (destLocation == 'panels')) ) {112 Studio2.swapElements(srcEl, destEl);113 this.runSpecialCode(srcEl, destEl);114 return;115 }116 // CASE4: swapping a special field from the toolbox with a field in a panel117 if (Studio2.copy() && (destLocation == 'panels')) {118 // CASE: split a field119 //Disallow (filler) on (filler)120 if( Studio2.isSpecial(destEl) ) {Studio2.removeCopy(); return }121 var destSibling = Studio2.nextField( destEl ) || Studio2.prevField( destEl );122 if( Studio2.isExpandable( destEl ) && destEl.getAttribute("state") == 'expanded' ){123 Studio2.removeCopy(); return;124 }125 if( Studio2.isExpandable( destEl ) && destEl.getAttribute("state") == 'reduced' ){ Studio2.unregisterExpandableField( destEl ); }126 var copy = Studio2.copyElement(srcEl);127 Studio2.activateElement(copy);128 YAHOO.util.Dom.setStyle(copy, "display", "");129 Studio2.swapElements( Studio2.copy(),destEl );130 YAHOO.util.Dom.setStyle(srcEl, "display", "");131 Studio2.registerExpandableField (destSibling );132 return;133 }134 // CASE5: moving a plain field from the panel to a special field in the toolbox - just copy135 if ( ! Studio2.isSpecial(srcEl) && Studio2.isSpecial(destEl) && (destLocation == 'toolbox')) {136 // make a copy of the destination137 if(Studio2.isExpandable (srcEl ) && Studio2.isExpanded( srcEl)) {138 Studio2.toggleFieldWidth(srcEl.id); //bring back the old filler.139 Studio2.unregisterExpandableField ( srcEl );140 }141 //check if srcSibling needs to expand142// var srcSibling = ;143 var copy = Studio2.copyElement(destEl);144 var destination = document.getElementById('availablefields');145 destination.appendChild(copy);146 Studio2.swapElements(copy,srcEl);147 YAHOO.util.Dom.setStyle(srcEl, "display", "");148 Studio2.activateElement(copy);149 //if src is expanded, reduce it then unregister150 //After Swap Only.151 Studio2.registerExpandableField( Studio2.nextField( srcEl ) || Studio2.prevField( srcEl ) );152 return;153 }154 //CASE6: (filler) droppped on a expandable field.155 if(Studio2.isSpecial(srcEl) && destLocation == srcLocation ){156 //Disallow Swap if dropping on a expanded field.157 if( Studio2.isExpandable( destEl ) && Studio2.isExpanded( destEl )) {return; }158 var srcSibling = Studio2.prevField( srcEl ) || Studio2.nextField( srcEl );159 var destSibling = Studio2.prevField( destEl ) || Studio2.nextField( destEl );160 Studio2.swapElements(srcEl, destEl); //don't change order.161 if ( !Studio2.isExpandable( destSibling ) && Studio2.isExpandable(srcSibling) && Studio2.isReduced(srcSibling) && !(srcSibling.id == destEl.id && srcEl.id == destSibling.id)) {162 Studio2.unregisterExpandableField( srcSibling );163 Studio2.registerExpandableField (destSibling );164 Studio2.unregisterExpandableField( destEl );165 }166 if ( !Studio2.isExpandable( destEl ) && Studio2.isSpecial( destSibling )) {167 Studio2.registerExpandableField (destEl );168 }169 if(!Studio2.isSpecial(destSibling)) {Studio2.registerExpandableField (destSibling )}170 return;171 }172 //CASE 7: A special field swapped with a regular field. Source is not-special, destination is special.173 if(!Studio2.isSpecial(srcEl) && Studio2.isSpecial(destEl) && destLocation == srcLocation) {174 /**175 if destination's left sibling is expandable.176 unregister left sibling from expandable.177 if src field's left sibling is not special178 register left sibling to expandable.179 */180 var srcSibling = Studio2.prevField(srcEl) || Studio2.nextField( srcEl ) ;181 var destSibling = Studio2.prevField(destEl) || Studio2.nextField( destEl );182 var sameRow = (srcSibling!=null && destSibling!=null) ? (srcSibling.id == destEl.id && destSibling.id == srcEl.id) : false;183 if (Studio2.isExpandable( srcEl ) && Studio2.isExpanded( srcEl )) {return;} //disallow dropping expanded fields onto fillers.184 if (Studio2.isExpandable ( srcEl ) && Studio2.isReduced( srcEl ) && !sameRow) {Studio2.unregisterExpandableField( srcEl );}185 if (Studio2.isExpandable (destSibling) && !sameRow ){Studio2.unregisterExpandableField( destSibling )}186 //expand src sibling187 if( srcEl.id == destSibling.id && srcSibling.id == destEl.id ) {Studio2.registerExpandableField ( srcEl ) }188 Studio2.swapElements(srcEl, destEl);189 if (Studio2.isSpecial(destSibling)) {Studio2.registerExpandableField(srcEl)}190 Studio2.registerExpandableField( srcSibling );191 return;192 }193 if( !Studio2.isSpecial( srcEl ) && Studio2.isSpecial( destEl) && destLocation == 'panels' && srcLocation =='toolbox'){194 var destSibling = Studio2.nextField( destEl ) || Studio2.prevField ( destEl );195 Studio2.unregisterExpandableField( destSibling );196 Studio2.swapElements( srcEl,destEl );197 Studio2.removeElement( destEl ) ;198 return;199 }200 Studio2.swapElements( srcEl,destEl );201 this.runSpecialCode(srcEl,destEl);202 if ((srcLocation != destLocation)) {203 if (Studio2.isSpecial(srcEl) && ! Studio2.isSpecial(destEl)) {204 Studio2.removeElement(srcEl);205 return;206 }207 if (Studio2.isSpecial(destEl) && ! Studio2.isSpecial(srcEl)) {208 Studio2.removeElement(destEl);209 return;210 }211 }212 },213 runSpecialCode: function(srcEl, destEl){214 var srcLeftSibling = Studio2.prevField(srcEl);215 var srcRightSibling = Studio2.nextField(srcEl);216 var destRightSibling = Studio2.nextField(destEl);217 var destLeftSibling = Studio2.prevField(destEl);218 //For every affected element unexpand if needed.219 //registration vs Transformation.220 if ( Studio2.isExpandable (srcEl ) && Studio2.isExpandable( destEl) ){221 //src is dest now. copy dest's properties to src.222 Studio2.swapStates( srcEl, destEl );223 }224 var registerSrc = !Studio2.isExpandable( srcEl );225 var destExpandable = !Studio2.isSpecial(destEl) && ((null==destRightSibling && null==destLeftSibling)226 || (null !== destRightSibling) && Studio2.isSpecial(destRightSibling));227 var srcUnexpandable = !Studio2.isSpecial(srcEl) && ((null!==srcLeftSibling && !Studio2.isSpecial(srcLeftSibling))228 || ((null !== srcRightSibling) && !Studio2.isSpecial(srcRightSibling)));229 var destUnexpandable = !Studio2.isSpecial(destEl) && ((null!==destLeftSibling && !Studio2.isSpecial(destLeftSibling))230 || ((null!== destRightSibling) && !Studio2.isSpecial(destRightSibling)));231 if( registerSrc ){232 Studio2.registerExpandableField( srcEl );233 }234 if(srcUnexpandable){235 Studio2.unregisterExpandableField( srcEl );236 }237 if(destExpandable){238 Studio2.registerExpandableField(destEl);239 }240 if(destUnexpandable){241 Studio2.unregisterExpandableField( destEl );242 }243 if(srcLeftSibling!==null && !Studio2.isSpecial(srcLeftSibling) && !Studio2.isSpecial(srcEl))244 Studio2.unregisterExpandableField( srcLeftSibling );245 return;246 }...

Full Screen

Full Screen

getDomSibling.test.js

Source:getDomSibling.test.js Github

copy

Full Screen

1import { createElement, render, Fragment } from '../../src/';2import { getDomSibling } from '../../src/component';3import { setupScratch, teardown } from '../_util/helpers';4/** @jsx createElement */5describe('getDomSibling', () => {6 /** @type {import('../../src/internal').PreactElement} */7 let scratch;8 const getRoot = dom => dom._children;9 beforeEach(() => {10 scratch = setupScratch();11 });12 afterEach(() => {13 teardown(scratch);14 });15 it('should find direct sibling', () => {16 render(17 <div>18 <div>A</div>19 <div>B</div>20 </div>,21 scratch22 );23 let vnode = getRoot(scratch)._children[0]._children[0];24 expect(getDomSibling(vnode)).to.equalNode(scratch.firstChild.childNodes[1]);25 });26 it('should find direct text node sibling', () => {27 render(28 <div>29 <div>A</div>B30 </div>,31 scratch32 );33 let vnode = getRoot(scratch)._children[0]._children[0];34 expect(getDomSibling(vnode)).to.equalNode(scratch.firstChild.childNodes[1]);35 });36 it('should find nested text node sibling', () => {37 render(38 <div>39 <Fragment>40 <div>A</div>41 </Fragment>42 <Fragment>B</Fragment>43 </div>,44 scratch45 );46 let vnode = getRoot(scratch)._children[0]._children[0];47 expect(getDomSibling(vnode)).to.equalNode(scratch.firstChild.childNodes[1]);48 });49 it('should find text node sibling with placeholder', () => {50 render(<div>A{null}B</div>, scratch);51 let vnode = getRoot(scratch)._children[0]._children[0];52 expect(getDomSibling(vnode)).to.equalNode(scratch.firstChild.childNodes[1]);53 });54 it('should find sibling with placeholder', () => {55 render(56 <div key="parent">57 <div key="A">A</div>58 {null}59 <div key="B">B</div>60 </div>,61 scratch62 );63 let vnode = getRoot(scratch)._children[0]._children[0];64 expect(getDomSibling(vnode)).to.equalNode(scratch.firstChild.childNodes[1]);65 });66 it('should find sibling with nested placeholder', () => {67 render(68 <div key="0">69 <Fragment key="0.0">70 <div key="A">A</div>71 </Fragment>72 <Fragment key="0.1">{null}</Fragment>73 <Fragment key="0.2">74 <div key="B">B</div>75 </Fragment>76 </div>,77 scratch78 );79 let vnode = getRoot(scratch)._children[0]._children[0]._children[0];80 expect(getDomSibling(vnode)).to.equalNode(scratch.firstChild.childNodes[1]);81 });82 it('should find sibling in parent', () => {83 render(84 <div>85 <Fragment>86 <div>A</div>87 </Fragment>88 <div>B</div>89 </div>,90 scratch91 );92 let vnode = getRoot(scratch)._children[0]._children[0]._children[0];93 expect(getDomSibling(vnode)).to.equalNode(scratch.firstChild.childNodes[1]);94 });95 it('should find unrelated sibling from a DOM VNode', () => {96 render(97 <div key="0">98 <Fragment key="0.0">99 <Fragment key="0.0.0">100 <Fragment key="0.0.0.0">101 <div key="A">A</div>102 </Fragment>103 </Fragment>104 </Fragment>105 <Fragment key="0.1">106 <Fragment key="0.1.0" />107 <Fragment key="0.1.1" />108 <Fragment key="0.1.2" />109 </Fragment>110 <Fragment key="0.2">111 <Fragment key="0.2.0" />112 <Fragment key="0.2.1" />113 <Fragment key="0.2.2">114 <div key="B">B</div>115 </Fragment>116 </Fragment>117 </div>,118 scratch119 );120 let divAVNode = getRoot(scratch)._children[0]._children[0]._children[0]121 ._children[0]._children[0];122 expect(divAVNode.type).to.equal('div');123 expect(getDomSibling(divAVNode)).to.equalNode(124 scratch.firstChild.childNodes[1]125 );126 });127 it('should find unrelated sibling from a Fragment VNode', () => {128 render(129 <div key="0">130 <Fragment key="0.0">131 <Fragment key="0.0.0">132 <Fragment key="0.0.0.0">133 <div key="A">A</div>134 </Fragment>135 </Fragment>136 </Fragment>137 <Fragment key="0.1">138 <Fragment key="0.1.0">139 <div key="B">B</div>140 </Fragment>141 </Fragment>142 </div>,143 scratch144 );145 let fragment = getRoot(scratch)._children[0]._children[0]._children[0]146 ._children[0];147 expect(fragment.type).to.equal(Fragment);148 expect(getDomSibling(fragment)).to.equalNode(149 scratch.firstChild.childNodes[1]150 );151 });152 it('should find unrelated sibling from a Component VNode', () => {153 const Foo = props => props.children;154 render(155 <div key="0">156 <Fragment key="0.0">157 <Fragment key="0.0.0">158 <Foo key="0.0.0.0">159 <div key="A">A</div>160 </Foo>161 </Fragment>162 </Fragment>163 <Fragment key="0.1">164 <Fragment key="0.1.0">165 <div key="B">B</div>166 </Fragment>167 </Fragment>168 </div>,169 scratch170 );171 let foo = getRoot(scratch)._children[0]._children[0]._children[0]172 ._children[0];173 expect(foo.type).to.equal(Foo);174 expect(getDomSibling(foo)).to.equalNode(scratch.firstChild.childNodes[1]);175 });176 it('should find sibling through components', () => {177 const Foo = props => props.children;178 render(179 <div key="0">180 <Foo key="0.0">181 <div key="A">A</div>182 </Foo>183 <Foo key="0.1" />184 <Foo key="0.2">185 <Foo key="0.2.0">186 <div key="B">B</div>187 </Foo>188 </Foo>189 </div>,190 scratch191 );192 let divAVNode = getRoot(scratch)._children[0]._children[0]._children[0];193 expect(divAVNode.type).to.equal('div');194 expect(getDomSibling(divAVNode)).to.equalNode(195 scratch.firstChild.childNodes[1]196 );197 });198 it('should find sibling rendered in Components that wrap JSX children', () => {199 const Foo = props => <p key="p">{props.children}</p>;200 render(201 <div key="0">202 <div key="A">A</div>203 <Foo key="Foo">204 <span key="span">a span</span>205 </Foo>206 </div>,207 scratch208 );209 let divAVNode = getRoot(scratch)._children[0]._children[0];210 expect(divAVNode.type).to.equal('div');211 let sibling = getDomSibling(divAVNode);212 expect(sibling).to.equalNode(scratch.firstChild.childNodes[1]);213 });214 it('should find sibling rendered in Components without JSX children', () => {215 const Foo = props => <p key="p">A paragraph</p>;216 render(217 <div key="0">218 <div key="A">A</div>219 <Foo key="Foo" />220 </div>,221 scratch222 );223 let divAVNode = getRoot(scratch)._children[0]._children[0];224 expect(divAVNode.type).to.equal('div');225 let sibling = getDomSibling(divAVNode);226 expect(sibling).to.equalNode(scratch.firstChild.childNodes[1]);227 });228 it('should climb through Components without JSX children', () => {229 const divAVNode = <div key="A">A</div>;230 const Foo = () => divAVNode;231 render(232 <div key="0">233 <Foo key="Foo" />234 <div key="B">B</div>235 </div>,236 scratch237 );238 let sibling = getDomSibling(divAVNode);239 expect(sibling).to.equalNode(scratch.firstChild.childNodes[1]);240 });241 it('should return null if last sibling', () => {242 render(243 <div key="0">244 <Fragment key="0.0">245 <div key="A">A</div>246 </Fragment>247 <Fragment key="0.1">248 <div key="B">B</div>249 </Fragment>250 <Fragment key="0.2">251 <div key="C">C</div>252 </Fragment>253 </div>,254 scratch255 );256 const divCVNode = getRoot(scratch)._children[0]._children[2]._children[0];257 expect(getDomSibling(divCVNode)).to.equal(null);258 });259 it('should return null if no sibling', () => {260 render(261 <div key="0">262 <Fragment key="0.0">263 <Fragment key="0.0.0">264 <Fragment key="0.0.0.0">265 <div key="A">A</div>266 </Fragment>267 </Fragment>268 </Fragment>269 <Fragment key="0.1">270 <Fragment key="0.1.0">{null}</Fragment>271 </Fragment>272 </div>,273 scratch274 );275 let divAVNode = getRoot(scratch)._children[0]._children[0]._children[0]276 ._children[0]._children[0];277 expect(getDomSibling(divAVNode)).to.equal(null);278 });279 it('should return null if no sibling with lots of empty trees', () => {280 render(281 <div key="0">282 <Fragment key="0.0">283 <Fragment key="0.0.0">284 <Fragment key="0.0.0.0">285 <div key="A">A</div>286 </Fragment>287 </Fragment>288 </Fragment>289 <Fragment key="0.1">290 <Fragment key="0.1.0" />291 <Fragment key="0.1.1" />292 <Fragment key="0.1.2" />293 </Fragment>294 <Fragment key="0.2">295 <Fragment key="0.2.0" />296 <Fragment key="0.2.1" />297 <Fragment key="0.2.2">{null}</Fragment>298 </Fragment>299 </div>,300 scratch301 );302 let divAVNode = getRoot(scratch)._children[0]._children[0]._children[0]303 ._children[0]._children[0];304 expect(getDomSibling(divAVNode)).to.equal(null);305 });306 it('should return null if current parent has no siblings (even if parent has siblings at same level)', () => {307 let divAVNode = <div key="A">A</div>;308 render(309 <div key="0">310 <div key="0.0">311 <div key="0.0.0" />312 {divAVNode}313 <Fragment key="0.1.2" />314 </div>315 <div key="0.1">316 <Fragment key="0.1.0" />317 <div key="B">B</div>318 </div>319 </div>,320 scratch321 );322 expect(getDomSibling(divAVNode)).to.equal(null);323 });...

Full Screen

Full Screen

docs.js

Source:docs.js Github

copy

Full Screen

1/*2 Functions for the navigation dropdowns 3*/4// dashboard dropdown function5function func1() {6 var x = document.getElementById("dashboard");7 if (x.className.indexOf("w3-show") == -1) {8 x.className += " w3-show";9 x.previousElementSibling.className += " w3-green";10 } else { 11 x.className = x.className.replace(" w3-show", "");12 x.previousElementSibling.className = 13 x.previousElementSibling.className.replace(" w3-green", "");14 }15}16// vitals dropdown function17function func2() {18 var x = document.getElementById("vitals");19 if (x.className.indexOf("w3-show") == -1) {20 x.className += " w3-show";21 x.previousElementSibling.className += " w3-green";22 } else { 23 x.className = x.className.replace(" w3-show", "");24 x.previousElementSibling.className = 25 x.previousElementSibling.className.replace(" w3-green", "");26 }27}28// patient assessment dropdown function29function func3() {30 var x = document.getElementById("patientA");31 if (x.className.indexOf("w3-show") == -1) {32 x.className += " w3-show";33 x.previousElementSibling.className += " w3-green";34 } else { 35 x.className = x.className.replace(" w3-show", "");36 x.previousElementSibling.className = 37 x.previousElementSibling.className.replace(" w3-green", "");38 }39}40// order entry dropdown function41function func4() {42 var x = document.getElementById("orderE");43 if (x.className.indexOf("w3-show") == -1) {44 x.className += " w3-show";45 x.previousElementSibling.className += " w3-green";46 } else { 47 x.className = x.className.replace(" w3-show", "");48 x.previousElementSibling.className = 49 x.previousElementSibling.className.replace(" w3-green", "");50 }51}52// medication administration dropdown function53function func5() {54 var x = document.getElementById("medAdmin");55 if (x.className.indexOf("w3-show") == -1) {56 x.className += " w3-show";57 x.previousElementSibling.className += " w3-green";58 } else { 59 x.className = x.className.replace(" w3-show", "");60 x.previousElementSibling.className = 61 x.previousElementSibling.className.replace(" w3-green", "");62 }63}64// daily care dropdown function65function func6() {66 var x = document.getElementById("dailyCare");67 if (x.className.indexOf("w3-show") == -1) {68 x.className += " w3-show";69 x.previousElementSibling.className += " w3-green";70 } else { 71 x.className = x.className.replace(" w3-show", "");72 x.previousElementSibling.className = 73 x.previousElementSibling.className.replace(" w3-green", "");74 }75}76// general head dropdown function77function func7() {78 var x = document.getElementById("general");79 if (x.className.indexOf("w3-show") == -1) {80 x.className += " w3-show";81 x.previousElementSibling.className += " w3-green";82 } else { 83 x.className = x.className.replace(" w3-show", "");84 x.previousElementSibling.className = 85 x.previousElementSibling.className.replace(" w3-green", "");86 }87}88// cardiovascular dropdown function89function func8() {90 var x = document.getElementById("cardiovascular");91 if (x.className.indexOf("w3-show") == -1) {92 x.className += " w3-show";93 x.previousElementSibling.className += " w3-green";94 } else { 95 x.className = x.className.replace(" w3-show", "");96 x.previousElementSibling.className = 97 x.previousElementSibling.className.replace(" w3-green", "");98 }99}100// peripheral pulse assessment dropdown function101function func9() {102 var x = document.getElementById("pulseAssess");103 if (x.className.indexOf("w3-show") == -1) {104 x.className += " w3-show";105 x.previousElementSibling.className += " w3-green";106 } else { 107 x.className = x.className.replace(" w3-show", "");108 x.previousElementSibling.className = 109 x.previousElementSibling.className.replace(" w3-green", "");110 }111}112// gastrointestinal dropdown function113function func10() {114 var x = document.getElementById("gastro");115 if (x.className.indexOf("w3-show") == -1) {116 x.className += " w3-show";117 x.previousElementSibling.className += " w3-green";118 } else { 119 x.className = x.className.replace(" w3-show", "");120 x.previousElementSibling.className = 121 x.previousElementSibling.className.replace(" w3-green", "");122 }123}124// genitourinary dropdown function125function func11() {126 var x = document.getElementById("geni");127 if (x.className.indexOf("w3-show") == -1) {128 x.className += " w3-show";129 x.previousElementSibling.className += " w3-green";130 } else { 131 x.className = x.className.replace(" w3-show", "");132 x.previousElementSibling.className = 133 x.previousElementSibling.className.replace(" w3-green", "");134 }135}136// integumentary dropdown function137function func12() {138 var x = document.getElementById("inte");139 if (x.className.indexOf("w3-show") == -1) {140 x.className += " w3-show";141 x.previousElementSibling.className += " w3-green";142 } else { 143 x.className = x.className.replace(" w3-show", "");144 x.previousElementSibling.className = 145 x.previousElementSibling.className.replace(" w3-green", "");146 }147}148// musculoskeletal dropdown function149function func13() {150 var x = document.getElementById("muscle");151 if (x.className.indexOf("w3-show") == -1) {152 x.className += " w3-show";153 x.previousElementSibling.className += " w3-green";154 } else { 155 x.className = x.className.replace(" w3-show", "");156 x.previousElementSibling.className = 157 x.previousElementSibling.className.replace(" w3-green", "");158 }159}160// neurological dropdown function161function func14() {162 var x = document.getElementById("neuro");163 if (x.className.indexOf("w3-show") == -1) {164 x.className += " w3-show";165 x.previousElementSibling.className += " w3-green";166 } else { 167 x.className = x.className.replace(" w3-show", "");168 x.previousElementSibling.className = 169 x.previousElementSibling.className.replace(" w3-green", "");170 }171}172// respiratory dropdown function173function func15() {174 var x = document.getElementById("resp");175 if (x.className.indexOf("w3-show") == -1) {176 x.className += " w3-show";177 x.previousElementSibling.className += " w3-green";178 } else { 179 x.className = x.className.replace(" w3-show", "");180 x.previousElementSibling.className = 181 x.previousElementSibling.className.replace(" w3-green", "");182 }183}184// safety dropdown function185function func16() {186 var x = document.getElementById("safety");187 if (x.className.indexOf("w3-show") == -1) {188 x.className += " w3-show";189 x.previousElementSibling.className += " w3-green";190 } else { 191 x.className = x.className.replace(" w3-show", "");192 x.previousElementSibling.className = 193 x.previousElementSibling.className.replace(" w3-green", "");194 }195}196// infection dropdown function197function func17() {198 var x = document.getElementById("infection");199 if (x.className.indexOf("w3-show") == -1) {200 x.className += " w3-show";201 x.previousElementSibling.className += " w3-green";202 } else { 203 x.className = x.className.replace(" w3-show", "");204 x.previousElementSibling.className = 205 x.previousElementSibling.className.replace(" w3-green", "");206 }207}208// vascular dropdown function209function func18() {210 var x = document.getElementById("vascular");211 if (x.className.indexOf("w3-show") == -1) {212 x.className += " w3-show";213 x.previousElementSibling.className += " w3-green";214 } else { 215 x.className = x.className.replace(" w3-show", "");216 x.previousElementSibling.className = 217 x.previousElementSibling.className.replace(" w3-green", "");218 }219}220// drains & tubes dropdown function221function func19() {222 var x = document.getElementById("drains");223 if (x.className.indexOf("w3-show") == -1) {224 x.className += " w3-show";225 x.previousElementSibling.className += " w3-green";226 } else { 227 x.className = x.className.replace(" w3-show", "");228 x.previousElementSibling.className = 229 x.previousElementSibling.className.replace(" w3-green", "");230 }...

Full Screen

Full Screen

formatBlock.js

Source:formatBlock.js Github

copy

Full Screen

1(function(wysihtml5) {2 var dom = wysihtml5.dom,3 // Following elements are grouped4 // when the caret is within a H1 and the H4 is invoked, the H1 should turn into H45 // instead of creating a H4 within a H1 which would result in semantically invalid html6 BLOCK_ELEMENTS_GROUP = ["H1", "H2", "H3", "H4", "H5", "H6", "P", "BLOCKQUOTE", "DIV"];7 8 /**9 * Remove similiar classes (based on classRegExp)10 * and add the desired class name11 */12 function _addClass(element, className, classRegExp) {13 if (element.className) {14 _removeClass(element, classRegExp);15 element.className += " " + className;16 } else {17 element.className = className;18 }19 }20 function _removeClass(element, classRegExp) {21 element.className = element.className.replace(classRegExp, "");22 }23 /**24 * Check whether given node is a text node and whether it's empty25 */26 function _isBlankTextNode(node) {27 return node.nodeType === wysihtml5.TEXT_NODE && !wysihtml5.lang.string(node.data).trim();28 }29 /**30 * Returns previous sibling node that is not a blank text node31 */32 function _getPreviousSiblingThatIsNotBlank(node) {33 var previousSibling = node.previousSibling;34 while (previousSibling && _isBlankTextNode(previousSibling)) {35 previousSibling = previousSibling.previousSibling;36 }37 return previousSibling;38 }39 /**40 * Returns next sibling node that is not a blank text node41 */42 function _getNextSiblingThatIsNotBlank(node) {43 var nextSibling = node.nextSibling;44 while (nextSibling && _isBlankTextNode(nextSibling)) {45 nextSibling = nextSibling.nextSibling;46 }47 return nextSibling;48 }49 /**50 * Adds line breaks before and after the given node if the previous and next siblings51 * aren't already causing a visual line break (block element or <br>)52 */53 function _addLineBreakBeforeAndAfter(node) {54 var doc = node.ownerDocument,55 nextSibling = _getNextSiblingThatIsNotBlank(node),56 previousSibling = _getPreviousSiblingThatIsNotBlank(node);57 if (nextSibling && !_isLineBreakOrBlockElement(nextSibling)) {58 node.parentNode.insertBefore(doc.createElement("br"), nextSibling);59 }60 if (previousSibling && !_isLineBreakOrBlockElement(previousSibling)) {61 node.parentNode.insertBefore(doc.createElement("br"), node);62 }63 }64 /**65 * Removes line breaks before and after the given node66 */67 function _removeLineBreakBeforeAndAfter(node) {68 var nextSibling = _getNextSiblingThatIsNotBlank(node),69 previousSibling = _getPreviousSiblingThatIsNotBlank(node);70 if (nextSibling && _isLineBreak(nextSibling)) {71 nextSibling.parentNode.removeChild(nextSibling);72 }73 if (previousSibling && _isLineBreak(previousSibling)) {74 previousSibling.parentNode.removeChild(previousSibling);75 }76 }77 function _removeLastChildIfLineBreak(node) {78 var lastChild = node.lastChild;79 if (lastChild && _isLineBreak(lastChild)) {80 lastChild.parentNode.removeChild(lastChild);81 }82 }83 function _isLineBreak(node) {84 return node.nodeName === "BR";85 }86 /**87 * Checks whether the elment causes a visual line break88 * (<br> or block elements)89 */90 function _isLineBreakOrBlockElement(element) {91 if (_isLineBreak(element)) {92 return true;93 }94 if (dom.getStyle("display").from(element) === "block") {95 return true;96 }97 return false;98 }99 /**100 * Execute native query command101 * and if necessary modify the inserted node's className102 */103 function _execCommand(doc, command, nodeName, className) {104 if (className) {105 var eventListener = dom.observe(doc, "DOMNodeInserted", function(event) {106 var target = event.target,107 displayStyle;108 if (target.nodeType !== wysihtml5.ELEMENT_NODE) {109 return;110 }111 displayStyle = dom.getStyle("display").from(target);112 if (displayStyle.substr(0, 6) !== "inline") {113 // Make sure that only block elements receive the given class114 target.className += " " + className;115 }116 });117 }118 doc.execCommand(command, false, nodeName);119 if (eventListener) {120 eventListener.stop();121 }122 }123 function _selectLineAndWrap(composer, element) {124 composer.selection.selectLine();125 composer.selection.surround(element);126 _removeLineBreakBeforeAndAfter(element);127 _removeLastChildIfLineBreak(element);128 composer.selection.selectNode(element, wysihtml5.browser.displaysCaretInEmptyContentEditableCorrectly());129 }130 function _hasClasses(element) {131 return !!wysihtml5.lang.string(element.className).trim();132 }133 134 wysihtml5.commands.formatBlock = {135 exec: function(composer, command, nodeName, className, classRegExp) {136 var doc = composer.doc,137 blockElement = this.state(composer, command, nodeName, className, classRegExp),138 useLineBreaks = composer.config.useLineBreaks,139 defaultNodeName = useLineBreaks ? "DIV" : "P",140 selectedNode;141 nodeName = typeof(nodeName) === "string" ? nodeName.toUpperCase() : nodeName;142 143 if (blockElement) {144 composer.selection.executeAndRestoreSimple(function() {145 if (classRegExp) {146 _removeClass(blockElement, classRegExp);147 }148 var hasClasses = _hasClasses(blockElement);149 if (!hasClasses && (useLineBreaks || nodeName === "P")) {150 // Insert a line break afterwards and beforewards when there are siblings151 // that are not of type line break or block element152 _addLineBreakBeforeAndAfter(blockElement);153 dom.replaceWithChildNodes(blockElement);154 } else {155 // Make sure that styling is kept by renaming the element to a <div> or <p> and copying over the class name156 dom.renameElement(blockElement, nodeName === "P" ? "DIV" : defaultNodeName);157 }158 });159 return;160 }161 // Find similiar block element and rename it (<h2 class="foo"></h2> => <h1 class="foo"></h1>)162 if (nodeName === null || wysihtml5.lang.array(BLOCK_ELEMENTS_GROUP).contains(nodeName)) {163 selectedNode = composer.selection.getSelectedNode();164 blockElement = dom.getParentElement(selectedNode, {165 nodeName: BLOCK_ELEMENTS_GROUP166 });167 if (blockElement) {168 composer.selection.executeAndRestore(function() {169 // Rename current block element to new block element and add class170 if (nodeName) {171 blockElement = dom.renameElement(blockElement, nodeName);172 }173 if (className) {174 _addClass(blockElement, className, classRegExp);175 }176 });177 return;178 }179 }180 if (composer.commands.support(command)) {181 _execCommand(doc, command, nodeName || defaultNodeName, className);182 return;183 }184 blockElement = doc.createElement(nodeName || defaultNodeName);185 if (className) {186 blockElement.className = className;187 }188 _selectLineAndWrap(composer, blockElement);189 },190 state: function(composer, command, nodeName, className, classRegExp) {191 nodeName = typeof(nodeName) === "string" ? nodeName.toUpperCase() : nodeName;192 var selectedNode = composer.selection.getSelectedNode();193 return dom.getParentElement(selectedNode, {194 nodeName: nodeName,195 className: className,196 classRegExp: classRegExp197 });198 }199 };...

Full Screen

Full Screen

red-black.js

Source:red-black.js Github

copy

Full Screen

1function d3_geom_voronoiRedBlackTree() {2 this._ = null; // root node3}4function d3_geom_voronoiRedBlackNode(node) {5 node.U = // parent node6 node.C = // color - true for red, false for black7 node.L = // left node8 node.R = // right node9 node.P = // previous node10 node.N = null; // next node11}12d3_geom_voronoiRedBlackTree.prototype = {13 insert: function(after, node) {14 var parent, grandpa, uncle;15 if (after) {16 node.P = after;17 node.N = after.N;18 if (after.N) after.N.P = node;19 after.N = node;20 if (after.R) {21 after = after.R;22 while (after.L) after = after.L;23 after.L = node;24 } else {25 after.R = node;26 }27 parent = after;28 } else if (this._) {29 after = d3_geom_voronoiRedBlackFirst(this._);30 node.P = null;31 node.N = after;32 after.P = after.L = node;33 parent = after;34 } else {35 node.P = node.N = null;36 this._ = node;37 parent = null;38 }39 node.L = node.R = null;40 node.U = parent;41 node.C = true;42 after = node;43 while (parent && parent.C) {44 grandpa = parent.U;45 if (parent === grandpa.L) {46 uncle = grandpa.R;47 if (uncle && uncle.C) {48 parent.C = uncle.C = false;49 grandpa.C = true;50 after = grandpa;51 } else {52 if (after === parent.R) {53 d3_geom_voronoiRedBlackRotateLeft(this, parent);54 after = parent;55 parent = after.U;56 }57 parent.C = false;58 grandpa.C = true;59 d3_geom_voronoiRedBlackRotateRight(this, grandpa);60 }61 } else {62 uncle = grandpa.L;63 if (uncle && uncle.C) {64 parent.C = uncle.C = false;65 grandpa.C = true;66 after = grandpa;67 } else {68 if (after === parent.L) {69 d3_geom_voronoiRedBlackRotateRight(this, parent);70 after = parent;71 parent = after.U;72 }73 parent.C = false;74 grandpa.C = true;75 d3_geom_voronoiRedBlackRotateLeft(this, grandpa);76 }77 }78 parent = after.U;79 }80 this._.C = false;81 },82 remove: function(node) {83 if (node.N) node.N.P = node.P;84 if (node.P) node.P.N = node.N;85 node.N = node.P = null;86 var parent = node.U,87 sibling,88 left = node.L,89 right = node.R,90 next,91 red;92 if (!left) next = right;93 else if (!right) next = left;94 else next = d3_geom_voronoiRedBlackFirst(right);95 if (parent) {96 if (parent.L === node) parent.L = next;97 else parent.R = next;98 } else {99 this._ = next;100 }101 if (left && right) {102 red = next.C;103 next.C = node.C;104 next.L = left;105 left.U = next;106 if (next !== right) {107 parent = next.U;108 next.U = node.U;109 node = next.R;110 parent.L = node;111 next.R = right;112 right.U = next;113 } else {114 next.U = parent;115 parent = next;116 node = next.R;117 }118 } else {119 red = node.C;120 node = next;121 }122 if (node) node.U = parent;123 if (red) return;124 if (node && node.C) { node.C = false; return; }125 do {126 if (node === this._) break;127 if (node === parent.L) {128 sibling = parent.R;129 if (sibling.C) {130 sibling.C = false;131 parent.C = true;132 d3_geom_voronoiRedBlackRotateLeft(this, parent);133 sibling = parent.R;134 }135 if ((sibling.L && sibling.L.C)136 || (sibling.R && sibling.R.C)) {137 if (!sibling.R || !sibling.R.C) {138 sibling.L.C = false;139 sibling.C = true;140 d3_geom_voronoiRedBlackRotateRight(this, sibling);141 sibling = parent.R;142 }143 sibling.C = parent.C;144 parent.C = sibling.R.C = false;145 d3_geom_voronoiRedBlackRotateLeft(this, parent);146 node = this._;147 break;148 }149 } else {150 sibling = parent.L;151 if (sibling.C) {152 sibling.C = false;153 parent.C = true;154 d3_geom_voronoiRedBlackRotateRight(this, parent);155 sibling = parent.L;156 }157 if ((sibling.L && sibling.L.C)158 || (sibling.R && sibling.R.C)) {159 if (!sibling.L || !sibling.L.C) {160 sibling.R.C = false;161 sibling.C = true;162 d3_geom_voronoiRedBlackRotateLeft(this, sibling);163 sibling = parent.L;164 }165 sibling.C = parent.C;166 parent.C = sibling.L.C = false;167 d3_geom_voronoiRedBlackRotateRight(this, parent);168 node = this._;169 break;170 }171 }172 sibling.C = true;173 node = parent;174 parent = parent.U;175 } while (!node.C);176 if (node) node.C = false;177 }178};179function d3_geom_voronoiRedBlackRotateLeft(tree, node) {180 var p = node,181 q = node.R,182 parent = p.U;183 if (parent) {184 if (parent.L === p) parent.L = q;185 else parent.R = q;186 } else {187 tree._ = q;188 }189 q.U = parent;190 p.U = q;191 p.R = q.L;192 if (p.R) p.R.U = p;193 q.L = p;194}195function d3_geom_voronoiRedBlackRotateRight(tree, node) {196 var p = node,197 q = node.L,198 parent = p.U;199 if (parent) {200 if (parent.L === p) parent.L = q;201 else parent.R = q;202 } else {203 tree._ = q;204 }205 q.U = parent;206 p.U = q;207 p.L = q.R;208 if (p.L) p.L.U = p;209 q.R = p;210}211function d3_geom_voronoiRedBlackFirst(node) {212 while (node.L) node = node.L;213 return node;...

Full Screen

Full Screen

register.js

Source:register.js Github

copy

Full Screen

1var tel = document.querySelector('[ id="tel" ]');2var psw = document.querySelector('[ id="psw" ]');3var name1 = document.querySelector('[id="name"]');4var btn1 = document.querySelector('[id="btn1"');5var btn2 = document.querySelector('[id="btn2"');6console.log(btn2);7var fom = document.querySelectorAll('.formlist');8console.log(fom);9var agre = document.querySelector('.agree');10var noagree = document.querySelector('.noagree');11var mask = document.querySelector('.register_mask')12// 是否点了同意13agre.onclick = function() {14 this.parentElement.previousElementSibling.parentElement.parentElement.remove();15 console.log(this.parentElement.previousElementSibling.parentElement)16 mask.remove();17 return true18 // console.log(btn1.parentElement.parentElement)19}20noagree.onclick = function() {21 alert('如果不同意将无法注')22}23tel.nextElementSibling.onclick = function() {24 this.previousElementSibling.value = '';25}26//电话27tel.onblur = function() {28 var reg = /^1[2-9]\d{9}$/;29 if (reg.test(this.value)) {30 this.nextElementSibling.style.backgroundPosition = '19px 0'31 this.nextElementSibling.nextElementSibling.style.backgroundPosition = '-214px 0';32 this.nextElementSibling.nextElementSibling.nextElementSibling.innerHTML = '';33 return true;34 } else {35 this.nextElementSibling.nextElementSibling.nextElementSibling.innerHTML = '手机号码输入错误,请重新输入';36 return false;37 }38}39if (tel = true) {40 btn1.onclick = function() {41 // console.log(this.parentElement.parentElement)42 this.parentElement.parentElement.style.display = 'none';43 this.parentElement.parentElement.nextElementSibling.style.display = 'block'44 }45 //密码46 psw.onblur = function() {47 var reg = /^\w{6,12}$/;48 if (reg.test(this.value) && this.value != '') {49 this.nextElementSibling.style.backgroundPosition = '19px 0'50 this.nextElementSibling.nextElementSibling.style.backgroundPosition = '-214px 0';51 this.nextElementSibling.nextElementSibling.nextElementSibling.innerHTML = '验证完后,你可以使用该手机登录或者找回密码';52 this.nextElementSibling.nextElementSibling.nextElementSibling.innerHTML.style.color = '#ccc';53 return true;54 } else {55 this.nextElementSibling.nextElementSibling.nextElementSibling.innerHTML = '请输入密码';56 return false;57 }58 }59 //确认密码60 //姓名61 name1.onblur = function() {62 var reg = /^[a-zA-Z]{2,10}$/;63 if (reg.test(this.value)) {64 this.nextElementSibling.style.backgroundPosition = '19px 0'65 this.nextElementSibling.nextElementSibling.style.backgroundPosition = '-214px 0';66 this.nextElementSibling.nextElementSibling.nextElementSibling.innerHTML = '';67 return true;68 } else {69 this.nextElementSibling.nextElementSibling.nextElementSibling.innerHTML = '用户名长度只能在4-20个字符之间';70 return false;71 }72 }73 console.log(tel.value)74 //此处还没做75 btn2.onclick = function(e) {76 if (!tel) {77 e = e || window.event;78 e.preventDafault ? e.preventDafault() : e.returnValue = false;79 // return;80 };81 //使用AJAX传参82 ajax({83 url: './php/register.php',84 type: 'post',85 data: {86 'psw': psw.value,87 'name': name1.value,88 },89 //传入参数90 success: function(a) {91 // console.log(111);92 // console.log(a);93 if (a === '注册成功') {94 window.location.href = './login.html';95 };96 if (a === '该电话已经被注册') {97 alert('请重新注册,该用户已经存在')98 }99 }100 })101 }...

Full Screen

Full Screen

quiz.js

Source:quiz.js Github

copy

Full Screen

1var $ = function(id) {2 return document.getElementById(id);3};45var checkAnswer = function(){ 6 7 var question3 = "";8 question3 = $("answer3").value;9 question3 = question3.toLowerCase();10 question3 = question3.trim(); 11 1213 // validate the entries14 15 if ($("SQ").checked) {16 17 $("SQ").nextElementSibling.firstChild.nodeValue = "Correct!!";18 $("NaCl").nextElementSibling.firstChild.nodeValue = "";19 $("$").nextElementSibling.firstChild.nodeValue = "";20 $("Servants").nextElementSibling.firstChild.nodeValue = "";21 22 } else if ($("Servants").checked) {23 24 $("Servants").nextElementSibling.firstChild.nodeValue = "Wrong!!";25 $("SQ").nextElementSibling.firstChild.nodeValue = "";26 $("NaCl").nextElementSibling.firstChild.nodeValue = "";27 $("$").nextElementSibling.firstChild.nodeValue = "";28 } else if ($("$").checked) {29 30 $("$").nextElementSibling.firstChild.nodeValue = "Wrong!!";31 $("Servants").nextElementSibling.firstChild.nodeValue = "";32 $("SQ").nextElementSibling.firstChild.nodeValue = "";33 $("NaCl").nextElementSibling.firstChild.nodeValue = "";34 } else if ($("NaCl").checked) {35 36 $("NaCl").nextElementSibling.firstChild.nodeValue = "Wrong!!";37 $("$").nextElementSibling.firstChild.nodeValue = "";38 $("Servants").nextElementSibling.firstChild.nodeValue = "";39 $("SQ").nextElementSibling.firstChild.nodeValue = "";40 }4142 if ($("Buster").checked) {43 44 $("Buster").nextElementSibling.firstChild.nodeValue = "Correct!!";45 }else{46 $("Buster").nextElementSibling.firstChild.nodeValue = "";47 }48 if ($("Arts").checked) {49 50 $("Arts").nextElementSibling.firstChild.nodeValue = "Correct!!";51 } else{52 $("Arts").nextElementSibling.firstChild.nodeValue = "";53 }54 if ($("Quick").checked){55 56 $("Quick").nextElementSibling.firstChild.nodeValue = "Correct!!";57 } else{58 $("Quick").nextElementSibling.firstChild.nodeValue = "";59 }60 if ($("Nuke").checked) {61 62 $("Nuke").nextElementSibling.firstChild.nodeValue = "Wrong!!";63 } else{64 $("Nuke").nextElementSibling.firstChild.nodeValue = "";65 }6667 if(question3 == "yes"){68 $("answer3").nextElementSibling.firstChild.nodeValue = "Download the app from the Apple store or the Play store.";69 } else if(question3 == "no"){70 $("answer3").nextElementSibling.firstChild.nodeValue = "A shame.";71 } else{72 $("answer3").nextElementSibling.firstChild.nodeValue = 'Please answer "yes" or "no".';73 }74 // submit the form if all entries are valid75 // otherwise, display an error message76 77 78 79};8081window.onload = function() {82 $("checkAnswer").onclick = checkAnswer;83 ...

Full Screen

Full Screen

ChildNode-impl.js

Source:ChildNode-impl.js Github

copy

Full Screen

1"use strict";2const { convertNodesIntoNode } = require("../node");3class ChildNodeImpl {4 remove() {5 if (!this.parentNode) {6 return;7 }8 this.parentNode._remove(this);9 }10 after(...nodes) {11 const parent = this.parentNode;12 if (parent) {13 let viableNextSibling = this.nextSibling;14 let idx = viableNextSibling ? nodes.indexOf(viableNextSibling) : -1;15 while (idx !== -1) {16 viableNextSibling = viableNextSibling.nextSibling;17 if (!viableNextSibling) {18 break;19 }20 idx = nodes.indexOf(viableNextSibling);21 }22 parent._preInsert(convertNodesIntoNode(this._ownerDocument, nodes), viableNextSibling);23 }24 }25 before(...nodes) {26 const parent = this.parentNode;27 if (parent) {28 let viablePreviousSibling = this.previousSibling;29 let idx = viablePreviousSibling ? nodes.indexOf(viablePreviousSibling) : -1;30 while (idx !== -1) {31 viablePreviousSibling = viablePreviousSibling.previousSibling;32 if (!viablePreviousSibling) {33 break;34 }35 idx = nodes.indexOf(viablePreviousSibling);36 }37 parent._preInsert(38 convertNodesIntoNode(this._ownerDocument, nodes),39 viablePreviousSibling ? viablePreviousSibling.nextSibling : parent.firstChild40 );41 }42 }43 replaceWith(...nodes) {44 const parent = this.parentNode;45 if (parent) {46 let viableNextSibling = this.nextSibling;47 let idx = viableNextSibling ? nodes.indexOf(viableNextSibling) : -1;48 while (idx !== -1) {49 viableNextSibling = viableNextSibling.nextSibling;50 if (!viableNextSibling) {51 break;52 }53 idx = nodes.indexOf(viableNextSibling);54 }55 const node = convertNodesIntoNode(this._ownerDocument, nodes);56 if (this.parentNode === parent) {57 parent._replace(node, this);58 } else {59 parent._preInsert(node, viableNextSibling);60 }61 }62 }63}64module.exports = {65 implementation: ChildNodeImpl...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My first test suite', function() 2{3it('My first test case',function() {4cy.get('#checkBoxOption1').check().should('be.checked').and('have.value', 'option1')5cy.get('#checkBoxOption1').uncheck().should('not.be.checked')6cy.get('input[type="checkbox"]').check(['option2', 'option3'])7cy.get('select').select('option2').should('have.value','option2')8cy.get('#autocomplete').type('ind')9cy.get('.ui-menu-item div').each(($el, index, $list) => {10if($el.text()==="India")11{12$el.click()13}14})15cy.get('#displayed-text').should('be.visible')16cy.get('#hide-textbox').click()17cy.get('#displayed-text').should('not.be.visible')18cy.get('#show-textbox').click()19cy.get('#displayed-text').should('be.visible')20cy.get('[value="radio2"]').check().should('be.checked')21})22})23{24 "env": {25 }26}27{28}29describe('My first test suite', function() 30{31it('My first test case',function() {32cy.visit(Cypress.env('url'))33cy.get('#checkBoxOption1

Full Screen

Using AI Code Generation

copy

Full Screen

1import 'cypress-file-upload';2describe('My First Test', function() {3 it('Does not do much!', function() {4 cy.contains('type').click()5 cy.url().should('include', '/commands/actions')6 cy.get('.action-email')7 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', () => {2 it('Does not do much!', () => {3 expect(true).to.equal(true)4 })5 it('Visits the Kitchen Sink', () => {6 cy.contains('type').click()7 cy.url().should('include', '/commands/actions')8 cy.get('.action-email')9 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', () => {2 it('Does not do much!', () => {3 expect(true).to.equal(true)4 })5})6describe('My First Test', () => {7 it('Does not do much!', () => {8 expect(true).to.equal(true)9 })10})11describe('My First Test', () => {12 it('Does not do much!', () => {13 expect(true).to.equal(true)14 })15})16describe('My First Test', () => {17 it('Does not do much!', () => {18 expect(true).to.equal(true)19 })20})21describe('My First Test', () => {22 it('Does not do much!', () => {23 expect(true).to.equal(true)24 })25})26describe('My First Test', () => {27 it('Does not do much!', () => {28 expect(true).to.equal(true)29 })30})31describe('My First Test', () => {32 it('Does not do much!', () => {33 expect(true).to.equal(true)34 })35})36describe('My First Test', () => {37 it('Does not do much!', () => {38 expect(true).to.equal(true)39 })40})41describe('My First Test', () => {42 it('Does not do much!', () => {43 expect(true).to.equal(true)44 })45})46describe('My First Test', () => {47 it('Does not do much!', () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1import 'cypress-file-upload';2describe("Upload file", () => {3 it("Upload file", () => {4 cy.get("#iframeResult").then($iframe => {5 const $body = $iframe.contents().find("body");6 cy.wrap($body)7 .find("#myFile")8 .attachFile("test.png");9 });10 });11});

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.get('button').contains('Add').siblings().click()2cy.get('button').contains('Add').next().click()3cy.get('button').contains('Add').prev().click()4cy.get('button').contains('Add').parent().click()5cy.get('button').contains('Add').parents().click()6cy.get('button').contains('Add').closest().click()7cy.get('button').contains('Add').children().click()8cy.get('button').contains('Add').children().click()9cy.get('button').contains('Add').children().click()10cy.get('button').contains('Add').children().click()11cy.get('button').contains('Add').children().click()12cy.get('button').contains('Add').children().click()13cy.get('button').contains('Add').children().click()

Full Screen

Using AI Code Generation

copy

Full Screen

1import 'cypress-file-upload';2import { AddProductPage } from '../page-objects/add-product-page';3const faker = require('faker');4const addProductPage = new AddProductPage();5describe('Add product', () => {6 beforeEach(() => {7 cy.visit('/admin');8 cy.login('admin', 'admin');9 });10 it('should add a new product', () => {11 addProductPage.visitAddProductPage();12 addProductPage.getProductNameField().type(faker.commerce.productName());13 addProductPage.getQuantityField().type(faker.datatype.number());14 addProductPage.getPriceField().type(faker.datatype.number());15 addProductPage.getUploadFileField().attachFile('test.png');16 addProductPage.getSubmitButton().click();17 addProductPage.getSuccessMessage().should('contain', 'Product added successfully');18 });19});20export class AddProductPage {21 visitAddProductPage() {22 cy.get('.nav-link').contains('Add Product').click();23 }24 getProductNameField() {25 return cy.get('#name');26 }27 getQuantityField() {28 return cy.get('#quantity');29 }30 getPriceField() {31 return cy.get('#price');32 }33 getUploadFileField() {34 return cy.get('#file');35 }36 getSubmitButton() {37 return cy.get('button').contains('Submit');38 }39 getSuccessMessage() {40 return cy.get('.alert-success');41 }42}43Cypress.Commands.add('login', (username, password) => {44 cy.get('#username').type(username);45 cy.get('#password').type(password);46 cy.get('button').contains('Log in').click();47});48import './commands';

Full Screen

Using AI Code Generation

copy

Full Screen

1 .get('[data-cy=child-iframe]')2 .its('0.contentWindow.document')3 .should('exist');4childWindow.its('body').should('not.be.undefined');5childWindow.its('body').should('not.be.empty');6childWindow.its('body').find('button').should('be.visible');7 .get('[data-cy=child-iframe]')8 .its('0.contentWindow.document')9 .should('exist');10childWindow.its('body').should('not.be.undefined');11childWindow.its('body').should('not.be.empty');12childWindow.its('body').find('button').should('be.visible');13 .get('[data-cy=child-iframe]')14 .its('0.contentWindow.document')15 .should('exist');16childWindow.its('body').should('not.be.undefined');17childWindow.its('body').should('not.be.empty');18childWindow.its('body').find('button').should('be.visible');19 .get('[data-cy=child-iframe]')20 .its('0.contentWindow.document')21 .should('exist');22childWindow.its('body').should('not.be.undefined');23childWindow.its('body').should('not.be.empty');24childWindow.its('body').find('button').should('be.visible');25 .get('[data-cy=child-iframe]')26 .its('0.contentWindow.document')27 .should('exist');

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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