How to use escapeHtml method in Playwright Internal

Best JavaScript code snippet using playwright-internal

commands.js

Source:commands.js Github

copy

Full Screen

1/* Server Commands parsing */2window.ServerCommandsHandlers = {3 "USER": function (room, cmd, spl, context) {4 context.client.changeLogin(spl.slice(3).join("|"), spl[1] === "0", spl[2]);5 },6 "ROOMS": function (room, cmd, spl, context) {7 context.client.home_room.setRoomsList(JSON.parse(spl.slice(1)));8 },9 "CHAT": function (room, cmd, spl, context) {10 room.addChat(spl[3], spl[2], spl.slice(4), (parseInt(spl[1]) * 1000) + context.client.timeoffset);11 },12 "ERR-CANNOT-CHAT": function (room, cmd, spl, context) {13 room.addLine('<span class="error-msg">You cannot chat in this room right now.</span>');14 },15 "ERR-CMD": function (room, cmd, spl, context) {16 if (spl[1] === "help") {17 room.add('<div class="chat-msg"><div class="chat-msg-box">' + $("#data-div-help-command").html() + '</div></div>');18 } else if (spl[1] === "adminhelp") {19 room.add('<div class="chat-msg"><div class="chat-msg-box">' + $("#data-div-adminhelp-command").html() + '</div></div>');20 } else {21 room.addLine('<span class="error-msg">Command not found: ' + Tools.escapeHTML(spl[1]) + '</span>');22 }23 },24 "ERR": function (room, cmd, spl, context) {25 switch (Tools.toId(spl[1])) {26 case "token":27 if (Tools.getCookie("token") === spl[3]) {28 document.cookie = "";29 }30 break;31 case "denied":32 room.addLine(Tools.escapeHTML(spl[2]) + ": access denied.");33 break;34 case "usage":35 if (spl[2] === "login") {36 context.client.logindialog.dialog("open");37 $("#login-dialog-error-msg").html("");38 } else if (spl[2] === "register") {39 context.client.registerdialog.dialog("open");40 $("#register-dialog-error-msg").html("");41 } else if (spl[2] === "changepassword") {42 context.client.cpassworddialog.dialog("open");43 $("#cpassword-dialog-error-msg").html("");44 } else if (CommandsUsageData[spl[2]]) {45 room.addLine("Usage: /" + Tools.escapeHTML(spl[2]) + " " + Tools.escapeHTML(CommandsUsageData[spl[2]]));46 } else {47 room.addLine("Invalid syntax for command /" + Tools.escapeHTML(spl[2]));48 }49 break;50 case "login":51 context.client.logindialog.dialog("open");52 switch (spl[2]) {53 case "INVALID-NAME":54 $("#login-dialog-error-msg").html("Ivalid username.");55 break;56 case "INVALID-LOGIN":57 $("#login-dialog-error-msg").html("Invalid password.");58 break;59 case "NOT-REGISTERED":60 $("#login-dialog-error-msg").html("The userame you chose is not registered.");61 break;62 }63 break;64 case "rename":65 context.client.renamedialog.dialog("open");66 switch (spl[2]) {67 case "INVALID-NAME":68 $("#rename-dialog-error-msg").html("Invalid username.");69 break;70 }71 break;72 case "register":73 context.client.registerdialog.dialog("open");74 switch (spl[2]) {75 case "GUEST":76 $("#register-dialog-error-msg").html("You cannot register a guest account.");77 break;78 case "INVALID-ID":79 $("#register-dialog-error-msg").html("Invalid user ID.");80 break;81 case "ALREADY-REGISTERED":82 $("#register-dialog-error-msg").html("The account is already registered");83 break;84 case "CANNOT-REGISTER":85 $("#register-dialog-error-msg").html("You are not allowed to register more than one account every 12 hours.");86 break;87 }88 break;89 case "deregister":90 switch (spl[2]) {91 case "IS-AUTH":92 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You cannot deregister an account with authority. " + (spl[3] ? ("(room auth in " + Tools.escapeHTML(spl[3])) : ""));93 break;94 case "NOT-REGISTERED":95 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "User '" + Tools.escapeHTML(spl[3]) + "' is not registered.");96 break;97 }98 break;99 case "changepassword":100 context.client.cpassworddialog.dialog("open");101 switch (spl[2]) {102 case "NOT-REGISTERED":103 $("#cpassword-dialog-error-msg").html("You are not registered.");104 break;105 case "INVALID-PASSWORD":106 $("#cpassword-dialog-error-msg").html("Wrong password.");107 break;108 }109 break;110 case "join":111 switch (spl[2]) {112 case "NOT-FOUND":113 context.client.showAlert("Join Failure", "Room <b>" + Tools.escapeHTML(spl[3]) + "</b> not found.");114 break;115 case "DENIED":116 context.client.showAlert("Join Failure", "You are not allowed to join the room <b>" + Tools.escapeHTML(spl[3]) + "</b>");117 break;118 }119 break;120 case "admin":121 switch (spl[2]) {122 case "ALREADY-ADMIN":123 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "User '" + Tools.escapeHTML(spl[3]) + "' is already administrator.");124 break;125 case "NOT-REGISTERED":126 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "User '" + Tools.escapeHTML(spl[3]) + "' is not registered.");127 break;128 }129 break;130 case "deadmin":131 switch (spl[2]) {132 case "NOT-ADMIN":133 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "User '" + Tools.escapeHTML(spl[3]) + "' is not an administrator.");134 break;135 case "NOT-REGISTERED":136 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "User '" + Tools.escapeHTML(spl[3]) + "' is not registered.");137 break;138 }139 break;140 case "manager":141 switch (spl[2]) {142 case "ALREADY":143 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "User '" + Tools.escapeHTML(spl[3]) + "' is already room manager.");144 break;145 case "NOT-REGISTERED":146 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "User '" + Tools.escapeHTML(spl[3]) + "' is not registered.");147 break;148 }149 break;150 case "moderator":151 switch (spl[2]) {152 case "ALREADY":153 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "User '" + Tools.escapeHTML(spl[3]) + "' is already moderator.");154 break;155 case "NOT-REGISTERED":156 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "User '" + Tools.escapeHTML(spl[3]) + "' is not registered.");157 break;158 }159 break;160 case "deauth":161 switch (spl[2]) {162 case "ALREADY":163 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "User '" + Tools.escapeHTML(spl[3]) + "' is not room auth.");164 break;165 case "NOT-REGISTERED":166 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "User '" + Tools.escapeHTML(spl[3]) + "' is not registered.");167 break;168 }169 break;170 case "makeroom":171 switch (spl[2]) {172 case "ID-TOO-LONG":173 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Room identifier is too long.");174 break;175 case "NAME-TOO-LONG":176 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Room name is too long.");177 break;178 case "ALREADY-EXISTS":179 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Room '" + Tools.escapeHTML(spl[3]) + "' already exists.");180 break;181 }182 break;183 case "deleteroom":184 switch (spl[2]) {185 case "NOT-EXISTS":186 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Room '" + Tools.escapeHTML(spl[3]) + "' does not exists.");187 break;188 }189 break;190 case "private":191 switch (spl[2]) {192 case "ALREADY":193 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Room '" + Tools.escapeHTML(spl[3]) + "' is already private.");194 break;195 }196 break;197 case "public":198 switch (spl[2]) {199 case "ALREADY":200 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Room '" + Tools.escapeHTML(spl[3]) + "' is already public.");201 break;202 }203 break;204 case "roomname":205 switch (spl[2]) {206 case "NAME-TOO-LONG":207 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Room name is too long.");208 break;209 }210 break;211 case "modchat":212 switch (spl[2]) {213 case "ALREADY":214 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Modchat is currently set to level " + Tools.escapeHTML(spl[3]) + ".");215 break;216 }217 break;218 case "ban":219 switch (spl[2]) {220 case "NOT-REGISTERED":221 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "User '" + Tools.escapeHTML(spl[3]) + "' is not registered.");222 break;223 }224 break;225 case "unban":226 switch (spl[2]) {227 case "NOT-BANNED":228 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "User '" + Tools.escapeHTML(spl[3]) + "' is not banned.");229 break;230 }231 break;232 case "config":233 switch (spl[2]) {234 case "BAD-CONFIG":235 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "The configuration you chose for this auction is not valid.");236 break;237 }238 break;239 case "turn":240 switch (spl[2]) {241 case "NOT-PAUSED":242 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You cannot do this when there is an active bid.");243 break;244 case "TEAM-NOT-FOUND":245 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Team '" + Tools.escapeHTML(spl[3]) + "' was not found.");246 break;247 }248 break;249 case "addplayers":250 switch (spl[2]) {251 case "NOT-PAUSED":252 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You cannot do this when there is an active bid.");253 break;254 case "NO-PLAYERS":255 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "No players where added.");256 break;257 }258 break;259 case "rmplayers":260 switch (spl[2]) {261 case "NOT-PAUSED":262 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You cannot do this when there is an active bid.");263 break;264 case "NO-PLAYERS":265 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "No players where removed.");266 break;267 }268 break;269 case "addteam":270 switch (spl[2]) {271 case "NOT-PAUSED":272 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You cannot do this when there is an active bid.");273 break;274 case "INVALID-MONEY":275 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Invalid money. You just use multiples of 0.5K.");276 break;277 case "INVALID-NAME":278 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Invalid name.");279 break;280 case "EXISTS":281 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Team '" + Tools.escapeHTML(spl[3]) + "' already exists");282 break;283 }284 break;285 case "rmteam":286 switch (spl[2]) {287 case "NOT-PAUSED":288 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You cannot do this when there is an active bid.");289 break;290 case "NOT-EXISTS":291 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Team '" + Tools.escapeHTML(spl[3]) + "' was not found.");292 break;293 }294 break;295 case "setcaptain":296 switch (spl[2]) {297 case "NOT-PAUSED":298 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You cannot do this when there is an active bid.");299 break;300 case "TEAM-NOT-FOUND":301 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Team '" + Tools.escapeHTML(spl[3]) + "' was not found.");302 break;303 case "NOT-REGISTERED":304 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "User '" + Tools.escapeHTML(spl[3]) + "' is not registered.");305 break;306 case "ALREADY-SET":307 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "User '" + Tools.escapeHTML(spl[3]) + "' is already a captain.");308 break;309 }310 break;311 case "unsetcaptain":312 switch (spl[2]) {313 case "NOT-PAUSED":314 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You cannot do this when there is an active bid.");315 break;316 case "NOT-CAPTAIN":317 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "User '" + Tools.escapeHTML(spl[3]) + "' is not a captain.");318 break;319 }320 break;321 case "setmoney":322 switch (spl[2]) {323 case "NOT-PAUSED":324 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You cannot do this when there is an active bid.");325 break;326 case "INVALID-MONEY":327 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Invalid money. You just use multiples of 0.5K.");328 break;329 case "TEAM-NOT-FOUND":330 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Team '" + Tools.escapeHTML(spl[3]) + "' was not found.");331 break;332 }333 break;334 case "teamname":335 switch (spl[2]) {336 case "NOT-PAUSED":337 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You cannot do this when there is an active bid.");338 break;339 case "INVALID-NAME":340 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Invalid name.");341 break;342 case "TEAM-NOT-FOUND":343 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Team '" + Tools.escapeHTML(spl[3]) + "' was not found.");344 break;345 }346 break;347 case "assign":348 switch (spl[2]) {349 case "NOT-PAUSED":350 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You cannot do this when there is an active bid.");351 break;352 case "INVALID-MONEY":353 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Invalid money. You must use multiples of 0.5K.");354 break;355 case "TEAM-NOT-FOUND":356 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Team '" + Tools.escapeHTML(spl[3]) + "' was not found.");357 break;358 case "PLAYER-NOT-FOUND":359 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Player '" + Tools.escapeHTML(spl[3]) + "' was not found.");360 break;361 case "PLAYER-NOT-FREE":362 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Player '" + Tools.escapeHTML(spl[3]) + "' is already member of another team.");363 break;364 case "LACKS-MONEY":365 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Team '" + Tools.escapeHTML(spl[3]) +366 "' does not have enougth money to paid " + Tools.escapeHTML(spl[4]) + "K.");367 break;368 case "CANNOT-PAID":369 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Team '" + Tools.escapeHTML(spl[3]) +370 "' cannot paid " + Tools.escapeHTML(spl[4]) + "K. They need to complete their team.");371 break;372 }373 break;374 case "free":375 switch (spl[2]) {376 case "NOT-PAUSED":377 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You cannot do this when there is an active bid.");378 break;379 case "PLAYER-NOT-FOUND":380 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Player '" + Tools.escapeHTML(spl[3]) + "' was not found.");381 break;382 case "ALREADY-FREE":383 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Player '" + Tools.escapeHTML(spl[3]) + "' is not assigned to any team.");384 break;385 }386 break;387 case "finalizebid":388 switch (spl[2]) {389 case "NOT-ACTIVE-BID":390 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "There is not an active bid.");391 break;392 }393 break;394 case "nominate":395 switch (spl[2]) {396 case "NOT-PAUSED":397 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You cannot do this when there is an active bid.");398 break;399 case "NOT-YOUR-TURN":400 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "It is not your turn.");401 break;402 case "LACKS-MONEY":403 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You have not enought money to nominate.");404 break;405 case "PLAYER-NOT-FOUND":406 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Player '" + Tools.escapeHTML(spl[3]) + "' was not found.");407 break;408 case "NOT-FREE":409 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Player '" + Tools.escapeHTML(spl[3]) + "' is already member of another team.");410 break;411 }412 break;413 case "pass":414 switch (spl[2]) {415 case "NOT-PAUSED":416 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You cannot do this when there is an active bid.");417 break;418 case "NOT-YOUR-TURN":419 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "It is not your turn.");420 break;421 case "CANNOT-PASS":422 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You cannot pass the turn. You need to complete your team.");423 break;424 }425 break;426 case "bid":427 switch (spl[2]) {428 case "NOT-ACTIVE-BID":429 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "There is not an active bid.");430 break;431 case "NOT-CAPTAIN":432 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You are not a team captain.");433 break;434 case "NOMINATING":435 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You already have the higher bid.");436 break;437 case "INVALID-MONEY":438 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Invalid money. You must use multiples of 0.5K.");439 break;440 case "LACKS-MONEY":441 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "You team does not have enougth money to paid " +442 Tools.escapeHTML(spl[3]) + "K.");443 break;444 case "CANNOT-PAID":445 room.addLine(Tools.escapeHTML(spl[1]) + ": " + "Your team cannot paid " +446 Tools.escapeHTML(spl[3]) + "K. You need to complete your team.");447 break;448 }449 break;450 }451 },452 "OK": function (room, cmd, spl, context) {453 switch (Tools.toId(spl[1])) {454 case "register":455 context.client.showAlert("Registered", "The account <b>" + Tools.escapeHTML(spl[2]) + "</b> was registered sucessfully.");456 break;457 case "deregister":458 room.addLine("Account deregistered: " + Tools.escapeHTML(spl[2]));459 break;460 case "changepassword":461 context.client.showAlert("Change Password", "You have changed your password sucessfully.");462 break;463 case "admin":464 room.addLine("User promoted to administrator: " + Tools.escapeHTML(spl[2]));465 break;466 case "deadmin":467 room.addLine("User demoted: " + Tools.escapeHTML(spl[2]));468 break;469 case "makeroom":470 room.addLine("Room created: " + Tools.escapeHTML(spl[2]));471 break;472 case "deleteroom":473 room.addLine("Room deleted: " + Tools.escapeHTML(spl[2]));474 break;475 }476 },477 "INIT": function (room, cmd, spl, context) {478 room.setRoomName(spl.slice(1));479 context.init = true;480 context.client.maintabs.tabs("option", "active", $('#tabs a[href="#' + room.id + '"]').parent().index());481 },482 "CLOSED": function (room, cmd, spl, context) {483 context.client.removeTab(room.id);484 delete context.client.rooms[room.id];485 },486 "USERS": function (room, cmd, spl, context) {487 var users = JSON.parse(spl.slice(1).join("|"));488 var user;489 room.users = {};490 for (var i = 0; i < users.length; i++) {491 user = users[i].split("|");492 console.log(user[1]);493 room.users[Tools.toId(user[1])] = {494 id: Tools.toId(user[1]),495 name: user[1],496 group: user[0]497 };498 }499 room.updateAuctionView();500 room.updateUsersTab();501 },502 "AUCTION": function (room, cmd, spl, context) {503 room.auction = JSON.parse(spl.slice(1).join("|"));504 room.updateAuctionView();505 },506 "STATUS": function (room, cmd, spl, context) {507 room.status = parseInt(spl[1]);508 room.updateAuctionView();509 },510 "BS": function (room, cmd, spl, context) {511 room.nominated = spl[1];512 room.timeout = parseInt(spl[2]);513 room.nominatedTeam = spl[3];514 room.nominatedCost = parseFloat(spl[4]);515 room.updateAuctionView();516 },517 "J": function (room, cmd, spl, context) {518 room.users[Tools.toId(spl[2])] = {519 id: Tools.toId(spl[2]),520 name: spl[2],521 group: spl[1]522 };523 if (spl[1] !== "+") {524 room.addLine(Tools.escapeHTML(spl[2]) + " joined the room.");525 }526 room.updateAuctionView();527 room.updateUsersTab();528 },529 "L": function (room, cmd, spl, context) {530 var id = Tools.toId(spl[1]);531 if (room.users[id] && room.users[id].group !== "+") {532 room.addLine(Tools.escapeHTML(room.users[id].name) + " left the room.");533 }534 delete room.users[id];535 room.updateAuctionView();536 room.updateUsersTab();537 },538 "RN": function (room, cmd, spl, context) {539 var id = Tools.toId(spl[1]);540 if (Tools.toId(spl[3]) === id) {541 room.users[id].name = spl[3];542 room.users[id].group = spl[2];543 room.updateAuctionView();544 room.updateUsersTab();545 return;546 }547 var txt = "";548 if (room.users[id] && room.users[id].group !== "+") {549 txt += Tools.escapeHTML(room.users[id].name) + " left the room.";550 }551 delete room.users[id];552 id = Tools.toId(spl[3]);553 if (!room.users[id] && spl[2] !== "+") {554 txt += Tools.escapeHTML(spl[3]) + " joined the room.";555 }556 room.users[id] = {557 id: id,558 name: spl[3],559 group: spl[2]560 };561 room.addLine(txt);562 room.updateAuctionView();563 room.updateUsersTab();564 },565 "PROMOTED-ADMIN-BY": function (room, cmd, spl, context) {566 context.client.showAlert("Promoted", "You were promoted to administrator by <i>" + Tools.escapeHTML(spl[1]) + "</i>.");567 },568 "DEMOTED-ADMIN-BY": function (room, cmd, spl, context) {569 context.client.showAlert("Demoted", "You were taken administrator permissions by <i>" + Tools.escapeHTML(spl[1]) + "</i>.");570 },571 "MC": function (room, cmd, spl, context) {572 var txt = "";573 room.modchat = parseInt(spl[1]);574 switch (room.modchat) {575 case 0:576 txt = "Any registered user can talk.";577 break;578 case 1:579 txt = "Only participants and above can talk.";580 break;581 case 2:582 txt = "Only room managers and above can talk.";583 break;584 }585 room.addLine('<div class="announcement">Modchat level ' + Tools.escapeHTML(spl[1]) + ': ' + txt + '</div>');586 },587 "PROMOTION": function (room, cmd, spl, context) {588 var names = {589 "~": "Administrator",590 "#": "Room Manager",591 "@": "Moderator"592 };593 room.addLine('<div class="ban-announcement">' + Tools.escapeHTML(room.userName(spl[2])) + ' was promoted to ' + names[spl[1]] +594 ' by ' + Tools.escapeHTML(room.userName(spl[3])) + '</div>');595 },596 "DEMOTE": function (room, cmd, spl, context) {597 room.addLine('<div class="ban-announcement">' + Tools.escapeHTML(room.userName(spl[1])) + ' was demoted by ' +598 Tools.escapeHTML(room.userName(spl[2])) + '</div>');599 },600 "BAN": function (room, cmd, spl, context) {601 room.addLine('<div class="ban-announcement">' + Tools.escapeHTML(room.userName(spl[1])) + ' was banned from this room by ' +602 Tools.escapeHTML(room.userName(spl[2])) + '</div>');603 },604 "UNBAN": function (room, cmd, spl, context) {605 room.addLine('<div class="ban-announcement">' + Tools.escapeHTML(room.userName(spl[1])) + ' was unbanned by ' +606 Tools.escapeHTML(room.userName(spl[2])) + '</div>');607 },608 "ROOM": function (room, cmd, spl, context) {609 switch (spl[1]) {610 case "PRIVATE":611 if (spl[2] === "TRUE") {612 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[3])) + ' made this room private.</div>');613 } else {614 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[3])) + ' made this room public.</div>');615 }616 break;617 }618 },619 "ROOM-NAME-INF": function (room, cmd, spl, context) {620 if (!context.init) room.setRoomName(spl[2]);621 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[1])) + ' changed the name of this room to ' + Tools.escapeHTML(spl.slice(2)) + '.</div>');622 },623 "MC-INF": function (room, cmd, spl, context) {624 var info = "";625 if (!context.init) room.modchat = parseInt(spl[1]);626 switch (room.modchat) {627 case 0:628 info = "Any registered user can talk now.";629 break;630 case 1:631 info = "Only participants and above can talk now.";632 break;633 case 2:634 info = "Only room managers can talk now.";635 break;636 }637 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[2])) + ' changed the modchat level. ' + info + '</div>');638 },639 "INF": function (room, cmd, spl, context) {640 var aux;641 switch (spl[1]) {642 case "SET-CONFIG":643 if (!context.init) {644 room.auction.config.timer = parseInt(spl[2]);645 room.auction.config.mincost = parseFloat(spl[3]);646 room.auction.config.minplayers = parseInt(spl[4]);647 }648 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[5])) + ' changed the auction configuration.</div>');649 break;650 case "SET-TURN":651 if (!context.init) {652 room.auction.turn = spl[2];653 }654 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[3])) + ' set the turn for ' +655 Tools.escapeHTML(room.teamName(spl[2])) + '</div>');656 break;657 case "ADD-PLAYERS":658 aux = JSON.parse(spl.slice(3).join("|"));659 if (!context.init) {660 for (var i = 0; i < aux.length; i++)661 room.addPlayer(aux[i]);662 }663 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[2])) + ' added players: ' +664 Tools.escapeHTML(aux.join(', ')) + '</div>');665 break;666 case "RM-PLAYERS":667 aux = JSON.parse(spl.slice(3).join("|"));668 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[2])) + ' deleted players: ' +669 Tools.escapeHTML(aux.join(', ')) + '</div>');670 if (!context.init) {671 for (var i = 0; i < aux.length; i++)672 room.removePlayer(aux[i]);673 }674 break;675 case "NEW-TEAM":676 if (!context.init) {677 room.addTeam(spl[3], parseFloat(spl[4]));678 }679 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[2])) + ' registered team: ' +680 Tools.escapeHTML(room.teamName(spl[3])) + '</div>');681 break;682 case "DELETE-TEAM":683 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[2])) + ' deleted team: ' +684 Tools.escapeHTML(room.teamName(spl[3])) + '</div>');685 if (!context.init) {686 room.deleteTeam(spl[3]);687 }688 break;689 case "SET-CAPTAIN":690 if (!context.init) {691 room.auction.teams[spl[3]].captains[spl[4]] = true;692 }693 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[2])) + ' add ' +694 Tools.escapeHTML(room.userName(spl[4])) + ' as a captain for team ' + Tools.escapeHTML(room.teamName(spl[3])) + '</div>');695 break;696 case "RM-CAPTAIN":697 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[2])) + ' removed ' +698 Tools.escapeHTML(room.userName(spl[4])) + ' as a captain.</div>');699 if (!context.init) {700 delete room.auction.teams[spl[3]].captains[spl[4]];701 }702 break;703 case "SET-MONEY":704 if (!context.init) {705 room.auction.teams[spl[3]].money = parseFloat(spl[4]);706 }707 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[2])) + ' set money of team ' +708 Tools.escapeHTML(room.teamName(spl[3])) + ' at ' + Tools.escapeHTML(spl[4]) + 'K.</div>');709 break;710 case "SET-NAME":711 if (!context.init) {712 room.auction.teams[spl[3]].name = spl.slice(4);713 }714 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[2])) + ' updated team name: ' +715 Tools.escapeHTML(room.teamName(spl[3])) + '</div>');716 break;717 case "ASSIGN":718 if (!context.init) {719 room.assignPlayer(spl[4], spl[3], parseFloat(spl[5]));720 }721 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[2])) + ' assigned player ' +722 Tools.escapeHTML(room.playerName(spl[4])) + ' to team ' + Tools.escapeHTML(room.teamName(spl[3])) +723 ' for ' + Tools.escapeHTML(spl[5]) + 'K.</div>');724 break;725 case "FREE":726 if (!context.init) {727 room.setFreePlayer(spl[3]);728 }729 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[2])) + ' removed player ' +730 Tools.escapeHTML(room.playerName(spl[3])) + ' from team ' + Tools.escapeHTML(room.teamName(spl[4])) +731 '. ' + Tools.escapeHTML(spl[5]) + 'K were retrived.</div>');732 break;733 case "FINALIZE-BID":734 room.addLine('<div class="config-announcement">' + Tools.escapeHTML(room.userName(spl[2])) + ' forced the timeout.</div>');735 break;736 case "PASS":737 room.addLine('<div class="auction-announcement">' + Tools.escapeHTML(room.userName(spl[2])) + ', ' + Tools.escapeHTML(room.teamName(spl[3])) + ' passed the turn.</div>');738 break;739 }740 if (!context.init) {741 room.updateAuctionView();742 }743 },744 "TURN-INF": function (room, cmd, spl, context) {745 if (!context.init) {746 room.status = 0;747 room.auction.turn = spl[1];748 room.updateAuctionView();749 }750 room.addLine('<div class="auction-announcement">' + Tools.escapeHTML(room.teamName(spl[1])) + ' has the turn for nominating a player.</div>');751 },752 "NOMINATED": function (room, cmd, spl, context) {753 if (!context.init) {754 room.nominated = spl[3];755 room.nominatedCost = room.auction.config.mincost;756 room.nominatedTeam = spl[2];757 room.status = 1;758 room.timeout = parseInt(spl[4]);759 room.updateAuctionView();760 }761 room.addLine('<div class="auction-announcement">' + Tools.escapeHTML(room.userName(spl[1])) + ', ' +762 Tools.escapeHTML(room.teamName(spl[2])) + ' nominated player ' + Tools.escapeHTML(room.playerName(spl[3])) +763 ' for ' + Tools.escapeHTML(room.auction.config.mincost) + 'K.</div>');764 },765 "BID": function (room, cmd, spl, context) {766 if (!context.init) {767 room.nominatedCost = parseFloat(spl[3]);768 room.nominatedTeam = spl[2];769 room.timeout = parseInt(spl[4]);770 room.updateAuctionView();771 }772 room.addLine('<div class="auction-announcement">' + Tools.escapeHTML(room.userName(spl[1])) + ', ' +773 Tools.escapeHTML(room.teamName(spl[2])) + ' offers ' + Tools.escapeHTML(spl[3]) + 'K.</div>');774 },775 "TO": function (room, cmd, spl, context) {776 console.log("TO: " + context.init);777 if (!context.init) {778 room.assignPlayer(spl[1], spl[2], parseFloat(spl[3]));779 room.nominated = null;780 room.nominatedCost = 0;781 room.nominatedTeam = null;782 room.status = 2;783 room.timeout = 0;784 room.updateAuctionView();785 }786 room.addLine('<div class="auction-announcement">Time is out! ' + Tools.escapeHTML(room.playerName(spl[1])) +787 ' was assigned to ' + Tools.escapeHTML(room.teamName(spl[2])) + ' for ' + Tools.escapeHTML(spl[3]) + 'K.</div>');788 },789 "TOKEN": function (room, cmd, spl, context) {790 document.cookie = "token=" + spl[1] + "; path=/";791 },792 "ERR-ROOM": function () {793 return;794 },...

Full Screen

Full Screen

copyright.js

Source:copyright.js Github

copy

Full Screen

1var copyright = copyright || {};2copyright.updateUI = function() {3 'use strict';4 $('#cn_urls .contenturl, #dn_urls .contenturl', '.cn-form').rebind('click', function() {5 if ($(this).val() === '') {6 $(this).select();7 }8 });9};10/**11 * Validate the email address, as without a valid email we can not contact the complainant12 * if there is a counter-notice, or to report stats on their complaints.13 * Further email validation may occur in the API14 * @param {String} email The email to validate15 * @return {Boolean} True if passing validation, false otherwise16 */17copyright.validateEmail = function(email) {18 'use strict';19 return isValidEmail(email);20};21copyright.ourDomains = {'mega.co.nz': 1, 'mega.nz': 1, 'mega.io': 1};22/**23 * Validate that the user has entered a link that is, or can be easily turned into, a valid MEGA link24 * @param {String} url The url to validate as a mega public link25 * @return {Array} The link type at idx 0, handle found as idx 1, and sub-node as idx 2 if any.26 */27copyright.validateUrl = function(url) {28 'use strict';29 url = tryCatch(() => new URL(mURIDecode(url).trim()), false)();30 const ext = url && String(url.protocol).endsWith('-extension:');31 if (!url || !this.ourDomains[url.host] && !ext) {32 return null;33 }34 let path = (ext ? '' : url.pathname) + url.hash;35 if (url.hash) {36 const hash = String(url.hash).replace('#', '');37 if (hash[0] === '!' || hash[0] === 'F' && hash[1] === '!') {38 path = hash[0] === 'F'39 ? hash.replace('F!', '/folder/').replace('!', '#').replace('!', '/folder/').replace('?', '/file/')40 : hash.replace('!', '/file/').replace('!', '#');41 }42 else if (hash[0] === 'P' && hash[1] === '!') {43 const a = base64urldecode(hash.substr(2));44 const b = String.fromCharCode(a.charCodeAt(2))45 + String.fromCharCode(a.charCodeAt(3))46 + String.fromCharCode(a.charCodeAt(4))47 + String.fromCharCode(a.charCodeAt(5))48 + String.fromCharCode(a.charCodeAt(6))49 + String.fromCharCode(a.charCodeAt(7));50 path = '/file/' + base64urlencode(b);51 }52 }53 const match = path.match(/^[#/]*(file|folder|embed)[!#/]+([\w-]{8})\b/i);54 if (!match) {55 console.warn('Invalid url.', url);56 return null;57 }58 const result = [match[1], match[2]];59 if (match[1] === 'folder') {60 result.push((path.replace(match[0], '').match(/(?:file|folder)\/([\w-]{8})/i) || [])[1]);61 }62 return result;63};64/**65 * Check if the entered URL is a folder link without a subfile link.66 * @param url67 * @return {Boolean} If is folder without subfile link.68 */69copyright.isFolderWithoutSubHandle = function(url) {70 'use strict';71 url = this.isFolderLink(url);72 return url && !url[2];73};74/**75 * Check if a URL is a folder link.76 * @param url77 * @return {Boolean}78 */79copyright.isFolderLink = function(url) {80 'use strict';81 url = this.validateUrl(url) || !1;82 return url[0] === 'folder' && url;83};84/**85 * Store the complainant details so they don't have to type them in next time86 * Puts them into localStorage.copyrightOwnerDetails87 */88copyright.saveCopyrightOwnerValues = function() {89 'use strict';90 var details = {91 owner: $('input.copyrightowner', '.cn-form').val(),92 jobtitle: $('input.jobtitle', '.cn-form').val(),93 email: $('input.email', '.cn-form').val(),94 fax: $('input.fax', '.cn-form').val(),95 city: $('input.city', '.cn-form').val(),96 postalcode: $('input.zip', '.cn-form').val(),97 name: $('input.agent', '.cn-form').val(),98 company: $('input.company', '.cn-form').val(),99 phone: $('input.phone', '.cn-form').val(),100 address: $('input.address', '.cn-form').val(),101 province: $('input.state', '.cn-form').val(),102 country: $('.select.country select', '.cn-form').val()103 };104 localStorage.setItem('copyrightOwnerDetails', JSON.stringify(details));105};106/**107 * Load the complainant details directly into the html elements so they don't have to type them in again108 */109copyright.loadCopyrightOwnerValues = function() {110 'use strict';111 if (localStorage.copyrightOwnerDetails) {112 var details = JSON.parse(localStorage.copyrightOwnerDetails);113 $('input.copyrightowner', '.cn-form').val(details.owner);114 $('input.jobtitle', '.cn-form').val(details.jobtitle);115 $('input.email', '.cn-form').val(details.email);116 $('input.fax', '.cn-form').val(details.fax);117 $('input.city', '.cn-form').val(details.city);118 $('input.zip', '.cn-form').val(details.postalcode);119 $('input.agent', '.cn-form').val(details.name);120 $('input.company', '.cn-form').val(details.company);121 $('input.phone', '.cn-form').val(details.phone);122 $('input.address', '.cn-form').val(details.address);123 $('input.state', '.cn-form').val(details.province);124 $('.select.country select', '.cn-form').val(details.country).change();125 }126};127copyright.step2Submit = function() {128 'use strict';129 if (!$('.select.content', '.cn-form').hasClass('selected')) {130 msgDialog('warninga', l[135], escapeHTML(l[657]));131 }132 else if ($('.select.type', '.cn-form').hasClass('selected')) {133 var invalidWords = ['asd', 'asdf', 'copyright'];134 var $copyrightwork = $('.copyrightwork', '.cn-form');135 var proceed = false;136 var takedownType = $('.select.type select', '.cn-form').val();137 var doStep2Submit = function() {138 copyright.step2Submit();139 };140 var $contentURL = $('.contenturl', '.cn-form');141 var e;142 for (var i = 0; i < $contentURL.length; i++) {143 e = $contentURL[i];144 var cVal = String($($copyrightwork[i]).val()).trim();145 var urls = String($(e).val()).split(/\n/);146 urls = urls.map(String.trim).filter(String);147 proceed = urls.length > 0;148 if (!proceed) {149 msgDialog('warninga', l[135], escapeHTML(l[659]));150 copyright.markInputWrong(e);151 return false;152 }153 for (var k = 0; k < urls.length; k++) {154 var eVal = urls[k];155 if (eVal !== '' && cVal === '' || invalidWords.indexOf(cVal.toLowerCase()) !== -1) {156 proceed = false;157 msgDialog('warninga', l[135], escapeHTML(l[660]));158 copyright.markInputWrong($copyrightwork[i]);159 return false;160 }161 if (eVal === '' || cVal === '') {162 proceed = false;163 msgDialog('warninga', l[135], escapeHTML(l[659]));164 copyright.markInputWrong(eVal ? $copyrightwork[i] : e);165 return false;166 }167 if (!copyright.validateUrl(eVal)) {168 proceed = false;169 msgDialog('warninga', l[135], escapeHTML(l[7686]));170 copyright.markInputWrong(e);171 return false;172 }173 if (copyright.validateUrl(cVal)) {174 proceed = false;175 msgDialog('warninga', l[135], escapeHTML(l[9056]));176 copyright.markInputWrong($copyrightwork[i]);177 return false;178 }179 if (takedownType === "1" && copyright.isFolderLink(eVal)180 && !copyright.isFolderWithoutSubHandle(eVal)) {181 proceed = false;182 msgDialog('warninga', l[135], l[19804]);183 return false;184 }185 if ((takedownType === "2" || takedownType === "3")186 && localStorage.tdFolderlinkWarning !== "1"187 && copyright.isFolderWithoutSubHandle(eVal)) {188 localStorage.tdFolderlinkWarning = 1;189 proceed = false;190 msgDialog('info', l[621], escapeHTML(l[19802]), null, doStep2Submit);191 return false;192 }193 }194 $(e).removeClass("red");195 }196 if (proceed && !$('.cn_check1 .checkinput', '.cn-form').prop('checked')) {197 msgDialog('warninga', l[135], escapeHTML(l[665]));198 }199 else if (proceed) {200 $('.cn.step1', '.cn-form').addClass('hidden');201 $('.cn.step2', '.cn-form').removeClass('hidden');202 document.getElementsByClassName('cn step2')[0].scrollIntoView();203 // Reload values from local storage if the user has previously been here204 copyright.loadCopyrightOwnerValues();205 }206 }207 else {208 msgDialog('warninga', l[135], escapeHTML(l[658]));209 }210};211/**212 * Initialises the copyright form page, binding the events the form requires213 */214copyright.init_cn = function() {215 'use strict';216 if (is_mobile) {217 $('.cn.main-pad-block').removeClass('hidden');218 $('.js-back-to-copyright', '.cn.header').rebind('click', () => {219 loadSubPage('copyright');220 });221 }222 $('.addurlbtn', '.cn-form').rebind('click', () => {223 $('#cn_urls', '.cn-form').safeAppend('<div class="new-affiliate-label">' +224 '<div class="new-affiliate-star"></div>@@</div>' +225 '<div class="clear"></div>' +226 '<div class="affiliate-input-block dynamic-height">' +227 '<textarea class="contenturl" rows="3"></textarea>' +228 '</div>' +229 '<div class="new-affiliate-label">' +230 '<div class="new-affiliate-star"></div>@@' +231 '</div>' +232 '<div class="clear"></div>' +233 '<div class="affiliate-input-block">' +234 '<input type="text" class="copyrightwork" value="">' +235 '</div>', l[641], l[648]);236 copyright.updateUI();237 });238 copyright.updateUI();239 $('.step2btn', '.cn-form').rebind('click', () => {240 copyright.step2Submit();241 });242 $('.backbtn', '.cn-form').rebind('click', () => {243 $('.cn.step1', '.cn-form').removeClass('hidden');244 $('.cn.step2', '.cn-form').addClass('hidden');245 });246 copyright.initCheckboxListeners();247 $('.select select', '.cn-form').rebind('change.initcn', function() {248 var c = $(this).attr('class');249 if (c && c.indexOf('type') > -1 && $(this).val() === 4) {250 msgDialog(251 'info',252 escapeHTML(l[701]),253 escapeHTML(l[700])254 .replace('[A1]', '<a href="mailto:copyright@mega.nz" class="red">')255 .replace('[/A1]', '</A>')256 .replace('[A2]', '<a href="/copyright" class="red clickurl">')257 .replace('[/A2]', '</A>'));258 clickURLs();259 $(this).val(0);260 $(this).parent().find('.affiliate-select-txt').text(l[1278]);261 }262 else if ($(this).val() !== 0) {263 $(this).parent().addClass('selected');264 $(this).parent().find('.affiliate-select-txt')265 .text($(this).find('option[value=\'' + $(this).val() + '\']').text());266 }267 });268 $('.signbtn', '.cn-form').rebind('click', () => {269 if ($('input.copyrightowner', '.cn-form').val() === '') {270 msgDialog('warninga', l[135], escapeHTML(l[661]), false, function() {271 $('input.copyrightowner', '.cn-form').trigger("focus");272 });273 }274 else if ($('input.agent', '.cn-form').val() === '') {275 msgDialog('warninga', l[135], escapeHTML(l[662]), false, function() {276 $('input.agent', '.cn-form').trigger("focus");277 });278 }279 else if ($('input.email', '.cn-form').val() === '') {280 msgDialog('warninga', l[135], escapeHTML(l[663]), false, function() {281 $('input.email', '.cn-form').trigger("focus");282 });283 }284 else if (!copyright.validateEmail($('input.email', '.cn-form').val())) {285 msgDialog('warninga', l[135], escapeHTML(l[198]), false, function() {286 $('input.email', '.cn-form').trigger("focus");287 });288 }289 else if ($('input.city', '.cn-form').val() === '') {290 msgDialog('warninga', l[135], escapeHTML(l[1262]), false, function() {291 $('input.city', '.cn-form').trigger("focus");292 });293 }294 else if (!$('.select.country', '.cn-form').hasClass('selected')) {295 msgDialog('warninga', l[135], escapeHTML(l[568]));296 }297 else if (!$('.cn_check2 .checkinput', '.cn-form').prop('checked')) {298 msgDialog('warninga', l[135], escapeHTML(l[666]));299 }300 else if ($('.cn_check3 .checkinput', '.cn-form').prop('checked')) {301 // Save the entered values into local storage so the user doesn't have to re-enter them next time302 copyright.saveCopyrightOwnerValues();303 var cn_post_urls = [];304 var cn_post_works = [];305 var $copyrightwork = $('.copyrightwork', '.cn-form');306 var $contentURL = $('.contenturl', '.cn-form');307 for (var i = 0; i < $contentURL.length; i++) {308 var e = $contentURL[i];309 var cVal = String($($copyrightwork[i]).val()).trim();310 var urls = String($(e).val() || $(e).html()).split(/\n/);311 urls = urls.map(String.trim).filter((url) => {312 return url !== "";313 });314 for (var k = 0; k < urls.length; k++) {315 cn_post_urls.push(urls[k]);316 cn_post_works.push(cVal);317 }318 }319 var cn_works_json = JSON.stringify([cn_post_urls, cn_post_works]);320 loadingDialog.show();321 api_req({322 a: 'cn',323 works: cn_works_json,324 infr_type: $('.select.content select', '.cn-form').val(),325 takedown_type: $('.select.type select', '.cn-form').val(),326 jobtitle: $('input.jobtitle', '.cn-form').val(),327 owner: $('input.copyrightowner', '.cn-form').val(),328 email: $('input.email', '.cn-form').val(),329 fax: $('input.fax', '.cn-form').val(),330 postalcode: $('input.zip', '.cn-form').val(),331 city: $('input.city', '.cn-form').val(),332 company: $('input.company', '.cn-form').val(),333 name: $('input.agent', '.cn-form').val(),334 phone: $('input.phone', '.cn-form').val(),335 address: $('input.address', '.cn-form').val(),336 province: $('input.state', '.cn-form').val(),337 country: $('.select.country select', '.cn-form').val()338 }, {339 callback: function() {340 loadingDialog.hide();341 msgDialog(342 'info',343 escapeHTML(l[1287]),344 escapeHTML(l[1288]),345 false,346 function() {347 loadSubPage('copyright');348 });349 }350 });351 }352 else {353 msgDialog('warninga', l[135], escapeHTML(l[667]));354 }355 });356 var markup = '<OPTION value="0"></OPTION>';357 var countries = M.getCountries();358 for (var country in countries) {359 if (countries.hasOwnProperty(country)) {360 markup += '<option value="' + escapeHTML(country) + '">'361 + escapeHTML(countries[country]) + '</option>';362 }363 }364 $('.select.country select', '.cn-form').safeHTML(markup);365};366copyright.validatePhoneNumber = function(phoneNumber) {367 'use strict';368 var p = /\d[^\d]*\d[^\d]*\d[^\d]*\d/;369 var match = p.exec(phoneNumber);370 // if not at least 4 numbers, what is this thing?371 return match !== null;372};373copyright.validateDisputeForm = function() {374 'use strict';375 var $copyrightwork = $('.copyrightwork', '.dn-form');376 var $explanation = $('.copyrightexplanation', '.dn-form');377 var proceed = true;378 var $contentURL = $('.contenturl', '.dn-form');379 for (var i = 0; i < $contentURL.length; i++) {380 proceed = true;381 var eVal = $($contentURL[i]).val();382 var cprVal = $($copyrightwork[i]).val();383 var explainVal = $($explanation[i]).val();384 if (eVal !== '' && cprVal !== '' && explainVal === '') {385 proceed = false;386 msgDialog('warninga', l[135], escapeHTML(l[8809]));387 return false;388 }389 else if (eVal !== '' && cprVal === '') {390 proceed = false;391 msgDialog('warninga', l[135], escapeHTML(l[8810]));392 return false;393 }394 else if (eVal === '' || cprVal === '') {395 proceed = false;396 msgDialog('warninga', l[135], escapeHTML(l[8811]));397 return false;398 }399 else if (!copyright.validateUrl(eVal)) {400 proceed = false;401 msgDialog('warninga', l[135], escapeHTML(l[8812]));402 return false;403 }404 }405 if (!proceed) {406 return false;407 }408 if ($('input.copyrightowner', '.dn-form').val() === '') {409 msgDialog('warninga', l[135], escapeHTML(l[662]), false, function() {410 $('input.copyrightowner', '.dn-form').trigger("focus");411 });412 return false;413 }414 else if ($('input.phonenumber', '.dn-form').val() === '') {415 msgDialog('warninga', l[135], escapeHTML(l[8813]), false, function() {416 $('input.phonenumber', '.dn-form').trigger("focus");417 });418 return false;419 }420 else if (!copyright.validatePhoneNumber($('input.phonenumber', '.dn-form').val())) {421 msgDialog('warninga', l[135], escapeHTML(l[8814]), false, function() {422 $('input.phonenumber', '.dn-form').trigger("focus");423 });424 return false;425 }426 else if ($('input.email', '.dn-form').val() === '') {427 msgDialog('warninga', l[135], escapeHTML(l[663]), false, function() {428 $('input.email', '.dn-form').trigger("focus");429 });430 return false;431 }432 else if (!copyright.validateEmail($('input.email', '.dn-form').val())) {433 msgDialog('warninga', l[135], escapeHTML(l[198]), false, function() {434 $('input.email', '.dn-form').trigger("focus");435 });436 return false;437 }438 else if ($('input.address', '.dn-form').val() === '') {439 msgDialog('warninga', l[135], escapeHTML(l[8815]), false, function() {440 $('input.address', '.dn-form').trigger("focus");441 });442 return false;443 }444 else if ($('input.city', '.dn-form').val() === '') {445 msgDialog('warninga', l[135], escapeHTML(l[1262]), false, function() {446 $('input.city', '.dn-form').trigger("focus");447 });448 return false;449 }450 else if (!$('.select.country', '.dn-form').hasClass('selected')) {451 msgDialog('warninga', l[135], escapeHTML(l[568]));452 return false;453 }454 // The checkboxes depend on the type455 if (proceed && !$('.cn_check1 .checkinput', '.dn-form').prop('checked')) {456 msgDialog('warninga', l[135], escapeHTML(l[8816]));457 return false;458 }459 else if (!$('.cn_check2 .checkinput', '.dn-form').prop('checked')) {460 msgDialog('warninga', l[135], escapeHTML(l[8817]));461 return false;462 }463 return true;464};465copyright.init_cndispute = function() {466 'use strict';467 if (is_mobile) {468 $('.dn.main-pad-block').removeClass('hidden');469 $('.js-back-to-dispute', '.dn.header').rebind('click', () => {470 loadSubPage('dispute');471 });472 }473 if (typeof (u_attr) !== 'undefined' && typeof (u_attr.email) !== 'undefined' && u_attr.email !== '') {474 $('input.email', '.dn-form').val(u_attr.email);475 }476 // prefill the URL with public node handle.477 if (u_attr) {478 var localStorageKey = 'takedownDisputeNodeURL';479 var disputeNodeURL = localStorage.getItem(localStorageKey);480 if (disputeNodeURL) {481 $('.bottom-page .copyrightdisputeform .contenturl', '.dn-form').val(disputeNodeURL);482 localStorage.removeItem(localStorageKey);483 }484 }485 // The sign button needs to validate the form486 $('.signbtn', '.dn-form').rebind('click.copydispute', () => {487 if (copyright.validateDisputeForm()) {488 // Show loading dialog489 loadingDialog.show();490 // The 'copyright notice dispute' api request. Pull the values straight from the inputs491 // as we have already validated them492 var url = $('input.contenturl', '.dn-form').val();493 var handles = copyright.validateUrl(url);494 var requestParameters = {495 a: 'cnd',496 ph: handles[1],497 ufsh: handles[2],498 desc: $('input.copyrightwork', '.dn-form').val(),499 comments: $('input.copyrightexplanation', '.dn-form').val(),500 name: $('input.copyrightowner', '.dn-form').val(),501 phonenumber: $('input.phonenumber', '.dn-form').val(),502 email: $('input.email', '.dn-form').val(),503 company: $('input.company', '.dn-form').val(),504 address1: $('input.address', '.dn-form').val(),505 address2: $('input.address2', '.dn-form').val(),506 city: $('input.city', '.dn-form').val(),507 province: $('input.state', '.dn-form').val(),508 postalcode: $('input.zip', '.dn-form').val(),509 country: $('.select.country select', '.dn-form').val(),510 otherremarks: $('input.otherremarks', '.dn-form').val()511 };512 api_req(requestParameters, {513 callback: function(response) {514 loadingDialog.hide();515 if (!isNaN(parseFloat(response)) && isFinite(response)) {516 // Its a number, must be error code of some kind517 if (response === -9) {518 // ENOENT error519 msgDialog('warninga',520 escapeHTML(l[135]), escapeHTML(l[8818]), false);521 return false;522 }523 if (response === -12) {524 // EEXIST error, they have already made a dispute for this link525 msgDialog('warninga',526 escapeHTML(l[135]), escapeHTML(l[8819]), false);527 return false;528 }529 else if (response === -11) {530 // Access531 msgDialog('warninga',532 escapeHTML(l[135]), escapeHTML(l[8820]), false);533 return false;534 }535 else {536 // Generic (probably args)537 msgDialog('warninga',538 escapeHTML(l[135]), escapeHTML(l[47]), false);539 return false;540 }541 }542 msgDialog('info',543 escapeHTML(l[1287]), escapeHTML(l[1288]), false,544 function() {545 loadSubPage('dispute');546 });547 }548 });549 }550 });551 // Add click and unclick functionality for the custom styled checkboxes552 copyright.initCheckboxListeners();553 $('.select select', '.dn-form').rebind('change.copydispute', function() {554 if ($(this).val() !== 0) {555 $(this).parent().addClass('selected');556 $(this).parent().find('.affiliate-select-txt')557 .text($(this).find('option[value=\'' + $(this).val() + '\']').text());558 }559 });560 // Set up the country values561 var markup = '<OPTION value="0"></OPTION>';562 var countries = M.getCountries();563 for (var country in countries) {564 if (countries.hasOwnProperty(country)) {565 markup += '<option value="' + escapeHTML(country) + '">'566 + escapeHTML(countries[country]) + '</option>';567 }568 }569 $('.select.country select', '.dn-form').safeHTML(markup);570};571// Add click and unclick functionality for the custom styled checkboxes572copyright.initCheckboxListeners = function() {573 'use strict';574 $('.cn_check1, .cn_check2, .cn_check3, .cn_check4').rebind('click.copydispute', function() {575 var $input = $(this).find('input');576 var $checkboxDiv = $(this).find('.checkdiv');577 // If unticked, tick the box578 if ($input.hasClass('checkboxOff')) {579 $input.removeClass('checkboxOff').addClass('checkboxOn').prop('checked', true);580 $checkboxDiv.removeClass('checkboxOff').addClass('checkboxOn');581 }582 else {583 // Otherwise untick the box584 $input.removeClass('checkboxOn').addClass('checkboxOff').prop('checked', false);585 $checkboxDiv.removeClass('checkboxOn').addClass('checkboxOff');586 }587 });588};589/**590 * Mark input field as wrong.591 * @param elm592 */593copyright.markInputWrong = function(elm) {594 'use strict';595 $(elm)596 .addClass("red")597 .css('font-weight', 'bold')598 .rebind('click', function() {599 $(this).off('click')600 .removeClass("red")601 .css('font-weight', 'normal')602 .parent()603 .css('box-shadow', 'none');604 })605 .parent().css('box-shadow', '0px 0px 8px #f00');...

Full Screen

Full Screen

set-params.js

Source:set-params.js Github

copy

Full Screen

...17 var $confirmBtn = modal.querySelector('button.confirm');18 /*19 * Title20 */21 $title.innerHTML = params.html ? params.title : _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.escapeHtml(params.title).split('\n').join('<br>');22 /*23 * Text24 */25 $text.innerHTML = params.html ? params.text : _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.escapeHtml(params.text || '').split('\n').join('<br>');26 if (params.text) _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.show($text);27 /*28 * Custom class29 */30 if (params.customClass) {31 _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.addClass(modal, params.customClass);32 modal.setAttribute('data-custom-class', params.customClass);33 } else {34 // Find previously set classes and remove them35 var customClass = modal.getAttribute('data-custom-class');36 _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.removeClass(modal, customClass);37 modal.setAttribute('data-custom-class', '');38 }39 /*40 * Icon41 */42 _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.hide(modal.querySelectorAll('.sa-icon'));43 if (params.type && !_isIE8.isIE8()) {44 var _ret = (function () {45 var validType = false;46 for (var i = 0; i < alertTypes.length; i++) {47 if (params.type === alertTypes[i]) {48 validType = true;49 break;50 }51 }52 if (!validType) {53 logStr('Unknown alert type: ' + params.type);54 return {55 v: false56 };57 }58 var typesWithIcons = ['success', 'error', 'warning', 'info'];59 var $icon = undefined;60 if (typesWithIcons.indexOf(params.type) !== -1) {61 $icon = modal.querySelector('.sa-icon.' + 'sa-' + params.type);62 _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.show($icon);63 }64 var $input = _getModal$getInput$setFocusStyle.getInput();65 // Animate icon66 switch (params.type) {67 case 'success':68 _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.addClass($icon, 'animate');69 _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.addClass($icon.querySelector('.sa-tip'), 'animateSuccessTip');70 _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.addClass($icon.querySelector('.sa-long'), 'animateSuccessLong');71 break;72 case 'error':73 _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.addClass($icon, 'animateErrorIcon');74 _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.addClass($icon.querySelector('.sa-x-mark'), 'animateXMark');75 break;76 case 'warning':77 _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.addClass($icon, 'pulseWarning');78 _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.addClass($icon.querySelector('.sa-body'), 'pulseWarningIns');79 _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.addClass($icon.querySelector('.sa-dot'), 'pulseWarningIns');80 break;81 case 'input':82 case 'prompt':83 $input.setAttribute('type', params.inputType);84 $input.value = params.inputValue;85 $input.setAttribute('placeholder', params.inputPlaceholder);86 _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.addClass(modal, 'show-input');87 setTimeout(function () {88 $input.focus();89 $input.addEventListener('keyup', swal.resetInputError);90 }, 400);91 break;92 }93 })();94 if (typeof _ret === 'object') {95 return _ret.v;96 }97 }98 /*99 * Custom image100 */101 if (params.imageUrl) {102 var $customIcon = modal.querySelector('.sa-icon.sa-custom');103 $customIcon.style.backgroundImage = 'url(' + params.imageUrl + ')';104 _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.show($customIcon);105 var _imgWidth = 80;106 var _imgHeight = 80;107 if (params.imageSize) {108 var dimensions = params.imageSize.toString().split('x');109 var imgWidth = dimensions[0];110 var imgHeight = dimensions[1];111 if (!imgWidth || !imgHeight) {112 logStr('Parameter imageSize expects value with format WIDTHxHEIGHT, got ' + params.imageSize);113 } else {114 _imgWidth = imgWidth;115 _imgHeight = imgHeight;116 }117 }118 $customIcon.setAttribute('style', $customIcon.getAttribute('style') + 'width:' + _imgWidth + 'px; height:' + _imgHeight + 'px');119 }120 /*121 * Show cancel button?122 */123 modal.setAttribute('data-has-cancel-button', params.showCancelButton);124 if (params.showCancelButton) {125 $cancelBtn.style.display = 'inline-block';126 } else {127 _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.hide($cancelBtn);128 }129 /*130 * Show confirm button?131 */132 modal.setAttribute('data-has-confirm-button', params.showConfirmButton);133 if (params.showConfirmButton) {134 $confirmBtn.style.display = 'inline-block';135 } else {136 _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.hide($confirmBtn);137 }138 /*139 * Custom text on cancel/confirm buttons140 */141 if (params.cancelButtonText) {142 $cancelBtn.innerHTML = _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.escapeHtml(params.cancelButtonText);143 }144 if (params.confirmButtonText) {145 $confirmBtn.innerHTML = _hasClass$addClass$removeClass$escapeHtml$_show$show$_hide$hide.escapeHtml(params.confirmButtonText);146 }147 /*148 * Custom color on confirm button149 */150 if (params.confirmButtonColor) {151 // Set confirm button to selected background color152 $confirmBtn.style.backgroundColor = params.confirmButtonColor;153 // Set the confirm button color to the loading ring154 $confirmBtn.style.borderLeftColor = params.confirmLoadingButtonColor;155 $confirmBtn.style.borderRightColor = params.confirmLoadingButtonColor;156 // Set box-shadow to default focused button157 _getModal$getInput$setFocusStyle.setFocusStyle($confirmBtn, params.confirmButtonColor);158 }159 /*...

Full Screen

Full Screen

validationSchema.js

Source:validationSchema.js Github

copy

Full Screen

1const BaseJoi = require("joi");2const sanitizeHTML = require("sanitize-html");3const extension = (joi) => ({4 type: "string",5 base: joi.string(),6 messages: {7 "string.escapeHTML": "{{#label}} must not include HTML"8 },9 rules: {10 escapeHTML: {11 validate(value, helpers) {12 const clean = sanitizeHTML(value, {13 allowedTags: [],14 allowedAtributes: {}15 });16 if (clean !== value)17 return helpers.error("string.escapeHTML", { value });18 return clean;19 }20 }21 }22});23const Joi = BaseJoi.extend(extension);24module.exports.dogSchema = Joi.object({25 dog: Joi.object({26 name: Joi.string().required().escapeHTML(),27 dateOfBirth: Joi.string().required(),28 parent1: Joi.string().required().escapeHTML(),29 parent2: Joi.string().required().escapeHTML(),30 description: Joi.string().required().escapeHTML(),31 status: Joi.string().required().escapeHTML(),32 yearOfDeath: Joi.number().integer().min(1800).max(9999)33 }).required(),34 deleteImages: Joi.array()35});36module.exports.newsSchema = Joi.object({37 news: Joi.object({38 title: Joi.string().required().escapeHTML(),39 content: Joi.string().required().escapeHTML(),40 date: Joi.string()41 }).required(),42 deleteImages: Joi.array()43});44module.exports.homeSchema = Joi.object({45 home: Joi.object({46 aboutUs: Joi.string().required().escapeHTML()47 }).required(),48 deleteImages: Joi.array()49});50module.exports.competitionSchema = Joi.object({51 competition: Joi.object({52 name: Joi.string().required().escapeHTML(),53 startDate: Joi.date().required(),54 endDate: Joi.date().greater(Joi.ref("startDate")).required(),55 location: Joi.string().required().escapeHTML(),56 award: Joi.string().required().escapeHTML(),57 linkTo: Joi.string().escapeHTML(),58 dog: Joi.string().required().escapeHTML()59 }).required(),60 deleteImages: Joi.array()61});62module.exports.aboutUsSchema = Joi.object({63 aboutUs: Joi.object({64 field1Title: Joi.string().required().escapeHTML(),65 field2Title: Joi.string().required().escapeHTML(),66 field3Title: Joi.string().required().escapeHTML(),67 field1: Joi.string().required().escapeHTML(),68 field2: Joi.string().required().escapeHTML(),69 field3: Joi.string().required().escapeHTML()70 }).required(),71 deleteImages: Joi.array()72});73module.exports.contactSchema = Joi.object({74 contact: Joi.object({75 street: Joi.string().required().escapeHTML(),76 streetNo: Joi.number().required(),77 city: Joi.string().required().escapeHTML(),78 country: Joi.string().required().escapeHTML(),79 phone: Joi.number().required(),80 email: Joi.string().required().escapeHTML(),81 faceLink: Joi.string().required().escapeHTML(),82 instaLink: Joi.string().required().escapeHTML(),83 twittLink: Joi.string().required().escapeHTML()84 }).required()85});86module.exports.messageSchema = Joi.object({87 message: Joi.object({88 name: Joi.string().required().escapeHTML(),89 email: Joi.string().required().escapeHTML(),90 message: Joi.string().required().escapeHTML()91 }).required()...

Full Screen

Full Screen

checkout.js

Source:checkout.js Github

copy

Full Screen

1import baseJoi from 'joi'2import sanitizeHtml from 'sanitize-html'3const extension = joi => ({4 type: 'string',5 base: joi.string(),6 messages: {7 'string.escapeHTML': '{{#label}} must not include HTML!',8 },9 rules: {10 escapeHTML: {11 validate(value, helpers) {12 const clean = sanitizeHtml(value, {13 allowedTags: [],14 allowedAttributes: {},15 })16 if (clean !== value)17 return helpers.error('string.escapeHTML', { value })18 return clean19 },20 },21 },22})23const Joi = baseJoi.extend(extension)24export const checkoutValidationSchema = Joi.object({25 totalAmount: Joi.object({26 amount: Joi.string().required().escapeHTML(),27 currency: Joi.string().required().escapeHTML(),28 }).required(),29 consumer: Joi.object({30 givenNames: Joi.string().required().escapeHTML(),31 surname: Joi.string().required().escapeHTML(),32 phoneNumber: Joi.string().escapeHTML(),33 email: Joi.string().escapeHTML(),34 }).required(),35 shipping: Joi.object({36 phoneNumber: Joi.string().escapeHTML(),37 countryCode: Joi.string().required().escapeHTML(),38 name: Joi.string().required().escapeHTML(),39 postcode: Joi.string().required().escapeHTML(),40 line1: Joi.string().required().escapeHTML(),41 }).required(),42 items: Joi.array()43 .items(44 Joi.object({45 gtin: Joi.string().escapeHTML(),46 brand: Joi.string().escapeHTML(),47 quantity: Joi.number().integer().required().min(0),48 price: Joi.object({49 amount: Joi.string().required().escapeHTML(),50 currency: Joi.string().required().escapeHTML(),51 }).required(),52 name: Joi.string().required().escapeHTML(),53 category: Joi.string().required().escapeHTML(),54 sku: Joi.string().required().escapeHTML(),55 })56 )57 .required(),58 merchant: Joi.object({59 redirectCancelUrl: Joi.string().required().escapeHTML(),60 redirectConfirmUrl: Joi.string().required().escapeHTML(),61 }).required(),...

Full Screen

Full Screen

tag.js

Source:tag.js Github

copy

Full Screen

1// ==========================================================================2// Project: SproutCore - JavaScript Application Framework3// Copyright: ©2006-2011 Strobe Inc. and contributors.4// Portions ©2008-2011 Apple Inc. All rights reserved.5// License: Licensed under MIT license (see license.js)6// ==========================================================================7/*global module test equals context */8var context = null;9module("SC.RenderContext#tag", {10 setup: function() {11 context = SC.RenderContext() ;12 }13});14test("should emit a self closing tag. like calling begin().end()", function() {15 context.tag("input");16 equals(SC.RenderContext.escapeHTML(context.get(1)), SC.RenderContext.escapeHTML("<input />"));17});18test("should respect passed opts when emitting", function() {19 context.tag("foo") ;20 equals(context.length, 3);21 equals(SC.RenderContext.escapeHTML(context.get(1)), SC.RenderContext.escapeHTML("<foo>"));22 equals(SC.RenderContext.escapeHTML(context.get(2)), SC.RenderContext.escapeHTML('<'+'/foo>'));23});24test("should NOT emit self closing tag if tag is script", function() {25 context.tag("script");26 equals(SC.RenderContext.escapeHTML(context.get(1)), SC.RenderContext.escapeHTML('<script>'));27 equals(SC.RenderContext.escapeHTML(context.get(2)), SC.RenderContext.escapeHTML('<'+'/script>'));28});29test("should NOT emit self closing tag if tag is div", function() {30 context.tag("div");31 equals(SC.RenderContext.escapeHTML(context.get(1)), SC.RenderContext.escapeHTML('<div>'));32 equals(SC.RenderContext.escapeHTML(context.get(2)), SC.RenderContext.escapeHTML('<'+'/div>'));33});34test("should NOT emit self closing tag if no tag is passed", function() {35 context.tag();36 equals(SC.RenderContext.escapeHTML(context.get(1)), SC.RenderContext.escapeHTML('<div>'));37 equals(SC.RenderContext.escapeHTML(context.get(2)), SC.RenderContext.escapeHTML('<'+'/div>'));...

Full Screen

Full Screen

schemas.js

Source:schemas.js Github

copy

Full Screen

1const BaseJoi = require('joi');2const sanitizeHTML=require('sanitize-html')3const extension=(joi)=>({4 type:'string',5 base:joi.string(),6 messages: {7 'string.escapeHTML':'{{#label}} must not include HTML'8 },9 rules:{10 escapeHTML: {11 validate(value, helpers){12 const clean = sanitizeHTML(value,{13 allowedTags: [],14 allowedAttributes: {},15 });16 if(clean!==value) return helpers.error('string.escapeHTML',{value})17 return clean18 }19 }20 }21});22const Joi=BaseJoi.extend(extension)23module.exports.locationSchema = Joi.object({24 location: Joi.object({25 title: Joi.string().required().escapeHTML(),26 price: Joi.number().required().min(0),27 description: Joi.string().required().escapeHTML(),28 location: Joi.string().required().escapeHTML(),29 }).required(),30 deleteImages: Joi.array()31})32module.exports.reviewSchema = Joi.object({33 review: Joi.object({34 rating: Joi.number().required().min(1).max(5),35 body: Joi.string().required().escapeHTML()36 }).required()...

Full Screen

Full Screen

escapeHTML.test.js

Source:escapeHTML.test.js Github

copy

Full Screen

1const test = require('tape');2const escapeHTML = require('./escapeHTML.js');3test('Testing escapeHTML', (t) => {4 //For more information on all the methods supported by tape5 //Please go to https://github.com/substack/tape6 t.true(typeof escapeHTML === 'function', 'escapeHTML is a Function');7 t.equal(escapeHTML('<a href="#">Me & you</a>'), '&lt;a href=&quot;#&quot;&gt;Me &amp; you&lt;/a&gt;', "Escapes a string for use in HTML");8 //t.deepEqual(escapeHTML(args..), 'Expected');9 //t.equal(escapeHTML(args..), 'Expected');10 //t.false(escapeHTML(args..), 'Expected');11 //t.throws(escapeHTML(args..), 'Expected');12 t.end();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { escapeHtml } = require('playwright/lib/utils/escape');2console.log(escapeHtml('<script>alert(1)</script>'));3const { escapeHtml } = require('playwright/lib/utils/escape');4console.log(escapeHtml('<script>alert(1)</script>'));5const { escapeHtml } = require('playwright/lib/utils/escape');6console.log(escapeHtml('<script>alert(1)</script>'));7const { escapeHtml } = require('playwright/lib/utils/escape');8console.log(escapeHtml('<script>alert(1)</script>'));9const { escapeHtml } = require('playwright/lib/utils/escape');10console.log(escapeHtml('<script>alert(1)</script>'));11const { escapeHtml } = require('playwright/lib/utils/escape');12console.log(escapeHtml('<script>alert(1)</script>'));13const { escapeHtml } = require('playwright/lib/utils/escape');14console.log(escapeHtml('<script>alert(1)</script>'));15const { escapeHtml } = require('playwright/lib/utils/escape');16console.log(escapeHtml('<script>alert(1)</script>'));17const { escapeHtml } =

Full Screen

Using AI Code Generation

copy

Full Screen

1const { escapeHtml } = require('playwright/lib/utils/escape');2const html = '<div>test</div>';3const { escapeHtml } = require('playwright/lib/utils/escape');4const html = '<div>test</div>';5const { escapeHtml } = require('playwright/lib/utils/escape');6const html = '<div>test</div>';7const { escapeHtml } = require('playwright/lib/utils/escape');8const html = '<div>test</div>';9const { escapeHtml } = require('playwright/lib/utils/escape');10const html = '<div>test</div>';11const { escapeHtml } = require('playwright/lib/utils/escape');12const html = '<div>test</div>';13const { escapeHtml } = require('playwright/lib/utils/escape');14const html = '<div>test</div>';15const { escapeHtml } = require('playwright/lib/utils/escape');16const html = '<div>test</div>';17const { escapeHtml } = require('playwright/lib/utils/escape');18const html = '<div>test</div>';19const { escapeHtml } = require('playwright/lib/utils/escape');

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