Best JavaScript code snippet using playwright-internal
highlight.js
Source:highlight.js
...283 throw 'No highlight';284 return result;285 }//blockText286 287 function blockLanguage(block) {288 var classes = block.className.split(/\s+/);289 for (var i = 0; i < classes.length; i++) {290 if (classes[i] == 'no-highlight') {291 throw 'No highlight'292 }//if293 if (LANGUAGES[classes[i]]) {294 return classes[i];295 }//if296 }//for297 }//blockLanguage298 function highlightBlock(block) {299 try {300 var text = blockText(block);301 var language = blockLanguage(block);302 } catch (e) {303 if (e == 'No highlight')304 return;305 }//try306 307 if (language) {308 var result = highlight(language, text).value;309 } else {310 var max_relevance = 2;311 var relevance = 0;312 for (var key in selected_languages) {313 var r = highlight(key, text);314 relevance = r.keyword_count + r.relevance;315 if (relevance > max_relevance) {...
detector.js
Source:detector.js
...13 function isCLikeLanguage(lang, exact) {14 exact = exact || false;15 return (exact ? (JAVA_ONLY.indexOf(lang)): (C_LIKE.indexOf(lang) > -1));16 }17 function blockLanguage(block) {18 var classes = (block.className + ' ' + (block.parentNode ? block.parentNode.className : '')).split(/\s+/);19 classes = classes.map(function(c) {return c.replace(/^lang(uage)?-/, '');});20 return classes.filter(function(c) {return hljs.getLanguage(c) || /no(-?)highlight/.test(c);})[0];21 }22 function isCLike(element, index, array) {23 return ["objective-c", "cpp"].indexOf(element) > -1;24 }25 function isPerlOrProlog(element, index, array) {26 return ["perl", "prolog"].indexOf(element) > -1;27 }28 function isEclOrProlog(element, index, array) {29 return ["ecl", "prolog"].indexOf(element) > -1;30 }31 function isTypeScriptOrXml(element, index, array) {32 return ["typescript", "xml"].indexOf(element) > -1;33 }34 function isCListOrOpenCl(element, index, array) {35 return ["common lisp", "opencl"].indexOf(element) > -1;36 }37 function isRebolOrR(element, index, array) {38 return ["rebol", "r"].indexOf(element) > -1;39 }40 function isCSOrJava(element, index, array) {41 return ["cs", "java"].indexOf(element) > -1;42 }43 function isCppOrJava(element, index, array) {44 return ["cpp", "java"].indexOf(element) > -1;45 }46 function isCLangOrJava(element, index, array) {47 return ["c", "java"].indexOf(element) > -1;48 }49 function isJsOrJava(element, index, array) {50 return ["javascript", "java"].indexOf(element) > -1;51 }52 function isCppOrCs(element, index, array) {53 return ["cpp", "cs"].indexOf(element) > -1;54 }55 function disambiguate_c(data) {56 var matches = [];57 if (data.indexOf("@interface") > -1) {58 matches.push("objective-c")59 }60 if (data.indexOf("#include <cstdint>") > -1 || (/include\\s*[<"]/.test(data))61 || (/\\b(deque|list|queue|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*</.test(data))62 || (data.indexOf("::"))) {63 matches.push("cpp")64 }65 return matches66 }67 function disambiguate_pl(data) {68 var matches = [];69 if (data.indexOf("use strict") > -1) {70 matches.push("perl")71 }72 if (data.indexOf(":-") > -1) {73 matches.push("prolog")74 }75 return matches76 }77 function disambiguate_ecl(data) {78 var matches = [];79 if (data.indexOf(":=") > -1) {80 matches.push("ecl")81 }82 if (data.indexOf(":-") > -1) {83 matches.push("prolog")84 }85 return matches86 }87 function disambiguate_ts(data) {88 var matches = [];89 if (data.indexOf("</translation>") > -1) {90 matches.push("xml")91 } else {92 matches.push("typescript")93 }94 return matches95 }96 function disambiguate_cl(data) {97 var matches = [];98 if (data.indexOf("(defun ") > -1) {99 matches.push("common lisp")100 }101 if (/\/\* |\/\/ |^\}/.test(data)) {102 matches.push("opencl")103 }104 return matches105 }106 function disambiguate_r(data) {107 var matches = [];108 if (/\bRebol\b/i.test(data)) {109 matches.push("rebol")110 }111 if (data.indexOf("<-") > -1) {112 matches.push("r")113 }114 return matches115 }116 function disambiguate_cs(data) {117 var matches = [];118 if ((data.indexOf("<summary>") > -1)119 || (data.indexOf("using System;") > -1)120 || (data.indexOf("typeof") > -1)121 || (data.indexOf("sizeof") > -1)) {122 matches.push("cs")123 }124 if ((data.indexOf("import") > -1)) {125 matches.push("java")126 }127 return matches128 }129 function disambiguate_cj(data) {130 var matches = [];131 if (data.indexOf("#include <cstdint>") > -1 || (/#include\\s*[<"]/.test(data))132 || (/\\b(deque|list|queue|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*</.test(data))133 || (data.indexOf("::"))) {134 matches.push("cpp")135 }136 if ((data.indexOf("import") > -1)) {137 matches.push("java")138 }139 return matches140 }141 function disambiguate_j(data) {142 var matches = [];143 if (data.indexOf("#include") > -1 || (/#include\\s*["]/.test(data))) {144 matches.push("c")145 }146 if ((data.indexOf("import") > -1)) {147 matches.push("java")148 }149 return matches150 }151 function disambiguate_js(data) {152 var matches = [];153 if (data.indexOf("!==") > -1 || ( /\$[(.]/.test(data))) {154 matches.push("javascript")155 }156 if ((data.indexOf("import") > -1)) {157 matches.push("java")158 }159 return matches160 }161 function disambiguate_cpp(data) {162 var matches = [];163 if (data.indexOf("#include <cstdint>") > -1 || (/#include\\s*[<"]/.test(data))164 || (/\\b(deque|list|queue|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array)\\s*</.test(data))165 || (data.indexOf("::"))) {166 matches.push("cpp")167 }168 if ((data.indexOf("<summary>") > -1)169 || (data.indexOf("using System;") > -1)170 || (data.indexOf("typeof") > -1)171 || (data.indexOf("sizeof") > -1)) {172 matches.push("cs")173 }174 return matches175 }176 // thx to github.com/linguist's heuristic.rb177 module.findByHeuristics = function(data, languages){178 if (languages.every(isCLike)) { return disambiguate_c(data) }179 if (languages.every(isPerlOrProlog)) { return disambiguate_pl(data) }180 if (languages.every(isEclOrProlog)) { return disambiguate_ecl(data) }181 if (languages.every(isTypeScriptOrXml)) { return disambiguate_ts(data) }182 if (languages.every(isCListOrOpenCl)) { return disambiguate_cl(data) }183 if (languages.every(isRebolOrR)) { return disambiguate_r(data) }184 if (languages.every(isCSOrJava)) { return disambiguate_cs(data) }185 if (languages.every(isCppOrJava)) { return disambiguate_cj(data) }186 if (languages.every(isCLangOrJava)) { return disambiguate_j(data) }187 if (languages.every(isJsOrJava)) { return disambiguate_js(data) }188 if (languages.every(isCppOrCs)) { return disambiguate_cpp(data) }189 };190 module.guessLanguage = function(block){191 var text = block.text();192 var lang = blockLanguage(block);193 if (/no(-?)highlight/.test(lang)) {194 return UNKNOWN_LANGUAGE;195 }196 var result = lang ? hljs.highlight(lang, text, true) : hljs.highlightAuto(text);197 var languages;198 var matches;199 if (isCLikeLanguage(result.language)) {200 return {201 language: result.language202 };203 } else {204 if (result.second_best) {205 var secondBest = {206 language: result.second_best.language...
languageAndHobbies.js
Source:languageAndHobbies.js
1import React from "react";2import Card from "@material-ui/core/Card";3import CardContent from "@material-ui/core/CardContent";4import DotsProgress from "./dotProgress";5import styles from "./languageAndHobbies.module.css";6import SportsEsportsIcon from "@material-ui/icons/SportsEsports";7import SportsSoccerIcon from "@material-ui/icons/SportsSoccer";8import TheatersIcon from "@material-ui/icons/Theaters";9import AirplanemodeActiveIcon from "@material-ui/icons/AirplanemodeActive";10import RestaurantIcon from "@material-ui/icons/Restaurant";11const LanguagesAndHobbies = () => {12 return (13 <div style={{ paddingBottom: "80px" }}>14 <div15 className={styles.container}16 style={{17 textAlign: "center",18 paddingBottom: "150px",19 }}20 >21 <div22 className={styles.heading}23 style={{24 textAlign: "center",25 paddingBottom: "45px",26 }}27 >28 <h229 style={{30 margin: "0",31 color: "#ff4081",32 fontSize: "34px",33 textTransform: "none",34 }}35 >36 Languages37 </h2>38 <p39 style={{40 fontFamily: "Open Sans,sans-serif",41 fontSize: "14px",42 lineHeight: "21px",43 fontWeight: "400",44 paddingBottom: "70px",45 margin: "0",46 }}47 >48 I speak49 </p>50 </div>51 <div className={styles.ResumeLanguagesAndHobbiesBlocklanguages}>52 <div className={styles.ResumeLanguagesAndHobbiesBlocklanguage}>53 <div54 className={55 styles.ResumeLanguagesAndHobbiesBlocklanguageTitleAndLevel56 }57 >58 <span59 className={styles.ResumeLanguagesAndHobbiesBlocklanguageTitle}60 >61 Persian62 </span>63 <br />64 <span65 className={styles.ResumeLanguagesAndHobbiesBlocklanguageLevel}66 >67 Native68 </span>69 </div>70 <DotsProgress maxNumberOfDots={10} numberOfActiveDots={10} />71 </div>72 <div className={styles.ResumeLanguagesAndHobbiesBlocklanguage}>73 <div74 className={75 styles.ResumeLanguagesAndHobbiesBlocklanguageTitleAndLevel76 }77 >78 <span79 className={styles.ResumeLanguagesAndHobbiesBlocklanguageTitle}80 >81 English82 </span>83 <br />84 <span85 className={styles.ResumeLanguagesAndHobbiesBlocklanguageLevel}86 >87 Elementary proficiency88 </span>89 </div>90 <DotsProgress maxNumberOfDots={10} numberOfActiveDots={6} />91 </div>92 </div>93 </div>94 <div id={styles.Resumehobbies}>95 <div96 className={styles.heading}97 style={{98 textAlign: "center",99 paddingBottom: "45px",100 }}101 >102 <h2103 style={{104 margin: "0",105 color: "#ff4081",106 fontSize: "34px",107 textTransform: "none",108 }}109 >110 Interests111 </h2>112 <p113 style={{114 fontFamily: "Open Sans,sans-serif",115 fontSize: "14px",116 lineHeight: "21px",117 fontWeight: "400",118 paddingBottom: "22px",119 margin: "0",120 }}121 >122 What I like123 </p>124 </div>125 </div>126 <div className={styles.ResumeLanguagesAndHobbiesBlockhobbies}>127 <div className={styles.ResumeLanguagesAndHobbiesBlockhobbycontainer}>128 <div className={styles.ResumeLanguagesAndHobbiesBlockhobby}>129 <Card130 className={styles.ResumeLanguagesAndHobbiesBlockhobbyfront}131 style={{ backgroundColor: "rgb(33, 150, 243)" }}132 >133 <CardContent>134 <SportsEsportsIcon135 fontSize="large"136 style={{ color: "white" }}137 />138 <h4 style={{ color: "#ffffff" }}>Games</h4>139 </CardContent>140 </Card>141 <Card142 className={styles.ResumeLanguagesAndHobbiesBlockhobbyback}143 style={{ color: "#ffffff", backgroundColor: "rgb(33, 150, 243)" }}144 >145 <CardContent>146 <div147 className={148 styles.ResumeLanguagesAndHobbiesBlockhobbybackdescription149 }150 >151 Playing Video games like Fifa, Call Of Duty in ps4 or mobile152 </div>153 </CardContent>154 </Card>155 </div>156 </div>157 <div className={styles.ResumeLanguagesAndHobbiesBlockhobbycontainer}>158 <div className={styles.ResumeLanguagesAndHobbiesBlockhobby}>159 <Card160 className={styles.ResumeLanguagesAndHobbiesBlockhobbyfront}161 style={{ backgroundColor: "rgb(33, 150, 243)" }}162 >163 <CardContent>164 <SportsSoccerIcon fontSize="large" style={{ color: "white" }} />165 <h4 style={{ color: "#ffffff" }}>Soccer</h4>166 </CardContent>167 </Card>168 <Card169 className={styles.ResumeLanguagesAndHobbiesBlockhobbyback}170 style={{ color: "#ffffff", backgroundColor: "rgb(33, 150, 243)" }}171 >172 <CardContent>173 <div174 className={175 styles.ResumeLanguagesAndHobbiesBlockhobbybackdescription176 }177 >178 Playing soccer with my friends179 </div>180 </CardContent>181 </Card>182 </div>183 </div>184 <div className={styles.ResumeLanguagesAndHobbiesBlockhobbycontainer}>185 <div className={styles.ResumeLanguagesAndHobbiesBlockhobby}>186 <Card187 className={styles.ResumeLanguagesAndHobbiesBlockhobbyfront}188 style={{ backgroundColor: "rgb(33, 150, 243)" }}189 >190 <CardContent>191 <AirplanemodeActiveIcon192 fontSize="large"193 style={{ color: "white" }}194 />195 <h4 style={{ color: "#ffffff" }}>Travelling</h4>196 </CardContent>197 </Card>198 <Card199 className={styles.ResumeLanguagesAndHobbiesBlockhobbyback}200 style={{ color: "#ffffff", backgroundColor: "rgb(33, 150, 243)" }}201 >202 <CardContent>203 <div204 className={205 styles.ResumeLanguagesAndHobbiesBlockhobbybackdescription206 }207 >208 Alone or with groups.209 </div>210 </CardContent>211 </Card>212 </div>213 </div>214 <div className={styles.ResumeLanguagesAndHobbiesBlockhobbycontainer}>215 <div className={styles.ResumeLanguagesAndHobbiesBlockhobby}>216 <Card217 className={styles.ResumeLanguagesAndHobbiesBlockhobbyfront}218 style={{ backgroundColor: "rgb(33, 150, 243)" }}219 >220 <CardContent>221 <TheatersIcon fontSize="large" style={{ color: "white" }} />222 <h4 style={{ color: "#ffffff" }}>Watching Movie/Series</h4>223 </CardContent>224 </Card>225 <Card226 className={styles.ResumeLanguagesAndHobbiesBlockhobbyback}227 style={{ color: "#ffffff", backgroundColor: "rgb(33, 150, 243)" }}228 >229 <CardContent>230 <div231 className={232 styles.ResumeLanguagesAndHobbiesBlockhobbybackdescription233 }234 >235 Most of the time I watch series and often see a movie.236 </div>237 </CardContent>238 </Card>239 </div>240 </div>241 </div>242 </div>243 );244};...
index.js
Source:index.js
...96 for (let i = 0; i < infoOther.length; i += 1) {97 create('p', 'info__content', `${infoOther[i]}`, item);98 }99};100const blockLanguage = function blockLanguage() {101 const item = create('section', 'info info__language','', info);102 create('h3', 'info__title',`${infoTitles.language}`, item);103 for (let i = 0; i < infoLanguage.length; i += 1) {104 create('p', 'info__content', `${infoLanguage[i]}`, item);105 }106};107createExperience();108createEducation();109createCertificates();110createProjects();111blockKnowledge();112blockTools();113blockOther();114blockLanguage();115/* preLoader(certificats); */116const blockSocial = create('section', 'info info__social', '', info);117create('h3', 'info__title info__title_social',`${infoTitles.social}`, blockSocial);118const boxSocial = create('div', 'box_social','', blockSocial);119create('a', 'link link_info', create('img', 'social__img social__img_li', '', '',['src',infoSocial.linkedinIcon]), boxSocial, ['href',infoSocial.linkedin]);120create('a', 'link link_info', create('img', 'social__img social__img_gh', '', '',['src',infoSocial.githubIcon]), boxSocial, ['href',infoSocial.github]);121create('a', 'link link_info', create('img', 'social__img social__img_cw', '', '',['src',infoSocial.codewarsIcon]), boxSocial, ['href',infoSocial.codewars]);122 let popupWindow = create('div', "popup__window","",body);123 let popupCard;124function popupCreator(i) {125 popupCard = create("img", "popup__card", "", popupWindow, ['src', blockCertificates[i].image]);126}127let cards = document.querySelectorAll(".item_certificate");128cards.forEach((card) => {...
setting.js
Source:setting.js
1var app = app || {};2app.init = function () {3 changeImage('#logoImage', 'input[id="logoFile"]');4 $('input[type="checkbox"].minimal').iCheck({5 checkboxClass: 'icheckbox_minimal-blue',6 radioClass : 'iradio_minimal-blue'7 });8 $('[data-mask]').inputmask();9 $('.my-colorpicker').colorpicker();10 $(document).on('shown.bs.tab', 'a[href="#language"]', function (e) {11 $.fn.dataTable.tables({ visible: true, api: true }).columns.adjust();12 });13 $(document).on('shown.bs.tab', 'a[href="#information"], a[href="#seo"]', function (e) {14 $('#blockLanguage').show();15 });16 $(document).on('shown.bs.tab', 'a[href="#social"], a[href="#language"]', function (e) {17 $('#blockLanguage').hide();18 });19 var table_dynamic_language = $('.table-dynamic-language').DataTable({20 "processing": true,21 "ajax": "/data/setting.json",22 'responsive': true,23 'paging': true,24 'lengthChange': true,25 'searching': true,26 'ordering': true,27 'info': true,28 'autoWidth': true,29 'scrollX': true,30 'scrollCollapse': true,31 "columns": [32 {"data": "id"},33 {"data": "name"},34 {"data": "code"},35 {"data": null},36 {"data": "currency"},37 {"data": "time"},38 {"data": null}39 ],40 'columnDefs': [41 {42 targets: [1],43 class: 'text-ellipsis'44 },45 {46 width: '150px',47 targets: [3, 4, 5],48 class: 'text-center'49 },50 {51 width: '100px',52 targets: [0, 2],53 class: 'text-center'54 },55 {56 width: '200px',57 targets: [-1],58 orderable: false,59 class: 'text-center',60 render: function (data, type, row, meta) {61 return '<a' +62 ' class="table-action table-action-edit text-green cursor-pointer" data-id="' + data.id + '"><i' +63 ' class="fa fa-edit"></i></a>';64 }65 },66 {67 targets: [3],68 orderable: false,69 render: function (data, type, full, meta) {70 if (full.enable == 1) {71 return '<input data-id="' + full.id + '" id="rdEnable" type="radio" class="minimal" checked name="defaultEnable">';72 } else {73 return '<input data-id="' + full.id + '" id="rdEnable" type="radio" class="minimal" name="defaultEnable">';74 }75 }76 }77 ],78 "drawCallback": function (settings) {79 if ($('input[type="radio"]').length > 0) {80 $('input[type="radio"]').iCheck({81 radioClass: 'iradio_minimal-blue'82 });83 }84 },85 });86 $(table_dynamic_language.table().container()).on('ifChecked', 'input[type="radio"]', function() {87 var id = $(this).data("id");88 $.ajax({89 // url: base_url + "/v1/period/init?default=1&id=" + id,90 // type: "post",91 success: function (response) {92 },93 error: function (jqXHR, textStatus, errorThrown) {94 $('#error_msg').html('<i class="fas fa-exclamation-triangle"></i> ' + response.msg).show();95 }96 });97 });98 $('#infoForm').validator().on('submit', function (e) {99 $('#addInfoBtn').button('loading');100 $('.alert').addClass('no-display');101 if (!e.isDefaultPrevented()) {102 e.preventDefault();103 setTimeout(function () {104 $('#alert_msg').removeClass('no-display');105 $('#addInfoBtn').button('reset');106 setTimeout(function () {107 $('.alert').addClass('no-display');108 }, 3000);109 }, 1000);110 } else {111 $('#addInfoBtn').button('reset');112 }113 });114 $('#seoForm').validator().on('submit', function (e) {115 $('#addSeoBtn').button('loading');116 $('.alert').addClass('no-display');117 if (!e.isDefaultPrevented()) {118 e.preventDefault();119 setTimeout(function () {120 $('#alert_msg').removeClass('no-display');121 $('#addSeoBtn').button('reset');122 setTimeout(function () {123 $('.alert').addClass('no-display');124 }, 3000);125 }, 1000);126 } else {127 $('#addSeoBtn').button('reset');128 }129 });130 $('#socialForm').validator().on('submit', function (e) {131 $('#addSocialBtn').button('loading');132 $('.alert').addClass('no-display');133 if (!e.isDefaultPrevented()) {134 e.preventDefault();135 setTimeout(function () {136 $('#alert_msg').removeClass('no-display');137 $('#addSocialBtn').button('reset');138 setTimeout(function () {139 $('.alert').addClass('no-display');140 }, 3000);141 }, 1000);142 } else {143 $('#addSocialBtn').button('reset');144 }145 });146 $('#editLanguageForm').validator().on('submit', function (e) {147 $('#editLanguageBtn').button('loading');148 $('.alert').addClass('no-display');149 if (!e.isDefaultPrevented()) {150 e.preventDefault();151 setTimeout(function () {152 $('#alert_msg').removeClass('no-display');153 $('#editLanguageBtn').button('reset');154 setTimeout(function () {155 $('.alert').addClass('no-display');156 }, 3000);157 }, 1000);158 } else {159 $('#editLanguageBtn').button('reset');160 }161 });162 $(document).on('click', '.table-action-delete', function (e) {163 e.preventDefault();164 var row = $(this);165 var table = $(this).parents('table').DataTable();166 $('#confirm-delete-modal').modal({167 backdrop: 'static',168 keyboard: false169 }).one('click', '#confirm-delete', function (e) {170 table.row(row.parents('tr')).remove().draw();171 });172 });173 $(document).on('click', '.table-action-edit', function (e) {174 e.preventDefault();175 var id = $(this).data('id');176 $('#modal-language-edit').modal('show');177 });178 $(document).on('click', '#AddInfoStatusBtn', function (e) {179 e.preventDefault();180 $('#AddInfoStatusForm').submit();181 });182 $(document).on('click', '#editLanguageBtn', function (e) {183 e.preventDefault();184 $('#editLanguageForm').submit();185 });186};187$(function() {188 app.init();...
edit_ribbon.js
Source:edit_ribbon.js
1function installEditRibbon() {2 var ribbonDiv = document.getElementById("edit_ribbon");3 var textArea = document.getElementById("body");4 function insertExample(pluginDesc) {5 var selStart = textArea.selectionStart;6 var selEnd = textArea.selectionEnd;7 var oldValue = textArea.value;8 var oldScrollTop = textArea.scrollTop;9 if (pluginDesc.plugin_category == "spanhandler"10 && pluginDesc.example_spacing != ""11 && selStart != selEnd)12 {13 // replace selection14 var newValue =15 oldValue.substring(0, selStart) +16 pluginDesc.example_prefix + pluginDesc.example_spacing +17 oldValue.substring(selStart, selEnd) +18 pluginDesc.example_postfix;19 var pos = newValue.length;20 newValue = newValue +21 oldValue.substring(selEnd);22 textArea.value = newValue;23 textArea.selectionStart = textArea.selectionEnd = pos;24 } else {25 if (selStart == selEnd) {26 // insert full example27 var newValue =28 oldValue.substring(0, selStart) +29 pluginDesc.example_prefix;30 var pos1 = newValue.length;31 newValue = newValue +32 pluginDesc.example_spacing +33 pluginDesc.example_template;34 var pos2 = newValue.length;35 newValue = newValue +36 pluginDesc.example_postfix;37 var pos3 = newValue.length;38 newValue = newValue +39 oldValue.substring(selEnd);40 textArea.value = newValue;41 if (pos1 == pos2) {42 textArea.selectionStart = textArea.selectionEnd = pos3;43 } else {44 textArea.selectionStart = pos1;45 textArea.selectionEnd = pos2;46 }47 }48 }49 textArea.scrollTop = oldScrollTop;50 textArea.focus();51 }52 function addButton(pluginDesc, containerDiv) {53 var e = document.createElement("button");54 e.className = "ribbon_button";55 e.innerHTML = pluginDesc.friendly_name;56 e.onclick = function () { insertExample(pluginDesc); return false; };57 containerDiv.appendChild(e);58 }59 function newContainer() {60 var c = document.createElement("div");61 c.className = "ribbon_button_container";62 ribbonDiv.appendChild(c);63 return c;64 }65 function strcmp(a, b) {66 if (a == b) return 0;67 if (a < b) return -1;68 return 1;69 }70 function addPlugins(plugins) {71 var c = newContainer();72 plugins = plugins.slice();73 plugins.sort(function (a, b) { return strcmp(a.friendly_name, b.friendly_name); });74 for (var i = 0; i < plugins.length; i++) {75 addButton(plugins[i], c);76 }77 return c;78 }79 var blocklanguage_container = newContainer();80 var spanhandler_container = addPlugins(pluginDescriptions.spanhandlers);81 var sublanguage_container = addPlugins(pluginDescriptions.sublanguages);82 var headerPrefix = "\n\n";83 for (var i = 0; i < 4; i++) {84 headerPrefix = headerPrefix + "*";85 addButton({friendly_name: "H" + (i + 1),86 plugin_category: "blockstructure",87 example_prefix: headerPrefix,88 example_spacing: " ",89 example_template: "Heading Text",90 example_postfix: ""},91 blocklanguage_container);92 }93 addButton({friendly_name: "Unnumbered Item",94 plugin_category: "blockstructure",95 example_prefix: "\n -",96 example_spacing: " ",97 example_template: "unnumbered list item",98 example_postfix: ""},99 blocklanguage_container);100 addButton({friendly_name: "Numbered Item",101 plugin_category: "blockstructure",102 example_prefix: "\n #",103 example_spacing: " ",104 example_template: "numbered list item",105 example_postfix: ""},106 blocklanguage_container);107 textArea.selectionStart = textArea.selectionEnd = 0;108}...
treeProcessor.js
Source:treeProcessor.js
...20function isLanguageSupported (lang: ?string): boolean {21 return lang === 'auto' || hjs.getLanguage(lang)22}23function processListing (processor: Processor, block: Block): void {24 const lang = blockLanguage(block)25 let source = block.getSource()26 if (!isLanguageSupported(lang)) { return }27 let passthroughs28 if (removeSubstitution(block, 'macros')) {29 passthroughs = passthroughsSubs(processor, block)30 source = passthroughs.extract(source)31 }32 let callouts33 if (removeSubstitution(block, 'callouts')) {34 callouts = calloutsSubs(processor, block)35 source = callouts.extract(source)36 }37 // Apply subs before 'specialcharacters', keep subs after 'specialcharacters'.38 // We don't escape special characters, highlight.js will take care of it....
Using AI Code Generation
1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const blockLanguage = await page._delegate.blockLanguage();7 console.log(blockLanguage);8 await browser.close();9})();10const playwright = require('playwright');11(async () => {12 const browser = await playwright.chromium.launch();13 const context = await browser.newContext({ locale: 'fr' });14 const page = await context.newPage();15 const blockLanguage = await page._delegate.blockLanguage();16 console.log(blockLanguage);17 await browser.close();18})();19const playwright = require('playwright');20(async () => {21 const browser = await playwright.chromium.launch();22 const context = await browser.newContext({ locale: 'fr' });23 const page = await context.newPage();24 const blockLanguage = await page._delegate.blockLanguage();25 console.log(blockLanguage);26 await browser.close();27})();28const playwright = require('playwright');29(async () => {30 const browser = await playwright.chromium.launch();31 const context = await browser.newContext({ locale: 'en' });32 const page = await context.newPage();33 const blockLanguage = await page._delegate.blockLanguage();34 console.log(blockLanguage);35 await browser.close();36})();37const playwright = require('playwright');38(async () => {39 const browser = await playwright.chromium.launch();40 const context = await browser.newContext();41 const page = await context.newPage();42 const blockLanguage = await page._delegate.blockLanguage();43 console.log(blockLanguage);44 await browser.close();45})();46const playwright = require('playwright');47(async () => {48 const browser = await playwright.chromium.launch();49 const context = await browser.newContext();
Using AI Code Generation
1const { blockLanguage } = require('playwright');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 await page.blockLanguage('en');7 await page.screenshot({ path: 'example.png' });8 await browser.close();9})();10import { chromium } from 'playwright';11import { blockLanguage } from 'playwright';12(async () => {13 const browser = await chromium.launch();14 const page = await browser.newPage();15 await blockLanguage(page, 'en');16 await page.screenshot({ path: 'example.png' });17 await browser.close();18})();19from playwright.sync_api import chromium20from playwright._impl._api_types import Error21from playwright._impl._api_types import Page22browser = chromium.launch()23page = browser.newPage()24blockLanguage(page, 'en')25page.screenshot(path='example.png')26browser.close()27import com.microsoft.playwright.*;28public class Example {29 public static void main(String[] args) {30 try (Playwright playwright = Playwright.create()) {31 BrowserType chromium = playwright.chromium();32 Browser browser = chromium.launch();33 Page page = browser.newPage();34 page.blockLanguage("en");35 page.screenshot(new Page.ScreenshotOptions().setPath("example.png"));36 browser.close();37 }38 }39}40using Microsoft.Playwright;41using Microsoft.Playwright.NUnit;42using NUnit.Framework;43{44 {45 [PlaywrightTest("playwright.spec.ts", "should be able to block a specific language")]46 [Test, Timeout(TestConstants.DefaultTestTimeout)]47 public async Task ShouldBeAbleToBlockASpecificLanguage()48 {49 await Page.BlockLanguageAsync("
Using AI Code Generation
1const { blockLanguage } = require('@playwright/test');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 await page.screenshot({ path: `example.png` });7 await browser.close();8})();9const { blockLanguage } = require('@playwright/test');10module.exports = {11 use: {12 viewport: { width: 1280, height: 720 },13 language: blockLanguage('en'),14 },15};16import { blockLanguage } from '@playwright/test';17import { chromium } from 'playwright';18(async () => {19 const browser = await chromium.launch();20 const page = await browser.newPage();21 await page.screenshot({ path: `example.png` });22 await browser.close();23})();24import { blockLanguage } from '@playwright/test';25module.exports = {26 use: {27 viewport: { width: 1280, height: 720 },28 language: blockLanguage('en'),29 },30};31const { blockLanguage } = require('@playwright/test');32const { chromium } = require('play
Using AI Code Generation
1const { blockLanguage } = require('playwright/lib/server/browserContext');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const language = await blockLanguage(page);8 console.log(language);9 await browser.close();10})();11const { blockLanguages } = require('playwright/lib/server/browserContext');12const { chromium } = require('playwright');13(async () => {14 const browser = await chromium.launch();15 const context = await browser.newContext();16 const page = await context.newPage();17 const languages = await blockLanguages(page);18 console.log(languages);19 await browser.close();20})();21const { blockTranslators } = require('playwright/lib/server/browserContext');22const { chromium } = require('playwright');23(async () => {24 const browser = await chromium.launch();25 const context = await browser.newContext();26 const page = await context.newPage();27 const translators = await blockTranslators(page);28 console.log(translators);29 await browser.close();30})();
Using AI Code Generation
1const { blockLanguage } = require('playwright-internal');2const { chromium } = require('playwright-internal');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.blockLanguage('en-US');8 await page.screenshot({ path: `example.png` });9 await browser.close();10})();11 at processTicksAndRejections (internal/process/task_queues.js:93:5)12await page.blockLanguage('en-US', 'en-US');
Using AI Code Generation
1const { internal } = require('playwright');2const blockLanguage = internal.blockLanguage;3const { internal } = require('playwright');4const blockLanguage = internal.blockLanguage;5const { internal } = require('playwright');6const blockLanguage = internal.blockLanguage;7const { internal } = require('playwright');8const blockLanguage = internal.blockLanguage;9const { internal } = require('playwright');10const blockLanguage = internal.blockLanguage;11const { internal } = require('playwright');12const blockLanguage = internal.blockLanguage;13const { internal } = require('playwright');14const blockLanguage = internal.blockLanguage;15const { internal } = require('playwright');16const blockLanguage = internal.blockLanguage;17const { internal } = require('playwright');18const blockLanguage = internal.blockLanguage;19const { internal } = require('playwright');20const blockLanguage = internal.blockLanguage;
Using AI Code Generation
1const { blockLanguage } = require('@playwright/test');2const { page } = require('@playwright/test');3const { test } = require('@playwright/test');4test.describe('Language detection', () => {5 test.beforeEach(async ({ page }) => {6 });7 test('should detect language', async ({ page }) => {8 const language = await blockLanguage(page);9 console.log(language);10 });11});
Using AI Code Generation
1const { PlaywrightInternalAPI } = require('playwright-core/lib/server/playwright');2const api = new PlaywrightInternalAPI();3const blockLanguage = api.blockLanguage('chromium');4console.log(blockLanguage);5const { PlaywrightInternalAPI } = require('playwright-core/lib/server/playwright');6const api = new PlaywrightInternalAPI();7const blockLanguage = api.blockLanguage('webkit');8console.log(blockLanguage);9const { PlaywrightInternalAPI } = require('playwright-core/lib/server/playwright');10const api = new PlaywrightInternalAPI();11const blockLanguage = api.blockLanguage('firefox');12console.log(blockLanguage);13const { PlaywrightInternalAPI } = require('playwright-core/lib/server/playwright');14const api = new PlaywrightInternalAPI();15const blockLanguage = api.blockLanguage('foo');16console.log(blockLanguage);17const { PlaywrightInternalAPI } = require('playwright-core/lib/server/playwright');18const api = new PlaywrightInternalAPI();19const blockLanguage = api.blockLanguage();20console.log(blockLanguage);21const { PlaywrightInternalAPI } = require('playwright-core/lib/server/playwright');22const api = new PlaywrightInternalAPI();23const blockLanguage = api.blockLanguage(null);24console.log(blockLanguage);25const { PlaywrightInternalAPI } = require('playwright-core/lib/server/playwright');26const api = new PlaywrightInternalAPI();27const blockLanguage = api.blockLanguage(undefined);28console.log(blockLanguage);29const { PlaywrightInternalAPI } = require('playwright-core/lib/server/playwright');
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.
Get 100 minutes of automation test minutes FREE!!