Best JavaScript code snippet using playwright-internal
webcam_ar_tracking.js
Source:webcam_ar_tracking.js
1import { scan_content } from './modules/contentPages/scanpage.js';2import { NFTObject } from './nftObject.js';3import { videos } from './modules/contentPages/videopage.js';4var video = document.getElementById('tracking_video');5var useTracking = false;6var videoMetaLoaded = false;7export default function EnableTracking(enableVideo, enableTracking) {8 if(video.srcObject && videoMetaLoaded) {9 useTracking = enableTracking;10 video.srcObject.getTracks().forEach(t => t.enabled = enableVideo);11 if(enableTracking) MainLoop();12 } else {13 setTimeout(function () {14 EnableTracking(enableVideo, enableTracking);15 }, 200);16 }17}18var canvas_process = document.createElement('canvas');19var context_process = canvas_process.getContext('2d');20let base_nft_url = "./Data/DataNFT/";21let nft_objects = [22 "page_1",23 "page_2",24 "page_5",25 "page_7",26 "page_11",27 "page_14",28 "page_17",29 "page_18",30 "page_21",31];32let nft_tracker_objects = [];33function OnTriggerFound(e) {34 console.log(e);35 switch (e) {36 case "page_1":37 scan_content.ShowFoundPage(1, videos.vid5);38 break;39 case "page_2":40 scan_content.ShowFoundPage(2, videos.edit);41 break;42 case "page_5":43 scan_content.ShowFoundPage(5, videos.rio);44 break;45 case "page_7":46 scan_content.ShowFoundPage(7, videos.color);47 break;48 case "page_11":49 scan_content.ShowFoundPage(11, null);50 break;51 case "page_14":52 scan_content.ShowFoundPage(14, videos.vid7);53 break;54 case "page_17":55 scan_content.ShowFoundPage(17, null);56 break;57 case "page_18":58 scan_content.ShowFoundPage(18, null);59 break;60 case "page_21":61 scan_content.ShowFoundPage(21, null);62 break;63 default:64 break;65 }66}67var vw, vh;68var pw, ph;69var ox, oy;70var w, h;71var trackerIndex = 0;72function MainLoop() {73 context_process.fillStyle = "black";74 context_process.fillRect(0, 0, pw, ph);75 context_process.drawImage(video, 0, 0, vw, vh, ox, oy, w, h);76 const img_data = context_process.getImageData(0, 0, pw, ph);77 // one per frame smoother but getting match my take longer. 78 nft_tracker_objects[trackerIndex].Update(img_data);79 trackerIndex++;80 if(trackerIndex >= nft_tracker_objects.length) {81 trackerIndex = 0;82 }83 // all together in one frame and slow but instant 84 // nft_tracker_objects.forEach(tracker_object => {85 // if(tracker_object) {86 // tracker_object.Update(img_data);87 // }88 // });89 if(useTracking) requestAnimationFrame(MainLoop);90}91if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {92 var hint = {93 facingMode: {"ideal": "environment"},94 audio: false,95 video: {96 width: { ideal: window.innerWidth * 2 },97 height: { ideal: window.innerHeight * 2 },98 }99 };100 navigator.mediaDevices.getUserMedia({video: hint}).then(function (stream) {101 video.srcObject = stream;102 video.play();103 video.addEventListener("loadedmetadata", function() {104 105 videoMetaLoaded = true;106 107 var pscale;108 vw = video.videoWidth;109 vh = video.videoHeight;110 pscale = 320 / Math.max(vw, vh / 3 * 4);111 w = vw * pscale;112 h = vh * pscale;113 pw = Math.max(w, h / 3 * 4);114 ph = Math.max(h, w / 4 * 3);115 ox = (pw - w) / 2;116 oy = (ph - h) / 2;117 canvas_process.style.clientWidth = pw + "px";118 canvas_process.style.clientHeight = ph + "px";119 canvas_process.width = pw;120 canvas_process.height = ph;121 122 nft_objects.forEach(nft_object => {123 const url = base_nft_url + nft_object;124 let nft_tracker_object = new NFTObject(pw, ph, url, OnTriggerFound);125 nft_tracker_objects.push(nft_tracker_object);126 });127 EnableTracking(false, false);128 });129 });...
sharing_buttons.js
Source:sharing_buttons.js
1jQuery(document).ready(function() {2 jQuery('.wpurp-twitter').each(function(index, elem) {3 var btn = jQuery(elem);4 btn.sharrre({5 share: { twitter: true },6 buttons: {7 twitter: {8 count: jQuery(btn).data('layout'),9 lang: wpurp_sharing_buttons.twitter_lang10 }11 },12 enableHover: false,13 enableCounter: false,14 enableTracking: false15 });16 });17 jQuery('.wpurp-facebook').each(function(index, elem) {18 var btn = jQuery(elem);19 btn.sharrre({20 share: { facebook: true },21 buttons: {22 facebook: {23 action: 'like',24 layout: jQuery(btn).data('layout'),25 share: jQuery(btn).data('share'),26 lang: wpurp_sharing_buttons.facebook_lang27 }28 },29 enableHover: false,30 enableCounter: false,31 enableTracking: false32 });33 });34 jQuery('.wpurp-google').each(function(index, elem) {35 var btn = jQuery(elem);36 btn.sharrre({37 share: { googlePlus: true },38 buttons: {39 googlePlus: {40 size: jQuery(btn).data('layout'),41 annotation: jQuery(btn).data('annotation'),42 lang: wpurp_sharing_buttons.google_lang43 }44 },45 enableHover: false,46 enableCounter: false,47 enableTracking: false48 });49 });50 jQuery('.wpurp-pinterest').each(function(index, elem) {51 var btn = jQuery(elem);52 btn.sharrre({53 share: { pinterest: true },54 buttons: {55 pinterest: {56 media: jQuery(btn).data('media'),57 description: jQuery(btn).data('description'),58 config: jQuery(btn).data('layout')59 }60 },61 enableHover: false,62 enableCounter: false,63 enableTracking: false,64 click: function(api, options) {65 api.openPopup('pinterest');66 }67 });68 });69 jQuery('.wpurp-stumbleupon').each(function(index, elem) {70 var btn = jQuery(elem);71 btn.sharrre({72 share: { stumbleupon: true },73 buttons: {74 stumbleupon: {75 layout: jQuery(btn).data('layout')76 }77 },78 enableHover: false,79 enableCounter: false,80 enableTracking: false81 });82 });83 jQuery('.wpurp-linkedin').each(function(index, elem) {84 var btn = jQuery(elem);85 btn.sharrre({86 share: { linkedin: true },87 buttons: {88 linkedin: {89 counter: jQuery(btn).data('layout')90 }91 },92 enableHover: false,93 enableCounter: false,94 enableTracking: false95 });96 });...
home.js
Source:home.js
1/* Home page GUI Script */2$.GUI().create('Home', function ( gui ) {3 if ( !Modernizr.touch ) {4 $('body').addClass('no-touch');5 no_touch_screen = true;6 }7 function initBoxSlider () {8 gui.$(document).ready(function() {9 var $box, opts_1, opts_2, opts_3;10 $box = gui.$('.box');11 opts_1 = {12 speed: 1200,13 autoScroll: true,14 timeout: 5000,15 effect: 'scrollHorz3d'16 };17 opts_2 = {18 speed: 1200,19 timeout: 1800,20 autoScroll: true,21 effect: 'scrollHorz3d'22 };23 opts_3 = {24 speed: 1200,25 timeout: 6200,26 autoScroll: true,27 effect: 'scrollHorz3d'28 };29 $('.box-1').boxSlider(opts_1);30 $('.box-2').boxSlider(opts_2);31 $('.box-3').boxSlider(opts_3);32 });33 }34 function initSharePlugin () {35 /* Navigation Share Icons */36 $('#twitterNav').sharrre({37 share: {38 twitter: true39 },40 enableHover: false,41 enableTracking: true,42 buttons: { twitter: {via: 'CreativeTim'}},43 click: function(api, options){44 api.simulateClick();45 api.openPopup('twitter');46 },47 template: '<i class="fa fa-twitter"></i>'48 });49 $('#facebookNav').sharrre({50 share: {51 facebook: true52 },53 enableHover: false,54 enableTracking: true,55 click: function (api, options) {56 api.simulateClick();57 api.openPopup('facebook');58 },59 template: '<i class="fa fa-facebook"></i>'60 });61 $('#googleplusNav').sharrre({62 share: {63 googlePlus: true64 },65 urlCurl: '',66 enableHover: false,67 enableTracking: true,68 click: function (api, options) {69 api.simulateClick();70 api.openPopup('googlePlus');71 },72 template: '<i class="fa fa-google-plus"></i>'73 });74 /* Share Buttons */75 $('#facebook').sharrre({76 share: {77 facebook: true78 },79 enableHover: false,80 enableTracking: true,81 click: function(api, options){82 api.simulateClick();83 api.openPopup('facebook');84 },85 template: '<button class="btn btn-info btn-social btn-neutral btn-block"><i class="fa fa-facebook-square"></i> Facebook · {total}</button>'86 });87 $('#googleplus').sharrre({88 share: {89 googlePlus: true90 },91 urlCurl: '',92 enableHover: false,93 enableTracking: true,94 click: function (api, options) {95 api.simulateClick();96 api.openPopup('googlePlus');97 },98 template: '<button class="btn btn-info btn-social btn-neutral btn-block"><i class="fa fa-google-plus-square"></i> Google+ · {total}</button>'99 });100 }101 return {102 load: function () {103 gui.log('Load method called in home.js :', TDella);104 initBoxSlider();105 initSharePlugin();106 TDella.onMouseMove();107 },108 unload: function () {109 gui.log('tdella unload method called');110 }111 };112});...
scanpage.js
Source:scanpage.js
1import { UpdateAppState } from '../updateAppState.js';2import Display from '../helperFunctions.js';3import { ShowPopup, HidePopup } from '../popup.js';4import EnableTracking from '../../webcam_ar_tracking.js';5import states from '../appStates.js';6import {clouds, clouds_manager } from '../clouds_manager.js';7import { video_content } from './videopage.js';8let scan_content = {9 container: document.getElementById("scan_view"),10 scanning: document.getElementsByClassName("scanning"),11 found_page: document.getElementById("found_page_text"),12 scan_succes: document.getElementById("scan_succes"),13 Show(callBack) {14 Display(true, this.container);15 EnableTracking(true, false);16 clouds_manager.hideClouds(clouds.top_left, clouds.top_right, clouds.mid_left, clouds.mid_right, clouds.bottom_center);17 ShowPopup(1, "¡Enfoca el libro con la cámara!", 'Apunta al Ãcono <img id="scan-phone-icon" src="Data/Frontend/Images/General/phone-icon.png"> y descubre la sorpresa escondida en esta página.', 1, function() {18 EnableTracking(true, true);19 scan_content.DisplayScanBanner(true);20 scanfailtimeout = setTimeout(function() {21 clearTimeout(scanfailtimeout);22 EnableTracking(true, false);23 scan_content.DisplayScanBanner(false);24 ShowPopup(1, 'Página no detectada', 'No se ha podido escanear el Ãcono de Kiddi App <img id="scan-phone-icon" src="Data/Frontend/Images/General/phone-icon.png">. ¿Necesitas ayuda?', 2, null);25 }, scanfailpopupdelay)26 });27 if(callBack) callBack();28 }, 29 Hide(callBack) {30 if(scanfailtimeout) {31 clearTimeout(scanfailtimeout); 32 }33 HidePopup();34 this.DisplayScanBanner(false);35 Display(false, this.scan_succes);36 Display(false, this.container);37 EnableTracking(false, false);38 if(callBack) callBack();39 },40 41 DisplayScanBanner(show) {42 for (let i = 0; i < this.scanning.length; i++) {43 const element = this.scanning[i];44 Display(show, element);45 }46 }, 47 ShowFoundPage(page_num, optionalData) {48 if(scanfailtimeout) clearTimeout(scanfailtimeout); 49 EnableTracking(true, false);50 this.DisplayScanBanner(false);51 this.found_page.innerHTML = ("Página " + page_num.toString());52 Display(true, this.scan_succes);53 setTimeout(function() { 54 switch (page_num) {55 case 1:56 case 2:57 case 5:58 case 7:59 case 14:60 UpdateAppState(states.Video);61 if(optionalData != null) video_content.SetAndPlayVideoSource(optionalData);62 break;63 case 11:64 UpdateAppState(states.CardGame);65 break;66 case 17:67 UpdateAppState(states.PaintingCharacterSelection);68 break;69 case 18:70 UpdateAppState(states.Answers);71 break;72 case 21:73 UpdateAppState(states.Information);74 break;75 }76 }, 1000);77 }78}...
start.js
Source:start.js
1function startShare() {2 $('.twitter').sharrre({3 share: {4 twitter: true5 },6 enableHover: false,7 enableTracking: true,8 buttons: { twitter: {via: '_JulienH'}},9 click: function(api, options){10 api.simulateClick();11 api.openPopup('twitter');12 }13 });14 $('.facebook').sharrre({15 share: {16 facebook: true17 },18 enableHover: false,19 enableTracking: true,20 click: function(api, options){21 api.simulateClick();22 api.openPopup('facebook');23 }24 });25 $('.googleplus').sharrre({26 share: {27 googlePlus: true28 },29 enableHover: false,30 enableTracking: true,31 urlCurl : 'kernel/lib/xorg/jQuery/plugin/sharrre/sharrre.php',32 click: function(api, options){33 api.simulateClick();34 api.openPopup('googlePlus');35 }36 });37 $('.stumbleupon').sharrre({38 share: {39 stumbleupon: true40 },41 enableHover: false,42 enableTracking: true,43 urlCurl : 'kernel/lib/xorg/jQuery/plugin/sharrre/sharrre.php',44 click: function(api, options){45 api.simulateClick();46 api.openPopup('stumbleupon');47 }48 });49 $('.delicious').sharrre({50 share: {51 delicious: true52 },53 enableHover: false,54 enableTracking: true,55// urlCurl : 'kernel/lib/xorg/jQuery/plugin/sharrre/sharrre.php',56 click: function(api, options){57 api.simulateClick();58 api.openPopup('delicious');59 }60 });61 $('.linkedin').sharrre({62 share: {63 linkedin: true64 },65 enableHover: false,66 enableTracking: true,67// urlCurl : 'kernel/lib/xorg/jQuery/plugin/sharrre/sharrre.php',68 click: function(api, options){69 api.simulateClick();70 api.openPopup('linkedin');71 }72 });73 $('.pinterest').sharrre({74 share: {75 pinterest: true76 },77 enableHover: false,78 enableTracking: true,79 urlCurl : 'kernel/lib/xorg/jQuery/plugin/sharrre/sharrre.php',80 click: function(api, options){81 api.simulateClick();82 api.openPopup('pinterest');83 }84 });...
jquery.sharrre.config.js
Source:jquery.sharrre.config.js
1$j(function(){2 $j('#twitter').sharrre({3 share: {4 twitter: true5 },6 template: '<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><i class="fa fa-twitter"></i></div></a>',7 enableHover: false,8 enableTracking: true,9 buttons: { twitter: {via: 'thevirginhair'}},10 click: function(api, options){11 api.simulateClick();12 api.openPopup('twitter');13 }14 });15 $j('#facebook').sharrre({16 share: {17 facebook: true18 },19 template: '<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><i class="fa fa-facebook"></i></div></a>',20 enableHover: false,21 enableTracking: true,22 click: function(api, options){23 api.simulateClick();24 api.openPopup('facebook');25 }26 });27 $j('#googleplus').sharrre({28 share: {29 googlePlus: true30 },31 template: '<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><i class="fa fa-google"></i></div></a>',32 enableHover: false,33 enableTracking: true,34 urlCurl: '/skin/frontend/rwd/tvhf/js/lib/sharrre.php',35 click: function(api, options){36 api.simulateClick();37 api.openPopup('googlePlus');38 }39 });40 $j('#pinterest').sharrre({41 share: {42 pinterest: true43 },44 template: '<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><i class="fa fa-pinterest"></i></div></a>',45 enableHover: false,46 enableTracking: true,47 click: function(api, options){48 api.simulateClick();49 api.openPopup('pinterest');50 }51 });52 ...
enableTracking.js
Source:enableTracking.js
...28 });29 it('does nothing if tracking is not allowed', async () => {30 config.trackingAllowed = false;31 config.trackingEnabled = false;32 await enableTracking();33 expect(config.trackingEnabled).toStrictEqual(false);34 });35 it('enqueues tracking script if tracking is allowed', async () => {36 config.trackingAllowed = true;37 config.trackingEnabled = false;38 await enableTracking();39 expect(config.trackingEnabled).toStrictEqual(true);40 const result = document.querySelector(`script[data-web-stories-tracking]`);41 expect(result).not.toBeNull();42 });...
sharrre_script.js
Source:sharrre_script.js
1$(document).ready(function() {2 $('.sharrre-container #twitter').sharrre({3 share: {4 twitter: true5 },6 template: '<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span></span>Tweet</div></a>',7 enableHover: false,8 enableTracking: true,9 buttons: { twitter: {via: '_JulienH'}},10 click: function(api, options){11 api.simulateClick();12 api.openPopup('twitter');13 }14 });15 $('.sharrre-container #facebook').sharrre({16 share: {17 facebook: true18 },19 template: '<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span></span>Tweet</div></a>',20 enableHover: false,21 enableTracking: true,22 click: function(api, options){23 api.simulateClick();24 api.openPopup('facebook');25 }26 });27 $('.sharrre-container #googleplus').sharrre({28 share: {29 googlePlus: true30 },31 template: '<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span></span>Tweet</div></a>',32 enableHover: false,33 enableTracking: true,34 click: function(api, options){35 api.simulateClick();36 api.openPopup('googlePlus');37 }38 });...
Using AI Code Generation
1const { enableTracking } = require('playwright-core/lib/server/trace/recorder/recorderApp');2enableTracking();3const { enableTracing } = require('playwright-core/lib/server/trace/recorder/recorderApp');4enableTracing();5const { enableRecording } = require('playwright-core/lib/server/trace/recorder/recorderApp');6enableRecording();7const { disableRecording } = require('playwright-core/lib/server/trace/recorder/recorderApp');8disableRecording();9const { disableTracing } = require('playwright-core/lib/server/trace/recorder/recorderApp');10disableTracing();11const { disableTracking } = require('playwright-core/lib/server/trace/recorder/recorderApp');12disableTracking();13const { startRecording } = require('playwright-core/lib/server/trace/recorder/recorderApp');14startRecording();15const { stopRecording } = require('playwright-core/lib/server/trace/recorder/recorderApp');16stopRecording();17const { stopTracing } = require('playwright-core/lib/server/trace/recorder/recorderApp');18stopTracing();19const { stopTracking } = require('playwright-core/lib/server/trace/recorder/recorderApp');20stopTracking();21const { startTracing } = require('playwright-core/lib/server/trace/recorder/recorderApp');22startTracing();23const { startTracking } = require('playwright-core/lib/server/trace/recorder/recorderApp');24startTracking();25const { getRecording } = require('playwright-core/lib/server/trace/recorder/recorderApp');26getRecording();27const { get
Using AI Code Generation
1const { Playwright } = require('playwright-internal');2const playwright = new Playwright();3const browser = await playwright.chromium.launch();4const context = await browser.newContext();5const page = await context.newPage();6await page.enableTracking();7const trace = await page.stopTracing();8fs.writeFileSync('trace.json', JSON.stringify(trace, null, 2));9await browser.close();10{11 {12 "args": {13 "data": {14 {15 }16 }17 }18 },19 {20 "args": {21 "data": {22 }23 }24 },25 {26 "args": {27 "data": {28 }29 }30 },31 {32 "args": {33 "data": {
Using AI Code Generation
1const { enableTracking } = require('playwright/lib/utils/trace');2enableTracking();3const { enableTracing } = require('playwright/lib/utils/trace');4enableTracing();5const { enableDebugging } = require('playwright/lib/utils/trace');6enableDebugging();7const { enableDebugging } = require('playwright/lib/utils/trace');8enableDebugging();9const { enableDebugging } = require('playwright/lib/utils/trace');10enableDebugging();11const { enableDebugging } = require('playwright/lib/utils/trace');12enableDebugging();13const { enableDebugging } = require('playwright/lib/utils/trace');14enableDebugging();15const { enableDebugging } = require('playwright/lib/utils/trace');16enableDebugging();17const { enableDebugging } = require('playwright/lib/utils/trace');18enableDebugging();19const { enableDebugging } = require('playwright/lib/utils/trace');20enableDebugging();21const { enableDebugging } = require('playwright/lib/utils/trace');22enableDebugging();23const { enableDebugging } = require('playwright/lib/utils/trace');24enableDebugging();25const { enableDebugging } = require('playwright/lib/utils/trace');26enableDebugging();27const { enableDebugging } = require('playwright/lib/utils/trace');28enableDebugging();29const { enableDebugging } = require('playwright/lib/utils/trace');30enableDebugging();
Using AI Code Generation
1const {enableTracking} = require('@playwright/test/lib/server/trace/recorder/recorderApp');2enableTracking();3const { test, expect } = require('@playwright/test');4test('should work', async ({ page }) => {5 await page.tracing.start({ screenshots: true, snapshots: true });6 await page.tracing.stop({ path: 'trace.zip' });7});8### `enableTracking(options)`
Using AI Code Generation
1const { enableTracking } = require('playwright/lib/internal/recorder/recorderApp');2enableTracking({3});4const { chromium } = require('playwright');5(async () => {6 const browser = await chromium.launch();7 const context = await browser.newContext();8 const page = await context.newPage();9 await page.close();10 await context.close();11 await browser.close();12})();13const { test, expect } = require('@playwright/test');14test('basic test', async ({ page }) => {15 const title = page.locator('.navbar__inner .navbar__title');16 expect(await title.innerText()).toBe('Playwright');17});18const { test, expect } = require('@playwright/test');19test('basic test', async ({ page }) => {20 const title = page.locator('.navbar__inner .navbar__title');21 expect(await title.innerText()).toBe('Playwright');22});23const { test, expect } = require('@playwright/test');24test('basic test', async ({ page }) => {25 const title = page.locator('.navbar__inner .navbar__title');26 expect(await title.innerText()).toBe('Playwright');27});28const { test, expect } = require('@playwright/test');29test('basic test', async ({ page }) => {30 const title = page.locator('.navbar__inner .navbar__title');31 expect(await title.innerText()).toBe('Playwright');32});33const { test, expect } = require('@playwright/test');34test('basic test', async ({ page }) => {
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!!