How to use insertBefore method in Playwright Internal

Best JavaScript code snippet using playwright-internal

game.js

Source:game.js Github

copy

Full Screen

...46 //help47 //48 if (input.indexOf("help") > -1) {49 if (input == "help") {50 $("#message_help").clone().insertBefore("#placeholder").fadeIn(1000);51 }52 }53 //54 //end help55 //56 57 58 59 60 61 62 //63 //take64 //65 else if (input.indexOf("take") > -1 || input.indexOf("read") > -1) {66 67 if (input == "take") {68 $('<p>Take what? Be specific. Type "help" for a list of all commands.</p>').insertBefore("#placeholder").fadeIn(1000);69 }70 71 //paperclip72 else if (input == "take paperclip" || input == "take paper clip") {73 if (currentroom == "jail" && paperclip == false) {74 paperclip = true;75 $('<p>You picked up a paper clip.</p>').insertBefore("#placeholder").fadeIn(1000);76 }77 else $('<p>That item is not here!</p>').insertBefore("#placeholder").fadeIn(1000);78 }79 //80 81 //dead bugs82 else if (input == "take dead bugs" || input == "take deadbugs") {83 if (currentroom == "jail" && deadbugs == false) {84 deadbugs = true;85 $('<p>You picked up some dead bugs. Gross.</p>').insertBefore("#placeholder").fadeIn(1000);86 }87 else $('<p>That item is not here!</p>').insertBefore("#placeholder").fadeIn(1000);88 }89 //90 91 //lunch tray92 else if (input == "take lunchtray" || input == "take lunch tray" || input == "take tray") {93 if (currentroom == "jail" && lunchtray == false) {94 lunchtray = true;95 $('<p>You picked up a lunch tray.</p>').insertBefore("#placeholder").fadeIn(1000);96 }97 else $('<p>That item is not here!</p>').insertBefore("#placeholder").fadeIn(1000);98 }99 //100 101 //torch102 else if (input == "take torch") {103 if (currentroom == "hallway" && torch == false) {104 torch = true;105 $('<p>You picked up a torch. You can now venture off into the dark hallway.</p>').insertBefore("#placeholder").fadeIn(1000);106 }107 else $('<p>That item is not here!</p>').insertBefore("#placeholder").fadeIn(1000);108 }109 //110 111 //note112 else if (input == "take note" || input == "read note") {113 if (currentroom == "hallway" && note == false) {114 note = true;115 $('<p>You picked up a note. It reads: <br />Well now. It seems you have managed to pass your first test. Don\'t worry. Things will get plenty more difficult and it will be almost impossible for you to escape with your life.<br /><br />Sincerely,<br/>Your Captors<br /><br />P.S. Watch out for my zombie.</p>').insertBefore("#placeholder").fadeIn(1000);116 }117 else $('<p>That item is not here!</p>').insertBefore("#placeholder").fadeIn(1000);118 }119 //120 121 //whip122 else if (input == "take whip") {123 if (currentroom == "torture" && whip == false) {124 whip = true;125 $('<p>You picked up a whip.</p>').insertBefore("#placeholder").fadeIn(1000);126 if (whip == true && hat == true) {127 $('<p>A whip and a hat? This is no time to play Indiana Jones!</p>').insertBefore("#placeholder").fadeIn(1000);128 }129 }130 else $('<p>That item is not here!</p>').insertBefore("#placeholder").fadeIn(1000);131 }132 //133 else $('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);134 135 }136 //137 //end take138 //139 140 141 142 143 144 //145 //search146 //147 else if (input.indexOf("search") > -1) {148 149 if (input == "search") {150 $('<p>Search what? Be specific. Type "help" for a list of all commands.</p>').insertBefore("#placeholder").fadeIn(1000);151 }152 153 //table154 else if (input == "search table") {155 if (currentroom == "torture" && hat == false && knife == false) {156 hat = true;157 knife = true;158 searchtable = true;159 $('<p>You found a knife stuck in the table and picked it up. You also take a hat from the table and place it on your head.</p>').insertBefore("#placeholder").fadeIn(1000);160 if (whip == true && hat == true) {161 $('<p>A whip and a hat? This is no time to play Indiana Jones!</p>').insertBefore("#placeholder").fadeIn(1000);162 }163 164 }165 else $('<p>There is nothing to search for.</p>').insertBefore("#placeholder").fadeIn(1000);166 }167 //168 169 //zombie170 else if (input == "search zombie") {171 if (currentroom == "morgue" && zombiedead == true) {172 key = true;173 $('<p>You found a key buried in the zombie\'s flesh.</p>').insertBefore("#placeholder").fadeIn(1000);174 }175 else $('<p>There is nothing to search for.</p>').insertBefore("#placeholder").fadeIn(1000);176 }177 //178 179 //crate180 else if (input == "search crate") {181 if (currentroom == "bonus") {182 powder = true;183 $('<p>You found a strange powder. What use could that possibly have?</p>').insertBefore("#placeholder").fadeIn(1000);184 }185 else $('<p>There is nothing to search for.</p>').insertBefore("#placeholder").fadeIn(1000);186 }187 //188 else $('<p>There is nothing to search for.</p>').insertBefore("#placeholder").fadeIn(1000);189 190 }191 //192 //end search193 //194 195 196 197 198 //199 //eat200 //201 else if (input.indexOf("eat") > -1) {202 203 if (input == "eat") {204 $('<p>Eat what? Be specific. Type "help" for a list of all commands.</p>').insertBefore("#placeholder").fadeIn(1000);205 }206 207 //powder208 else if (input == "eat powder" || input == "eat strange powder") {209 if (powder == true) {210 $("#container").fadeOut(3000, function() {211 $("#foodpoisoning").fadeIn(3000);212 });213 }214 else $('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);215 }216 //217 218 219 //bugs220 else if (input == "eat bugs" || input == "eat dead bugs") {221 if (deadbugs == true) {222 $('<p>You did not just do that.</p>').insertBefore("#placeholder").fadeIn(1000);223 deadbugs = "ate";224 }225 else $('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);226 }227 //228 229 else $('<p>I don\'t understand "' + input + '</p>').insertBefore("#placeholder").fadeIn(1000);230 231 }232 //233 //end eat234 //235 236 237 238 239 240 //241 //kill242 //243 else if (input.indexOf("kill") > -1) {244 245 if (input == "kill") {246 $('<p>Kill what with what? Be specific. Type "help" for a list of all commands.</p>').insertBefore("#placeholder").fadeIn(1000);247 }248 else if (input == "kill zombie" && currentroom == "morgue") {249 $('<p>Kill zombie with what?</p>').insertBefore("#placeholder").fadeIn(1000);250 }251 252 //zombie253 else if (input == "kill zombie with knife") {254 if (currentroom == "morgue" && knife == true) {255 $('<p>You attack the zombie with a knife and kill it!</p>').insertBefore("#placeholder").fadeIn(1000);256 zombiedead = true;257 }258 else {259 $('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);260 }261 }262 263 else if (input == "kill zombie with lunch tray" || input == "kill zombie with lunchtray" || input == "kill zombie with tray") {264 if (currentroom == "morgue" && lunchtray == true) {265 $('<p>You attack the zombie with a lunch tray and kill it!</p>').insertBefore("#placeholder").fadeIn(1000);266 zombiedead = true;267 }268 else {269 $('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);270 }271 }272 //273 274 //kill self275 else if (input == "kill self with lunch tray" || input == "kill self with lunchtray" || input == "kill self with tray") {276 if (lunchtray == true) {277 $("#container").fadeOut(3000, function() {278 $("#killself").fadeIn(3000);279 });280 }281 else {282 $('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);283 }284 }285 286 else if (input == "kill self with knife") {287 if (knife == true) {288 $("#container").fadeOut(3000, function() {289 $("#killself").fadeIn(3000);290 });291 }292 else {293 $('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);294 }295 }296 297 else if (input == "kill self with whip") {298 if (whip == true) {299 $("#container").fadeOut(3000, function() {300 $("#killself").fadeIn(3000);301 });302 }303 else {304 $('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);305 }306 }307 //308 309 else $('<p>You can\'t do that!</p>').insertBefore("#placeholder").fadeIn(1000);310 311 312 }313 //314 //end kill315 //316 317 318 319 320 //321 //inventory322 //323 else if (input.indexOf("inventory") > -1) {324 if (input == "inventory") {325 //paperclips326 if (paperclip == true) {327 pclip = "Paper Clip<br />";328 }329 else {330 pclip = "";331 }332 //333 334 //dead bugs335 if (deadbugs == true) {336 dbugs = "Dead Bugs<br />";337 }338 else {339 dbugs = "";340 }341 //342 343 //lunch tray344 if (lunchtray == true) {345 ltray = "Lunch Tray<br />";346 }347 else {348 ltray = "";349 }350 //351 352 //lunch tray353 if (torch == true) {354 tch = "Torch<br />";355 }356 else {357 tch = "";358 }359 //360 361 //lunch tray362 if (note == true) {363 nt = "Note from Captors<br />";364 }365 else {366 nt = "";367 }368 //369 370 //hat371 if (hat == true) {372 ht = "Hat<br />";373 }374 else {375 ht = "";376 }377 //378 379 //knife380 if (knife == true) {381 knf = "Knife<br />";382 }383 else {384 knf = "";385 }386 //387 388 //whip389 if (whip == true) {390 whp = "Whip<br />";391 }392 else {393 whp = "";394 }395 //396 397 //key398 if (key == true) {399 ky = "Key<br />";400 }401 else {402 ky = "";403 }404 //405 406 //goo407 if (powder == true) {408 powd = "Strange Powder<br />";409 }410 else {411 powd = "";412 }413 //414 415 if (pclip == "" && dbugs == "" && ltray == "") {416 $('<p>Inventory:<br /><i>There is nothing in your inventory</i></p>').insertBefore("#placeholder").fadeIn(1000);417 }418 else {419 $('<p>Inventory:<br />' + pclip + dbugs + ltray + tch + nt + ht + whp + knf + ky + powd + '</p>').insertBefore("#placeholder").fadeIn(1000);420 }421 }422 else $('<p>I don\'t understand "' + input + '"</p>').insertBefore("#placeholder").fadeIn(1000);423 }424 //425 //end inventory426 //427 428 429 430 431 432 433 //434 //unlock435 //436 437 else if (input.indexOf("unlock") > -1) {438 if (input == "unlock" || input == "unlock door" || input == "unlock jail door" || input == "unlock jaildoor") {439 $('<p>Unlock door with what? Be specific. Type "help" for a list of all commands.</p>').insertBefore("#placeholder").fadeIn(1000);440 }441 442 //jail door443 else if (input == "unlock jail door with paperclip" || input == "unlock jaildoor with paperclip" || input == "unlock jail door with paper clip" || input == "unlock jaildoor with paper clip" || input == "unlock door with paper clip" || input == "unlock door with paperclip") {444 if (currentroom != "jail") {445 $('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);446 }447 else if (cellunlocked == true) {448 $('<p>The door is already unlocked.</p>').insertBefore("#placeholder").fadeIn(1000);449 }450 else if (currentroom == "jail" && paperclip == true) {451 cellunlocked = true;452 $('<p>You unlocked the jail door successfully. You can now proceed northward.</p>').insertBefore("#placeholder").fadeIn(1000);453 }454 else $('<p>The door cannot be unlocked.</p>').insertBefore("#placeholder").fadeIn(1000);455 }456 //457 458 //exit door459 else if (input == "unlock door with key") {460 if (currentroom != "exit") {461 $('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);462 }463 else if (exitunlocked == true) {464 $('<p>The door is already unlocked.</p>').insertBefore("#placeholder").fadeIn(1000);465 }466 else if (currentroom == "exit" && key == true) {467 exitunlocked = true;468 $('<p>You unlocked the door successfully. You can now proceed northward.</p>').insertBefore("#placeholder").fadeIn(1000);469 }470 else $('<p>The door cannot be unlocked.</p>').insertBefore("#placeholder").fadeIn(1000);471 }472 //473 474 else $('<p>I don\'t understand "' + input + '"</p>').insertBefore("#placeholder").fadeIn(1000);475 476 }477 //478 //end unlock479 //480 481 482 483 484 485 486 487 //488 //go489 //490 else if (input.indexOf("go") > -1) {491 if (input == "go") {492 $('<p>Go in which direction?</p>').insertBefore("#placeholder").fadeIn(1000);493 }494 495 //go from jail cell496 else if (input == "go north" && currentroom == "jail") {497 if (cellunlocked == true) {498 if (beentohallway == true) {499 if (note == false) {500 hallnote = " The note is still here. ";501 }502 else {503 hallnote = "";504 }505 if (torch == false) {506 halltorch = " The torch continues to light the dim hallway. ";507 }508 else {509 halltorch = "";510 }511 $('<p>You are back in the hallway. The hallway continues to the east and west. The jail room is to the south. ' + hallnote + halltorch + '</p>').insertBefore("#placeholder").fadeIn(1000);512 currentroom = "hallway";513 }514 else {515 $("#area_hallway").clone().insertBefore("#placeholder").fadeIn(1000);516 currentroom = "hallway";517 beentohallway = true;518 }519 }520 else {521 $('<p>The door is locked.</p>').insertBefore("#placeholder").fadeIn(1000);522 }523 } 524 //525 526 //go back to jail cell527 else if (input == "go south" && currentroom == "hallway") {528 if (deadbugs == false) {529 jailbugs = "The dead bugs are still here";530 jailperiod = ".";531 }532 else {533 jailbugs = "";534 }535 if (lunchtray == false) {536 jailtray = "The lunch tray is still here";537 jailperiod = ".";538 }539 else {540 jailtray = "";541 }542 if (deadbugs == false && lunchtray == false) {543 jailword = " and ";544 jailtray = "the lunch tray is still here";545 jailperiod = ".";546 }547 else {548 jailword = "";549 }550 if (deadbugs == true && lunchtray == true) {551 jailperiod = "";552 }553 $('<p>You are back in the jail cell. To the north is the door. ' + jailbugs + jailword + jailtray + jailperiod + '</p>').insertBefore("#placeholder").fadeIn(1000);554 currentroom = "jail";555 }556 //557 558 //go to torture room from hallway559 else if (input == "go east" && currentroom == "hallway") {560 if (torch == true) {561 if (beentorture == true) {562 if (searchtable == false) {563 torturetable = "The table seems to emit a strange energy. ";564 }565 else {566 torturetable = "";567 }568 if (whip == false) {569 torturewhip = "The whip remains stationed on the wall. ";570 }571 else {572 torturewhip = "";573 }574 $('<p>You are back in the room of strange devices. To the south is a doorway, and to the west is the hallway you came from. ' + torturetable + torturewhip + '</p>').insertBefore("#placeholder").fadeIn(1000);575 currentroom = "torture";576 }577 else {578 $("#area_torture").clone().insertBefore("#placeholder").fadeIn(1000);579 beentorture = true;580 currentroom = "torture";581 }582 }583 else {584 $('<p>It seems awful dark that way...</p>').insertBefore("#placeholder").fadeIn(1000);585 }586 }587 //588 589 //go to westhall from hallway590 else if (input == "go west" && currentroom == "hallway") {591 if (torch == true) {592 if (beentowesthall == true) {593 $('<p>You are back at the west hallway. To the east is where you came from. To the north and south are dark rooms.</p>').insertBefore("#placeholder").fadeIn(1000);594 currentroom = "westhall";595 }596 else {597 $("#area_westhall").clone().insertBefore("#placeholder").fadeIn(1000);598 beentowesthall = true;599 currentroom = "westhall";600 }601 }602 else {603 $('<p>It seems awful dark that way...</p>').insertBefore("#placeholder").fadeIn(1000);604 }605 }606 //607 608 //go to exit from westhallway609 else if (input == "go north" && currentroom == "westhall") {610 if (beentoexit == true) {611 $('<p>You are back at the room with the strange door. To the south is the hallway you came from.</p>').insertBefore("#placeholder").fadeIn(1000);612 currentroom = "exit";613 }614 else {615 $("#area_exit").clone().insertBefore("#placeholder").fadeIn(1000);616 beentoexit = true;617 currentroom = "exit";618 }619 }620 //621 622 //go to westhallway from exit623 else if (input == "go south" && currentroom == "exit") {624 if (beentowesthall == true) {625 $('<p>You are back at the west hallway. To the north and south are dark rooms. The hallway continues east.</p>').insertBefore("#placeholder").fadeIn(1000);626 currentroom = "westhall";627 }628 else {629 $("#area_westhall").clone().insertBefore("#placeholder").fadeIn(1000);630 beentowesthall = true;631 currentroom = "westhall";632 }633 }634 //635 636 //go through exit637 else if (input == "go north" && currentroom == "exit") {638 if (exitunlocked == true) {639 $("#container").fadeOut(3000, function() {640 $("#wingame").fadeIn(3000);641 });642 }643 else {644 $('<p>The door is locked.</p>').insertBefore("#placeholder").fadeIn(1000);645 }646 }647 //648 649 650 //go back to hallway from west hall651 else if (input == "go east" && currentroom == "westhall") {652 if (note == false) {653 hallnote = " The note is still here. ";654 }655 else {656 hallnote = "";657 }658 if (torch == false) {659 halltorch = " The torch continues to light the dim hallway. ";660 }661 else {662 halltorch = "";663 }664 $('<p>You are back in the main hallway. The hallway continues to the east and west. The jail room is to the south.' + hallnote + halltorch + '</p>').insertBefore("#placeholder").fadeIn(1000);665 currentroom = "hallway";666 }667 //668 669 //go to bonus room from westhall670 else if (input == "go south" && currentroom == "westhall") {671 if (beentobonus == true) {672 if (powder == false) {673 bonuscrate = "The lone crate in the corner looks untouched.";674 }675 else {676 bonuscrate = "";677 }678 $('<p>You are back in the small storage room. You came from the north. ' + bonuscrate + '</p>').insertBefore("#placeholder").fadeIn(1000);679 currentroom = "bonus";680 }681 else {682 $("#area_bonus").clone().insertBefore("#placeholder").fadeIn(1000);683 beentobonus = true;684 currentroom = "bonus";685 }686 }687 //688 689 //go to westhall from bonus room690 else if (input == "go north" && currentroom == "bonus") {691 $('<p>You are back in the hallway. To the north and south are dark rooms. The hallway continues east.</p>').insertBefore("#placeholder").fadeIn(1000);692 currentroom = "westhall";693 }694 //695 696 //go back to hallway from torture room697 else if (input == "go west" && currentroom == "torture") {698 if (note == false) {699 hallnote = " The note is still here. ";700 }701 else {702 hallnote = "";703 }704 if (torch == false) {705 halltorch = " The torch continues to light the dim hallway. ";706 }707 else {708 halltorch = "";709 }710 $('<p>You are back in the main hallway. The hallway continues to the east and west. The jail room is to the south.' + hallnote + halltorch + '</p>').insertBefore("#placeholder").fadeIn(1000);711 currentroom = "hallway";712 }713 //714 715 716 //go to morgue from torture room717 else if (input == "go south" && currentroom == "torture") {718 if (beenmorgue == true) {719 if (zombiedead == false) {720 morguezombie = "The zombie is still here!";721 }722 else {723 morguezombie = "The zombie remains on the floor rotting in a cesspool of it's juices.";724 }725 $('<p>You are back in the morgue. To the north is the doorway to the room of strange devices. ' + morguezombie + '</p>').insertBefore("#placeholder").fadeIn(1000);726 currentroom = "morgue";727 }728 else {729 $("#area_morgue").clone().insertBefore("#placeholder").fadeIn(1000);730 beenmorgue = true;731 currentroom = "morgue";732 }733 }734 //735 736 //go to torture room from morgue737 else if (input == "go north" && currentroom == "morgue") {738 if (searchtable == false) {739 torturetable = "The table seems to emit a strange energy. ";740 }741 else {742 torturetable = "";743 }744 if (whip == false) {745 torturewhip = "The whip remains stationed on the wall. ";746 }747 else {748 torturewhip = "";749 }750 $('<p>You are back in the room of strange devices. To the south is a doorway, and to the west is the hallway. ' + torturetable + torturewhip + '</p>').insertBefore("#placeholder").fadeIn(1000);751 currentroom = "torture";752 }753 //754 755 756 757 else $('<p>You can\'t go that way.</p>').insertBefore("#placeholder").fadeIn(1000);758 }759 //760 //end go761 //762 763 764 765 766 767 768 769 else if (input != "") {770 $('<p>I don\'t understand "' + input + '"</p>').insertBefore("#placeholder").fadeIn(1000);771 }772 773 $("#console").scrollTop($("#console")[0].scrollHeight);774 $("#command_line").val("");775 });...

