How to use parentNode method in Playwright Internal

Best JavaScript code snippet using playwright-internal

admin.js

Source:admin.js Github

copy

Full Screen

1import Station from './Station.js';2import Libs from './Libs.js';3import User from './User.js';4// const url = 'http://localhost:8000/api/stations/';5// const urlBase = 'http://localhost:8000/';6const url = 'http://192.168.1.24:8000/api/stations/';7const urlBase = 'http://192.168.1.24:8000/';8let typeStation = "";9//MinValues10//Invernadero11let minTemperature = false;12let minHumidity = false;13let minRadiation = false;14//Acuícola15let minPh = false;16let minOxigen = false;17//Max values18//Invernadero19let maxTemperature = false;20let maxHumidity = false;21let maxRadiation = false;22//Acuícola23let maxPh = false;24let maxOxigen = false;25const user = new User();26const station = new Station();27const lib = new Libs();28//Listeners29document.getElementById('btnNew').addEventListener('click', (ev) => {30 ev.preventDefault();31 document.getElementById('titleModal').textContent = 'Nueva estación';32 lib.resetForm();33 lib.closeLoader();34 document.getElementById('divSearch').style.display = 'initial';35});36document.addEventListener('DOMContentLoaded', (ev) => {37 station.loadStations();38 lib.hideInputsBoolean(true);39});40document.getElementById('divStations').addEventListener('click', (ev) => {41 ev.preventDefault();42 document.getElementById('divSearch').style.display = 'initial';43 if (ev.target.classList[1] === 'delete' || ev.target.classList[3] === 'a-delete') {44 let id = ev.target.parentNode.parentNode.parentNode.querySelector("#idStation").firstChild.nodeValue.toString();45 let state = "";46 let action = "";47 let mensaje = "";48 if (ev.target.classList[1] == 'delete') {49 const section = ev.target.parentNode.parentNode.parentNode.parentNode.parentNode.firstChild.textContent;50 if (section == "Deshabilitadas") {51 state = "habilitará";52 action = "Habilitar";53 mensaje = "Habilitada";54 } else if (section == "Habilitadas") {55 state = "deshabilitará";56 action = "Deshabilitar";57 mensaje = "Deshabilitada";58 }59 } else if (ev.target.classList[3] === 'a-delete') {60 const section = ev.target.parentNode.parentNode.parentNode.parentNode.firstChild.textContent;61 if (section == "Deshabilitadas") {62 state = "habilitará";63 action = "Habilitar";64 mensaje = "Habilitada";65 } else if (section == "Habilitadas") {66 state = "deshabilitará";67 action = "Deshabilitar";68 mensaje = "Deshabilitada";69 }70 }71 Swal.fire({72 title: '¿Estás seguro?',73 text: `Esta acción ${state} la estación.`,74 icon: 'warning',75 showCancelButton: true,76 confirmButtonColor: '#3085d6',77 cancelButtonColor: '#d33',78 confirmButtonText: action79 }).then((result) => {80 if (result.value) {81 const data = {82 id: id83 }84 station.deleteStation(data);85 Swal.fire(86 `¡${mensaje}!`,87 `La estación ha sido ${mensaje.toLowerCase()}.`,88 'success'89 )90 }91 })92 }93 if (ev.target.classList[1] === 'edit' || ev.target.classList[4] === 'a-edit') {94 ev.preventDefault();95 let id = 0;96 const divMinBtnsInv = document.getElementById('minValueButtonsInv');97 const divMinBtnsAcu = document.getElementById('minValueButtonsAcu');98 divMinBtnsInv.style.display = 'none';99 divMinBtnsAcu.style.display = 'none';100 document.getElementById('titleModal').textContent = 'Editar estación';101 if (ev.target.classList[1] === 'edit') {102 id = ev.target.parentNode.parentNode.parentNode.querySelector("#idStation").firstChild.nodeValue;103 const title = ev.target.parentNode.parentNode.parentNode.querySelector("#titleStation").firstChild.nodeValue;104 const desc = ev.target.parentNode.parentNode.parentNode.querySelector("#descStation").firstChild.nodeValue;105 const photo = ev.target.parentNode.parentNode.parentNode.querySelector("#photoStation").src;106 const humidity = ev.target.parentNode.parentNode.parentNode.querySelector("#humidityL").firstChild.nodeValue;107 const temperature = ev.target.parentNode.parentNode.parentNode.querySelector("#temperatureL").firstChild.nodeValue;108 const radiation = ev.target.parentNode.parentNode.parentNode.querySelector("#radiationL").firstChild.nodeValue;109 const ph = ev.target.parentNode.parentNode.parentNode.querySelector("#phL").firstChild.nodeValue;110 const oxigen = ev.target.parentNode.parentNode.parentNode.querySelector("#oxigenL").firstChild.nodeValue;111 const humidityM = ev.target.parentNode.parentNode.parentNode.querySelector("#humidityM").firstChild.nodeValue;112 const temperatureM = ev.target.parentNode.parentNode.parentNode.querySelector("#temperatureM").firstChild.nodeValue;113 const radiationM = ev.target.parentNode.parentNode.parentNode.querySelector("#radiationM").firstChild.nodeValue;114 const phM = ev.target.parentNode.parentNode.parentNode.querySelector("#phM").firstChild.nodeValue;115 const oxigenM = ev.target.parentNode.parentNode.parentNode.querySelector("#oxigenM").firstChild.nodeValue;116 document.getElementById('inId').textContent = id;117 document.getElementById('inPhotoPre').src = photo;118 document.getElementById('inName').value = title;119 document.getElementById('inDescription').value = desc;120 document.getElementById('inLowestPH').value = humidity;121 document.getElementById('inLowestPHL').value = ph;122 document.getElementById('inLowestOX').value = oxigen;123 document.getElementById('inLowestPR').value = radiation;124 document.getElementById('inLowestPT').value = temperature;125 document.getElementById('inHighestPH').value = humidityM;126 document.getElementById('inHighestPR').value = radiationM;127 document.getElementById('inHighestPT').value = temperatureM;128 document.getElementById('inHighestPHL').value = phM;129 document.getElementById('inHighestOX').value = oxigenM;130 document.getElementById('divInputsLow').style.display = 'initial';131 document.getElementById('divVar').style.display = 'initial';132 if (document.getElementById('inLowestPH').value == "") {133 document.getElementById('divLowHum').style.display = 'none';134 document.getElementById('divHighHum').style.display = 'none';135 } else {136 document.getElementById('divLowHum').style.display = 'initial';137 document.getElementById('divHighHum').style.display = 'initial';138 }139 if (document.getElementById('inLowestPT').value == "") {140 document.getElementById('divLowTemp').style.display = 'none';141 document.getElementById('divHighTemp').style.display = 'none';142 } else {143 document.getElementById('divLowTemp').style.display = 'initial';144 document.getElementById('divHighTemp').style.display = 'initial';145 }146 if (document.getElementById('inLowestPHL').value == "") {147 document.getElementById('divLowPHL').style.display = 'none';148 document.getElementById('divHighPHL').style.display = 'none';149 } else {150 document.getElementById('divLowPHL').style.display = 'initial';151 document.getElementById('divHighPHL').style.display = 'initial';152 }153 if (document.getElementById('inLowestPR').value == "") {154 document.getElementById('divLowRad').style.display = 'none';155 document.getElementById('divHighRad').style.display = 'none';156 } else {157 document.getElementById('divLowRad').style.display = 'initial';158 document.getElementById('divHighRad').style.display = 'initial';159 }160 if (document.getElementById('inLowestOX').value == "") {161 document.getElementById('divLowOx').style.display = 'none';162 document.getElementById('divHighOx').style.display = 'none';163 } else {164 document.getElementById('divLowOx').style.display = 'initial';165 document.getElementById('divHighOx').style.display = 'initial';166 }167 if (document.getElementById('inLowestPH').value != "" || document.getElementById('inLowestPR').value != "") {168 document.getElementById('btnTypeAcu').style.display = 'none';169 document.getElementById('btnTypeInv').style.display = 'initial';170 typeStation = 'Invernadero';171 // console.log('Invernadero')172 // console.log(typeStation)173 }174 if (document.getElementById('inLowestPHL').value != "" || document.getElementById('inLowestOX').value != "") {175 document.getElementById('btnTypeAcu').style.display = 'initial';176 document.getElementById('btnTypeInv').style.display = 'none';177 typeStation = 'Acuicola';178 // console.log('Acuicola')179 // console.log(typeStation)180 }181 } else {182 id = ev.target.parentNode.parentNode.querySelector("#idStation").firstChild.nodeValue;183 const title = ev.target.parentNode.parentNode.querySelector("#titleStation").firstChild.nodeValue;184 const desc = ev.target.parentNode.parentNode.querySelector("#descStation").firstChild.nodeValue;185 const photo = ev.target.parentNode.parentNode.querySelector("#photoStation").src;186 const humidity = ev.target.parentNode.parentNode.querySelector("#humidityL").firstChild.nodeValue;187 const temperature = ev.target.parentNode.parentNode.querySelector("#temperatureL").firstChild.nodeValue;188 const radiation = ev.target.parentNode.parentNode.querySelector("#radiationL").firstChild.nodeValue;189 const ph = ev.target.parentNode.parentNode.querySelector("#phL").firstChild.nodeValue;190 const oxigen = ev.target.parentNode.parentNode.querySelector("#oxigenL").firstChild.nodeValue;191 const humidityM = ev.target.parentNode.parentNode.querySelector("#humidityM").firstChild.nodeValue;192 const temperatureM = ev.target.parentNode.parentNode.querySelector("#temperatureM").firstChild.nodeValue;193 const radiationM = ev.target.parentNode.parentNode.querySelector("#radiationM").firstChild.nodeValue;194 const phM = ev.target.parentNode.parentNode.querySelector("#phM").firstChild.nodeValue;195 const oxigenM = ev.target.parentNode.parentNode.querySelector("#oxigenM").firstChild.nodeValue;196 document.getElementById('inId').textContent = id;197 document.getElementById('inPhotoPre').src = photo;198 document.getElementById('inName').value = title;199 document.getElementById('inDescription').value = desc;200 document.getElementById('inLowestPH').value = humidity;201 document.getElementById('inLowestPHL').value = ph;202 document.getElementById('inLowestOX').value = oxigen;203 document.getElementById('inLowestPR').value = radiation;204 document.getElementById('inLowestPT').value = temperature;205 document.getElementById('inHighestPH').value = humidityM;206 document.getElementById('inHighestPR').value = radiationM;207 document.getElementById('inHighestPT').value = temperatureM;208 document.getElementById('inHighestPHL').value = phM;209 document.getElementById('inHighestOX').value = oxigenM;210 document.getElementById('divInputsLow').style.display = 'initial';211 document.getElementById('divVar').style.display = 'initial';212 if (document.getElementById('inLowestPH').value === "") {213 document.getElementById('divLowHum').style.display = 'none';214 document.getElementById('divHighHum').style.display = 'none';215 } else {216 document.getElementById('divLowHum').style.display = 'initial';217 document.getElementById('divHighHum').style.display = 'initial';218 }219 if (document.getElementById('inLowestPT').value === "") {220 document.getElementById('divLowTemp').style.display = 'none';221 document.getElementById('divHighTemp').style.display = 'none';222 } else {223 document.getElementById('divLowTemp').style.display = 'initial';224 document.getElementById('divHighTemp').style.display = 'initial';225 }226 if (document.getElementById('inLowestPHL').value === "") {227 document.getElementById('divLowPHL').style.display = 'none';228 document.getElementById('divHighPHL').style.display = 'none';229 } else {230 document.getElementById('divLowPHL').style.display = 'initial';231 document.getElementById('divHighPHL').style.display = 'initial';232 }233 if (document.getElementById('inLowestPR').value === "") {234 document.getElementById('divLowRad').style.display = 'none';235 document.getElementById('divHighRad').style.display = 'none';236 } else {237 document.getElementById('divLowRad').style.display = 'initial';238 document.getElementById('divHighRad').style.display = 'initial';239 }240 if (document.getElementById('inLowestOX').value == "") {241 document.getElementById('divLowOx').style.display = 'none';242 document.getElementById('divHighOx').style.display = 'none';243 } else {244 document.getElementById('divLowOx').style.display = 'initial';245 document.getElementById('divHighOx').style.display = 'initial';246 }247 if (document.getElementById('inLowestPH').value != "" || document.getElementById('inLowestPR').value != "") {248 document.getElementById('btnTypeAcu').style.display = 'none';249 document.getElementById('btnTypeInv').style.display = 'initial';250 // console.log('invernadero')251 }252 if (document.getElementById('inLowestPHL').value != "" || document.getElementById('inLowestOX').value != "") {253 document.getElementById('btnTypeAcu').style.display = 'initial';254 document.getElementById('btnTypeInv').style.display = 'none';255 // console.log('Acuicola')256 }257 }258 const data = {259 idStation: id260 }261 user.getUsersAllowed(data);262 }263});264document.getElementById('saveStation').addEventListener('click', (ev) => {265 if (document.getElementById('titleModal').textContent === "Editar estación") {266 document.getElementById('divSearch').style.display = 'initial';267 const id = document.getElementById('inId').textContent;268 const name = document.getElementById('inName').value;269 const desc = document.getElementById('inDescription').value;270 //Greenhouse271 const temperature = document.getElementById('inLowestPT').value;272 const humidity = document.getElementById('inLowestPH').value;273 const radiation = document.getElementById('inLowestPR').value;274 const maxTemperature = document.getElementById('inHighestPT').value;275 const maxHumidity = document.getElementById('inHighestPH').value;276 const maxRadiation = document.getElementById('inHighestPR').value;277 //Aquaculture278 const ph = document.getElementById('inLowestPHL').value;279 const ox = document.getElementById('inLowestOX').value;280 const maxPh = document.getElementById('inHighestPHL').value;281 const maxOx = document.getElementById('inHighestOX').value;282 let minVars = new Array();283 let maximums = new Array();284 let minimums = new Array();285 //If the values are true will be push to the array286 if (typeStation === 'Invernadero') {287 if (temperature) {288 minVars.push('temperature');289 minimums.push(temperature);290 maximums.push(maxTemperature);291 }292 if (humidity) {293 minVars.push('humidity');294 minimums.push(humidity);295 maximums.push(maxHumidity);296 }297 if (radiation) {298 minVars.push('radiation');299 minimums.push(radiation);300 maximums.push(maxRadiation);301 }302 } else {303 if (temperature) {304 minVars.push('temperature');305 minimums.push(temperature);306 maximums.push(maxTemperature);307 }308 if (ph) {309 minVars.push('ph');310 minimums.push(ph);311 maximums.push(maxPh);312 }313 if (ox) {314 minVars.push('oxigen');315 minimums.push(ox);316 maximums.push(maxOx);317 }318 }319 const data = new FormData();320 data.append('id', id);321 data.append('title', name);322 data.append('description', desc);323 data.append('minVars', minVars);324 data.append('minimums', minimums);325 data.append('maximums', maximums);326 if (document.getElementById('inFile').files[0] !== undefined) {327 const photo = document.getElementById('inFile');328 data.append('photo', photo.files[0]);329 }330 // console.log(minVars)331 // console.log(minimums)332 // console.log(maximums)333 station.editStation(data);334 } else if (document.getElementById('titleModal').textContent === "Nueva estación") {335 const photo = document.getElementById('inFile');336 const name = document.getElementById('inName').value;337 const desc = document.getElementById('inDescription').value;338 //Greenhouse339 const temperature = document.getElementById('inLowestPT').value;340 const humidity = document.getElementById('inLowestPH').value;341 const radiation = document.getElementById('inLowestPR').value;342 const maxTemperature = document.getElementById('inHighestPT').value;343 const maxHumidity = document.getElementById('inHighestPH').value;344 const maxRadiation = document.getElementById('inHighestPR').value;345 //Aquaculture346 const ph = document.getElementById('inLowestPHL').value;347 const ox = document.getElementById('inLowestOX').value;348 const maxPh = document.getElementById('inHighestPHL').value;349 const maxOx = document.getElementById('inHighestOX').value;350 let minVars = new Array();351 let maximums = new Array();352 let minimums = new Array();353 //If the values are true will be push to the array354 if (typeStation === 'Invernadero') {355 if (minTemperature) {356 minVars.push('temperature');357 minimums.push(temperature);358 maximums.push(maxTemperature);359 }360 if (minHumidity) {361 minVars.push('humidity');362 minimums.push(humidity);363 maximums.push(maxHumidity);364 }365 if (minRadiation) {366 minVars.push('radiation');367 minimums.push(radiation);368 maximums.push(maxRadiation);369 }370 } else {371 if (minTemperature) {372 minVars.push('temperature');373 minimums.push(temperature);374 maximums.push(maxTemperature);375 }376 if (minPh) {377 minVars.push('ph');378 minimums.push(ph);379 maximums.push(maxPh);380 }381 if (minOxigen) {382 minVars.push('oxigen');383 minimums.push(ox);384 maximums.push(maxOx);385 }386 }387 const data = new FormData();388 data.append('photo', photo.files[0]);389 data.append('title', name);390 data.append('description', desc);391 data.append('minVars', minVars);392 data.append('minimums', minimums);393 data.append('maximums', maximums);394 station.addStation(data);395 }396});397document.getElementById('inFile').addEventListener('change', (ev) => {398 lib.loadPreview(ev);399});400document.getElementById('btnUserSearch').addEventListener('click', (ev) => {401 ev.preventDefault();402 const email = document.getElementById('inUser').value;403 const id = document.getElementById('inId').textContent;404 const data = {405 idStation: id,406 email: email,407 }408 user.findUser(data);409});410document.getElementById('divUserSearched').addEventListener('click', (ev) => {411 const id = document.getElementById('inId').textContent;412 const email = ev.target.parentNode.parentNode.parentNode.querySelector('#userEmail').firstChild.nodeValue;413 const data = {414 idStation: id,415 email: email416 }417 user.addUserStation(data, data);418});419document.getElementById('divUserAllowed').addEventListener('click', (ev) => {420 if (ev.target.textContent == 'delete') {421 Swal.fire({422 icon: 'warning',423 title: '¿Deseas eliminar a este usuario?',424 text: 'Esta acción no se puede deshacer.',425 showCancelButton: true,426 confirmButtonText: `Eliminar`,427 }).then((result) => {428 if (result.isConfirmed) {429 let id;430 let email;431 if (ev.target.classList[0] === 'btn') {432 id = ev.target.parentNode.parentNode.parentNode.parentNode.433 parentNode.parentNode.parentNode.parentNode.querySelector('#inId').firstChild.nodeValue;434 email = ev.target.parentNode.parentNode.parentNode.querySelector('#userEmail').firstChild.nodeValue;435 } else if (ev.target.classList[0] === 'material-icons') {436 email = ev.target.parentNode.parentNode.parentNode.querySelector('#userEmail').firstChild.nodeValue;437 id = ev.target.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector('#inId').firstChild.nodeValue438 }439 const data = {440 idStation: id,441 email: email,442 }443 const users = {444 idStation: id445 }446 user.deleteUserSuscription(data, users);447 }448 })449 }450});451document.getElementById('divTypeButtons').addEventListener('click', (ev) => {452 const divMinBtnsInv = document.getElementById('minValueButtonsInv');453 const divMinBtnsAcu = document.getElementById('minValueButtonsAcu');454 document.getElementById('divInputsLow').style.display = 'none';455 document.getElementById('divInputsHigh').style.display = 'none';456 divMinBtnsInv.style.display = 'none';457 divMinBtnsAcu.style.display = 'none';458 lib.hideInputsBoolean(true);459 const idButton = ev.target.id;460 // console.log(idButton)461 if (idButton == 'btnTypeInv') {462 typeStation = 'Invernadero';463 } else {464 typeStation = 'Acuícola';465 }466 document.getElementById('divVar').style.display = 'initial';467});468document.getElementById('btnMinValues').addEventListener('click', () => {469 const divMinBtnsInv = document.getElementById('minValueButtonsInv');470 const divMinBtnsAcu = document.getElementById('minValueButtonsAcu');471 divMinBtnsInv.style.display = 'none';472 divMinBtnsAcu.style.display = 'none';473 document.getElementById('divInputsLow').style.display = 'initial';474 document.getElementById('divInputsHigh').style.display = 'initial';475 // console.log(typeStation)476 if (typeStation == 'Invernadero') {477 if (divMinBtnsInv.style.display === 'initial') {478 divMinBtnsInv.style.display = 'none'479 } else {480 divMinBtnsInv.style.display = 'initial'481 }482 } else {483 if (divMinBtnsAcu.style.display === 'initial') {484 divMinBtnsAcu.style.display = 'none'485 } else {486 divMinBtnsAcu.style.display = 'initial'487 }488 }489});490document.getElementById('btnMinRad').addEventListener('click', () => {491 const divRad = document.getElementById('divLowRad');492 const inLowestPR = document.getElementById('inLowestPR');493 const divMaxRad = document.getElementById('divHighRad');494 const inHighestPR = document.getElementById('inHighestPR');495 if (divRad.style.display === 'initial') {496 divRad.style.display = 'none'497 divMaxRad.style.display = 'none'498 inLowestPR.value = "";499 inHighestPR.value = "";500 maxRadiation = false;501 minRadiation = false;502 } else {503 // inLowestPR.value = 17;504 minRadiation = true;505 maxRadiation = true;506 divRad.style.display = 'initial'507 divMaxRad.style.display = 'initial'508 }509});510document.getElementById('btnMinTemp').addEventListener('click', () => {511 const divTemp = document.getElementById('divLowTemp');512 const inLowestPT = document.getElementById('inLowestPT');513 const divMaxTemp = document.getElementById('divHighTemp');514 const inHighestPT = document.getElementById('inHighestPT');515 if (divTemp.style.display === 'initial') {516 divTemp.style.display = 'none'517 divMaxTemp.style.display = 'none'518 inLowestPT.value = "";519 inHighestPT.value = "";520 minTemperature = false;521 maxTemperature = false;522 } else {523 minTemperature = true;524 maxTemperature = true;525 divTemp.style.display = 'initial'526 divMaxTemp.style.display = 'initial'527 }528});529document.getElementById('btnMinHum').addEventListener('click', () => {530 const divHum = document.getElementById('divLowHum');531 const inLowestPH = document.getElementById('inLowestPH');532 const divMaxHum = document.getElementById('divHighHum');533 const inHighestPH = document.getElementById('inHighestPH');534 if (divHum.style.display === 'initial') {535 divHum.style.display = 'none'536 divMaxHum.style.display = 'none'537 inLowestPH.value = "";538 inHighestPH.value = "";539 minHumidity = false;540 maxHumidity = false;541 } else {542 minHumidity = true;543 maxHumidity = true;544 divHum.style.display = 'initial'545 divMaxHum.style.display = 'initial'546 }547});548//Acuicola549document.getElementById('btnMinTempAcu').addEventListener('click', () => {550 const divTemp = document.getElementById('divLowTemp');551 const inLowestPT = document.getElementById('inLowestPT');552 const divMaxTemp = document.getElementById('divHighTemp');553 const inHighestPT = document.getElementById('inHighestPT');554 if (divTemp.style.display === 'initial') {555 divTemp.style.display = 'none'556 divMaxTemp.style.display = 'none'557 inLowestPT.value = "";558 inHighestPT.value = "";559 minTemperature = false;560 maxTemperature = false;561 } else {562 minTemperature = true;563 maxTemperature = true;564 divTemp.style.display = 'initial'565 divMaxTemp.style.display = 'initial'566 }567});568document.getElementById('btnMinPH').addEventListener('click', () => {569 const divPh = document.getElementById('divLowPHL');570 const inLowestPHL = document.getElementById('inLowestPHL');571 const divMaxPh = document.getElementById('divHighPHL');572 const inHighestPHL = document.getElementById('inHighestPHL');573 if (divPh.style.display === 'initial') {574 divPh.style.display = 'none';575 divMaxPh.style.display = 'none';576 inLowestPHL.value = "";577 inHighestPHL.value = "";578 minPh = false;579 maxPh = false;580 } else {581 minPh = true;582 maxPh = true;583 divPh.style.display = 'initial';584 divMaxPh.style.display = 'initial';585 }586});587document.getElementById('btnMinOx').addEventListener('click', () => {588 const divOx = document.getElementById('divLowOx');589 const inLowestOx = document.getElementById('inLowestOX');590 const divMaxOx = document.getElementById('divHighOx');591 const inHighestOx = document.getElementById('inHighestOX');592 if (divOx.style.display === 'initial') {593 divOx.style.display = 'none';594 divMaxOx.style.display = 'none';595 inLowestOx.value = "";596 inHighestOx.value = "";597 minOxigen = false;598 maxOxigen = false;599 } else {600 minOxigen = true;601 maxOxigen = true;602 divOx.style.display = 'initial'603 divMaxOx.style.display = 'initial'604 }...

