How to use pushValue method in Cypress

Best JavaScript code snippet using cypress

WoeCrystalSale.js

Source:WoeCrystalSale.js Github

copy

Full Screen

...74 });75 76 it("fail to purchase with too little funds: pre-launch", async () => {77 // set randoms78 await testableRandom.pushValue(51); // roll to get SUN79 await testableRandom.pushValue(51); // roll to get SUN80 await testableRandom.pushValue(51); // roll to get SUN81 await testableRandom.pushValue(51); // roll to get SUN82 await testableRandom.pushValue(51); // roll to get SUN83 await testableRandom.pushValue(51); // roll to get SUN84 await testableRandom.pushValue(51); // roll to get SUN85 await testableRandom.pushValue(51); // roll to get SUN86 await testableRandom.pushValue(51); // roll to get SUN87 await testableRandom.pushValue(51); // roll to get SUN88 await testableRandom.pushValue(51); // roll to get SUN89 await testableRandom.pushValue(51); // roll to get SUN90 await testableRandom.pushValue(51); // roll to get SUN91 await testableRandom.pushValue(51); // roll to get SUN92 await testableRandom.pushValue(51); // roll to get SUN93 await testableRandom.pushValue(51); // roll to get SUN94 await testableRandom.pushValue(51); // roll to get SUN95 await testableRandom.pushValue(51); // roll to get SUN96 await testableRandom.pushValue(51); // roll to get SUN97 await testableRandom.pushValue(51); // roll to get SUN98 await testableRandom.pushValue(51); // roll to get SUN99 await testableRandom.pushValue(51); // roll to get SUN100 await testableRandom.pushValue(51); // roll to get SUN101 await testableRandom.pushValue(51); // roll to get SUN102 await testableRandom.pushValue(51); // roll to get SUN103 var isPostLaunch = await woeCrystalSale.postLaunch.call();104 assert(!isPostLaunch);105 //get price for 1 crystal106 var fee = await woeCrystalSale.RANDOM_CRYSTAL_PRE_LAUNCH_PRICE.call();107 //fail purchase of 1 crystal with reduced funds108 await expectThrow(woeCrystalSale.purchaseRandomCrystal( { value : fee * .9 , from : account_four }));109 110 //get price for 5 crystals111 fee = await woeCrystalSale.RANDOM_CRYSTAL_FIVE_PRE_LAUNCH_PRICE.call();112 //fail purchase of 5 crystals with reduced funds113 await expectThrow(woeCrystalSale.purchaseRandomCrystalFive( { value : fee * .9 , from : account_four }));114 115 //get price for 25 crystals116 fee = await woeCrystalSale.RANDOM_CRYSTAL_TWENTY_FIVE_PRE_LAUNCH_PRICE.call();117 //fail purchase of 25 crystals with reduced funds118 await expectThrow(woeCrystalSale.purchaseRandomCrystalTwentyFive( { value : fee * .9 , from : account_four }));119 });120 it("fail to purchase with too little funds: POST-launch", async () => {121 // set randoms122 await testableRandom.pushValue(51); // roll to get SUN123 await testableRandom.pushValue(51); // roll to get SUN124 await testableRandom.pushValue(51); // roll to get SUN125 await testableRandom.pushValue(51); // roll to get SUN126 await testableRandom.pushValue(51); // roll to get SUN127 await testableRandom.pushValue(51); // roll to get SUN128 await testableRandom.pushValue(51); // roll to get SUN129 await testableRandom.pushValue(51); // roll to get SUN130 await testableRandom.pushValue(51); // roll to get SUN131 await testableRandom.pushValue(51); // roll to get SUN132 await testableRandom.pushValue(51); // roll to get SUN133 await testableRandom.pushValue(51); // roll to get SUN134 await testableRandom.pushValue(51); // roll to get SUN135 await testableRandom.pushValue(51); // roll to get SUN136 await testableRandom.pushValue(51); // roll to get SUN137 await testableRandom.pushValue(51); // roll to get SUN138 await testableRandom.pushValue(51); // roll to get SUN139 await testableRandom.pushValue(51); // roll to get SUN140 await testableRandom.pushValue(51); // roll to get SUN141 await testableRandom.pushValue(51); // roll to get SUN142 await testableRandom.pushValue(51); // roll to get SUN143 await testableRandom.pushValue(51); // roll to get SUN144 await testableRandom.pushValue(51); // roll to get SUN145 await testableRandom.pushValue(51); // roll to get SUN146 await testableRandom.pushValue(51); // roll to get SUN147 // launch mainnet price148 await woeCrystalSale.launch();149 var isPostLaunch = await woeCrystalSale.postLaunch.call();150 assert(isPostLaunch);151 //get price for 1 crystal152 var fee = await woeCrystalSale.RANDOM_CRYSTAL_PRE_LAUNCH_PRICE.call();153 //fail purchase of 1 crystal with reduced funds154 await expectThrow(woeCrystalSale.purchaseRandomCrystal( { value : fee , from : account_four }));155 156 //get price for 5 crystals157 fee = await woeCrystalSale.RANDOM_CRYSTAL_FIVE_PRE_LAUNCH_PRICE.call();158 //fail purchase of 5 crystals with reduced funds159 await expectThrow(woeCrystalSale.purchaseRandomCrystalFive( { value : fee , from : account_four }));160 161 //get price for 25 crystals162 fee = await woeCrystalSale.RANDOM_CRYSTAL_TWENTY_FIVE_PRE_LAUNCH_PRICE.call();163 //fail purchase of 25 crystals with reduced funds164 await expectThrow(woeCrystalSale.purchaseRandomCrystalTwentyFive( { value : fee, from : account_four }));165 });166 it("purchase 1 random crystal | pre-launch", async () => {167 await testableRandom.pushValue(51); // roll to get SUN168 await testableRandom.pushValue(51); // roll to get SUN169 //no crystal yet in account four170 var totalCrystals = await woeSunCrystal.totalSupply.call({ from: account_four });171 assert.equal(totalCrystals.toNumber(), 0);172 var isPostLaunch = await woeCrystalSale.postLaunch.call();173 assert(!isPostLaunch);174 //get price for 1 crystal175 var fee = await woeCrystalSale.RANDOM_CRYSTAL_PRE_LAUNCH_PRICE.call();176 //purchase 1 crystal177 await woeCrystalSale.purchaseRandomCrystal( { value : fee, from : account_four });178 await woeCrystalSale.purchaseRandomCrystal( { value : fee, from : account_one });179 // check account ones balance180 var crystalOwner = await woeSunCrystal.balanceOf(account_one);181 assert.equal(crystalOwner.toNumber(), 2);182 // check account fours balance183 crystalOwner = await woeSunCrystal.balanceOf(account_four);184 assert.equal(crystalOwner.toNumber(), 2);185 //total crystals now at 2186 totalCrystals = await woeSunCrystal.totalSupply.call();187 assert.equal(totalCrystals.toNumber(), 4);188 });189 it("purchase 1 random crystal | post-launch", async () => {190 await testableRandom.pushValue(51); // roll to get SUN191 await testableRandom.pushValue(51); // roll to get SUN192 //no crystal yet in account four193 var totalCrystals = await woeSunCrystal.totalSupply.call({ from: account_four });194 assert.equal(totalCrystals.toNumber(), 0);195 // launch mainnet price196 await woeCrystalSale.launch();197 var isPostLaunch = await woeCrystalSale.postLaunch.call();198 assert(isPostLaunch);199 //get price for 1 crystal200 var fee = await woeCrystalSale.RANDOM_CRYSTAL_POST_LAUNCH_PRICE.call();201 //purchase 1 crystal202 await woeCrystalSale.purchaseRandomCrystal( { value : fee, from : account_four });203 await woeCrystalSale.purchaseRandomCrystal( { value : fee, from : account_one });204 // check account ones balance205 var crystalOwner = await woeSunCrystal.balanceOf(account_one);206 assert.equal(crystalOwner.toNumber(), 2);207 // check account fours balance208 crystalOwner = await woeSunCrystal.balanceOf(account_four);209 assert.equal(crystalOwner.toNumber(), 2);210 //total crystals now at 2211 totalCrystals = await woeSunCrystal.totalSupply.call();212 assert.equal(totalCrystals.toNumber(), 4);213 });214 it("purchase 5 random crystals | pre-launch", async () => {215 await testableRandom.pushValue(51); // roll to get SUN216 await testableRandom.pushValue(40); // roll to get OCEAN217 await testableRandom.pushValue(29); // roll to get LIFE218 await testableRandom.pushValue(14); // roll to get DEATH219 await testableRandom.pushValue(4); // roll to get ASTRAL220 //no SUN crystal yet in account four221 var totalCrystals = await woeSunCrystal.totalSupply.call({ from: account_four });222 assert.equal(totalCrystals.toNumber(), 0);223 //no OCEAN crystal yet in account four224 totalCrystals = await woeOceanCrystal.totalSupply.call({ from: account_four });225 assert.equal(totalCrystals.toNumber(), 0);226 //no LIFE crystal yet in account four227 totalCrystals = await woeLifeCrystal.totalSupply.call({ from: account_four });228 assert.equal(totalCrystals.toNumber(), 0);229 //no DEATH crystal yet in account four230 totalCrystals = await woeDeathCrystal.totalSupply.call({ from: account_four });231 assert.equal(totalCrystals.toNumber(), 0);232 //no ASTRAL crystal yet in account four233 totalCrystals = await woeAstralCrystal.totalSupply.call({ from: account_four });234 assert.equal(totalCrystals.toNumber(), 0);235 var isPostLaunch = await woeCrystalSale.postLaunch.call();236 assert(!isPostLaunch);237 //get price for 5 crystals238 var fee = await woeCrystalSale.RANDOM_CRYSTAL_FIVE_PRE_LAUNCH_PRICE.call();239 //purchase 5 crystals240 await woeCrystalSale.purchaseRandomCrystalFive( { value : fee, from : account_four });241 // check account fours SUN balance242 var crystalOwner = await woeSunCrystal.balanceOf(account_four);243 assert.equal(crystalOwner.toNumber(), 2);244 // check account fours OCEAN balance245 var crystalOwner = await woeOceanCrystal.balanceOf(account_four);246 assert.equal(crystalOwner.toNumber(), 1);247 // check account fours LIFE balance248 var crystalOwner = await woeLifeCrystal.balanceOf(account_four);249 assert.equal(crystalOwner.toNumber(), 1);250 // check account fours DEATH balance251 var crystalOwner = await woeDeathCrystal.balanceOf(account_four);252 assert.equal(crystalOwner.toNumber(), 1);253 // check account fours ASTRAL balance254 var crystalOwner = await woeAstralCrystal.balanceOf(account_four);255 assert.equal(crystalOwner.toNumber(), 1);256 });257 it("purchase 5 random crystals | pre-launch", async () => {258 await testableRandom.pushValue(51); // roll to get SUN259 await testableRandom.pushValue(40); // roll to get OCEAN260 await testableRandom.pushValue(29); // roll to get LIFE261 await testableRandom.pushValue(14); // roll to get DEATH262 await testableRandom.pushValue(4); // roll to get ASTRAL263 //no SUN crystal yet in account four264 var totalCrystals = await woeSunCrystal.totalSupply.call({ from: account_four });265 assert.equal(totalCrystals.toNumber(), 0);266 //no OCEAN crystal yet in account four267 totalCrystals = await woeOceanCrystal.totalSupply.call({ from: account_four });268 assert.equal(totalCrystals.toNumber(), 0);269 //no LIFE crystal yet in account four270 totalCrystals = await woeLifeCrystal.totalSupply.call({ from: account_four });271 assert.equal(totalCrystals.toNumber(), 0);272 //no DEATH crystal yet in account four273 totalCrystals = await woeDeathCrystal.totalSupply.call({ from: account_four });274 assert.equal(totalCrystals.toNumber(), 0);275 //no ASTRAL crystal yet in account four276 totalCrystals = await woeAstralCrystal.totalSupply.call({ from: account_four });277 assert.equal(totalCrystals.toNumber(), 0);278 // launch mainnet price279 await woeCrystalSale.launch();280 var isPostLaunch = await woeCrystalSale.postLaunch.call();281 assert(isPostLaunch);282 //get price for 5 crystals283 var fee = await woeCrystalSale.RANDOM_CRYSTAL_FIVE_POST_LAUNCH_PRICE.call();284 //purchase 5 crystals285 await woeCrystalSale.purchaseRandomCrystalFive( { value : fee, from : account_four });286 // check account fours SUN balance287 var crystalOwner = await woeSunCrystal.balanceOf(account_four);288 assert.equal(crystalOwner.toNumber(), 2);289 // check account fours OCEAN balance290 var crystalOwner = await woeOceanCrystal.balanceOf(account_four);291 assert.equal(crystalOwner.toNumber(), 1);292 // check account fours LIFE balance293 var crystalOwner = await woeLifeCrystal.balanceOf(account_four);294 assert.equal(crystalOwner.toNumber(), 1);295 // check account fours DEATH balance296 var crystalOwner = await woeDeathCrystal.balanceOf(account_four);297 assert.equal(crystalOwner.toNumber(), 1);298 // check account fours ASTRAL balance299 var crystalOwner = await woeAstralCrystal.balanceOf(account_four);300 assert.equal(crystalOwner.toNumber(), 1);301 });302 it("purchase 25 random crystals | pre-launch", async () => {303 await testableRandom.pushValue(4); // roll to get ASTRAL304 await testableRandom.pushValue(4); // roll to get ASTRAL305 await testableRandom.pushValue(4); // roll to get ASTRAL306 await testableRandom.pushValue(4); // roll to get ASTRAL307 await testableRandom.pushValue(4); // roll to get ASTRAL308 await testableRandom.pushValue(4); // roll to get ASTRAL309 await testableRandom.pushValue(4); // roll to get ASTRAL310 await testableRandom.pushValue(4); // roll to get ASTRAL311 await testableRandom.pushValue(4); // roll to get ASTRAL312 await testableRandom.pushValue(4); // roll to get ASTRAL313 await testableRandom.pushValue(4); // roll to get ASTRAL314 await testableRandom.pushValue(4); // roll to get ASTRAL315 await testableRandom.pushValue(4); // roll to get ASTRAL316 await testableRandom.pushValue(4); // roll to get ASTRAL317 await testableRandom.pushValue(4); // roll to get ASTRAL318 await testableRandom.pushValue(4); // roll to get ASTRAL319 await testableRandom.pushValue(4); // roll to get ASTRAL320 await testableRandom.pushValue(4); // roll to get ASTRAL321 await testableRandom.pushValue(4); // roll to get ASTRAL322 await testableRandom.pushValue(4); // roll to get ASTRAL323 await testableRandom.pushValue(4); // roll to get ASTRAL324 await testableRandom.pushValue(4); // roll to get ASTRAL325 await testableRandom.pushValue(4); // roll to get ASTRAL326 await testableRandom.pushValue(4); // roll to get ASTRAL327 await testableRandom.pushValue(4); // roll to get ASTRAL328 await testableRandom.pushValue(4); // roll to get ASTRAL329 await testableRandom.pushValue(4); // roll to get ASTRAL330 await testableRandom.pushValue(4); // roll to get ASTRAL331 await testableRandom.pushValue(4); // roll to get ASTRAL332 await testableRandom.pushValue(4); // roll to get ASTRAL333 334 //no crystal yet in account four335 var totalCrystals = await woeAstralCrystal.totalSupply.call({ from: account_four });336 assert.equal(totalCrystals.toNumber(), 0);337 var isPostLaunch = await woeCrystalSale.postLaunch.call();338 assert(!isPostLaunch);339 //get price for 1 crystal340 var fee = await woeCrystalSale.RANDOM_CRYSTAL_TWENTY_FIVE_PRE_LAUNCH_PRICE.call();341 //purchase 25 crystals342 await woeCrystalSale.purchaseRandomCrystalTwentyFive( { value : fee, from : account_four });343 //total crystals now at 25344 var totalCrystals = await woeAstralCrystal.totalSupply.call();345 assert.equal(totalCrystals.toNumber(), 25);346 });347 it("purchase 25 random crystals | pre-launch", async () => {348 await testableRandom.pushValue(4); // roll to get ASTRAL349 await testableRandom.pushValue(4); // roll to get ASTRAL350 await testableRandom.pushValue(4); // roll to get ASTRAL351 await testableRandom.pushValue(4); // roll to get ASTRAL352 await testableRandom.pushValue(4); // roll to get ASTRAL353 await testableRandom.pushValue(4); // roll to get ASTRAL354 await testableRandom.pushValue(4); // roll to get ASTRAL355 await testableRandom.pushValue(4); // roll to get ASTRAL356 await testableRandom.pushValue(4); // roll to get ASTRAL357 await testableRandom.pushValue(4); // roll to get ASTRAL358 await testableRandom.pushValue(4); // roll to get ASTRAL359 await testableRandom.pushValue(4); // roll to get ASTRAL360 await testableRandom.pushValue(4); // roll to get ASTRAL361 await testableRandom.pushValue(4); // roll to get ASTRAL362 await testableRandom.pushValue(4); // roll to get ASTRAL363 await testableRandom.pushValue(4); // roll to get ASTRAL364 await testableRandom.pushValue(4); // roll to get ASTRAL365 await testableRandom.pushValue(4); // roll to get ASTRAL366 await testableRandom.pushValue(4); // roll to get ASTRAL367 await testableRandom.pushValue(4); // roll to get ASTRAL368 await testableRandom.pushValue(4); // roll to get ASTRAL369 await testableRandom.pushValue(4); // roll to get ASTRAL370 await testableRandom.pushValue(4); // roll to get ASTRAL371 await testableRandom.pushValue(4); // roll to get ASTRAL372 await testableRandom.pushValue(4); // roll to get ASTRAL373 await testableRandom.pushValue(4); // roll to get ASTRAL374 await testableRandom.pushValue(4); // roll to get ASTRAL375 await testableRandom.pushValue(4); // roll to get ASTRAL376 await testableRandom.pushValue(4); // roll to get ASTRAL377 await testableRandom.pushValue(4); // roll to get ASTRAL378 379 //no crystal yet in account four380 var totalCrystals = await woeAstralCrystal.totalSupply.call({ from: account_four });381 assert.equal(totalCrystals.toNumber(), 0);382 // launch mainnet price383 await woeCrystalSale.launch();384 var isPostLaunch = await woeCrystalSale.postLaunch.call();385 assert(isPostLaunch);386 //get price for 1 crystal387 var fee = await woeCrystalSale.RANDOM_CRYSTAL_TWENTY_FIVE_POST_LAUNCH_PRICE.call();388 //purchase 25 crystals389 await woeCrystalSale.purchaseRandomCrystalTwentyFive( { value : fee, from : account_four });390 //total crystals now at 25391 var totalCrystals = await woeAstralCrystal.totalSupply.call();392 assert.equal(totalCrystals.toNumber(), 25);393 });394 it("fail without having purchased Egg", async () => {395 await testableRandom.pushValue(51); // value irrelevant396 //fail to redeem397 await expectThrow(woeCrystalSale.redeemCrystal( {from : account_four }));398 });399 it("redeem random crystal: sun", async () => {400 await testableRandom.pushValue(51); // roll to get SUN401 //no crystal yet in account four402 var totalCrystals = await woeSunCrystal.totalSupply.call({ from: account_four });403 assert.equal(totalCrystals.toNumber(), 0);404 405 //set has purcahsed egg406 await woeDatabase.setHasPurchasedEgg(account_four);407 408 //redeem crystal409 await woeCrystalSale.redeemCrystal( { from : account_four });410 // check account fours balance411 var crystalOwner = await woeSunCrystal.balanceOf(account_four);412 assert.equal(crystalOwner.toNumber(), 2);413 //total crystals now at 1414 totalCrystals = await woeSunCrystal.totalSupply.call();415 assert.equal(totalCrystals.toNumber(), 2);416 });417 it("redeem crystal: ocean", async () => {418 await testableRandom.pushValue(40); // roll to get OCEAN419 //no crystal yet in account four420 var totalCrystals = await woeOceanCrystal.totalSupply.call({ from: account_four });421 assert.equal(totalCrystals.toNumber(), 0);422 ///set has purcahsed egg423 await woeDatabase.setHasPurchasedEgg(account_four);424 425 //redeem crystal426 await woeCrystalSale.redeemCrystal( { from : account_four });427 // check account fours balance428 var crystalOwner = await woeOceanCrystal.balanceOf(account_four);429 assert.equal(crystalOwner.toNumber(), 1);430 //total crystals now at 1431 totalCrystals = await woeOceanCrystal.totalSupply.call();432 assert.equal(totalCrystals.toNumber(), 1);433 });434 it("redeem crystal: life", async () => {435 await testableRandom.pushValue(29); // roll to get LIFE436 //no crystal yet in account four437 var totalCrystals = await woeLifeCrystal.totalSupply.call({ from: account_four });438 assert.equal(totalCrystals.toNumber(), 0);439 //set has purcahsed egg440 await woeDatabase.setHasPurchasedEgg(account_four);441 442 //redeem crystal443 await woeCrystalSale.redeemCrystal( { from : account_four });444 // check account fours balance445 var crystalOwner = await woeLifeCrystal.balanceOf(account_four);446 assert.equal(crystalOwner.toNumber(), 1);447 //total crystals now at 1448 totalCrystals = await woeLifeCrystal.totalSupply.call();449 assert.equal(totalCrystals.toNumber(), 1);450 });451 it("redeem crystal: death", async () => {452 await testableRandom.pushValue(14); // roll to get death453 //no crystal yet in account four454 var totalCrystals = await woeDeathCrystal.totalSupply.call({ from: account_four });455 assert.equal(totalCrystals.toNumber(), 0);456 //set has purcahsed egg457 await woeDatabase.setHasPurchasedEgg(account_four);458 459 //redeem crystal460 await woeCrystalSale.redeemCrystal( { from : account_four });461 // check account fours balance462 var crystalOwner = await woeDeathCrystal.balanceOf(account_four);463 assert.equal(crystalOwner.toNumber(), 1);464 //total crystals now at 1465 totalCrystals = await woeDeathCrystal.totalSupply.call();466 assert.equal(totalCrystals.toNumber(), 1);467 });468 it("redeem crystal: astral", async () => {469 await testableRandom.pushValue(4); // roll to get astral470 //no crystal yet in account four471 var totalCrystals = await woeAstralCrystal.totalSupply.call({ from: account_four });472 assert.equal(totalCrystals.toNumber(), 0);473 //set has purcahsed egg474 await woeDatabase.setHasPurchasedEgg(account_four);475 476 //redeem crystal477 await woeCrystalSale.redeemCrystal( { from : account_four });478 // check account fours balance479 var crystalOwner = await woeAstralCrystal.balanceOf(account_four);480 assert.equal(crystalOwner.toNumber(), 1);481 //total crystals now at 1482 totalCrystals = await woeAstralCrystal.totalSupply.call();483 assert.equal(totalCrystals.toNumber(), 1);...

Full Screen

Full Screen

node-red-contrib-prolights.js

Source:node-red-contrib-prolights.js Github

copy

Full Screen

...23 return;24 }25 }26 }27 function pushValue(arr, index, v) {28 if(checkValue(v)) {29 removeChannelByIndex(arr, index);30 arr.push({channel:index, value:v});31 return v;32 }33 return -1;34 }35 function getValue(name, c, p) {36 var fromPayload = node.data_source === 'payload' || node.data_source === "configuration_payload";37 return fromPayload ? (p.hasOwnProperty(name) ? p[name] : -1) : (c.hasOwnProperty(name) ? c[name] : -1);38 }39 function checkValue(v) {40 return v > -1 && v < 256;41 }42 function parseLUMIPAR12UTRI(payload) {43 var buckets = payload.buckets || [];44 var conf = {};45 conf.channels = node.data_source !== 'payload' ? config.channels : (payload.channels || "3channels");46 conf.address_start = node.data_source !== 'payload' ? config.address_start : (payload.address_start || 1);47 var isChannelsFromPayload = node.data_source === 'payload' || node.data_source === "configuration_payload";48 var isChannelsFromConfig = node.data_source === 'configuration';49 var is8Channels = conf.channels == "8channels";50 var index = conf.address_start;51 if(isChannelsFromPayload || isChannelsFromConfig){52 conf.red = pushValue(buckets, index++, getValue("red", config, payload));53 conf.green = pushValue(buckets, index++, getValue("green", config, payload));54 conf.blue = pushValue(buckets, index++, getValue("blue", config, payload));55 if(is8Channels) {56 conf.color = pushValue(buckets, index++, getValue("color", config, payload));57 conf.strobe = pushValue(buckets, index++, getValue("strobe", config, payload));58 conf.program = pushValue(buckets, index++, getValue("program", config, payload));59 conf.dimmer = pushValue(buckets, index++, getValue("dimmer", config, payload));60 conf.dimmer_speed = pushValue(buckets, index++, getValue("dimmer_speed", config, payload));61 }62 } else {63 var parameters = payload.ParameterList.Parameter;64 var colorStateObject = node.findObjectById(57, parameters);65 var powerStateObject = node.findObjectById(56, parameters);66 if(powerStateObject && is8Channels) {67 conf.dimmer = pushValue(buckets, conf.address_start+6, powerStateObject.Value === "on" ? 255 : 0 );68 }69 if(colorStateObject){70 var colorState = colorStateObject.Value;71 var colors = ["Red", "Green", "Blue"];72 var colorsIndexes = [0, 1, 2];73 var colorIndex = colors.indexOf(colorState);74 if(colorIndex != -1){75 conf[colors[colorIndex].toLocaleLowerCase()] = pushValue(buckets, conf.address_start + colorsIndexes[colorIndex], 255);76 }77 var htoR = node.hexToRgb(colorState);78 var rgb = /\((\d{1,3})\,(\d{1,3})\,(\d{1,3})\)/.exec(colorState);79 if(rgb && rgb.length == 4){80 htoR = {r: rgb[1],g: rgb[2], b: rgb[3]};81 }82 if(htoR){83 conf.red = pushValue(buckets, conf.address_start, htoR.r);84 conf.green = pushValue(buckets, conf.address_start+1, htoR.g);85 conf.blue = pushValue(buckets, conf.address_start+2, htoR.b);86 }87 }88 }89 return buckets;90 }91 function parseLUMIPAR12UQPRO(payload) {92 var buckets = payload.buckets || [];93 var conf = {};94 conf.channels = node.data_source !== 'payload' ? config.channels : (payload.channels || "4channels");95 conf.address_start = node.data_source !== 'payload' ? config.address_start : (payload.address_start || 1);96 var isChannelsFromPayload = node.data_source === 'payload' || node.data_source === "configuration_payload";97 var isChannelsFromConfig = node.data_source === 'configuration';98 var is9Channels = conf.channels == "9channels";99 var index = conf.address_start;100 if(isChannelsFromPayload || isChannelsFromConfig){101 conf.red = pushValue(buckets, index++, getValue("red", config, payload));102 conf.green = pushValue(buckets, index++, getValue("green", config, payload));103 conf.blue = pushValue(buckets, index++, getValue("blue", config, payload));104 conf.white = pushValue(buckets, index++, getValue("white", config, payload));105 if(is9Channels) {106 conf.color = pushValue(buckets, index++, getValue("color", config, payload));107 conf.strobe = pushValue(buckets, index++, getValue("strobe", config, payload));108 conf.program = pushValue(buckets, index++, getValue("program", config, payload));109 conf.dimmer = pushValue(buckets, index++, getValue("dimmer", config, payload));110 conf.dimmer_speed = pushValue(buckets, index++, getValue("dimmer_speed", config, payload));111 }112 } else {113 var parameters = payload.ParameterList.Parameter;114 var colorStateObject = node.findObjectById(57, parameters);115 var powerStateObject = node.findObjectById(56, parameters);116 if(powerStateObject) {117 var powerState = powerStateObject.Value === "on" ? 255 : 0;118 if(is9Channels) {119 conf.dimmer = pushValue(buckets, conf.address_start + 7, powerState);120 }121 if(colorStateObject) {122 var colorState = colorStateObject.Value;123 var colors = ["Red", "Green", "Blue", "White"];124 var colorsIndexes = [0, 1, 2, 3];125 var colorIndex = colors.indexOf(colorState);126 if(colorIndex != -1){127 conf[colors[colorIndex].toLocaleLowerCase()] = pushValue(buckets, conf.address_start + colorsIndexes[colorIndex], 255);128 }129 var htoR = node.hexToRgb(colorState);130 var rgb = /\((\d{1,3})\,(\d{1,3})\,(\d{1,3})\)/.exec(colorState);131 if(rgb && rgb.length == 4){132 htoR = {r: rgb[1],g: rgb[2], b: rgb[3]};133 }134 if(htoR){135 conf.red = pushValue(buckets, conf.address_start, htoR.r);136 conf.green = pushValue(buckets, conf.address_start+1, htoR.g);137 conf.blue = pushValue(buckets, conf.address_start+2, htoR.b);138 }139 } else {140 conf.white = pushValue(buckets, conf.address_start + 3, powerState);141 }142 }143 }144 return buckets;145 }146 function parseLUMIPAR12UAW(payload) {147 var buckets = payload.buckets || [];148 var conf = {};149 conf.channels = node.data_source !== 'payload' ? config.channels : (payload.channels || "3channels");150 conf.address_start = node.data_source !== 'payload' ? config.address_start : (payload.address_start || 1);151 var isChannelsFromPayload = node.data_source === 'payload' || node.data_source === "configuration_payload";152 var isChannelsFromConfig = node.data_source === 'configuration';153 var is7Channels = conf.channels == "7channels";154 var index = conf.address_start;155 if(isChannelsFromPayload || isChannelsFromConfig){156 conf.amber = pushValue(buckets, index++, getValue("amber", config, payload));157 conf.cold_white = pushValue(buckets, index++, getValue("cold_white", config, payload));158 conf.warm_white = pushValue(buckets, index++, getValue("warm_white", config, payload));159 if(is7Channels) {160 conf.strobe = pushValue(buckets, index++, getValue("strobe", config, payload));161 conf.program = pushValue(buckets, index++, getValue("program", config, payload));162 conf.dimmer = pushValue(buckets, index++, getValue("dimmer", config, payload));163 conf.dimmer_speed = pushValue(buckets, index++, getValue("dimmer_speed", config, payload));164 }165 } else {166 var parameters = payload.ParameterList.Parameter;167 var powerStateObject = node.findObjectById(56, parameters);168 if(powerStateObject && is7Channels) {169 var powerState = powerStateObject.Value === "on" ? 255 : 0;170 conf.cold_white = pushValue(buckets, conf.address_start + 1, powerState);171 if(is7Channels) {172 conf.dimmer = pushValue(buckets, conf.address_start + 5, powerState);173 }174 }175 }176 return buckets;177 }178 function parsePIXIEWASH(payload) {179 var buckets = payload.buckets || [];180 var conf = {};181 conf.channels = node.data_source !== 'payload' ? config.channels : (payload.channels || "13channels");182 conf.address_start = node.data_source !== 'payload' ? config.address_start : (payload.address_start || 1);183 var isChannelsFromPayload = node.data_source === 'payload' || node.data_source === "configuration_payload";184 var isChannelsFromConfig = node.data_source === 'configuration';185 186 var is16Channels = conf.channels == "16channels";187 var index = conf.address_start;188 if(isChannelsFromPayload || isChannelsFromConfig){189 conf.pan = pushValue(buckets, index++, getValue("pan", config, payload));190 conf.pan_fine = pushValue(buckets, index++, getValue("pan_fine", config, payload));191 conf.tilt = pushValue(buckets, index++, getValue("tilt", config, payload));192 conf.tilt_fine = pushValue(buckets, index++, getValue("tilt_fine", config, payload));193 conf.pan_tilt_speed = pushValue(buckets, index++, getValue("pan_tilt_speed", config, payload));194 conf.special_function = pushValue(buckets, index++, getValue("special_function", config, payload));195 conf.dimmer = pushValue(buckets, index++, getValue("dimmer", config, payload));196 conf.shutter = pushValue(buckets, index++, getValue("shutter", config, payload));197 conf.red = pushValue(buckets, index++, getValue("red", config, payload));198 conf.green = pushValue(buckets, index++, getValue("green", config, payload));199 conf.blue = pushValue(buckets, index++, getValue("blue", config, payload));200 conf.white = pushValue(buckets, index++, getValue("white", config, payload));201 if(is16Channels) {202 conf.color_function = pushValue(buckets, index++, getValue("color_function", config, payload));203 conf.color = pushValue(buckets, index++, getValue("color", config, payload));204 conf.zoom = pushValue(buckets, index++, getValue("zoom", config, payload));205 conf.dimmer_speed = pushValue(buckets, index++, getValue("dimmer_speed", config, payload));206 } else {207 conf.zoom = pushValue(buckets, index++, getValue("zoom", config, payload));208 }209 } else {210 var parameters = payload.ParameterList.Parameter;211 var colorStateObject = node.findObjectById(57, parameters);212 var powerStateObject = node.findObjectById(56, parameters);213 if(powerStateObject) {214 var powerState = powerStateObject.Value === "on" ? 255 : 0;215 conf.dimmer = pushValue(buckets, conf.address_start + 6, powerState);216 if(colorStateObject){217 var colorState = colorStateObject.Value;218 var colors = ["Red", "Green", "Blue", "White"];219 var colorsIndexes = [8, 9, 10, 11];220 var colorIndex = colors.indexOf(colorState);221 if(colorIndex != -1){222 conf[colors[colorIndex].toLocaleLowerCase()] = pushValue(buckets, conf.address_start + colorsIndexes[colorIndex], 255);223 }224 var htoR = node.hexToRgb(colorState);225 var rgb = /\((\d{1,3})\,(\d{1,3})\,(\d{1,3})\)/.exec(colorState);226 if(rgb && rgb.length == 4){227 htoR = {r: rgb[1],g: rgb[2], b: rgb[3]};228 }229 if(htoR){230 conf.red = pushValue(buckets, conf.address_start + 8, htoR.r);231 conf.green = pushValue(buckets, conf.address_start + 9, htoR.g);232 conf.blue = pushValue(buckets, conf.address_start + 10, htoR.b);233 }234 } else {235 conf.white = pushValue(buckets, conf.address_start + 11, powerState);236 }237 }238 }239 return buckets;240 }241 this.on('input', function (msg) {242 var payload = msg.payload;243 var device_type = node.data_source !== 'payload' ? config.device_type : (payload.device_type || "LUMIPAR12UTRI");244 var transition = (node.data_source !== 'payload' ? config.transition : payload.transition) || false;245 var duration = (node.data_source !== 'payload' ? config.duration : payload.duration) || 0;246 var isTransition = transition && duration > 0;247 if(isTransition){248 var startBuckets = payload.buckets || [];249 if(payload.buckets){...

Full Screen

Full Screen

click.js

Source:click.js Github

copy

Full Screen

...19 var date = new Date();20 var s = [];21 var im = new Image;22 23 function pushValue(name, value) {24 s.push(name + '=' + value);25 }26 27 function saveToCookise(name, value, days) {28 date.setTime(date.getTime() + (days * 24 * 3600 * 1000 * 365));29 document.cookie = name + "=" + escape(value) + ((days == null) ? "" : "; expires=" + date.toGMTString()) + "; domain=.xywy.com ;path=/";30 }31 32 function getFromCookise(name) {33 if (document.cookie.length > 0) {34 var begin = document.cookie.indexOf(name + "=");35 if (begin != -1) {36 begin += name.length + 1;37 var end = document.cookie.indexOf(";", begin);38 if (end == -1)39 end = document.cookie.length;40 return ue(document.cookie.substring(begin, end));41 }42 }43 return null;44 }45 46 // 澶勭悊ref47 if (ref_click) {48 pushValue('ref', ref_click + 'ref');49 }50 51 // 澶勭悊clientID52 if (!getFromCookise('clientac')) {53 var clientID = date.getTime() + parseInt(Math.random(10, 1) * 100);54 pushValue('clientID', clientID + 'clientID');55 saveToCookise('clientac', clientID, '5');56 } else {57 pushValue('clientID', getFromCookise('clientac') + 'clientID');58 }59 60 // 澶勭悊loginID61 if (getFromCookise("cookie_user")) {62 pushValue('loginID', getFromCookise("cookie_user") + 'loginID');63 } else {64 pushValue('loginID', '' + 'loginID');65 }66 67 // 澶勭悊usertype68 if (getFromCookise("cookie_usertype")) {69 pushValue('usertype', getFromCookise("cookie_usertype") + 'usertype');70 } else {71 pushValue('usertype', '' + 'usertype');72 }73 // 澶勭悊鎭舵剰鍒锋柊 瀵艰嚧pv缁熻涓嶅噯鐨勯棶棰� 鏍规嵁cookie涓偍瀛樼殑涓婁竴涓姹傚拰璇锋眰鏃堕棿 鍒ゆ柇鏄惁闇€瑕佸彂鍑篶l.png璇锋眰74 var canSendCLpng = true;75 var acl = encodeURI(document.location.href.replace(/#/g, "~"));76 if (getFromCookise("cl_lastUrl")) {77 if (acl == getFromCookise("cl_lastUrl")) {78 if (getFromCookise("cl_lastUrl_time")) {79 var offset = parseInt(date.getTime()) - parseInt(getFromCookise("cl_lastUrl_time"));80 if (parseInt(offset) < 2000) {81 canSendCLpng = false;82 }83 }84 } else {85 }86 } else {87 }88 // 璁拌浇璁块棶url鍜屾椂闂�89 saveToCookise('cl_lastUrl', acl, '5');90 saveToCookise('cl_lastUrl_time', new Date().getTime(), '5');91 pushValue('AcT', acl + 'AcT');92 93 // 娣诲姞鏃ュ織绫诲瀷鍙傛暟94 // 姝ゆ暟鎹互鍚庣敤鏉ユ爣璇嗕笟鍔$被鍨嬶紙瑙佷笅闈級95 // pushValue('clickType', '0' + 'clickType');96 97 // 娣诲姞xpoint98 pushValue('xPoint', xpoint + 'xPoint');99 100 // 娣诲姞ypoint101 pushValue('yPoint', ypoint + 'yPoint');102 103 // 娣诲姞domid104 pushValue('domID', domid + 'domID');105 106 // 娣诲姞clicken107 pushValue('clickEN', clicken + 'clickEN');108 // 娣诲姞clickType109 pushValue('clickType', clickType + 'clickType');110 // 娣诲姞random鍙傛暟锛屼娇璇锋眰鐪嬭捣鏉ヤ笉鍚�111 pushValue('randomNUM', Math.random(10, 1)*100 + 'randomNUM');112 113 if (canSendCLpng) {114 if (!getFromCookise('visit_dt')) {115 // 鐢ㄦ埛璁块棶缃戠珯鐨勬棩鏈熶负绌� 璇存槑涔嬪墠娌℃湁瀛樿繃杩欎釜cookie 閭d箞杩欐槸涓€涓柊璁垮116 // 璁$畻鐢ㄦ埛璁块棶鐨勬棩鏈� 浠ュぉ涓哄崟浣�117 var vd_day = new Date();118 var vd_year = vd_day.getFullYear();119 var vd_month = vd_day.getMonth();120 var vd_dt = vd_year + '-' + vd_month + '-' + vd_day;121 // 鎶妚d_dt鐨勫€� 鍔犲叆cookie122 saveToCookise('visit_dt', vd_dt, '5');123 pushValue('isNew_User', 'trueisNew_User');124 } else {125 // 宸茬粡璁板綍浜嗚闂綉绔欑殑鏃ユ湡 閭d箞闇€瑕佹瘮杈冧竴涓嬪綋鍓嶆棩鏈熷拰杩欎釜鏃ユ湡 濡傛灉涓嶆槸鍚屼竴澶� 璇存槑鏄€佽瀹� 濡傛灉鏄竴澶� 璇存槑鏄柊璁垮126 var vd_day = new Date();127 var vd_year = vd_day.getFullYear();128 var vd_month = vd_day.getMonth();129 var vd_dt = vd_year + '-' + vd_month + '-' + vd_day;130 if (getFromCookise('visit_dt') == vd_dt) {131 // 鍚屼竴澶� 璇存槑鏄柊璁垮132 pushValue('isNew_User', 'trueisNew_User');133 } else {134 // 涓嶆槸鍚屼竴澶� 璇存槑鏄€佽瀹�135 pushValue('isNew_User', 'falseisNew_User');136 }137 }138 im.src = "http:\/\/stat-y.xywy.com\/cl.png?" + s.join('&');139 }140}141function buttonShow(item) {142 var ref_click = document.referrer;143 var xpoint = item.offsetLeft;144 var ypoint = item.offsetTop;145 var domid = item.id;146 var clicken = item.attributes["clicken"].nodeValue;147 var clickType = item.attributes["displayType"].nodeValue;148 var ue = unescape;149 150 var date = new Date();151 var s = [];152 var im = new Image;153 154 function pushValue(name, value) {155 s.push(name + '=' + value);156 }157 158 function saveToCookise(name, value, days) {159 date.setTime(date.getTime() + (days * 24 * 3600 * 1000 * 365));160 document.cookie = name + "=" + escape(value) + ((days == null) ? "" : "; expires=" + date.toGMTString()) + "; domain=.xywy.com ;path=/";161 }162 163 function getFromCookise(name) {164 if (document.cookie.length > 0) {165 var begin = document.cookie.indexOf(name + "=");166 if (begin != -1) {167 begin += name.length + 1;168 var end = document.cookie.indexOf(";", begin);169 if (end == -1)170 end = document.cookie.length;171 return ue(document.cookie.substring(begin, end));172 }173 }174 return null;175 }176 177 // 澶勭悊ref178 if (ref_click) {179 pushValue('ref', ref_click + 'ref');180 }181 182 // 澶勭悊clientID183 if (!getFromCookise('clientac')) {184 var clientID = date.getTime() + parseInt(Math.random(10, 1) * 100);185 pushValue('clientID', clientID + 'clientID');186 saveToCookise('clientac', clientID, '5');187 } else {188 pushValue('clientID', getFromCookise('clientac') + 'clientID');189 }190 191 // 澶勭悊loginID192 if (getFromCookise("cookie_user")) {193 pushValue('loginID', getFromCookise("cookie_user") + 'loginID');194 } else {195 pushValue('loginID', '' + 'loginID');196 }197 198 // 澶勭悊usertype199 if (getFromCookise("cookie_usertype")) {200 pushValue('usertype', getFromCookise("cookie_usertype") + 'usertype');201 } else {202 pushValue('usertype', '' + 'usertype');203 }204 // 璁拌浇璁块棶url鍜屾椂闂�205 var acl = encodeURI(document.location.href.replace(/#/g, "~"));206 saveToCookise('cl_lastUrl', acl, '5');207 saveToCookise('cl_lastUrl_time', new Date().getTime(), '5');208 pushValue('AcT', acl + 'AcT');209 210 // 娣诲姞鏃ュ織绫诲瀷鍙傛暟211 // 姝ゆ暟鎹互鍚庣敤鏉ユ爣璇嗕笟鍔$被鍨嬶紙瑙佷笅闈級212 // pushValue('clickType', '0' + 'clickType');213 214 // 娣诲姞xpoint215 pushValue('xPoint', xpoint + 'xPoint');216 217 // 娣诲姞ypoint218 pushValue('yPoint', ypoint + 'yPoint');219 220 // 娣诲姞domid221 pushValue('domID', domid + 'domID');222 223 // 娣诲姞clicken224 pushValue('clickEN', clicken + 'clickEN');225 // 娣诲姞clickType226 pushValue('clickType', clickType + 'clickType');227 // 娣诲姞random鍙傛暟锛屼娇璇锋眰鐪嬭捣鏉ヤ笉鍚�228 pushValue('randomNUM', Math.random(10, 1)*100 + 'randomNUM');229 230 if (!getFromCookise('visit_dt')) {231 // 鐢ㄦ埛璁块棶缃戠珯鐨勬棩鏈熶负绌� 璇存槑涔嬪墠娌℃湁瀛樿繃杩欎釜cookie 閭d箞杩欐槸涓€涓柊璁垮232 // 璁$畻鐢ㄦ埛璁块棶鐨勬棩鏈� 浠ュぉ涓哄崟浣�233 var vd_day = new Date();234 var vd_year = vd_day.getFullYear();235 var vd_month = vd_day.getMonth();236 var vd_dt = vd_year + '-' + vd_month + '-' + vd_day;237 // 鎶妚d_dt鐨勫€� 鍔犲叆cookie238 saveToCookise('visit_dt', vd_dt, '5');239 pushValue('isNew_User', 'trueisNew_User');240 } else {241 // 宸茬粡璁板綍浜嗚闂綉绔欑殑鏃ユ湡 閭d箞闇€瑕佹瘮杈冧竴涓嬪綋鍓嶆棩鏈熷拰杩欎釜鏃ユ湡 濡傛灉涓嶆槸鍚屼竴澶� 璇存槑鏄€佽瀹� 濡傛灉鏄竴澶� 璇存槑鏄柊璁垮242 var vd_day = new Date();243 var vd_year = vd_day.getFullYear();244 var vd_month = vd_day.getMonth();245 var vd_dt = vd_year + '-' + vd_month + '-' + vd_day;246 if (getFromCookise('visit_dt') == vd_dt) {247 // 鍚屼竴澶� 璇存槑鏄柊璁垮248 pushValue('isNew_User', 'trueisNew_User');249 } else {250 // 涓嶆槸鍚屼竴澶� 璇存槑鏄€佽瀹�251 pushValue('isNew_User', 'falseisNew_User');252 }253 }254 im.src = "http:\/\/stat-y.xywy.com\/cl.png?" + s.join('&');255}256//鎸夐挳浼犻€抜dfunction257function buttonClick(item,firstId,secondId) {258 var ref_click = document.referrer;259 var xpoint = item.offsetLeft;260 var ypoint = item.offsetTop;261 var domid = item.id;262 var clicken = item.attributes["clicken"].nodeValue+"_"+firstId+"_"+secondId;263 var clickType = item.attributes["clickType"].nodeValue;264 var ue = unescape;265 266 var date = new Date();267 var s = [];268 var im = new Image;269 270 function pushValue(name, value) {271 s.push(name + '=' + value);272 }273 274 function saveToCookise(name, value, days) {275 date.setTime(date.getTime() + (days * 24 * 3600 * 1000 * 365));276 document.cookie = name + "=" + escape(value) + ((days == null) ? "" : "; expires=" + date.toGMTString()) + "; domain=.xywy.com ;path=/";277 }278 279 function getFromCookise(name) {280 if (document.cookie.length > 0) {281 var begin = document.cookie.indexOf(name + "=");282 if (begin != -1) {283 begin += name.length + 1;284 var end = document.cookie.indexOf(";", begin);285 if (end == -1)286 end = document.cookie.length;287 return ue(document.cookie.substring(begin, end));288 }289 }290 return null;291 }292 293 // 澶勭悊ref294 if (ref_click) {295 pushValue('ref', ref_click + 'ref');296 }297 298 // 澶勭悊clientID299 if (!getFromCookise('clientac')) {300 var clientID = date.getTime() + parseInt(Math.random(10, 1) * 100);301 pushValue('clientID', clientID + 'clientID');302 saveToCookise('clientac', clientID, '5');303 } else {304 pushValue('clientID', getFromCookise('clientac') + 'clientID');305 }306 307 // 澶勭悊loginID308 if (getFromCookise("cookie_user")) {309 pushValue('loginID', getFromCookise("cookie_user") + 'loginID');310 } else {311 pushValue('loginID', '' + 'loginID');312 }313 314 // 澶勭悊usertype315 if (getFromCookise("cookie_usertype")) {316 pushValue('usertype', getFromCookise("cookie_usertype") + 'usertype');317 } else {318 pushValue('usertype', '' + 'usertype');319 }320 // 澶勭悊鎭舵剰鍒锋柊 瀵艰嚧pv缁熻涓嶅噯鐨勯棶棰� 鏍规嵁cookie涓偍瀛樼殑涓婁竴涓姹傚拰璇锋眰鏃堕棿 鍒ゆ柇鏄惁闇€瑕佸彂鍑篶l.png璇锋眰321 var canSendCLpng = true;322 var acl = encodeURI(document.location.href);323 if (getFromCookise("cl_lastUrl")) {324 if (acl == getFromCookise("cl_lastUrl")) {325 if (getFromCookise("cl_lastUrl_time")) {326 var offset = parseInt(date.getTime()) - parseInt(getFromCookise("cl_lastUrl_time"));327 if (parseInt(offset) < 2000) {328 canSendCLpng = false;329 }330 }331 } else {332 }333 } else {334 }335 // 璁拌浇璁块棶url鍜屾椂闂�336 saveToCookise('cl_lastUrl', acl, '5');337 saveToCookise('cl_lastUrl_time', new Date().getTime(), '5');338 pushValue('AcT', acl + 'AcT');339 340 // 娣诲姞鏃ュ織绫诲瀷鍙傛暟341 // 姝ゆ暟鎹互鍚庣敤鏉ユ爣璇嗕笟鍔$被鍨嬶紙瑙佷笅闈級342 // pushValue('clickType', '0' + 'clickType');343 344 // 娣诲姞xpoint345 pushValue('xPoint', xpoint + 'xPoint');346 347 // 娣诲姞ypoint348 pushValue('yPoint', ypoint + 'yPoint');349 350 // 娣诲姞domid351 pushValue('domID', domid + 'domID');352 353 // 娣诲姞clicken354 pushValue('clickEN', clicken + 'clickEN');355 // 娣诲姞clickType356 pushValue('clickType', clickType + 'clickType');357 // 娣诲姞random鍙傛暟锛屼娇璇锋眰鐪嬭捣鏉ヤ笉鍚�358 pushValue('randomNUM', Math.random(10, 1)*100 + 'randomNUM');359 360 if (canSendCLpng) {361 if (!getFromCookise('visit_dt')) {362 // 鐢ㄦ埛璁块棶缃戠珯鐨勬棩鏈熶负绌� 璇存槑涔嬪墠娌℃湁瀛樿繃杩欎釜cookie 閭d箞杩欐槸涓€涓柊璁垮363 // 璁$畻鐢ㄦ埛璁块棶鐨勬棩鏈� 浠ュぉ涓哄崟浣�364 var vd_day = new Date();365 var vd_year = vd_day.getFullYear();366 var vd_month = vd_day.getMonth();367 var vd_dt = vd_year + '-' + vd_month + '-' + vd_day;368 // 鎶妚d_dt鐨勫€� 鍔犲叆cookie369 saveToCookise('visit_dt', vd_dt, '5');370 pushValue('isNew_User', 'trueisNew_User');371 } else {372 // 宸茬粡璁板綍浜嗚闂綉绔欑殑鏃ユ湡 閭d箞闇€瑕佹瘮杈冧竴涓嬪綋鍓嶆棩鏈熷拰杩欎釜鏃ユ湡 濡傛灉涓嶆槸鍚屼竴澶� 璇存槑鏄€佽瀹� 濡傛灉鏄竴澶� 璇存槑鏄柊璁垮373 var vd_day = new Date();374 var vd_year = vd_day.getFullYear();375 var vd_month = vd_day.getMonth();376 var vd_dt = vd_year + '-' + vd_month + '-' + vd_day;377 if (getFromCookise('visit_dt') == vd_dt) {378 // 鍚屼竴澶� 璇存槑鏄柊璁垮379 pushValue('isNew_User', 'trueisNew_User');380 } else {381 // 涓嶆槸鍚屼竴澶� 璇存槑鏄€佽瀹�382 pushValue('isNew_User', 'falseisNew_User');383 }384 }385 im.src = "http:\/\/stat-y.xywy.com\/cl.png?" + s.join('&');386 }...

Full Screen

Full Screen

approveResponse.js

Source:approveResponse.js Github

copy

Full Screen

...260 * Runs when the email has been sent to the manager (step1 responder)261 * @param {*} response262 */263 function stepOneWaiting(response) {264 pushValue(response.step1.timestamp, new Date());265 pushValue(response.step1.comments, "Checking Inbounds...");266 var result = getStatusInbound(267 response.payloads.id.value,268 response.step1.email.value269 );270 /* Calculate deadlines and skip the row when the time is out */271 deadline =272 response.payloads.timestamp.value - response.step1.timestamp.value;273 if (deadline <= 0) {274 sendEmails(275 CONFIG.admin_email_address,276 "Response ID : " +277 response.payloads.id.value +278 " takes too long to respond",279 ""280 );281 pushValue(response.payloads.skipRow, "Time out");282 }283 deadline = milisecToTime(deadline);284 if (result) {285 pushValue(response.step1.status, result.status);286 pushValue(response.step1.timestamp, result.timestamp);287 pushValue(response.step1.comments, result.comments);288 } else {289 pushValue(response.step1.comments, "Time left : " + deadline);290 }291 }292 /**293 * Runs when step 1 status is Approved, and requires next step to take action294 * @param {*} response295 */296 function stepTwoWaiting(response) {297 pushValue(response.step2.timestamp, new Date());298 pushValue(response.step2.comments, "Checking Inbounds...");299 var result = getStatusInbound(300 response.payloads.id.value,301 response.step2.email.value302 );303 /* Calculate deadlines and skip the row when the time is out */304 deadline =305 response.payloads.timestamp.value - response.step2.timestamp.value;306 if (deadline <= 0) {307 sendEmails(308 CONFIG.admin_email_address,309 "Response ID : " +310 response.payloads.id.value +311 " takes too long to respond",312 ""313 );314 pushValue(response.payloads.skipRow, "Timed out");315 }316 deadline = milisecToTime(deadline);317 if (result) {318 pushValue(response.step2.status, result.status);319 pushValue(response.step2.timestamp, result.timestamp);320 pushValue(response.step2.comments, result.comments);321 } else {322 pushValue(response.step2.comments, "Time left : " + deadline);323 }324 }325 /**326 * Starts when one of the step have declined the request327 * @param {*} response328 */329 function stepRejected(response) {330 /* Check wheather who rejects the response */331 if (response.step2.status.value === "Reject") {332 stepTwoRejectEmail(response);333 pushValue(response.payloads.skipRow, "Rejected in Step 2");334 } else {335 stepOneRejectEmail(response);336 pushValue(response.payloads.skipRow, "Rejected in Step 1");337 }338 }339 /**340 * Starts when all of the steps have approved the request341 * @param {*} response342 */343 function stepApproved(response) {344 sendFinalEmail(response);345 pushValue(response.payloads.skipRow, "Approved");346 }347 /**348 *349 * @param {*} response350 */351 function newEntry(response) {352 /* Set the formURL to the response ID */353 pushValue(354 response.step1.formUrl,355 CONFIG.approval_form_url + response.payloads.id.value356 );357 pushValue(response.step1.comments, "Sending email to requester");358 sendRecieptEmail(response);359 pushValue(response.step1.timestamp, new Date());360 pushValue(response.step1.comments, "Email sent to requester");361 /* Sending emails to the corresponding user */362 pushValue(response.step1.comments, "Sending approval email ...");363 stepOneApprovalEmail(response);364 pushValue(response.step1.timestamp, new Date());365 pushValue(response.step1.comments, "Email sent to approver");366 pushValue(response.step1.status, "Waiting");367 pushValue(response.step1.timestamp, new Date());368 pushValue(response.step1.comments, "");369 }370 function stepTwoApproval(response) {371 /* Set the formURL to the response ID */372 pushValue(373 response.step2.formUrl,374 CONFIG.approval_form_url + response.payloads.id.value375 );376 pushValue(response.step2.comments, "Sending email to Approver 2 ...");377 stepTwoApprovalEmail(response);378 pushValue(response.step2.timestamp, new Date());379 pushValue(response.step2.comments, "Email sent");380 /* Sending emails to the corresponding user */381 pushValue(response.step2.status, "Waiting");382 pushValue(response.step2.timestamp, new Date());383 pushValue(response.step2.comments, "");384 }...

Full Screen

Full Screen

bridgeservice.js

Source:bridgeservice.js Github

copy

Full Screen

...34 title: title,35 groupId: parent36 }));37 }38 function pushValue(id, value)39 {40 bridge.emit('dynamicui.pushvalue', JSON.stringify({41 id: id,42 value: value43 }));44 }45 function destroy(id)46 {47 bridge.emit('dynamicui.destroy', JSON.stringify({48 id: id49 }));50 }51 function onUserbadgeUpdate(badge)52 {53 var str = 'Userbadge Updated: ' + badge.badge_key + '(' + badge.current + '/' + badge.total + ')';54 pushValue('bs-userbadge-status', str);55 }56 function onLeaderboardUpdate(leaderboard)57 {58 pushValue('bs-userbadge-status', 'Leaderboard Updated: ' + leaderboard.title + ' - ' + leaderboard.score);59 }60 function onGameSessionCreated(gameSessionId)61 {62 pushValue('bs-game-session-info-status', 'Game session ' + gameSessionId + 'created');63 }64 function onGameSessionStatus(gameSessionId, status)65 {66 pushValue('bs-game-session-info-status', gameSessionId + ": " + status);67 }68 function onGameSessionDestroyed(gameSessionId)69 {70 pushValue('bs-game-session-info-status', 'Game session ' + gameSessionId + ' destroyed');71 }72 function createPlayerBlock(index)73 {74 var groupId = 'bs-game-session-players-' + index;75 createGroup('Player', groupId, 'bs-game-session-players');76 createWatch('Name', groupId + '-name', groupId);77 createWatch('Team', groupId + '-team', groupId);78 createWatch('Color', groupId + '-color', groupId);79 createWatch('Score', groupId + '-score', groupId);80 createWatch('Status', groupId + '-status', groupId);81 createWatch('Rank', groupId + '-rank', groupId);82 createWatch('Sort Key', groupId + '-sortkey', groupId);83 }84 function onGameSessionInfo(info)85 {86 var data = JSON.parse(info);87 var playerList = [];88 var teamList = data.sessionData.teamList || [];89 var i, player, name, playerData, groupId;90 pushValue('bs-game-session-info-teamlist', '[' + teamList.join(',') + ']');91 pushValue('bs-game-session-info-sessionid', data.sessionData.gameSessionId);92 for (player in data.playerSessionData)93 {94 if (data.playerSessionData.hasOwnProperty(player))95 {96 playerList.push(player);97 }98 }99 playerList.sort(function (playerA, playerB)100 {101 var teamA = -1;102 var teamB = -1;103 var playerDataA = data.playerSessionData[playerA];104 var playerDataB = data.playerSessionData[playerB];105 var teamList = data.sessionData.teamList;106 if (teamList)107 {108 teamA = teamList.indexOf(playerDataA.team);109 teamB = teamList.indexOf(playerDataB.team);110 }111 if (teamA === teamB)112 {113 return playerDataA.sortkey - playerDataB.sortkey;114 }115 else116 {117 return teamA - teamB;118 }119 });120 while (numPlayersShown < playerList.length)121 {122 createPlayerBlock(numPlayersShown);123 numPlayersShown += 1;124 }125 while (numPlayersShown > playerList.length)126 {127 destroy('bs-game-session-players-' + (numPlayersShown - 1));128 numPlayersShown -= 1;129 }130 for (i = 0; i < playerList.length; i += 1)131 {132 name = playerList[i];133 playerData = data.playerSessionData[name];134 groupId = 'bs-game-session-players-' + i;135 pushValue(groupId + '-name', name);136 pushValue(groupId + '-team', playerData.team);137 pushValue(groupId + '-color', playerData.color);138 pushValue(groupId + '-score', playerData.score);139 pushValue(groupId + '-status', playerData.status);140 pushValue(groupId + '-rank', playerData.rank);141 pushValue(groupId + '-sortkey', playerData.sortkey);142 }143 }144 function onMultiplayerSessionJoined(session)145 {146 pushValue('bs-mp-session-status', "Joined");147 pushValue('bs-mp-session-id', session.sessionId);148 pushValue('bs-mp-session-numplayers', session.numplayers);149 pushValue('bs-mp-session-playerId', session.playerId);150 }151 function onMultiplayerSessionLeave(sessionId)152 {153 pushValue('bs-mp-session-status', 'Left Session ' + sessionId);154 pushValue('bs-mp-session-id', "");155 }156 function onMultiplayerSessionMakepublic(sessionId)157 {158 pushValue('bs-mp-session-status', 'Session ' + sessionId + ' is public');159 }160 function onStatusLoadingStart(force)161 {162 pushValue('bs-loading-status', 'Loading Started (force=' + force + ')');163 }164 function onStatusLoadingStop(force)165 {166 pushValue('bs-loading-status', 'Loading Stopped (force=' + force + ')');167 }168 function onStatusSavingStart(force)169 {170 pushValue('bs-saving-status', 'Saving Started (force=' + force + ')');171 }172 function onStatusSavingStop(force)173 {174 pushValue('bs-saving-status', 'Saving Stopped (force=' + force + ')');175 }176 function register()177 {178 // Create UI179 createGroup('Turbulenz Services Display', 'bs-root', '#bsui', true);180 createGroup('Loading Status', 'bs-loading', 'bs-root');181 createWatch('Status', 'bs-loading-status', 'bs-loading');182 createGroup('Saving Status', 'bs-saving', 'bs-root');183 createWatch('Status', 'bs-saving-status', 'bs-saving');184 createGroup('Userbadge Events', 'bs-userbadge', 'bs-root');185 createWatch('Status', 'bs-userbadge-status', 'bs-userbadge');186 createGroup('Leaderboard Events', 'bs-leaderboard', 'bs-root');187 createWatch('Status', 'bs-leaderboard-status', 'bs-leaderboard');188 createGroup('Game Session Status', 'bs-game-session', 'bs-root');...

Full Screen

Full Screen

spf.js

Source:spf.js Github

copy

Full Screen

...4*/5var SPFS=new Array();6// 初期値7SPFS[0]=[8["ceil","切り上げ",function(){pushValue(Math.ceil(operandStack.top()));}],9["round","四捨五入",function(){pushValue(Math.round(operandStack.top()));}],10["floor","切り捨て",function(){pushValue(Math.floor(operandStack.top()));}],11["rnd","ランダム",function(){pushValue(Math.random());}],12["rnd2","正規化ランダム",function(){pushValue(operandStack.pop()*Math.random());}],13["tot","合計",function(){pushKey('tot');}],14["avr","平均",function(){pushKey('avr');}],15["max","最大",function(){pushKey('max');}],16["min","最少",function(){pushKey('min');}]];17SPFS[0].name="Math-1";1819// 三角関数20SPFS[1]=[21["r2d","radians>degrees",function(){pushValue(radiansToDegrees(operandStack.top()));}],22["d2r","degrees>radians",function(){pushValue(degreesToRadians(operandStack.top()));}],23["sin","sin",function(){pushValue(Math.sin(degreesToRadians(operandStack.top())));}],24["cos","cosin",function(){pushValue(Math.cos(degreesToRadians(operandStack.top())));}],25["tan","tan",function(){pushValue(Math.tan(degreesToRadians(operandStack.top())));}],26["asin","asin",function(){pushValue(radiansToDegrees(Math.asin(operandStack.top())));}],27["acos","acosin",function(){pushValue(radiansToDegrees(Math.acos(operandStack.top())));}],28["atan","atan",function(){pushValue(radiansToDegrees(Math.atan(operandStack.top())));}],29["atan2","atan2",function(){operandStack.push(radiansToDegrees(Math.atan2(operandStack.pop(),operandStack.pop())));syncST2IB();}]];30SPFS[1].name="Math-2";3132//["abs","絶対値",function(){pushValue(Math.abs(operandStack.pop()));}],33//["PI","円周率",function(){pushValue(Math.PI);}],3435// 定数I36SPFS[2]=[37["E","自然対数の底",function(){pushValue(Math.E);}],38["log2","log2",function(){pushValue(Math.LN2);}],39["log10","log10",function(){pushValue(Math.LN10);}],40["log2e","2を底とするeの対数",function(){pushValue(Math.LOG2E);}]41];42SPFS[2].name="Constant-1";434445// 定数II46SPFS[3]=[47["Fph","1時間のフレーム数",function(){pushValue(nas.FRATE*60*60);}],48["Fpm","1分のフレーム数",function(){pushValue(nas.FRATE*60);}],49["Fps","毎秒フレーム数",function(){pushValue(nas.FRATE);}],50["nm","ノーティカルマイル(M)",function(){pushValue(1852);}],51["Eg","地球重力加速度(m/ss)",function(){pushValue(9.78);}],52["Er","地球赤道半径(km)",function(){pushValue(6378.140);}],53["Erd","地球自転角速度(rad/s)",function(){pushValue(0.7292/100000);}],54["","",function(){pushValue(0);}],55["getTC","",function(){pushValue(getTC());}]56];57SPFS[3].name="Constant-2";5859// debug60SPFS[4]=[61 ["Fit","ウインドウのサイズ調整",function(){sizeToContent();}]62, ["cc2FR","cc2FR",function(){pushValue(nas_cc2FR(operandStack.top()));}]63, ["Start","Start",function(){pushValue(Start);}]64, ["Stop","Stop",function(){pushValue(Stop);}]65, ["000","000",function(){editBuf('000');}]66];67SPFS[4].name="Debug";68/*6970*/71var CurrentSet=1;7273function changeSPFB(myButton){74mySet=SPFS[CurrentSet];75 for(var idx=0;idx<9;idx++){76 if(idx<mySet.length){77 myButton=document.getElementById("SPF"+(idx+1));78 myButton.value=mySet[idx][0];79 myButton.title=mySet[idx][1];80 myButton.onclick=mySet[idx][2];81 }else{82 myButton=document.getElementById("SPF"+(idx+1));83 myButton.value=" ";84 myButton.title="no Function";85 myButton.onclick="viod(0);";86 }87 }88// myButton.value==mySet.name;89 document.getElementById("PF2").value=mySet.name;90CurrentSet=(CurrentSet+1)%SPFS.length;91}92//9394/*95 演算済のスタックと画面を同期させる96こちらの方がはるかにスッキリするのであとで置換97*/98 if(false){99function syncST2IB(){100 operandStack.dup();101switch (INPUTmode) {102case "fct":103 if (TCf) {104 inBuf=nas_FR2TC(Math.floor(operandStack.pop()))[1]; //TC105 }else{106 inBuf=operandStack.pop().toString(10); //TC保留107 }108 break;109default: inBuf= operandStack.pop().toString(cardinal);110}111//ディスプレイ更新112 updateDP();113}114 }115116/*117 getTC/putTC118 ストップウオッチ部分と電卓連結119*/120function getTC()121{122//何はなくとも現在時をキャプチャ123 var ClockClicks = new Date();ct_K = ClockClicks.getTime();124//電卓のステータスをみて計測中ならCC値を使用それ以外は(Stop - Start)125 var myCC=(STATUS=='stop')?(Stop-Start):(ct_K-Start);126// alert("start:"+Start+"\nstop:"+Stop+"\ncc:"+ nas_cc2FR(myCC))127 newStack=true;pushValue(nas_cc2FR(myCC));128 return nas_cc2FR(myCC);129}130function putTC()131{132//何はなくとも現在時をキャプチャ133 var ClockClicks = new Date();ct_K = ClockClicks.getTime();134//強制的に計測時をリセット135 Start=ct_K-nas_FR2cc(operandStack.top());136 Stop=ct_K+1; ...

Full Screen

Full Screen

PushComponent.js

Source:PushComponent.js Github

copy

Full Screen

1/**2 * @author thurston30173 */4var PushComponent = function (domElement, btnID) {5 6 console.log("PushComponent.constructor."+domElement);7 this.domElement = domElement;8 this.pushValue = 0;9 this.lastPushValue = -1;10 this.btnID = btnID;11 var ref = this;12 if(btnID!=null && btnID>-1) {13 $( domElement ).click(function() {14 //alert( "Handler for .click() called."+ref.btnID );15 pushCore.btnClick(ref.btnID);16 });17 }18 this.pushMode = PushMode.awake;19 this.wasPushed = false;20 this.wasPulled = false;21 this.duration = .5; //.1+Math.random();22 this.x = $(this.domElement).offset().left;23 this.y = $(this.domElement).offset().top;24 this.y = parseInt($(this.domElement).css('marginTop'));25 this.offx = 0;26 this.offy = 0;27 this.alpha = 1.0;28 this.value = "";29 this.update();30}31PushComponent.prototype.push = function(value, btnID) {32 if(btnID!=null) this.btnID = btnID;33 this.value = value;34 $(this.domElement).css({"visibility":"visible"});35 this.pushValue+=pushCore.deltaTime/this.duration;36 this.wasPushed = true;37 if(this.pushValue>1) this.pushValue = 1;38 this.pushMode = PushMode.push;39};40PushComponent.prototype.pull = function() {41 if(this.wasPushed) return;42 //console.log("pushCore.deltaTime."+pushCore.deltaTime);43 this.wasPushed = false;44 this.pushValue-=pushCore.deltaTime/this.duration;45 if(this.pushValue<0) {46 this.pushValue = 0;47 this.pushMode = PushMode.idle;48 $(this.domElement).css({"visibility":"hidden"});49 } else {50 this.pushMode = PushMode.pull;51 }52};53PushComponent.prototype.update = function() {54 if(this.pushMode == PushMode.idle) return;55 if(isNaN(this.pushValue)) this.pushValue=0;56 this.pull();57 this.wasPushed = false;58 //console.log("PushComponent.update"); 59 // PUT YOUR OWN STUFF IN HERE:60 jQuery(this.domElement).css('opacity', this.pushValue*this.pushValue*this.alpha);61 var offset = {top: -32*(1-this.pushValue), left: 100};62 63 var pushValueInOutExpo = Math.easeInOutExpo(1-this.pushValue,0,1,1);64 var pushValueOutExpo = Math.easeOutExpo(1-this.pushValue,0,1,1);65 var pushValueInExpo = Math.easeInExpo(1-this.pushValue,0,1,1);66 offset.top = pushValueInExpo*this.offy+this.y;67 offset.left = this.x;68 if(this.pushMode == PushMode.pull) {69 //offset.top = pushValueOutExpo*this.offy+this.y;70 }71 if(this.lastPushValue!=this.pushValue) {72 //$(this.domElement).offset({ top: offset.top});73 $(this.domElement).css({ 'margin-top': offset.top+'px' }); 74 //this.domElement.innerHTML = this.pushMode+" / "+Math.round(this.pushValue*100)+"% "+this.value;75 if(this.value!="") this.domElement.innerHTML = "<tt>"+this.value+"</tt>";76 }77 this.lastPushValue = this.pushValue;...

Full Screen

Full Screen

colector.js

Source:colector.js Github

copy

Full Screen

...18 this.sum = 0;19 this.count = 0;20 this.timings = Array.from({length: 19000}, (_, i) => 0);21 }22 pushValue(responseTimeMs /*number*/) /*void*/ {23 this.sum += responseTimeMs;24 this.count++;25 this.timings[responseTimeMs]++;26 }27 getMedian() /*number*/ {28 if (this.count == 0) {29 return 0;30 }31 var half = Math.floor(this.count / 2);32 var zeroIndex = undefined;33 for (var i = 0; i < this.timings.length; i++) {34 half -= this.timings[i];35 if (half < 0) {36 zeroIndex = zeroIndex ? zeroIndex : i37 return this.count % 2 == 0 ? (i + zeroIndex) / 2 : i;38 }39 if (half == 0 && zeroIndex == undefined) {40 zeroIndex = i;41 }42 }43 }44 getAverage() /*number*/ {45 return this.count > 0 ? this.sum / this.count : 0;46 }47}48// Configure Mocha, telling both it and chai to use BDD-style tests.49mocha.setup("bdd");50chai.should();51describe('StatsCollector', function(){52 it('[1,1,3,6,6]', function(){53 var c = new StatsCollector();54 c.pushValue(0);55 c.pushValue(0);56 c.pushValue(3);57 c.pushValue(19000);58 c.pushValue(19000);59 c.getAverage().should.equal(7600.6);60 c.getMedian().should.equal(3);61 });62 it('[]', function(){63 var c = new StatsCollector();64 c.getAverage().should.equal(0);65 c.getMedian().should.equal(0);66 });67 it('[1,1,3,3]', function(){68 var c = new StatsCollector();69 c.pushValue(1);70 c.pushValue(1);71 c.pushValue(3);72 c.pushValue(3);73 c.getAverage().should.equal(2);74 c.getMedian().should.equal(2);75 });76 it('[1,1,1,1,3,2]', function(){77 var c = new StatsCollector();78 c.pushValue(1);79 c.pushValue(1);80 c.pushValue(1);81 c.pushValue(1);82 c.pushValue(3);83 c.pushValue(2);84 c.getAverage().should.equal(1.5);85 c.getMedian().should.equal(1);86 });87 it('[6,6,1,1]', function(){88 var c = new StatsCollector();89 c.pushValue(6);90 c.pushValue(6);91 c.pushValue(1);92 c.pushValue(1);93 c.getAverage().should.equal(3.5);94 c.getMedian().should.equal(3.5);95 });96});97// Run all our test suites. Only necessary in the browser.98mocha.run();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('pushValue', { prevSubject: true }, (subject, value) => {2 cy.wrap(subject).then((el) => {3 el.push(value);4 });5});6Cypress.Commands.add('pushValue', { prevSubject: true }, (subject, value) => {7 cy.wrap(subject).then((el) => {8 el.push(value);9 });10});11Cypress.Commands.add('pushValue', { prevSubject: true }, (subject, value) => {12 cy.wrap(subject).then((el) => {13 el.push(value);14 });15});16Cypress.Commands.add('pushValue', { prevSubject: true }, (subject, value) => {17 cy.wrap(subject).then((el) => {18 el.push(value);19 });20});21Cypress.Commands.add('pushValue', { prevSubject: true }, (subject, value) => {22 cy.wrap(subject).then((el) => {23 el.push(value);24 });25});26Cypress.Commands.add('pushValue', { prevSubject: true }, (subject, value) => {27 cy.wrap(subject).then((el) => {28 el.push(value);29 });30});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.get('input')4 .type('hello')5 .should('have.value', 'hello')6 })7})

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.get('#username').type('test')2cy.get('#password').type('test')3cy.get('#login').click()4cy.get('#logout').should('be.visible')5cy.get('#logout').click()6cy.get('#login').should('be.visible')7cy.pushValue('#username', 'test')8cy.pushValue('#password', 'test')9cy.pushValue('#login', 'click')10cy.pushValue('#logout', 'should', 'be.visible')11cy.pushValue('#logout', 'click')12cy.pushValue('#login', 'should', 'be.visible')13cy.pushValue('#username', 'test')14cy.pushValue('#password', 'test')15cy.pushValue('#login', 'click')16cy.pushValue('#logout', 'should', 'be.visible')17cy.pushValue('#logout', 'click')18cy.pushValue('#login', 'should', 'be.visible')19Cypress.Commands.add('pushValue', (selector, value1, value2) => {20 cy.get(selector).then(($element) => {21 if ($element.is('input')) {22 cy.get(selector).type(value1)23 }24 else if ($element.is('button')) {25 cy.get(selector).click()26 }27 else if ($element.is('a')) {28 cy.get(selector).click()29 }30 else if ($element.is('h1')) {31 cy.get(selector).should(value1, value2)32 }33 else if ($element.is('h2')) {34 cy.get(selector).should(value1, value2)35 }36 else if ($element.is('h3')) {37 cy.get(selector).should(value1, value2)38 }39 else if ($element.is('h4')) {40 cy.get(selector).should(value1, value2)41 }42 else if ($element.is('h5')) {43 cy.get(selector).should(value1, value2)44 }45 else if ($element.is('h6')) {46 cy.get(selector).should(value1, value2)47 }48 else if ($element.is('p')) {49 cy.get(selector).should(value1, value2)50 }51 else if ($element.is('span')) {52 cy.get(selector).should(value1, value2)53 }54 else if ($element.is('div

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