Full Screen

Full Screen

dom.js

Source:dom.js Github

copy

Full Screen

...21// Element#insertBefore22// --------------------23test('insertBefore: no element', function() {24 var el = paper.rect();25 el.insertBefore(null);26 equalNodePosition(el.node, paper.canvas, paper.defs, null);27});28test('insertBefore: first element', function() {29 var x = paper.rect();30 var el = paper.rect();31 el.insertBefore(x);32 equalNodePosition(el.node, paper.canvas, paper.defs, x.node);33});34test('insertBefore: middle element', function() {35 var x = paper.rect();36 var y = paper.rect();37 var el = paper.rect();38 el.insertBefore(y);39 equalNodePosition(el.node, paper.canvas, x.node, y.node);40});41test('insertBefore: no element when wrapped in <a>', function() {42 var el = paper.rect().attr('href', url),43 anchor = el.node.parentNode;44 el.insertBefore(null);45 equalNodePositionWrapped(el.node, anchor, paper.canvas, paper.defs, null);46});47test('insertBefore: first element when wrapped in <a>', function() {48 var x = paper.rect();49 var el = paper.rect().attr('href', url),50 anchor = el.node.parentNode;51 el.insertBefore(x);52 equalNodePositionWrapped(el.node, anchor, paper.canvas, paper.defs, x.node);53});54test('insertBefore: first element wrapped in <a> and wrapped in <a>', function() {55 var x = paper.rect().attr('href', url),56 xAnchor = x.node.parentNode;57 var el = paper.rect().attr('href', url),58 anchor = el.node.parentNode;59 el.insertBefore(x);60 equalNodePositionWrapped(el.node, anchor, paper.canvas, paper.defs, xAnchor);61});62test('insertBefore: middle element when wrapped in <a>', function() {63 var x = paper.rect();64 var y = paper.rect();65 var el = paper.rect().attr('href', url),66 anchor = el.node.parentNode;67 el.insertBefore(y);68 equalNodePositionWrapped(el.node, anchor, paper.canvas, x.node, y.node);69});70test('insertBefore: middle element wrapped in <a> and wrapped in <a>', function() {71 var x = paper.rect().attr('href', url),72 xAnchor = x.node.parentNode;73 var y = paper.rect().attr('href', url),74 yAnchor = y.node.parentNode;75 var el = paper.rect().attr('href', url),76 anchor = el.node.parentNode;77 el.insertBefore(y);78 equalNodePositionWrapped(el.node, anchor, paper.canvas, xAnchor, yAnchor);79});80// TODO...81// insertBefore: with set82// insertBefore: with nested set.83// Element#insertAfter84// -------------------85test('insertAfter: no element', function() {86 var el = paper.rect();87 el.insertAfter(null);88 equalNodePosition(el.node, paper.canvas, paper.defs, null);89});90test('insertAfter: last element', function() {91 var x = paper.rect();...