Full Screen

Full Screen

paralleltrees.js

Source:paralleltrees.js Github

copy

Full Screen

1/*2 * Copyright 2012 The Polymer Authors. All rights reserved.3 * Use of this source code is goverened by a BSD-style4 * license that can be found in the LICENSE file.5 */6suite('Parallel Trees', function() {7 var wrap = ShadowDOMPolyfill.wrap;8 var unwrap = ShadowDOMPolyfill.unwrap;9 var visual = ShadowDOMPolyfill.visual;10 suite('Visual', function() {11 test('removeAllChildNodes wrapper', function() {12 var div = document.createElement('div');13 div.textContent = 'a';14 var textNode = div.firstChild;15 visual.removeAllChildNodes(div);16 expectStructure(unwrap(div), {});17 expectStructure(unwrap(textNode), {});18 expectStructure(div, {19 firstChild: textNode,20 lastChild: textNode21 });22 expectStructure(textNode, {23 parentNode: div24 });25 });26 test('removeAllChildNodes wrapper with 3 child nodes', function() {27 var div = document.createElement('div');28 div.innerHTML = '<a></a><b></b><c></c>';29 var a = div.firstChild;30 var b = a.nextSibling;31 var c = div.lastChild;32 visual.removeAllChildNodes(div);33 expectStructure(unwrap(div), {});34 expectStructure(unwrap(a), {});35 expectStructure(unwrap(b), {});36 expectStructure(unwrap(c), {});37 expectStructure(div, {38 firstChild: a,39 lastChild: c40 });41 expectStructure(a, {42 parentNode: div,43 nextSibling: b44 });45 expectStructure(b, {46 parentNode: div,47 previousSibling: a,48 nextSibling: c49 });50 expectStructure(c, {51 parentNode: div,52 previousSibling: b53 });54 });55 test('appendChild, start with no children', function() {56 var div = document.createElement('div');57 var textNode = document.createTextNode('hello');58 expectStructure(div, {});59 expectStructure(textNode, {});60 unwrapAndExpectStructure(div, {});61 unwrapAndExpectStructure(textNode, {});62 visual.appendChild(div, textNode);63 unwrapAndExpectStructure(div, {64 firstChild: textNode,65 lastChild: textNode66 });67 unwrapAndExpectStructure(textNode, {68 parentNode: div69 });70 expectStructure(div, {});71 expectStructure(textNode, {});72 });73 test('appendChild, start with one child', function() {74 var div = document.createElement('div');75 div.innerHTML = '<a></a>';76 var a = div.firstChild;77 var b = document.createElement('b');78 visual.appendChild(div, b);79 unwrapAndExpectStructure(div, {80 firstChild: a,81 lastChild: b82 });83 unwrapAndExpectStructure(a, {84 parentNode: div,85 nextSibling: b86 });87 unwrapAndExpectStructure(b, {88 parentNode: div,89 previousSibling: a90 });91 expectStructure(div, {92 firstChild: a,93 lastChild: a94 });95 expectStructure(a, {96 parentNode: div97 });98 expectStructure(b, {});99 });100 test('appendChild, start with two children', function() {101 var div = document.createElement('div');102 div.innerHTML = '<a></a><b></b>';103 var a = div.firstChild;104 var b = div.lastChild;105 var c = document.createElement('c');106 visual.appendChild(div, c);107 unwrapAndExpectStructure(div, {108 firstChild: a,109 lastChild: c110 });111 unwrapAndExpectStructure(a, {112 parentNode: div,113 nextSibling: b114 });115 unwrapAndExpectStructure(b, {116 parentNode: div,117 previousSibling: a,118 nextSibling: c119 });120 unwrapAndExpectStructure(c, {121 parentNode: div,122 previousSibling: b123 });124 expectStructure(div, {125 firstChild: a,126 lastChild: b127 });128 expectStructure(a, {129 parentNode: div,130 nextSibling: b131 });132 expectStructure(b, {133 parentNode: div,134 previousSibling: a135 });136 expectStructure(c, {});137 });138 test('appendChild with document fragment', function() {139 var div = document.createElement('div');140 var df = document.createDocumentFragment();141 var a = df.appendChild(document.createElement('a'));142 var b = df.appendChild(document.createElement('b'));143 visual.appendChild(div, df);144 unwrapAndExpectStructure(div, {145 firstChild: a,146 lastChild: b147 });148 unwrapAndExpectStructure(df, {});149 unwrapAndExpectStructure(a, {150 parentNode: div,151 nextSibling: b152 });153 unwrapAndExpectStructure(b, {154 parentNode: div,155 previousSibling: a156 });157 expectStructure(div, {});158 expectStructure(df, {159 firstChild: a,160 lastChild: b161 });162 expectStructure(a, {163 parentNode: df,164 nextSibling: b165 });166 expectStructure(b, {167 parentNode: df,168 previousSibling: a169 });170 });171 test('appendChild with document fragment again', function() {172 var div = document.createElement('div');173 div.innerHTML = '<a></a>';174 var a = div.lastChild;175 var df = document.createDocumentFragment();176 var b = df.appendChild(document.createElement('b'));177 var c = df.appendChild(document.createElement('c'));178 div.appendChild(df);179 expectStructure(df, {});180 expectStructure(div, {181 firstChild: a,182 lastChild: c183 });184 expectStructure(a, {185 parentNode: div,186 nextSibling: b187 });188 expectStructure(b, {189 parentNode: div,190 previousSibling: a,191 nextSibling: c192 });193 expectStructure(c, {194 parentNode: div,195 previousSibling: b196 });197 unwrapAndExpectStructure(df, {});198 unwrapAndExpectStructure(div, {199 firstChild: a,200 lastChild: c201 });202 unwrapAndExpectStructure(a, {203 parentNode: div,204 nextSibling: b205 });206 unwrapAndExpectStructure(b, {207 parentNode: div,208 previousSibling: a,209 nextSibling: c210 });211 unwrapAndExpectStructure(c, {212 parentNode: div,213 previousSibling: b214 });215 });216 test('appendChild with empty document fragment', function() {217 var div = document.createElement('div');218 div.innerHTML = '<a></a>';219 var a = div.lastChild;220 var df = document.createDocumentFragment();221 div.appendChild(df);222 expectStructure(df, {});223 expectStructure(div, {224 firstChild: a,225 lastChild: a226 });227 expectStructure(a, {228 parentNode: div229 });230 unwrapAndExpectStructure(df, {});231 unwrapAndExpectStructure(div, {232 firstChild: a,233 lastChild: a234 });235 unwrapAndExpectStructure(a, {236 parentNode: div237 });238 });239 test('removeChild, start with one child', function() {240 var div = document.createElement('div');241 div.innerHTML = '<a></a>';242 var a = div.firstChild;243 visual.removeChild(div, a);244 unwrapAndExpectStructure(div, {});245 unwrapAndExpectStructure(a, {});246 expectStructure(div, {247 firstChild: a,248 lastChild: a249 });250 expectStructure(a, {251 parentNode: div252 });253 });254 test('removeChild, start with two children, remove first', function() {255 var div = document.createElement('div');256 div.innerHTML = '<a></a><b></b>';257 var a = div.firstChild;258 var b = div.lastChild;259 visual.removeChild(div, a);260 unwrapAndExpectStructure(div, {261 firstChild: b,262 lastChild: b263 });264 unwrapAndExpectStructure(a, {});265 unwrapAndExpectStructure(b, {266 parentNode: div267 });268 expectStructure(div, {269 firstChild: a,270 lastChild: b271 });272 expectStructure(a, {273 parentNode: div,274 nextSibling: b275 });276 expectStructure(b, {277 parentNode: div,278 previousSibling: a279 });280 });281 test('removeChild, start with two children, remove last', function() {282 var div = document.createElement('div');283 div.innerHTML = '<a></a><b></b>';284 var a = div.firstChild;285 var b = div.lastChild;286 visual.removeChild(div, b);287 unwrapAndExpectStructure(div, {288 firstChild: a,289 lastChild: a290 });291 unwrapAndExpectStructure(a, {292 parentNode: div293 });294 unwrapAndExpectStructure(b, {});295 expectStructure(div, {296 firstChild: a,297 lastChild: b298 });299 expectStructure(a, {300 parentNode: div,301 nextSibling: b302 });303 expectStructure(b, {304 parentNode: div,305 previousSibling: a306 });307 });308 test('removeChild, start with three children, remove middle', function() {309 var div = document.createElement('div');310 div.innerHTML = '<a></a><b></b><c></c>';311 var a = div.firstChild;312 var b = a.nextSibling;313 var c = div.lastChild;314 visual.removeChild(div, b);315 unwrapAndExpectStructure(div, {316 firstChild: a,317 lastChild: c318 });319 unwrapAndExpectStructure(a, {320 parentNode: div,321 nextSibling: c322 });323 unwrapAndExpectStructure(b, {});324 unwrapAndExpectStructure(c, {325 parentNode: div,326 previousSibling: a327 });328 expectStructure(div, {329 firstChild: a,330 lastChild: c331 });332 expectStructure(a, {333 parentNode: div,334 nextSibling: b335 });336 expectStructure(b, {337 parentNode: div,338 previousSibling: a,339 nextSibling: c340 });341 expectStructure(c, {342 parentNode: div,343 previousSibling: b344 });345 });346 });347 suite('Logical', function() {348 suite('removeAllChildNodes', function() {349 test('simple', function() {350 var div = document.createElement('div');351 div.innerHTML = '<a></a><b></b><c></c>';352 var a = div.firstChild;353 var b = a.nextSibling;354 var c = div.lastChild;355 div.textContent = '';356 unwrapAndExpectStructure(div, {});357 unwrapAndExpectStructure(a, {});358 unwrapAndExpectStructure(b, {});359 unwrapAndExpectStructure(c, {});360 expectStructure(div, {});361 expectStructure(a, {});362 expectStructure(b, {});363 expectStructure(c, {});364 });365 test('with wrappers before removal', function() {366 var div = document.createElement('div');367 div.innerHTML = '<a></a><b></b><c></c>';368 var a = div.firstChild;369 var b = a.nextSibling;370 var c = div.lastChild;371 div.textContent = '';372 unwrapAndExpectStructure(div, {});373 unwrapAndExpectStructure(a, {});374 unwrapAndExpectStructure(b, {});375 unwrapAndExpectStructure(c, {});376 expectStructure(div, {});377 expectStructure(a, {});378 expectStructure(b, {});379 expectStructure(c, {});380 });381 test('change visual first', function() {382 var div = document.createElement('div');383 div.innerHTML = '<a></a><b></b><c></c>';384 var a = div.firstChild;385 var b = a.nextSibling;386 var c = div.lastChild;387 visual.removeAllChildNodes(div);388 unwrapAndExpectStructure(div, {});389 unwrapAndExpectStructure(a, {});390 unwrapAndExpectStructure(b, {});391 unwrapAndExpectStructure(c, {});392 div.textContent = '';393 expectStructure(div, {});394 expectStructure(a, {});395 expectStructure(b, {});396 expectStructure(c, {});397 });398 });399 suite('appendChild', function() {400 test('simple', function() {401 var div = document.createElement('div');402 div.innerHTML = '<a></a><b></b>';403 var a = div.firstChild;404 var b = a.nextSibling;405 var c = document.createElement('c');406 div.appendChild(c);407 unwrapAndExpectStructure(div, {408 firstChild: a,409 lastChild: c410 });411 unwrapAndExpectStructure(a, {412 parentNode: div,413 nextSibling: b414 });415 unwrapAndExpectStructure(b, {416 parentNode: div,417 previousSibling: a,418 nextSibling: c419 });420 unwrapAndExpectStructure(c, {421 parentNode: div,422 previousSibling: b423 });424 expectStructure(div, {425 firstChild: a,426 lastChild: c427 });428 expectStructure(a, {429 parentNode: div,430 nextSibling: b431 });432 expectStructure(b, {433 parentNode: div,434 previousSibling: a,435 nextSibling: c436 });437 expectStructure(c, {438 parentNode: div,439 previousSibling: b440 });441 });442 test('with wrappers before', function() {443 var div = document.createElement('div');444 div.innerHTML = '<a></a><b></b>';445 var a = div.firstChild;446 var b = a.nextSibling;447 var c = document.createElement('c');448 div.appendChild(c);449 unwrapAndExpectStructure(div, {450 firstChild: a,451 lastChild: c452 });453 unwrapAndExpectStructure(a, {454 parentNode: div,455 nextSibling: b456 });457 unwrapAndExpectStructure(b, {458 parentNode: div,459 previousSibling: a,460 nextSibling: c461 });462 unwrapAndExpectStructure(c, {463 parentNode: div,464 previousSibling: b465 });466 expectStructure(div, {467 firstChild: a,468 lastChild: c469 });470 expectStructure(a, {471 parentNode: div,472 nextSibling: b473 });474 expectStructure(b, {475 parentNode: div,476 previousSibling: a,477 nextSibling: c478 });479 expectStructure(c, {480 parentNode: div,481 previousSibling: b482 });483 });484 test('change visual first', function() {485 var div = document.createElement('div');486 div.innerHTML = '<a></a><b></b>';487 var a = div.firstChild;488 var b = a.nextSibling;489 var c = document.createElement('c');490 visual.removeAllChildNodes(div);491 div.appendChild(c);492 unwrapAndExpectStructure(div, {493 firstChild: c,494 lastChild: c495 });496 unwrapAndExpectStructure(a, {});497 unwrapAndExpectStructure(b, {});498 unwrapAndExpectStructure(c, {499 parentNode: div500 });501 expectStructure(div, {502 firstChild: a,503 lastChild: c504 });505 expectStructure(a, {506 parentNode: div,507 nextSibling: b508 });509 expectStructure(b, {510 parentNode: div,511 previousSibling: a,512 nextSibling: c513 });514 expectStructure(c, {515 parentNode: div,516 previousSibling: b517 });518 });519 });520 suite('insertBefore', function() {521 test('simple', function() {522 var div = document.createElement('div');523 div.innerHTML = '<a></a><c></c>';524 var a = div.firstChild;525 var c = a.nextSibling;526 var b = document.createElement('b');527 div.insertBefore(b, c);528 unwrapAndExpectStructure(div, {529 firstChild: a,530 lastChild: c531 });532 unwrapAndExpectStructure(a, {533 parentNode: div,534 nextSibling: b535 });536 unwrapAndExpectStructure(b, {537 parentNode: div,538 previousSibling: a,539 nextSibling: c540 });541 unwrapAndExpectStructure(c, {542 parentNode: div,543 previousSibling: b544 });545 expectStructure(div, {546 firstChild: a,547 lastChild: c548 });549 expectStructure(a, {550 parentNode: div,551 nextSibling: b552 });553 expectStructure(b, {554 parentNode: div,555 previousSibling: a,556 nextSibling: c557 });558 expectStructure(c, {559 parentNode: div,560 previousSibling: b561 });562 });563 test('with wrappers before', function() {564 var div = document.createElement('div');565 div.innerHTML = '<a></a><c></c>';566 var a = div.firstChild;567 var c = a.nextSibling;568 var b = document.createElement('b');569 div.insertBefore(b, c);570 unwrapAndExpectStructure(div, {571 firstChild: a,572 lastChild: c573 });574 unwrapAndExpectStructure(a, {575 parentNode: div,576 nextSibling: b577 });578 unwrapAndExpectStructure(b, {579 parentNode: div,580 previousSibling: a,581 nextSibling: c582 });583 unwrapAndExpectStructure(c, {584 parentNode: div,585 previousSibling: b586 });587 expectStructure(div, {588 firstChild: a,589 lastChild: c590 });591 expectStructure(a, {592 parentNode: div,593 nextSibling: b594 });595 expectStructure(b, {596 parentNode: div,597 previousSibling: a,598 nextSibling: c599 });600 expectStructure(c, {601 parentNode: div,602 previousSibling: b603 });604 });605 test('change visual first', function() {606 var div = document.createElement('div');607 div.innerHTML = '<a></a><c></c>';608 var a = div.firstChild;609 var c = a.nextSibling;610 var b = document.createElement('b');611 visual.removeAllChildNodes(div);612 div.insertBefore(b, c);613 unwrapAndExpectStructure(div, {});614 unwrapAndExpectStructure(a, {});615 unwrapAndExpectStructure(b, {});616 unwrapAndExpectStructure(c, {});617 expectStructure(div, {618 firstChild: a,619 lastChild: c620 });621 expectStructure(a, {622 parentNode: div,623 nextSibling: b624 });625 expectStructure(b, {626 parentNode: div,627 previousSibling: a,628 nextSibling: c629 });630 expectStructure(c, {631 parentNode: div,632 previousSibling: b633 });634 // swap a and b635 div.insertBefore(b, a);636 expectStructure(div, {637 firstChild: b,638 lastChild: c639 });640 expectStructure(b, {641 parentNode: div,642 nextSibling: a643 });644 expectStructure(a, {645 parentNode: div,646 previousSibling: b,647 nextSibling: c648 });649 expectStructure(c, {650 parentNode: div,651 previousSibling: a652 });653 // swap a and c654 div.insertBefore(c, a);655 expectStructure(div, {656 firstChild: b,657 lastChild: a658 });659 expectStructure(b, {660 parentNode: div,661 nextSibling: c662 });663 expectStructure(c, {664 parentNode: div,665 previousSibling: b,666 nextSibling: a667 });668 expectStructure(a, {669 parentNode: div,670 previousSibling: c671 });672 });673 });674 test('insertBefore with document fragment', function() {675 var div = document.createElement('div');676 var c = div.appendChild(document.createElement('c'));677 var df = document.createDocumentFragment();678 var a = df.appendChild(document.createElement('a'));679 var b = df.appendChild(document.createElement('b'));680 visual.removeAllChildNodes(div);681 visual.removeAllChildNodes(df);682 div.insertBefore(df, c);683 unwrapAndExpectStructure(div, {});684 unwrapAndExpectStructure(df, {});685 unwrapAndExpectStructure(a, {});686 unwrapAndExpectStructure(b, {});687 unwrapAndExpectStructure(c, {});688 expectStructure(div, {689 firstChild: a,690 lastChild: c691 });692 expectStructure(df, {});693 expectStructure(a, {694 parentNode: div,695 nextSibling: b696 });697 expectStructure(b, {698 parentNode: div,699 previousSibling: a,700 nextSibling: c701 });702 expectStructure(c, {703 parentNode: div,704 previousSibling: b705 });706 });707 test('insertBefore with document fragment again', function() {708 var div = document.createElement('div');709 div.innerHTML = '<a></a><d></d>';710 var a = div.firstChild;711 var d = div.lastChild;712 var df = document.createDocumentFragment();713 var b = df.appendChild(document.createElement('b'));714 var c = df.appendChild(document.createElement('c'));715 div.insertBefore(df, d);716 expectStructure(df, {});717 expectStructure(div, {718 firstChild: a,719 lastChild: d720 });721 expectStructure(a, {722 parentNode: div,723 nextSibling: b724 });725 expectStructure(b, {726 parentNode: div,727 previousSibling: a,728 nextSibling: c729 });730 expectStructure(c, {731 parentNode: div,732 previousSibling: b,733 nextSibling: d734 });735 expectStructure(d, {736 parentNode: div,737 previousSibling: c738 });739 unwrapAndExpectStructure(df, {});740 unwrapAndExpectStructure(div, {741 firstChild: a,742 lastChild: d743 });744 unwrapAndExpectStructure(a, {745 parentNode: div,746 nextSibling: b747 });748 unwrapAndExpectStructure(b, {749 parentNode: div,750 previousSibling: a,751 nextSibling: c752 });753 unwrapAndExpectStructure(c, {754 parentNode: div,755 previousSibling: b,756 nextSibling: d757 });758 unwrapAndExpectStructure(d, {759 parentNode: div,760 previousSibling: c761 });762 });763 suite('replaceChild', function() {764 test('simple', function() {765 var div = document.createElement('div');766 div.innerHTML = '<a></a><c></c>';767 var a = div.firstChild;768 var c = a.nextSibling;769 var b = document.createElement('b');770 div.replaceChild(b, c);771 unwrapAndExpectStructure(div, {772 firstChild: a,773 lastChild: b774 });775 unwrapAndExpectStructure(a, {776 parentNode: div,777 nextSibling: b778 });779 unwrapAndExpectStructure(b, {780 parentNode: div,781 previousSibling: a782 });783 unwrapAndExpectStructure(c, {});784 expectStructure(div, {785 firstChild: a,786 lastChild: b787 });788 expectStructure(a, {789 parentNode: div,790 nextSibling: b791 });792 expectStructure(b, {793 parentNode: div,794 previousSibling: a795 });796 expectStructure(c, {});797 });798 test('with wrappers before', function() {799 var div = document.createElement('div');800 div.innerHTML = '<a></a><c></c>';801 var a = div.firstChild;802 var c = a.nextSibling;803 var b = document.createElement('b');804 div.replaceChild(b, c);805 expectStructure(div, {806 firstChild: a,807 lastChild: b808 });809 expectStructure(a, {810 parentNode: div,811 nextSibling: b812 });813 expectStructure(b, {814 parentNode: div,815 previousSibling: a816 });817 expectStructure(c, {});818 expectStructure(div, {819 firstChild: a,820 lastChild: b821 });822 expectStructure(a, {823 parentNode: div,824 nextSibling: b825 });826 expectStructure(b, {827 parentNode: div,828 previousSibling: a829 });830 expectStructure(c, {});831 });832 test('change visual first', function() {833 var div = document.createElement('div');834 div.innerHTML = '<a></a><c></c>';835 var a = div.firstChild;836 var c = a.nextSibling;837 var b = document.createElement('b');838 visual.removeAllChildNodes(div);839 div.replaceChild(b, c);840 unwrapAndExpectStructure(div, {});841 unwrapAndExpectStructure(a, {});842 unwrapAndExpectStructure(b, {});843 unwrapAndExpectStructure(c, {});844 expectStructure(div, {845 firstChild: a,846 lastChild: b847 });848 expectStructure(a, {849 parentNode: div,850 nextSibling: b851 });852 expectStructure(b, {853 parentNode: div,854 previousSibling: a855 });856 expectStructure(c, {});857 // Remove a858 div.replaceChild(b, a);859 expectStructure(div, {860 firstChild: b,861 lastChild: b862 });863 expectStructure(a, {});864 expectStructure(b, {865 parentNode: div866 });867 expectStructure(c, {});868 // Swap b with c869 div.replaceChild(c, b);870 expectStructure(div, {871 firstChild: c,872 lastChild: c873 });874 expectStructure(a, {});875 expectStructure(b, {});876 expectStructure(c, {877 parentNode: div878 });879 });880 test('replaceChild with document fragment', function() {881 var div = document.createElement('div');882 div.innerHTML = '<a></a><e></e><d></d>';883 var a = div.firstChild;884 var e = a.nextSibling;885 var d = e.nextSibling;886 var df = document.createDocumentFragment();887 var b = df.appendChild(document.createElement('b'));888 var c = df.appendChild(document.createElement('c'));889 div.replaceChild(df, e);890 expectStructure(df, {});891 expectStructure(e, {});892 expectStructure(div, {893 firstChild: a,894 lastChild: d895 });896 expectStructure(a, {897 parentNode: div,898 nextSibling: b899 });900 expectStructure(b, {901 parentNode: div,902 previousSibling: a,903 nextSibling: c904 });905 expectStructure(c, {906 parentNode: div,907 previousSibling: b,908 nextSibling: d909 });910 expectStructure(d, {911 parentNode: div,912 previousSibling: c913 });914 unwrapAndExpectStructure(df, {});915 unwrapAndExpectStructure(e, {});916 unwrapAndExpectStructure(div, {917 firstChild: a,918 lastChild: d919 });920 unwrapAndExpectStructure(a, {921 parentNode: div,922 nextSibling: b923 });924 unwrapAndExpectStructure(b, {925 parentNode: div,926 previousSibling: a,927 nextSibling: c928 });929 unwrapAndExpectStructure(c, {930 parentNode: div,931 previousSibling: b,932 nextSibling: d933 });934 unwrapAndExpectStructure(d, {935 parentNode: div,936 previousSibling: c937 });938 });939 });940 });941 test('innerHTML', function() {942 var doc = wrap(document);943 var div = doc.createElement('div');944 div.innerHTML = '<a></a>';945 visual.removeAllChildNodes(div);946 var a = div.firstChild;947 div.innerHTML = '<b></b>';948 assert.equal(div.firstChild.tagName, 'B');949 });...

Full Screen

Full Screen

emailAutoComplete.js

Source:emailAutoComplete.js Github

copy

Full Screen

1/**2 * ÓÊÏä×Ô¶¯Ìáʾ²å¼þ3 * @constructor EmailAutoComplete4 * @ options {object} ¿ÉÅäÖÃÏî5 */6 function EmailAutoComplete(options) {7 8 this.config = {9 targetCls : '.inputElem', // Ä¿±êinputÔªËØ10 parentCls : '.reg-form-content', // µ±Ç°inputÔªËصĸ¸¼¶Àà11 hiddenCls : '.hiddenCls', // µ±Ç°inputÒþ²ØÓò 12 searchForm : '.jqtransformdone', //form±íµ¥13 hoverBg : 'hoverBg', // Êó±êÒÆÉÏÈ¥µÄ±³¾°14 inputValColor : 'black', // ÊäÈë¿òÊäÈëÌáʾÑÕÉ«15 mailArr : ["@qq.com","@gmail.com","@126.com","@163.com","@hotmail.com","@yahoo.com","@sohu.com","@sina.com"], //ÓÊÏäÊý×é16 isSelectHide : true, // µã»÷ÏÂÀ­¿ò ÊÇ·ñÒþ²Ø ĬÈÏΪtrue17 callback : function() {18 $('.inputElem').focus();19 $('.inputElem').blur();20 } // µã»÷ijһÏî»Øµ÷º¯Êý21 };22 this.cache = {23 onlyFlag : true, // Ö»äÖȾһ´Î24 currentIndex : -1,25 oldIndex : -126 };27 28 this.init(options);29 }30EmailAutoComplete.prototype = {31 32 constructor: EmailAutoComplete,33 init: function(options){34 this.config = $.extend(this.config,options || {});35 var self = this,36 _config = self.config,37 _cache = self.cache;38 39 $(_config.targetCls).each(function(index,item){40 41 $(item).keyup(function(e){42 var target = e.target,43 targetVal = $.trim($(this).val()),44 keycode = e.keyCode,45 elemHeight = $(this).outerHeight(),46 elemWidth = $(this).outerWidth(),47 parentNode = $(this).closest(_config.parentCls);48 49 $(parentNode).css({'position':'relative'});50 // Èç¹ûÊäÈë¿òֵΪ¿ÕµÄ»° ÄÇôÏÂÀ­¿òÒþ²Ø51 if(targetVal == '') {52 $(item).attr({'data-html':''});53 // ¸øÒþ²ØÓò¸³Öµ54 $(_config.hiddenCls,parentNode).val('');55 _cache.currentIndex = -1;56 _cache.oldIndex = -1;57 $(".auto-tip",parentNode) && !$(".auto-tip",parentNode).hasClass('hidden') && $(".auto-tip",parentNode).addClass('hidden');58 self._removeBg(parentNode);59 }else {60 61 $(item).attr({'data-html':targetVal});62 // ¸øÒþ²ØÓò¸³Öµ63 $(_config.hiddenCls,parentNode).val(targetVal);64 65 $(".auto-tip",parentNode) && $(".auto-tip",parentNode).hasClass('hidden') && $(".auto-tip",parentNode).removeClass('hidden');66 // äÖȾÏÂÀ­¿òÄÚÈÝ67 self._renderHTML({keycode:keycode,e:e,target:target,targetVal:targetVal,height:elemHeight,width:elemWidth,parentNode:parentNode});68 }69 70 71 });72 });73 74 // ×èÖ¹form±íµ¥Ä¬ÈÏenter¼üÌá½»75 $(_config.searchForm).each(function(index,item) {76 $(item).keydown(function(e){77 var keyCode = e.keyCode;78 if(keyCode == 13) {79 return false;80 }81 });82 });83 // µã»÷Îĵµdocumentʱºò ÏÂÀ­¿òÒþ²Øµô84 $(document).click(function(e){85 e.stopPropagation();86 var target = e.target,87 tagCls = _config.targetCls.replace(/^\./,'');88 if(!$(target).hasClass(tagCls)) {89 $('.auto-tip') && $('.auto-tip').each(function(index,item){90 !$(item).hasClass('hidden') && $(item).addClass('hidden');91 });92 }93 });94 },95 /*96 * äÖȾÏÂÀ­¿òÌáʾÄÚÈÝ97 * @param cfg{object}98 */99 _renderHTML: function(cfg) {100 var self = this,101 _config = self.config,102 _cache = self.cache,103 curVal;104 var curIndex = self._keyCode(cfg.keycode);105 106 $('.auto-tip',cfg.parentNode).hasClass('hidden') && $('.auto-tip',cfg.parentNode).removeClass('hidden');107 if(curIndex > -1){108 // ¼üÅÌÉÏϲÙ×÷109 self._keyUpAndDown(cfg.targetVal,cfg.e,cfg.parentNode);110 }else {111 if(/@/.test(cfg.targetVal)) {112 curVal = cfg.targetVal.replace(/@.*/,'');113 }else {114 curVal = cfg.targetVal;115 }116 if(_cache.onlyFlag) {117 $(cfg.parentNode).append('<input type="hidden" class="hiddenCls"/>');118 var wrap = '<ul class="auto-tip">';119 for(var i = 0; i < _config.mailArr.length; i++) {120 wrap += '<li class="p-index'+i+'">'+'<span class="output-num"></span><em class="em" data-html="'+_config.mailArr[i]+'">'+_config.mailArr[i]+'</em></li>';121 }122 wrap += '</ul>';123 _cache.onlyFlag = false;124 $(cfg.parentNode).append(wrap);125 $('.auto-tip',cfg.parentNode).css({'position':'absolute','top':cfg.height,'width':cfg.width - 2 + 'px','left':0,126 'border':'1px solid #ccc','z-index':10000});127 }128 129 // ¸øËùÓÐliÌí¼ÓÊôÐÔ data-html130 $('.auto-tip li',cfg.parentNode).each(function(index,item){131 $('.output-num',item).html(curVal);132 !$('.output-num',item).hasClass(_config.inputValColor) && 133 $('.output-num',item).addClass(_config.inputValColor);134 var emVal = $.trim($('.em',item).attr('data-html'));135 $(item).attr({'data-html':curVal + '' +emVal});136 });137 // ¾«È·Æ¥ÅäÄÚÈÝ138 self._accurateMate({target:cfg.target,parentNode:cfg.parentNode});139 // Êó±êÒƵ½Ä³Ò»ÏîliÉÏÃæʱºò140 self._itemHover(cfg.parentNode);141 142 // µã»÷¶ÔÓ¦µÄÏîʱ143 self._executeClick(cfg.parentNode);144 }145 146 },147 /**148 * ¾«È·Æ¥ÅäijÏîÄÚÈÝ149 */150 _accurateMate: function(cfg) {151 var self = this,152 _config = self.config,153 _cache = self.cache;154 155 var curVal = $.trim($(cfg.target,cfg.parentNode).attr('data-html')),156 newArrs = [];157 if(/@/.test(curVal)) {158 159 // »ñµÃ@ Ç°Ãæ ºóÃæµÄÖµ160 var prefix = curVal.replace(/@.*/, ""),161 suffix = curVal.replace(/.*@/, "");162 $.map(_config.mailArr,function(n){163 var reg = new RegExp(suffix);164 if(reg.test(n)) {165 newArrs.push(n);166 }167 });168 if(newArrs.length > 0) {169 $('.auto-tip',cfg.parentNode).html('');170 $(".auto-tip",cfg.parentNode) && $(".auto-tip",cfg.parentNode).hasClass('hidden') && 171 $(".auto-tip",cfg.parentNode).removeClass('hidden');172 var html = '';173 for(var j = 0, jlen = newArrs.length; j < jlen; j++) {174 html += '<li class="p-index'+j+'">'+'<span class="output-num"></span><em class="em" data-html="'+newArrs[j]+'">'+newArrs[j]+'</em></li>';175 }176 $('.auto-tip',cfg.parentNode).html(html);177 178 // ¸øËùÓÐliÌí¼ÓÊôÐÔ data-html179 $('.auto-tip li',cfg.parentNode).each(function(index,item){180 $('.output-num',item).html(prefix);181 !$('.output-num',item).hasClass(_config.inputValColor) && 182 $('.output-num',item).addClass(_config.inputValColor);183 var emVal = $.trim($('.em',item).attr('data-html'));184 185 $(item).attr('data-html','');186 $(item).attr({'data-html':prefix + '' +emVal});187 });188 // ¾«È·Æ¥Å䵽ijÏîʱºò Èõ±Ç°µÄË÷ÒýµÈÓÚ³õʼֵ189 _cache.currentIndex = -1;190 _cache.oldIndex = -1;191 192 $('.auto-tip .output-num',cfg.parentNode).html(prefix);193 // Êó±êÒƵ½Ä³Ò»ÏîliÉÏÃæʱºò194 self._itemHover(cfg.parentNode);195 // µã»÷¶ÔÓ¦µÄÏîʱ196 self._executeClick(cfg.parentNode);197 }else {198 $(".auto-tip",cfg.parentNode) && !$(".auto-tip",cfg.parentNode).hasClass('hidden') && 199 $(".auto-tip",cfg.parentNode).addClass('hidden');200 $('.auto-tip',cfg.parentNode).html('');201 }202 }203 },204 /*205 * Êó±êÒƵ½Ä³Ò»ÏîliÉÏʱ206 */207 _itemHover: function(parentNode) {208 var self = this,209 _config = self.config,210 _cache = self.cache;211 $('.auto-tip li',parentNode).hover(function(index,item) {212 !$(this).hasClass(_config.hoverBg) && $(this).addClass(_config.hoverBg);213 },function() {214 $(this).hasClass(_config.hoverBg) && $(this).removeClass(_config.hoverBg);215 });216 },217 /*218 * µ±ÊäÈë¿òֵΪ¿Õʱºò liÏɾµôclass hoverBg219 */220 _removeBg: function(parentNode){221 var self = this,222 _config = self.config;223 $(".auto-tip li",parentNode).each(function(index,item){224 $(item).hasClass(_config.hoverBg) && $(item).removeClass(_config.hoverBg);225 }); 226 },227 /**228 * ¼üÅÌÉÏϼü²Ù×÷229 */230 _keyUpAndDown: function(targetVal,e,parentNode) {231 var self = this,232 _cache = self.cache,233 _config = self.config;234 // Èç¹ûÇëÇó³É¹¦ºó ·µ»ØÁËÊý¾Ý(¸ù¾ÝÔªËصij¤¶ÈÀ´ÅжÏ) Ö´ÐÐÒÔϲÙ×÷235 if($('.auto-tip' + ' li',parentNode) && $('.auto-tip' + ' li').length > 0) {236 var plen = $('.auto-tip' + ' li',parentNode).length,237 keyCode = e.keyCode;238 _cache.oldIndex = _cache.currentIndex;239 240 // ÉÏÒƲÙ×÷241 if(keyCode == 38) {242 if(_cache.currentIndex == -1) {243 _cache.currentIndex = plen - 1;244 }else {245 _cache.currentIndex = _cache.currentIndex - 1;246 if(_cache.currentIndex < 0) {247 _cache.currentIndex = plen - 1;248 }249 }250 if(_cache.currentIndex !== -1) {251 252 !$('.auto-tip .p-index'+_cache.currentIndex,parentNode).hasClass(_config.hoverBg) &&253 $('.auto-tip .p-index'+_cache.currentIndex,parentNode).addClass(_config.hoverBg).siblings().removeClass(_config.hoverBg);254 var curAttr = $('.auto-tip' + ' .p-index'+_cache.currentIndex,parentNode).attr('data-html');255 $(_config.targetCls,parentNode).val(curAttr);256 257 // ¸øÒþ²ØÓò¸³Öµ258 $(_config.hiddenCls,parentNode).val(curAttr);259 }260 }else if(keyCode == 40) { //ÏÂÒƲÙ×÷261 if(_cache.currentIndex == plen - 1) {262 _cache.currentIndex = 0;263 }else {264 _cache.currentIndex++;265 if(_cache.currentIndex > plen - 1) {266 _cache.currentIndex = 0;267 }268 }269 if(_cache.currentIndex !== -1) {270 271 !$('.auto-tip .p-index'+_cache.currentIndex,parentNode).hasClass(_config.hoverBg) &&272 $('.auto-tip .p-index'+_cache.currentIndex,parentNode).addClass(_config.hoverBg).siblings().removeClass(_config.hoverBg);273 274 var curAttr = $('.auto-tip' + ' .p-index'+_cache.currentIndex,parentNode).attr('data-html');275 $(_config.targetCls,parentNode).val(curAttr);276 // ¸øÒþ²ØÓò¸³Öµ277 $(_config.hiddenCls,parentNode).val(curAttr);278 }279 280 }else if(keyCode == 13) { //»Ø³µ²Ù×÷281 var curVal = $('.auto-tip' + ' .p-index'+_cache.oldIndex,parentNode).attr('data-html');282 $(_config.targetCls,parentNode).val(curVal);283 284 // ¸øÒþ²ØÓò¸³Öµ285 $(_config.hiddenCls,parentNode).val(curVal);286 if(_config.isSelectHide) {287 !$(".auto-tip",parentNode).hasClass('hidden') && $(".auto-tip",parentNode).addClass('hidden');288 }289 _config.callback && $.isFunction(_config.callback) && _config.callback();290 _cache.currentIndex = -1;291 _cache.oldIndex = -1;292 293 }294 }295 },296 _keyCode: function(code) {297 var arrs = ['17','18','38','40','37','39','33','34','35','46','36','13','45','44','145','19','20','9'];298 for(var i = 0, ilen = arrs.length; i < ilen; i++) {299 if(code == arrs[i]) {300 return i;301 }302 }303 return -1;304 },305 /**306 * µ±Êý¾ÝÏàͬµÄʱ µã»÷¶ÔÓ¦µÄÏîʱ ·µ»ØÊý¾Ý307 */308 _executeClick: function(parentNode) {309 310 var _self = this,311 _config = _self.config;312 $('.auto-tip' + ' li',parentNode).unbind('click');313 $('.auto-tip' + ' li',parentNode).bind('click',function(e){314 var dataAttr = $(this).attr('data-html');315 $(_config.targetCls,parentNode).val(dataAttr);316 if(_config.isSelectHide) {317 !$(".auto-tip",parentNode).hasClass('hidden') && $(".auto-tip",parentNode).addClass('hidden');318 }319 // ¸øÒþ²ØÓò¸³Öµ320 $(_config.hiddenCls,parentNode).val(dataAttr);321 _config.callback && $.isFunction(_config.callback) && _config.callback();322 323 });324 }325};326// ³õʼ»¯327$(function() {328 new EmailAutoComplete({});...

Full Screen

Full Screen

admincp.js

Source:admincp.js Github

copy

Full Screen

1/*2 [Discuz!] (C)2001-2009 Comsenz Inc.3 This is NOT a freeware, use is subject to license terms4 $Id: admincp.js 22381 2011-05-05 03:05:16Z monkey $5*/6function redirect(url) {7 window.location.replace(url);8}9function scrollTopBody() {10 return Math.max(document.documentElement.scrollTop, document.body.scrollTop);11}12function checkAll(type, form, value, checkall, changestyle) {13 var checkall = checkall ? checkall : 'chkall';14 for(var i = 0; i < form.elements.length; i++) {15 var e = form.elements[i];16 if(type == 'option' && e.type == 'radio' && e.value == value && e.disabled != true) {17 e.checked = true;18 } else if(type == 'value' && e.type == 'checkbox' && e.getAttribute('chkvalue') == value) {19 e.checked = form.elements[checkall].checked;20 if(changestyle) {21 multiupdate(e);22 }23 } else if(type == 'prefix' && e.name && e.name != checkall && (!value || (value && e.name.match(value)))) {24 e.checked = form.elements[checkall].checked;25 if(changestyle) {26 if(e.parentNode && e.parentNode.tagName.toLowerCase() == 'li') {27 e.parentNode.className = e.checked ? 'checked' : '';28 }29 if(e.parentNode.parentNode && e.parentNode.parentNode.tagName.toLowerCase() == 'div') {30 e.parentNode.parentNode.className = e.checked ? 'item checked' : 'item';31 }32 }33 }34 }35}36function altStyle(obj, disabled) {37 function altStyleClear(obj) {38 var input, lis, i;39 lis = obj.parentNode.getElementsByTagName('li');40 for(i=0; i < lis.length; i++){41 lis[i].className = '';42 }43 }44 var disabled = !disabled ? 0 : disabled;45 if(disabled) {46 return;47 }48 var input, lis, i, cc, o;49 cc = 0;50 lis = obj.getElementsByTagName('li');51 for(i=0; i < lis.length; i++){52 lis[i].onclick = function(e) {53 o = BROWSER.ie ? event.srcElement.tagName : e.target.tagName;54 altKey = BROWSER.ie ? window.event.altKey : e.altKey;55 if(cc) {56 return;57 }58 cc = 1;59 input = this.getElementsByTagName('input')[0];60 if(input.getAttribute('type') == 'checkbox' || input.getAttribute('type') == 'radio') {61 if(input.getAttribute('type') == 'radio') {62 altStyleClear(this);63 }64 if(BROWSER.ie || o != 'INPUT' && input.onclick) {65 input.click();66 }67 if(this.className != 'checked') {68 this.className = 'checked';69 input.checked = true;70 } else {71 this.className = '';72 input.checked = false;73 }74 if(altKey && input.name.match(/^multinew\[\d+\]/)) {75 miid = input.id.split('|');76 mi = 0;77 while($(miid[0] + '|' + mi)) {78 $(miid[0] + '|' + mi).checked = input.checked;79 if(input.getAttribute('type') == 'radio') {80 altStyleClear($(miid[0] + '|' + mi).parentNode);81 }82 $(miid[0] + '|' + mi).parentNode.className = input.checked ? 'checked' : '';83 mi++;84 }85 }86 }87 };88 lis[i].onmouseup = function(e) {89 cc = 0;90 }91 }92}93var addrowdirect = 0;94function addrow(obj, type) {95 var table = obj.parentNode.parentNode.parentNode.parentNode.parentNode;96 if(!addrowdirect) {97 var row = table.insertRow(obj.parentNode.parentNode.parentNode.rowIndex);98 } else {99 var row = table.insertRow(obj.parentNode.parentNode.parentNode.rowIndex + 1);100 }101 var typedata = rowtypedata[type];102 for(var i = 0; i <= typedata.length - 1; i++) {103 var cell = row.insertCell(i);104 cell.colSpan = typedata[i][0];105 var tmp = typedata[i][1];106 if(typedata[i][2]) {107 cell.className = typedata[i][2];108 }109 tmp = tmp.replace(/\{(\d+)\}/g, function($1, $2) {return addrow.arguments[parseInt($2) + 1];});110 cell.innerHTML = tmp;111 }112 addrowdirect = 0;113}114function deleterow(obj) {115 var table = obj.parentNode.parentNode.parentNode.parentNode.parentNode;116 var tr = obj.parentNode.parentNode.parentNode;117 table.deleteRow(tr.rowIndex);118}119function dropmenu(obj){120 showMenu({'ctrlid':obj.id, 'menuid':obj.id + 'child', 'evt':'mouseover'});121 $(obj.id + 'child').style.top = (parseInt($(obj.id + 'child').style.top) - Math.max(document.body.scrollTop, document.documentElement.scrollTop)) + 'px';122 if(BROWSER.ie > 6 || !BROWSER.ie) {123 $(obj.id + 'child').style.left = (parseInt($(obj.id + 'child').style.left) - Math.max(document.body.scrollLeft, document.documentElement.scrollLeft)) + 'px';124 }125}126var heightag = BROWSER.chrome ? 4 : 0;127function textareasize(obj, op) {128 if(!op) {129 if(obj.scrollHeight > 70) {130 obj.style.height = (obj.scrollHeight < 300 ? obj.scrollHeight - heightag: 300) + 'px';131 if(obj.style.position == 'absolute') {132 obj.parentNode.style.height = (parseInt(obj.style.height) + 20) + 'px';133 }134 }135 } else {136 if(obj.style.position == 'absolute') {137 obj.style.position = '';138 obj.style.width = '';139 obj.parentNode.style.height = '';140 } else {141 obj.parentNode.style.height = obj.parentNode.offsetHeight + 'px';142 obj.style.width = BROWSER.ie > 6 || !BROWSER.ie ? '90%' : '600px';143 obj.style.position = 'absolute';144 }145 }146}147function showanchor(obj) {148 var navs = $('submenu').getElementsByTagName('li');149 for(var i = 0; i < navs.length; i++) {150 if(navs[i].id.substr(0, 4) == 'nav_' && navs[i].id != obj.id) {151 if($(navs[i].id.substr(4))) {152 navs[i].className = '';153 $(navs[i].id.substr(4)).style.display = 'none';154 if($(navs[i].id.substr(4) + '_tips')) $(navs[i].id.substr(4) + '_tips').style.display = 'none';155 }156 }157 }158 obj.className = 'current';159 currentAnchor = obj.id.substr(4);160 $(currentAnchor).style.display = '';161 if($(currentAnchor + '_tips')) $(currentAnchor + '_tips').style.display = '';162 if($(currentAnchor + 'form')) {163 $(currentAnchor + 'form').anchor.value = currentAnchor;164 } else if($('cpform')) {165 $('cpform').anchor.value = currentAnchor;166 }167}168function updatecolorpreview(obj) {169 $(obj).style.background = $(obj + '_v').value;170}171function entersubmit(e, name) {172 var e = e ? e : event;173 if(e.keyCode != 13) {174 return;175 }176 var tag = BROWSER.ie ? e.srcElement.tagName : e.target.tagName;177 if(tag != 'TEXTAREA') {178 doane(e);179 if($('submit_' + name).offsetWidth) {180 $('formscrolltop').value = document.documentElement.scrollTop;181 $('submit_' + name).click();182 }183 }184}185function parsetag(tag) {186 var parse = function (tds) {187 for(var i = 0; i < tds.length; i++) {188 if(tds[i].getAttribute('s') == '1') {189 var str = tds[i].innerHTML.replace(/(^|>)([^<]+)(?=<|$)/ig, function($1, $2, $3) {190 if(tag && $3.indexOf(tag) != -1) {191 re = new RegExp(tag, "g");192 $3 = $3.replace(re, '<h_>');193 }194 return $2 + $3;195 });196 tds[i].innerHTML = str.replace(/<h_>/ig, function($1, $2) {197 return '<font class="highlight">' + tag + '</font>';198 });199 }200 }201 }202 parse(document.body.getElementsByTagName('td'));203 parse(document.body.getElementsByTagName('span'));204}205function sdisplay(id, obj) {206 obj.innerHTML = $(id).style.display == 'none' ? '<img src="static/image/admincp/desc.gif" style="vertical-align:middle" />' : '<img src="static/image/admincp/add.gif" style="vertical-align:middle" />'207 display(id);208}209if(ISFRAME) {210 try {211 _attachEvent(document.documentElement, 'keydown', parent.resetEscAndF5);212 } catch(e) {}213}214var multiids = new Array();215function multiupdate(obj) {216 v = obj.value;217 if(obj.checked) {218 multiids[v] = v;219 } else {220 multiids[v] = null;221 }222}223function getmultiids() {224 var ids = '', comma = '';225 for(i in multiids) {226 if(multiids[i] != null) {227 ids += comma + multiids[i];228 comma = ',';229 }230 }231 return ids;232}233function toggle_group(oid, obj, conf) {234 obj = obj ? obj : $('a_'+oid);235 if(!conf) {236 var conf = {'show':'[-]','hide':'[+]'};237 }238 var obody = $(oid);239 if(obody.style.display == 'none') {240 obody.style.display = '';241 obj.innerHTML = conf.show;242 } else {243 obody.style.display = 'none';244 obj.innerHTML = conf.hide;245 }246}247function show_all() {248 var tbodys = $("cpform").getElementsByTagName('tbody');249 for(var i = 0; i < tbodys.length; i++) {250 var re = /^group_(\d+)$/;251 var matches = re.exec(tbodys[i].id);252 if(matches != null) {253 tbodys[i].style.display = '';254 $('a_group_' + matches[1]).innerHTML = '[-]';255 }256 }257}258function hide_all() {259 var tbodys = $("cpform").getElementsByTagName('tbody');260 for(var i = 0; i < tbodys.length; i++) {261 var re = /^group_(\d+)$/;262 var matches = re.exec(tbodys[i].id);263 if(matches != null) {264 tbodys[i].style.display = 'none';265 $('a_group_' + matches[1]).innerHTML = '[+]';266 }267 }268}269function srchforum() {270 var fname = $('srchforumipt').value;271 if(!fname) return false;272 var inputs = $("cpform").getElementsByTagName('input');273 for(var i = 0; i < inputs.length; i++) {274 if(inputs[i].name.match(/^name\[\d+\]$/)) {275 if(inputs[i].value.substr(0, fname.length).toLowerCase() == fname.toLowerCase()) {276 inputs[i].parentNode.parentNode.parentNode.parentNode.style.display = '';277 inputs[i].parentNode.parentNode.parentNode.style.background = '#eee';278 window.scrollTo(0, fetchOffset(inputs[i]).top - 100);279 return false;280 }281 }282 }283 return false;284}285function setfaq(obj, id) {286 if(!$(id)) {287 return;288 }289 $(id).style.display = '';290 if(!obj.onmouseout) {291 obj.onmouseout = function () {292 $(id).style.display = 'none';293 }294 }...

Full Screen

Full Screen

getValuesTest.js

Source:getValuesTest.js Github

copy

Full Screen

1const path = require("path");2const fs = require("fs");3const jsdom = require("jsdom");4const { JSDOM } = jsdom;5let {apiNameTransform} = require('./utils');6// 读取边界条件分析函数7let {getBoundaryConditions} = require('./boundaryAnalysis');8// 读取自定义异常类型9let {ApiTransformError} = require('./error');10// 读取核心的映射函数11let {textToCode} = require('./textToCode');12// 加载 document13console.log('正在加载document,请稍等...');14console.time('getDocument');15let htmlString = fs.readFileSync(path.join(__dirname, '../../resources/ES10-standard.html')).toString();16const dom = new JSDOM(htmlString);17let document = dom.window.document;18console.timeEnd('getDocument');19// 核心函数:输入 apiName,返回一个列表,其中元素是各个参数的对象20function getApiValues(apiName) {21 try {22 var apiId = apiNameTransform(apiName);23 let codeString = '';24 let parameterNameList = [];25 // 获取对应clause节点26 var clauseNode = document.getElementById(apiId);27 if (clauseNode === null) {28 throw new ApiTransformError('[FATAL]API名称到ID号的映射失败,请更新映射规则:' + apiName);29 }30 // 解析出其中的参数列表 parameterNameList,包括可选参数和必须参数31 var titleNode = clauseNode.firstElementChild;32 console.assert(titleNode.nodeName === 'H1', '[ERROR]解析参数列表错误,该条目中第一个节点不是H1.');33 titleNode.childNodes.forEach(function (node) {34 if (node.nodeName === 'VAR') {35 parameterNameList.push(node.textContent);36 }37 });38 // 获取到该clause中第一个emu-alg下的第一个ol节点39 // TODO:增强鲁棒性:处理掉Math.cos这类不用 emu-alg 包裹的节点40 // TODO:一个api下可能包含多个emu-alg节点,如Array.prototype.sort41 var olNode = clauseNode.querySelector('emu-alg').querySelector('ol');42 // 获取其中的所有li节点,包括后代li节点(这一点一定要注意)43 var liNodes = olNode.querySelectorAll('li');44 // 核心逻辑,递归地逐句翻译;45 // 先将第一个li节点直接加入到结果中46 codeString += textToCode(liNodes[0]);47 // 内嵌函数检测48 let brace = 0;49 // 核心算法:遍历li节点,逐条转化为代码。以最大为4的滑动窗口来判断节点间的父子关系,以添加适当的 '{' 和 '}' 符号50 for (let j = 1; j < liNodes.length; j++) {51 let previousNode = liNodes[j - 1];52 let nowNode = liNodes[j];53 let behindNode = nowNode;54 if ((j + 1) < liNodes.length) {55 behindNode = liNodes[j + 1];56 }57 let statementString = textToCode(nowNode);58 if (j === (liNodes.length -1) ){59 var right_brace = "";60 if (brace !== 0){61 for (var ii = 0; ii<brace; ii++){62 right_brace += "}\n";63 }64 }65 codeString += statementString;66 codeString += right_brace;67 continue;68 }69 // 情况1:前后两个节点是兄弟节点,那么不添加括号70 if (nowNode.parentNode.isSameNode(previousNode.parentNode)) {71 // console.log('是兄弟');72 // codeString += statementString;73 }74 // 情况2:后一个发生了缩进75 else if (nowNode.parentNode.parentNode.isSameNode(previousNode)) {76 // console.log('发生缩进');77 codeString += '{\n';78 brace += 1;79 // codeString += statementString;80 }81 // 情况3:缩进回收82 if (nowNode.parentNode.parentNode.parentNode.isSameNode(behindNode.parentNode)) {83 codeString += statementString;84 codeString += '}\n';85 brace -= 1;86 // codeString += statementString;87 } else if (nowNode.parentNode.parentNode.parentNode.parentNode.parentNode.isSameNode(behindNode.parentNode)) {88 // console.log('缩进回收');89 codeString += statementString;90 codeString += '}\n}\n';91 brace -= 2;92 // codeString += statementString;93 } else if (nowNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.isSameNode(behindNode.parentNode)) {94 codeString += statementString;95 codeString += '}\n}\n}\n';96 brace -= 3;97 // codeString += statementString;98 } else if (nowNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.isSameNode(behindNode.parentNode)) {99 codeString += statementString;100 codeString += '}\n}\n}\n}\n';101 brace -= 4;102 // codeString += statementString;103 } else {104 codeString += statementString;105 }106 }107 // TODO:对 codeString 进行第二遍处理,主要是解决内嵌函数的问题108 // 包裹成函数,填入参数109 let parameterString = parameterNameList.join(', ');110 let functionName = 'TempFunctionName';111 let functionString =112 `var ${functionName} = function (that, ${parameterString}) {\n\n${codeString}\n};`; // 注意这里的that113 console.log(functionString);114 // 调用 esprima 分析边界条件115 return getBoundaryConditions(functionString, apiName);116 } catch (e) {117 console.error(`[ERROR] ${apiName} 解析成代码时存在异常:` + e.name + e.message);118 return [];119 }120}121let result = getApiValues('sec-object.defineproperties');...

Full Screen

Full Screen

nodeToCode.js

Source:nodeToCode.js Github

copy

Full Screen

1// 读取核心的映射函数2let {textToCode} = require('./textToCode');3function nodeToCode(emuNodes, ulNodes){4 let codeString = '';5 for (let i = 0; i < emuNodes.length; i++) {6 let olNode = emuNodes[i].querySelector('ol');7 // 获取其中的所有li节点,包括后代li节点(这一点一定要注意)8 let liNodes = olNode.querySelectorAll('li');9 // 核心逻辑,递归地逐句翻译;10 // 先将第一个li节点直接加入到结果中11 codeString += textToCode(liNodes[0]);12 let brace = 0;13 // 核心算法:遍历li节点,逐条转化为代码。以最大为4的滑动窗口来判断节点间的父子关系,以添加适当的 '{' 和 '}' 符号14 for (let j = 1; j < liNodes.length; j++) {15 let previousNode = liNodes[j - 1];16 let nowNode = liNodes[j];17 let behindNode = nowNode;18 if ((j + 1) < liNodes.length) {19 behindNode = liNodes[j + 1];20 }21 let statementString = textToCode(nowNode);22 if (j === (liNodes.length - 1)) {23 var right_brace = "";24 if (brace !== 0) {25 for (var ii = 0; ii < brace; ii++) {26 right_brace += "}\n";27 }28 }29 codeString += statementString;30 codeString += right_brace;31 continue;32 }33 // 情况1:前后两个节点是兄弟节点,那么不添加括号34 if (nowNode.parentNode.isSameNode(previousNode.parentNode)) {35 // console.log('是兄弟');36 // codeString += statementString;37 }38 // 情况2:后一个发生了缩进39 else if (nowNode.parentNode.parentNode.isSameNode(previousNode)) {40 // console.log('发生缩进');41 codeString += '{\n';42 brace += 1;43 // codeString += statementString;44 }45 // 情况3:缩进回收46 if (nowNode.parentNode.parentNode.parentNode.isSameNode(behindNode.parentNode)) {47 codeString += statementString;48 codeString += '}\n';49 brace -= 1;50 // codeString += statementString;51 } else if (nowNode.parentNode.parentNode.parentNode.parentNode.parentNode.isSameNode(behindNode.parentNode)) {52 // console.log('缩进回收');53 codeString += statementString;54 codeString += '}\n}\n';55 brace -= 2;56 // codeString += statementString;57 } else if (nowNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.isSameNode(behindNode.parentNode)) {58 codeString += statementString;59 codeString += '}\n}\n}\n';60 brace -= 3;61 // codeString += statementString;62 } else if (nowNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.isSameNode(behindNode.parentNode)) {63 codeString += statementString;64 codeString += '}\n}\n}\n}\n';65 brace -= 4;66 // codeString += statementString;67 } else {68 codeString += statementString;69 }70 }71 }72 // 将ul节点的内容转换为代码73 for(let i = 0; i < ulNodes.length; i++){74 let liNodes = ulNodes[i].querySelectorAll('li');75 for (let j = 0; j < liNodes.length; j++){76 let statementString = textToCode(liNodes[j]);77 codeString += statementString;78 }79 }80 return codeString;81}...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

1var checkBox = document.getElementsByClassName("fa-check-square");2var returnArrow = document.getElementsByClassName("fa-arrow-left");3var trash = document.getElementsByClassName("fa-trash");4Array.from(checkBox).forEach(function(element) {5 element.addEventListener('click', function(){6 const title = this.parentNode.parentNode.childNodes[3].innerText7 const author = this.parentNode.parentNode.childNodes[5].innerText8 // const checkOut = this.parentNode.parentNode.childNodes[7].innerText9 const titleSpan = this.parentNode.parentNode.childNodes[3]10 const authorSpan = this.parentNode.parentNode.childNodes[5]11 console.log(element)12 console.log(title)13 // titleSpan.classList.add('strikethrough')14 // authorSpan.classList.add('strikethrough')15 fetch('checkOut', {16 method: 'put',17 headers: {18 'Content-Type': 'application/json'19 },20 body: JSON.stringify({21 'title': title,22 'author': author23 })24 }).then(function (response) {25 window.location.reload()26 })27 });28});29Array.from(returnArrow).forEach(function(element) {30 element.addEventListener('click', function(){31 const title = this.parentNode.parentNode.childNodes[3].innerText32 const author = this.parentNode.parentNode.childNodes[5].innerText33 34 const titleSpan = this.parentNode.parentNode.childNodes[3]35 const authorSpan = this.parentNode.parentNode.childNodes[5]36 console.log(element)37 console.log(title)38 // titleSpan.classList.add('strikethrough')39 // authorSpan.classList.add('strikethrough')40 fetch('checkIn', {41 method: 'put',42 headers: {43 'Content-Type': 'application/json'44 },45 body: JSON.stringify({46 'title': title,47 'author': author48 49 })50 }).then(function (response) {51 window.location.reload()52 })53 });54});55Array.from(trash).forEach(function(element) {56 element.addEventListener('click', function(){57 const title = this.parentNode.parentNode.childNodes[3].innerText58 const author = this.parentNode.parentNode.childNodes[5].innerText59 fetch('messages', {60 method: 'delete',61 headers: {62 'Content-Type': 'application/json'63 },64 body: JSON.stringify({65 'title': title,66 'author': author67 })68 }).then(function (response) {69 window.location.reload()70 })71 });...

Full Screen

Full Screen

tree.js

Source:tree.js Github

copy

Full Screen

1AUI().ready('event', 'node', 'anim',function(A) {23 A.all('.lms-tree ul li.option-more ul').each(function(ul){4 ul.hide();5 });6 7 A.all('.lms-tree ul li span.desplegar').each(function(span){8 9 var parentNode=span.get('parentNode');10 if(parentNode.one('div.lms-desplegable')) {11 var wrapper=parentNode.one('div.lms-desplegable');12 var height=wrapper.height();13 var open = new A.Anim({node: wrapper, to: {height: height},14 easing: A.Easing.easeOut});15 var close = new A.Anim({node: wrapper, to: {height: 0},16 easing: A.Easing.easeIn});17 18 span.on('click',function(){19 20 if(parentNode.hasClass('option-more')) {21 parentNode.removeClass("option-more");22 parentNode.addClass("option-less");23 open.run();24 25 }26 else {27 parentNode.removeClass("option-less");28 parentNode.addClass("option-more");29 close.run();30 }31 32 });33 }34 });3536 A.all('span.ico-desplegable, .preg_content div > span.label-col').each(function(span){37 var parentNode=span.get('parentNode');38 var wrapper = A.Node.create('<div style="overflow: hidden;" ></div>');39 wrapper.append(parentNode.one('div.collapsable').replace(wrapper));40 parentNode.one('div.collapsable').setStyle('display','block');41 var height=wrapper.height();42 43 if (height == 0) {44 parentNode.get('parentNode').setStyles({'position':'absolute','visibility':'hidden', 'display':'block'});45 height=wrapper.height();46 parentNode.get('parentNode').setStyles({'position':'relative','visibility':'visible', 'display':'none'});47 }48 wrapper.height(0);49 var open = new A.Anim({node: wrapper, to: {height: height},50 easing: A.Easing.easeOut});51 var close = new A.Anim({node: wrapper, to: {height: 0},52 easing: A.Easing.easeIn});53 span.on('click',function(){54 55 if(parentNode.hasClass('option-less')) {56 parentNode.removeClass("option-less");57 parentNode.addClass("option-more");58 close.run();59 }60 else {61 parentNode.removeClass("option-more");62 parentNode.addClass("option-less");63 open.run();64 }6566 });67 }); ...

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 const elementHandle = await page.$('input[name="q"]');7 const parent = await elementHandle.parentNode();8 await parent.click();9 await browser.close();10})();11const {chromium} = require('playwright');12(async () => {13 const browser = await chromium.launch({headless: false});14 const context = await browser.newContext();15 const page = await context.newPage();16 const elementHandle = await page.$('input[name="q"]');17 const parent = await elementHandle.parentElementHandle();18 await parent.click();19 await browser.close();20})();21const {chromium} = require('playwright');22(async () => {23 const browser = await chromium.launch({headless: false});24 const context = await browser.newContext();25 const page = await context.newPage();26 const elementHandle = await page.$('input[name="q"]');27 const childCount = await elementHandle.childElementCount();28 console.log(childCount);29 await browser.close();30})();31const {chromium} = require('playwright');32(async () => {33 const browser = await chromium.launch({headless: false});34 const context = await browser.newContext();35 const page = await context.newPage();36 const elementHandle = await page.$('input[name="q"]');37 const children = await elementHandle.childElements();38 console.log(children);39 await browser.close();40})();41const {chromium} = require('playwright');42(async () => {43 const browser = await chromium.launch({headless: false});44 const context = await browser.newContext();45 const page = await context.newPage();

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 const searchElement = await page.$('input[name="q"]');7 const searchInputElement = await searchElement.asElement();8 const searchInputParentElement = await searchInputElement.parentNode();9 const searchInputParentElementTagName = await searchInputParentElement.tagName();10 console.log('searchInputParentElementTagName: ', searchInputParentElementTagName);11 await browser.close();12})();13const { chromium } = require('playwright');14(async () => {15 const browser = await chromium.launch({headless: false});16 const context = await browser.newContext();17 const page = await context.newPage();18 const searchElement = await page.$('input[name="q"]');19 const searchInputElement = await searchElement.asElement();20 const searchInputParentElement = await searchInputElement.parentNode();21 const searchInputParentElementTagName = await searchInputParentElement.tagName();22 console.log('searchInputParentElementTagName: ', searchInputParentElementTagName);23 const searchButtonElement = await searchInputParentElement.$('input[type="submit"]:nth-child(2)');24 const searchButtonElementTagName = await searchButtonElement.tagName();25 console.log('searchButtonElementTagName: ', searchButtonElementTagName);26 await browser.close();27})();28As you can see, the parentNode()

Full Screen

Using AI Code Generation

copy

Full Screen

1const path = require('path');2const playwright = require('playwright');3(async () => {4 const browser = await playwright.webkit.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const frame = page.mainFrame();8 const elementHandle = await frame.$('a');9 const parent = await elementHandle.parentNode();10 const parentText = await parent.innerText();11 console.log(parentText);12 await browser.close();13})();14### `page.frames()`15const path = require('path');16const playwright = require('playwright');17(async () => {18 const browser = await playwright.webkit.launch();19 const context = await browser.newContext();20 const page = await context.newPage();21 const frames = page.frames();22 for (let frame of frames) {23 console.log(frame.url());24 }25 await browser.close();26})();27### `page.route(url, handler)`28const path = require('path');29const playwright = require('playwright');30(async () => {31 const browser = await playwright.webkit.launch();32 const context = await browser.newContext();33 const page = await context.newPage();34 route.fulfill({35 });36 });37 await browser.close();38})();39### `page.waitForRequest(url, options)`

Full Screen

Using AI Code Generation

copy

Full Screen

1const parent = await page.$('.parent');2const child = await page.$('.child');3const parentElement = await parent.asElement();4const childElement = await child.asElement();5const parentElementHandle = await parentElement._context._adoptBackendNodeId(parentElement._remoteObject.objectId);6const childElementHandle = await childElement._context._adoptBackendNodeId(childElement._remoteObject.objectId);7const parentElementHandle = await parentElement._context._adoptBackendNodeId(parentElement._remoteObject.objectId);8const childElementHandle = await childElement._context._adoptBackendNodeId(childElement._remoteObject.objectId);9const parentElementHandle = await parentElement._context._adoptBackendNodeId(parentElement._remoteObject.objectId);10const childElementHandle = await childElement._context._adoptBackendNodeId(childElement._remoteObject.objectId);11const parentElementHandle = await parentElement._context._adoptBackendNodeId(parentElement._remoteObject.objectId);12const childElementHandle = await childElement._context._adoptBackendNodeId(childElement._remoteObject.objectId);13const parentElementHandle = await parentElement._context._adoptBackendNodeId(parentElement._remoteObject.objectId);14const childElementHandle = await childElement._context._adoptBackendNodeId(childElement._remoteObject.objectId);15const parentElementHandle = await parentElement._context._adoptBackendNodeId(parentElement._remoteObject.objectId);16const childElementHandle = await childElement._context._adoptBackendNodeId(childElement._remoteObject.objectId);17const parentElementHandle = await parentElement._context._adoptBackendNodeId(parentElement._remoteObject.objectId);18const childElementHandle = await childElement._context._adoptBackendNodeId(childElement._remoteObject.objectId);19const parentElementHandle = await parentElement._context._adoptBackendNodeId(parentElement._remoteObject.objectId);20const childElementHandle = await childElement._context._adoptBackendNodeId(childElement._remoteObject.objectId);21const parentElementHandle = await parentElement._context._adoptBackendNodeId(parentElement._remoteObject.objectId);22const childElementHandle = await childElement._context._adoptBackendNodeId(childElement._remoteObject.objectId);23const parentElementHandle = await parentElement._context._adoptBackendNodeId(parentElement._remoteObject.objectId);24const childElementHandle = await childElement._context._adoptBackendNodeId(childElement._remoteObject.objectId);25const parentElementHandle = await parentElement._context._adoptBackendNodeId(parentElement._remoteObject.objectId

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Page } = require('playwright');2const { getInternalMethods } = require('playwright/lib/server/dom');3const { getInternalMethods } = require('playwright/lib/server/dom');4const { getInternalMethods } = require('playwright/lib/server/dom');5const { getInternalMethods } = require('playwright/lib/server/dom');6const { getInternalMethods } = require('playwright/lib/server/dom');7const { getInternalMethods } = require('playwright/lib/server/dom');8const { getInternalMethods } = require('playwright/lib/server/dom');9const { getInternalMethods } = require('playwright/lib/server/dom');10const { getInternalMethods } = require('playwright/lib/server/dom');11const { getInternalMethods } = require('playwright/lib/server/dom');12const { getInternalMethods } = require('playwright/lib/server/dom');13const { getInternalMethods } = require('playwright/lib/server/dom');14const { getInternalMethods } = require('playwright/lib/server/dom');15const { getInternalMethods } = require('playwright/lib/server/dom');16const { getInternalMethods } = require('playwright/lib/server/dom');17const { getInternalMethods } = require('playwright/lib/server/dom');18const { getInternalMethods } = require('playwright/lib/server/dom');19const { getInternalMethods } = require('playwright/lib/server/dom');20const { getInternalMethods } = require('playwright/lib/server/dom');21const { getInternalMethods } = require('playwright/lib/server/dom');22const { getInternalMethods } = require('playwright/lib/server/dom');23const { getInternalMethods } = require('playwright/lib/server/dom');24const { getInternalMethods } = require('playwright/lib/server/dom');25const { getInternalMethods } = require('playwright/lib/server/dom');26const { getInternalMethods } = require('playwright/lib/server/dom');27const { getInternalMethods } = require('playwright/lib/server/dom');28const { getInternalMethods } = require('playwright/lib/server/dom');29const { getInternalMethods } = require('playwright/lib/server/dom');30const { getInternalMethods } = require('playwright/lib/server/dom');31const { getInternalMethods } = require('playwright/lib/server/dom');32const { getInternalMethods } = require('playwright/lib/server/dom');33const { getInternalMethods } = require('playwright/lib/server/dom');34const { getInternalMethods } =

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getPlaywright } = require('playwright');2const playwright = getPlaywright('chromium');3const { CDPSession } = playwright;4const { getCDPSession } = require('playwright-core/lib/server/cdpsession');5const { ElementHandle } = require('playwright-core/lib/server/dom');6const { Page } = require('playwright-core/lib/server/page');7const { helper } = require('playwright-core/lib/helper');8const { assert } = require('playwright-core/lib/helper');9(async () => {10 const browser = await playwright.chromium.launch();11 const context = await browser.newContext();12 const page = await context.newPage();13 const element = await page.$('input[name="q"]');14 const cdpSession = await getCDPSession(page);15 const nodeInfo = await cdpSession.send('DOM.describeNode', { objectId: element._remoteObject.objectId });16 const parentNode = await cdpSession.send('DOM.describeNode', { objectId: nodeInfo.node.parentNodeId });17 console.log(parentNode);18 await browser.close();19})();20{21 node: {22 importedDocument: [Object],23 },24}25- [Playwright](

Full Screen

Using AI Code Generation

copy

Full Screen

1await page.evaluate(() => {2 const element = document.getElementById('my-id');3 const parent = element.parentNode;4 const parentId = parent.id;5 console.log(parentId);6});7await page.evaluate(() => {8 const element = document.getElementById('my-id');9 const parent = element.parentElement;10 const parentId = parent.id;11 console.log(parentId);12});13await page.evaluate(() => {14 const element = document.getElementById('my-id');15 const parent = element.parentElement;16 const parentId = parent.id;17 console.log(parentId);18});19await page.evaluate(() => {20 const element = document.getElementById('my-id');21 const parent = element.parentElement;22 const parentId = parent.id;23 console.log(parentId);24});25await page.evaluate(() => {26 const element = document.getElementById('my-id');27 const parent = element.parentElement;28 const parentId = parent.id;29 console.log(parentId);30});31await page.evaluate(() => {32 const element = document.getElementById('my-id');33 const parent = element.parentElement;34 const parentId = parent.id;35 console.log(parentId);36});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { InternalAPI } = require('playwright');2const { parseSelector } = require('playwright/lib/client/selectorParser');3const { parseSelector } = require('playwright/lib/client/selectorParser');4const { parseSelector } = require('playwright/lib/client/selectorParser');5async function getParentNode(page, selector) {6 const parsedSelector = parseSelector(selector);7 const node = await InternalAPI.queryOne(page, parsedSelector, { force: true });

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