Full Screen

Full Screen

comparison.js

Source:comparison.js Github

copy

Full Screen

2 if(attempt<4){3 if(playerChoice === compChoice){4 elem.innerHTML = `Round ${attempt}, It is a tie!`;5 console.log(elem.innerHTML);6 options.parentNode.insertBefore(elem, options.nextSibling);7 elem.parentNode.insertBefore(picField, elem.nextSibling);8 picField.appendChild(picUser);9 picUser.src =`img/${playerChoice}.png`;10 picField.appendChild(picComputer);11 picComputer.src =`img/${compChoice}.png`;12 console.log(attempt);13 }14 else if(playerChoice === 'Paper'){15 if(compChoice === 'Rock'){16 elem.innerHTML = `Round ${attempt}, ${playerChoice} vs. ${compChoice}, You’ve WON!`;17 options.parentNode.insertBefore(elem, options.nextSibling);18 elem.parentNode.insertBefore(picField, elem.nextSibling);19 picField.appendChild(picUser);20 picUser.src =`img/${playerChoice}.png`;21 picField.appendChild(picComputer);22 picComputer.src =`img/${compChoice}.png`;23 }else{24 elem.innerHTML = `Round ${attempt}, ${playerChoice} vs. ${compChoice}, You’ve LOST!`;25 options.parentNode.insertBefore(elem, options.nextSibling); 26 elem.parentNode.insertBefore(picField, elem.nextSibling);27 picField.appendChild(picUser);28 picUser.src =`img/${playerChoice}.png`;29 picField.appendChild(picComputer);30 picComputer.src =`img/${compChoice}.png`; 31 }32 }33 if(playerChoice === 'Scissors'){34 if(compChoice === 'Paper'){35 elem.innerHTML = `Round ${attempt}, ${playerChoice} vs. ${compChoice}, You’ve WON!`;36 options.parentNode.insertBefore(elem, options.nextSibling); 37 elem.parentNode.insertBefore(picField, elem.nextSibling);38 picField.appendChild(picUser);39 picUser.src =`img/${playerChoice}.png`;40 picField.appendChild(picComputer);41 picComputer.src =`img/${compChoice}.png`; 42 playerScore++; 43 }else{44 elem.innerHTML = `Round ${attempt}, ${playerChoice} vs. ${compChoice}, You’ve LOST!`;45 options.parentNode.insertBefore(elem, options.nextSibling); 46 elem.parentNode.insertBefore(picField, elem.nextSibling);47 picField.appendChild(picUser);48 picUser.src =`img/${playerChoice}.png`;49 picField.appendChild(picComputer);50 picComputer.src =`img/${compChoice}.png`; 51 compScore++; 52 }53 }54 if(playerChoice === 'Rock'){55 if(compChoice === 'Scissors'){56 elem.innerHTML = `Round ${attempt}, ${playerChoice} vs. ${compChoice}, You’ve WON!`;57 options.parentNode.insertBefore(elem, options.nextSibling); 58 elem.parentNode.insertBefore(picField, elem.nextSibling);59 picField.appendChild(picUser);60 picUser.src =`img/${playerChoice}.png`;61 picField.appendChild(picComputer);62 picComputer.src =`img/${compChoice}.png`; 63 playerScore++;64 }else{65 elem.innerHTML = `Round ${attempt}, ${playerChoice} vs. ${compChoice}, You’ve LOST!`;66 options.parentNode.insertBefore(elem, options.nextSibling); 67 elem.parentNode.insertBefore(picField, elem.nextSibling);68 picField.appendChild(picUser);69 picUser.src =`img/${playerChoice}.png`;70 picField.appendChild(picComputer);71 picComputer.src =`img/${compChoice}.png`; 72 compScore++;73 }74 }75 attempt++;76 }else77 winner(playerScore, compScore);78 }...

Full Screen

Full Screen

slick.rowmovemanager.js

Source:slick.rowmovemanager.js Github

copy

Full Screen

1(function ($) {2 // register namespace3 $.extend(true, window, {4 "Slick": {5 "RowMoveManager": RowMoveManager6 }7 });8 function RowMoveManager(options) {9 var _grid;10 var _canvas;11 var _dragging;12 var _self = this;13 var _handler = new Slick.EventHandler();14 var _defaults = {15 cancelEditOnDrag: false16 };17 function init(grid) {18 options = $.extend(true, {}, _defaults, options);19 _grid = grid;20 _canvas = _grid.getCanvasNode();21 _handler22 .subscribe(_grid.onDragInit, handleDragInit)23 .subscribe(_grid.onDragStart, handleDragStart)24 .subscribe(_grid.onDrag, handleDrag)25 .subscribe(_grid.onDragEnd, handleDragEnd);26 }27 function destroy() {28 _handler.unsubscribeAll();29 }30 function handleDragInit(e, dd) {31 // prevent the grid from cancelling drag'n'drop by default32 e.stopImmediatePropagation();33 }34 function handleDragStart(e, dd) {35 var cell = _grid.getCellFromEvent(e);36 if (options.cancelEditOnDrag && _grid.getEditorLock().isActive()) {37 _grid.getEditorLock().cancelCurrentEdit();38 }39 if (_grid.getEditorLock().isActive() || !/move|selectAndMove/.test(_grid.getColumns()[cell.cell].behavior)) {40 return false;41 }42 _dragging = true;43 e.stopImmediatePropagation();44 var selectedRows = _grid.getSelectedRows();45 if (selectedRows.length == 0 || $.inArray(cell.row, selectedRows) == -1) {46 selectedRows = [cell.row];47 _grid.setSelectedRows(selectedRows);48 }49 var rowHeight = _grid.getOptions().rowHeight;50 dd.selectedRows = selectedRows;51 dd.selectionProxy = $("<div class='slick-reorder-proxy'/>")52 .css("position", "absolute")53 .css("zIndex", "99999")54 .css("width", $(_canvas).innerWidth())55 .css("height", rowHeight * selectedRows.length)56 .appendTo(_canvas);57 dd.guide = $("<div class='slick-reorder-guide'/>")58 .css("position", "absolute")59 .css("zIndex", "99998")60 .css("width", $(_canvas).innerWidth())61 .css("top", -1000)62 .appendTo(_canvas);63 dd.insertBefore = -1;64 }65 function handleDrag(e, dd) {66 if (!_dragging) {67 return;68 }69 e.stopImmediatePropagation();70 var top = e.pageY - $(_canvas).offset().top;71 dd.selectionProxy.css("top", top - 5);72 var insertBefore = Math.max(0, Math.min(Math.round(top / _grid.getOptions().rowHeight), _grid.getDataLength()));73 if (insertBefore !== dd.insertBefore) {74 var eventData = {75 "rows": dd.selectedRows,76 "insertBefore": insertBefore77 };78 if (_self.onBeforeMoveRows.notify(eventData) === false) {79 dd.guide.css("top", -1000);80 dd.canMove = false;81 } else {82 dd.guide.css("top", insertBefore * _grid.getOptions().rowHeight);83 dd.canMove = true;84 }85 dd.insertBefore = insertBefore;86 }87 }88 function handleDragEnd(e, dd) {89 if (!_dragging) {90 return;91 }92 _dragging = false;93 e.stopImmediatePropagation();94 dd.guide.remove();95 dd.selectionProxy.remove();96 if (dd.canMove) {97 var eventData = {98 "rows": dd.selectedRows,99 "insertBefore": dd.insertBefore100 };101 // TODO: _grid.remapCellCssClasses ?102 _self.onMoveRows.notify(eventData);103 }104 }105 $.extend(this, {106 "onBeforeMoveRows": new Slick.Event(),107 "onMoveRows": new Slick.Event(),108 "init": init,109 "destroy": destroy110 });111 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.screenshot({ path: `google.png` });7 await browser.close();8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { insertBefore } = require('playwright/lib/utils/utils');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await insertBefore(page, 'text=Get started', '<h1>Heading</h1>');8 await page.screenshot({ path: 'example.png' });9 await browser.close();10})();11const { chromium } = require('playwright');12(async () => {13 const browser = await chromium.launch();14 const context = await browser.newContext();15 const page = await context.newPage();16 await page.$eval('text=Get started', (el, html) => el.insertAdjacentHTML('beforebegin', html), '<h1>Heading</h1>');17 await page.screenshot({ path: 'example.png' });18 await browser.close();19})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { insertBefore } = require('@playwright/test');2const { insertAfter } = require('@playwright/test');3insertBefore('test', async ({}, test) => {4 await test();5});6insertAfter('test', async ({}, test) => {7 await test();8});9test('test', async ({}) => {10});11insertBefore('test', async ({}, test) => {12 await test();13});14insertAfter('test', async ({}, test) => {15 await test();16});17test('test', async ({}) => {18});19insertBefore('test', async ({}, test) => {20 await test();21});22insertAfter('test', async ({}, test) => {23 await test();24});25test('test', async ({}) => {26});27insertBefore('test', async ({}, test) => {28 await test();29});30insertAfter('test', async ({}, test) => {31 await test();32});33test('test', async ({}) => {34});35insertBefore('test', async ({}, test) => {36 await test();37});38insertAfter('test', async ({}, test) => {39 await test();40});41test('test', async ({}) => {42});43insertBefore('test', async ({}, test) => {44 await test();45});46insertAfter('test', async ({}, test) => {47 await test();48});49test('test', async ({}) => {50});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { insertBefore } = require('@playwright/test/lib/runner/test');2const { test } = require('@playwright/test');3test('insertBefore test', async ({ page }) => {4 await page.click('text=Get started');5 await page.click('text=Docs');6 await page.click('text=API reference');7 await page.click('text=class: Test');8 await page.click('text=insertBefore');9 await page.click('text=Parameters');10 await page.click('text=selector');11 await page.click('text=Returns');12 await page.click('text=void');13 await page.click('text=Example');14 await page.click('text=test.beforeEach(async ({ page }) => {');15 await page.click('text=await page

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const fs = require('fs');3const { chromium } = require('playwright');4(async () => {5 const browser = await chromium.launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 const scriptPath = path.join(__dirname, 'script.js');9 const scriptContent = fs.readFileSync(scriptPath, 'utf8');10 await page.evaluate(scriptContent);11 await page.screenshot({ path: 'example.png' });12 await browser.close();13})();14console.log('Hello from injected script!');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { insertBefore } = require('playwright/lib/protocol/dom');2const { Page } = require('playwright/lib/page');3const { ElementHandle } = require('playwright/lib/elementHandle');4Page.prototype.insertBefore = function (selector, html) {5 return this.mainFrame().insertBefore(selector, html);6};7ElementHandle.prototype.insertBefore = function (selector, html) {8 return this.ownerFrame().insertBefore(selector, html);9};10(async () => {11 const browser = await chromium.launch();12 const page = await browser.newPage();13 await page.insertBefore('h1', '<h1>My custom content</h1>');14 await page.waitForSelector('h2');15 await page.insertBefore('h2', '<h2>My custom content</h2>');16 await page.waitForSelector('h3');17 await page.insertBefore('h3', '<h3>My custom content</h3>');18 await page.waitForSelector('h4');19 await page.insertBefore('h4', '<h4>My custom content</h4>');20 await page.waitForSelector('h5');21 await page.insertBefore('h5', '<h5>My custom content</h5>');22 await page.waitForSelector('h6');23 await page.insertBefore('h6', '<h6>My custom content</h6>');24 await page.waitForSelector('h7');25 await page.insertBefore('h7', '<h7>My custom content</h7>');26 await page.waitForSelector('h8');27 await page.insertBefore('h8', '<h8>My custom content</h8>');28 await page.waitForSelector('h9');29 await page.insertBefore('h9', '<h9>My custom content</h9>');30 await page.waitForSelector('h10');31 await page.insertBefore('h10',

Full Screen

Using AI Code Generation

copy

Full Screen

1const { insertBefore } = require('@playwright/test/lib/server/trace/recorder/recorderApp');2const { SourceMapConsumer } = require('source-map');3const fs = require('fs');4const path = require('path');5const { promisify } = require('util');6const readFileAsync = promisify(fs.readFile);7(async () => {8 const sourceMap = await readFileAsync(path.join(__dirname, 'test.js.map'), 'utf-8');9 const consumer = await new SourceMapConsumer(sourceMap);10 const source = await readFileAsync(path.join(__dirname, 'test.ts'), 'utf-8');11 const sourceLines = source.split('12');13 const result = insertBefore(consumer, sourceLines, 5, 'console.log(\'test\');');14 console.log(result.join('15'));16})();

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Page } from 'playwright';2const page = new Page();3const element = await page.$('div');4const newElement = await page.$('p');5await page.evaluate((element, newElement) => {6 element.parentNode.insertBefore(newElement, element);7}, element, newElement);8import { Page } from 'playwright';9const page = new Page();10const element = await page.$('div');11const newElement = await page.$('p');12await element.evaluate((element, newElement) => {13 element.parentNode.insertBefore(newElement, element);14}, newElement);15import { Page } from 'playwright';16const page = new Page();17const element = await page.$('div');18const newElement = await page.$('p');19await element.evaluate((element, newElement) => {20 element.parentNode.insertBefore(newElement, element);21}, newElement);22const puppeteer = require('puppeteer');23const browser = await puppeteer.launch();24const page = await browser.newPage();25const element = await page.$('div');26const newElement = await page.$('p');27await page.evaluate((element, newElement) => {28 element.parentNode.insertBefore(newElement, element);29}, element, newElement);30const puppeteer = require('puppeteer');31const browser = await puppeteer.launch();32const page = await browser.newPage();33const element = await page.$('div');34const newElement = await page.$('p');35await element.evaluate((element, newElement) => {36 element.parentNode.insertBefore(newElement, element);37}, newElement);38const puppeteer = require('puppeteer');39const browser = await puppeteer.launch();40const page = await browser.newPage();41const element = await page.$('div');42const newElement = await page.$('p');43await element.evaluate((element, newElement) => {44 element.parentNode.insertBefore(newElement, element);45}, newElement);46const puppeteer = require('puppeteer');47const browser = await puppeteer.launch();

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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