Best JavaScript code snippet using wpt
HiHo.js
Source:HiHo.js
1/* eslint-disable no-undef, no-unused, no-unused-vars */2class HiHoSign {3 constructor() {4 this.nL = 0;5 }6 increment() {7 this.step = this.step + 1;8 if (SwitchSign) this.step = 0;9 }1011 render(signTime) {12 background(0);13 var Ocenter = [windowWidth / 2, windowHeight / 2];14 var WW = min(windowHeight * (3 / 2), windowWidth) * 0.9;15 var WH = (WW * 2) / 3;16 push();17 translate(Ocenter[0], Ocenter[1]);18 noFill();19 var rectLines = [0, 0.15, 0.2, 0.5, 0.55, 0.85, 0.9, 1];20 var boardText = [21 "",22 "MERRITT PARKWAY",23 "",24 "MOTEL",25 "",26 "HI-HO",27 "",28 "RESTAURANT COCKTAIL LOUNGE"29 ];30 var textSz = [20, 30, 120, 5, 5, 5, 120, 30, 120];31 textAlign(CENTER);32 for (var j = 1; j < 8; j++) {33 Flicker = !Flicker;34 var rowText = boardText[j];35 textSize(WW / textSz[j]);36 var Yvar = [(rectLines[j] - 0.5) * WH, (rectLines[j - 1] - 0.5) * WH];37 Yvar[2] = 0.5 * (Yvar[0] + Yvar[1]);38 var StrLen = boardText[j].length;39 var Xwide = WW / StrLen;4041 for (var k = 0; k < StrLen; k++) {42 var Xvar = [-WW / 2 + k * Xwide, -WW / 2 + (k + 1) * Xwide];43 Xvar[2] = 0.5 * (Xvar[0] + Xvar[1]);44 push();45 if (j === 5)46 Xvar[2] = Xvar[2] - Xwide * [-0.4, -0.15, +0.2, 0.35, 0.35][k];4748 translate(Xvar[2], Yvar[2]); // ellipse(0, 0, 1);49 stroke(220, 3, 9);50 strokeWeight(WW / 600);51 var XwideHalf = (Xvar[1] - Xvar[0]) / 2;52 var Yhite = Yvar[1] - Yvar[0];53 var Xrite = XwideHalf * 0.5;54 var Xleft = -Xrite;55 var Ytop = Yhite * 0.38;56 var Ybot = -Ytop;57 if (j === 3 || j === 5) {58 if (rowText[k] === "E")59 drawHiHoE(WW, Ybot, Ytop, Xleft, Xrite, signTime);60 if (rowText[k] === "L")61 drawHiHoL(WW, Ybot, Ytop, Xleft, Xrite, signTime);62 if (rowText[k] === "M")63 drawHiHoM(WW, Ybot, Ytop, Xleft, Xrite, signTime);64 if (rowText[k] === "H")65 drawHiHoH(WW, Ybot, Ytop, Xleft, Xrite, j, signTime, k);66 if (rowText[k] === "O")67 drawHiHoO(WW, Ybot, Ytop, Xleft, Xrite, j, signTime);68 if (rowText[k] === "T")69 drawHiHoT(WW, Ybot, Ytop, Xleft, Xrite, signTime);70 if (rowText[k] === "I")71 drawHiHoI(WW, Ybot, Ytop, Xleft, Xrite, signTime);72 if (rowText[k] === "-")73 drawHiHoDash(WW, Ybot, Ytop, Xleft, Xrite, signTime);74 }75 if (j !== 3 && j !== 5) {76 push();77 stroke(250);78 fill(250);79 translate(0, (Yvar[0] - Yvar[2]) * 0.25);80 text(rowText[k], 0, 0);81 pop();82 }83 pop();84 }85 }86 pop();87 }88}8990function setRedLetterSizeStroke(j, WW) {91 var ColorSpike = (j + 2) % 4;92 var baseColor = 200 + (random() < 0.5) * 55;93 stroke(baseColor, baseColor * ColorSpike, baseColor * ColorSpike);94 var baseW = 700 + ColorSpike * 200;95 strokeWeight(WW / (200 + ColorSpike * baseW));96}97function drawHiHoT(WW, Ybot, Ytop, Xleft, Xrite, signTime) {98 for (j = 0; j < 7; j = j + 2) {99 var EpsilonW = (j * WW) / 400;100 var EpsilonH = (j * WW) / 496;101 setRedLetterSizeStroke(j, WW);102 noFill();103 // if (j === 2 && 2 === signTime[1] % 5) fill(150);104105 beginShape();106 vertex(EpsilonW, Ybot + EpsilonH);107 vertex(-EpsilonW, Ybot + EpsilonH);108 vertex(-EpsilonW, Ytop + EpsilonH);109 vertex(Xleft - EpsilonW, Ytop + EpsilonH); /// C110 vertex(Xleft - EpsilonW, Ytop - EpsilonH); /// C111 vertex(Xrite + EpsilonW, Ytop - EpsilonH); /// C112 vertex(Xrite + EpsilonW, Ytop + EpsilonH); /// C113 vertex(+EpsilonW, Ytop + EpsilonH);114 endShape(CLOSE);115 }116}117118function drawHiHoI(WW, Ybot, Ytop, Xleft, Xrite, signTime) {119 for (j = 0; j < 7; j = j + 2) {120 var EpsilonW = (j * WW) / 400;121 var EpsilonH = (j * WW) / 496;122 setRedLetterSizeStroke(j, WW);123 noFill();124 if (j === 2 && 2 === signTime[1] % 5) fill(250);125126 beginShape();127 vertex(EpsilonW, Ybot + EpsilonH);128 vertex(EpsilonW, Ytop - EpsilonH);129 vertex(-EpsilonW, Ytop - EpsilonH);130 vertex(-EpsilonW, Ybot + EpsilonH);131132 endShape(CLOSE);133 }134}135136function drawHiHoM(WW, Ybot, Ytop, Xleft, Xrite, signTime) {137 Xleft = Xleft * 1.25;138 Xrite = Xrite * 1.25;139 for (j = 0; j < 7; j = j + 2) {140 setRedLetterSizeStroke(j, WW);141 noFill();142 // if (j === 2 && 0 === signTime[1] % 5) fill(150);143 var EpsilonW = (j * WW) / 400;144 var EpsilonH = (j * WW) / 496;145146 beginShape();147 vertex(Xleft + EpsilonW, Ybot + EpsilonH); /// A148 vertex(Xleft - EpsilonW, Ybot + EpsilonH); /// B149 vertex(Xleft - EpsilonW, Ytop - EpsilonH); /// C150 vertex(Xleft + EpsilonW, Ytop - EpsilonH); /// D151 vertex(0, Ybot - 3 * EpsilonH); ///152153 vertex(Xrite - EpsilonW, Ytop - EpsilonH); /// G154 vertex(Xrite + EpsilonW, Ytop - EpsilonH); /// H155 vertex(Xrite + EpsilonW, Ybot + EpsilonH); /// I156 vertex(Xrite - EpsilonW, Ybot + EpsilonH); /// J157158 vertex(Xrite - EpsilonW, Ytop + 6 * EpsilonH); /// J159 vertex(EpsilonW, Ybot + EpsilonH); ///160 vertex(-EpsilonW, Ybot + EpsilonH); ///161 vertex(Xleft + EpsilonW, Ytop + 6 * EpsilonH); /// J162163 endShape(CLOSE);164 }165}166167function drawHiHoL(WW, Ybot, Ytop, Xleft, Xrite, signTime) {168 for (j = 0; j < 7; j = j + 2) {169 setRedLetterSizeStroke(j, WW);170171 var EpsilonW = (j * WW) / 400;172 var EpsilonH = (j * WW) / 496;173 noFill();174 // if (j === 2 && 4 === signTime[1] % 5) fill(150);175176 beginShape();177 vertex(Xrite + EpsilonW, Ybot + EpsilonH); /// I178 vertex(Xleft - EpsilonW, Ybot + EpsilonH); /// B179 vertex(Xleft - EpsilonW, Ytop - EpsilonH); /// C180 vertex(Xleft + EpsilonW, Ytop - EpsilonH); /// D181 vertex(Xleft + EpsilonW, Ybot - EpsilonH); /// M182 vertex(Xrite + EpsilonW, Ybot - EpsilonH); /// I183 endShape(CLOSE);184 }185}186187function drawHiHoE(WW, Ybot, Ytop, Xleft, Xrite, signTime) {188 for (j = 0; j < 7; j = j + 2) {189 var EpsilonW = (j * WW) / 400;190 var EpsilonH = (j * WW) / 496;191192 setRedLetterSizeStroke(j, WW);193 noFill();194 // if (j === 2 && 3 === signTime[1] % 5) fill(150);195196 beginShape();197 vertex(Xrite + EpsilonW, Ybot + EpsilonH); /// I198 vertex(Xleft - EpsilonW, Ybot + EpsilonH); /// B199 vertex(Xleft - EpsilonW, Ytop - EpsilonH); /// C200 vertex(Xrite + EpsilonW, Ytop - EpsilonH); /// H201 vertex(Xrite + EpsilonW, Ytop + EpsilonH); /// P202 vertex(Xleft + EpsilonW, Ytop + EpsilonH); /// Q203 vertex(Xleft + EpsilonW, -EpsilonH); /// E204 vertex(Xrite + EpsilonW, -EpsilonH); /// F Prime205 vertex(Xrite + EpsilonW, +EpsilonH); /// K206 vertex(Xleft + EpsilonW, +EpsilonH); /// L207 vertex(Xleft + EpsilonW, Ybot - EpsilonH); /// M208 vertex(Xrite + EpsilonW, Ybot - EpsilonH); /// I Prime209210 endShape(CLOSE);211 }212}213214function drawHiHoO(WW, Ybot, Ytop, Xleft, Xrite, topBot, signTime) {215 JJ = 15;216 setRedLetterSizeStroke(-2, WW);217218 var EpsilonW = (+JJ * WW) / 400;219 var EpsilonH = (-8 * WW) / 596;220 beginShape();221 vertex(EpsilonW, Ybot + EpsilonH);222 vertex(EpsilonW, Ytop - EpsilonH);223 vertex(-EpsilonW, Ytop - EpsilonH);224 vertex(-EpsilonW, Ybot + EpsilonH);225 endShape(CLOSE);226 for (j = 2; j < 13; j = j + 2) {227 setRedLetterSizeStroke(j - 2, WW);228 noFill();229 if (topBot === 5 && j === 6 && 4 === signTime[1] % 5) {230 stroke(250);231 var ColorSpike = (6 + 2) % 4;232 var baseW = 700 + ColorSpike * 200;233 strokeWeight(WW / (200 + ColorSpike * baseW));234 }235236 EpsilonW = ((j + JJ) * WW) / 400;237 EpsilonH = ((j - 4) * WW) / 496;238 rect(-EpsilonW, Ytop - EpsilonH, 2 * EpsilonW, 2 * (Ybot + EpsilonH), 15);239 }240}241242function drawHiHoDash(WW, Ybot, Ytop, Xleft, Xrite, signTime) {243 for (j = 0; j < 7; j = j + 2) {244 setRedLetterSizeStroke(j, WW);245 noFill();246 if (j === 4 && 0 === signTime[1] % 5) fill(250);247248 var EpsilonW = (j * WW) / 400;249 var EpsilonH = (j * WW) / 496;250251 beginShape();252 vertex(EpsilonW - Xleft / 2, EpsilonH);253 vertex(EpsilonW - Xleft / 2, -EpsilonH);254 vertex(-EpsilonW + Xleft / 2, -EpsilonH);255 vertex(-EpsilonW + Xleft / 2, +EpsilonH);256257 endShape(CLOSE);258 }259}260261function drawHiHoH(WW, Ybot, Ytop, Xleft, Xrite, minInd, signTime, k) {262 for (j = 0; j < 7; j = j + 2) {263 setRedLetterSizeStroke(j, WW);264 noFill();265 var ppp = k === 0 && 1 === signTime[1] % 5;266 var ddd = k === 3 && 3 === signTime[1] % 5;267 if (j === 2 && (ppp || ddd)) fill(250);268269 var EpsilonW = (j * WW) / 400;270 var EpsilonH = (j * WW) / 496;271272 beginShape();273 vertex(Xleft + EpsilonW, Ybot + EpsilonH);274 vertex(Xleft - EpsilonW, Ybot + EpsilonH);275 vertex(Xleft - EpsilonW, Ytop - EpsilonH);276 vertex(Xleft + EpsilonW, Ytop - EpsilonH);277 vertex(Xleft + EpsilonW, -EpsilonH);278 vertex(Xrite - EpsilonW, -EpsilonH);279 vertex(Xrite - EpsilonW, Ytop - EpsilonH);280 vertex(Xrite + EpsilonW, Ytop - EpsilonH);281 vertex(Xrite + EpsilonW, Ybot + EpsilonH);282 vertex(Xrite - EpsilonW, Ybot + EpsilonH);283 vertex(Xrite - EpsilonW, +EpsilonH);284 vertex(Xleft + EpsilonW, +EpsilonH);285 endShape(CLOSE);286 }
...
gruntfile.js
Source:gruntfile.js
1'use strict';2module.exports = function( grunt ) {3 // load all tasks4 require( 'load-grunt-tasks' )( grunt, { scope: 'devDependencies' } );5 grunt.util.linefeed = '\n';6 grunt.initConfig( {7 pkg: grunt.file.readJSON( 'package.json' ),8 dirs: {9 css: 'assets/css',10 js: 'assets/js'11 },12 concat: {13 epsilonFramework: {14 src: [15 'assets/vendors/epsilon-framework/customizer/components/epsilon-object.js',16 'assets/vendors/epsilon-framework/customizer/components/controls/repeater/repeater-object.js',17 'assets/vendors/epsilon-framework/customizer/components/controls/section-repeater/section-repeater-object.js',18 'assets/vendors/epsilon-framework/customizer/components/controls/**/*.js',19 'assets/vendors/epsilon-framework/customizer/components/sections/**/*.js',20 'assets/vendors/epsilon-framework/customizer/components/panels/**/*.js',21 'assets/vendors/epsilon-framework/customizer/components/wp-customize-extenders/**/*.js',22 'assets/vendors/epsilon-framework/customizer/epsilon.js',23 '!assets/vendors/epsilon-framework/customizer/epsilon.min.js',24 '!assets/vendors/epsilon-framework/customizer/epsilon-concat.js'25 ],26 dest: 'assets/js/epsilon.js'27 },28 epsilonAdmin: {29 src: [30 'assets/vendors/epsilon-framework/admin/components/epsilon-admin-object.js',31 'assets/vendors/epsilon-framework/admin/**/*.js',32 'assets/vendors/epsilon-framework/admin/epsilon-admin.js',33 '!assets/vendors/epsilon-framework/admin/epsilon-admin.min.js',34 '!assets/vendors/epsilon-framework/admin/epsilon-admin-concat.js'35 ],36 dest: 'assets/js/epsilon-admin.js'37 },38 epsilonPreviewer: {39 src: [40 'assets/vendors/epsilon-framework/previewer/components/epsilon-previewer-object.js',41 'assets/vendors/epsilon-framework/previewer/**/*.js',42 'assets/vendors/epsilon-framework/previewer/epsilon-previewer.js',43 '!assets/vendors/epsilon-framework/previewer/epsilon-previewer.min.js',44 '!assets/vendors/epsilon-framework/previewer/epsilon-previewer-concat.js'45 ],46 dest: 'assets/js/epsilon-previewer.js'47 },48 },49 uglify: {50 epsilon: {51 options: {52 sourceMap: false,53 sourceMapName: 'sourceMap.map'54 },55 src: [ 'assets/js/epsilon.js', '!assets/js/epsilon.min.js' ],56 dest: 'assets/js/epsilon.min.js'57 },58 epsilonAdmin: {59 options: {60 sourceMap: false,61 sourceMapName: 'sourceMap.map'62 },63 src: [ 'assets/js/epsilon-admin.js', '!assets/js/epsilon-admin.min.js' ],64 dest: 'assets/js/epsilon-admin.min.js'65 },66 epsilonPreviewer: {67 options: {68 sourceMap: false,69 sourceMapName: 'sourceMap.map'70 },71 src: [ 'assets/js/epsilon-previewer.js', '!assets/js/epsilon-previewer.min.js' ],72 dest: 'assets/js/epsilon-previewer.min.js'73 }74 },75 sass: {76 dist: {77 options: {78 style: 'expanded',79 sourcemap: 'none',80 },81 files: [82 {83 expand: true,84 cwd: 'assets/css/',85 src: [ '*.scss' ],86 dest: 'assets/css/',87 ext: '.css'88 } ]89 }90 }91 } );92 grunt.config( 'watch', {93 scss: {94 tasks: [ 'sass:dist' ],95 files: [96 'assets/css/*.scss',97 'assets/css/**/*.scss',98 'assets/css/**/**/*.scss',99 ]100 }101 } );102 grunt.event.on( 'watch', function( action, filepath ) {103 // Determine task based on filepath104 var get_ext = function( path ) {105 var ret = '';106 var i = path.lastIndexOf( '.' );107 if ( - 1 !== i && i <= path.length ) {108 ret = path.substr( i + 1 );109 }110 return ret;111 };112 switch ( get_ext( filepath ) ) {113 // PHP114 case 'php' :115 //grunt.config('paths.php.files', [ filepath ]);116 break;117 // JavaScript118 case 'js' :119 grunt.config( 'paths.js.files', [ filepath ] );120 break;121 }122 } );123 grunt.registerTask( 'startSass', [124 'sass'125 ] );126 // Concatenate Epsilon127 grunt.registerTask( 'concat-epsilon', [128 'concat:epsilonFramework',129 'concat:epsilonAdmin',130 'concat:epsilonPreviewer',131 'uglify:epsilon',132 'uglify:epsilonAdmin',133 'uglify:epsilonPreviewer'134 ] );...
Using AI Code Generation
1var wptools = require('wptools');2var fs = require('fs');3var jsonfile = require('jsonfile');4var file = 'wikipedia.json';5var file2 = 'wikipedia2.json';6var file3 = 'wikipedia3.json';7var file4 = 'wikipedia4.json';8var file5 = 'wikipedia5.json';9var file6 = 'wikipedia6.json';10var file7 = 'wikipedia7.json';11var file8 = 'wikipedia8.json';12var file9 = 'wikipedia9.json';13var file10 = 'wikipedia10.json';14var file11 = 'wikipedia11.json';15var file12 = 'wikipedia12.json';16var file13 = 'wikipedia13.json';17var file14 = 'wikipedia14.json';18var file15 = 'wikipedia15.json';19var file16 = 'wikipedia16.json';20var file17 = 'wikipedia17.json';21var file18 = 'wikipedia18.json';22var file19 = 'wikipedia19.json';23var file20 = 'wikipedia20.json';24var file21 = 'wikipedia21.json';25var file22 = 'wikipedia22.json';26var file23 = 'wikipedia23.json';27var file24 = 'wikipedia24.json';28var file25 = 'wikipedia25.json';29var file26 = 'wikipedia26.json';30var file27 = 'wikipedia27.json';31var file28 = 'wikipedia28.json';32var file29 = 'wikipedia29.json';33var file30 = 'wikipedia30.json';34var file31 = 'wikipedia31.json';35var file32 = 'wikipedia32.json';36var file33 = 'wikipedia33.json';37var file34 = 'wikipedia34.json';38var file35 = 'wikipedia35.json';39var file36 = 'wikipedia36.json';40var file37 = 'wikipedia37.json';41var file38 = 'wikipedia38.json';42var file39 = 'wikipedia39.json';43var file40 = 'wikipedia40.json';44var file41 = 'wikipedia41.json';45var file42 = 'wikipedia42.json';46var file43 = 'wikipedia43.json';47var file44 = 'wikipedia44.json';48var file45 = 'wikipedia45.json';49var file46 = 'wikipedia46.json';
Using AI Code Generation
1var wpt = require('wptools');2var page = wpt.page('Wikipedia');3page.get(function(err, resp) {4 console.log(resp);5});6var wpt = require('wptools');7var page = wpt.page('Wikipedia');8page.get(function(err, resp) {9 console.log(resp);10});11var wpt = require('wptools');12var page = wpt.page('Wikipedia');13page.get(function(err, resp) {14 console.log(resp);15});16var wpt = require('wptools');17var page = wpt.page('Wikipedia');18page.get(function(err, resp) {19 console.log(resp);20});21var wpt = require('wptools');22var page = wpt.page('Wikipedia');23page.get(function(err, resp) {24 console.log(resp);25});26var wpt = require('wptools');27var page = wpt.page('Wikipedia');28page.get(function(err, resp) {29 console.log(resp);30});31var wpt = require('wptools');32var page = wpt.page('Wikipedia');33page.get(function(err, resp) {34 console.log(resp);35});36var wpt = require('wptools');37var page = wpt.page('Wikipedia');38page.get(function(err, resp) {39 console.log(resp);40});41var wpt = require('wptools');42var page = wpt.page('Wikipedia');43page.get(function(err, resp) {44 console.log(resp);45});46var wpt = require('wptools');47var page = wpt.page('Wikipedia');48page.get(function(err, resp) {49 console.log(resp);50});
Using AI Code Generation
1var test = function() {2 var test = document.createElement('div');3 test.style.cssText = 'background-color:rgba(150,255,150,.5)';4 return ('' + test.style.backgroundColor).indexOf('rgba') > -1;5};6var test = function() {7 var test = document.createElement('div');8 test.style.cssText = 'background-color:rgba(150,255,150,.5)';9 return ('' + test.style.backgroundColor).indexOf('rgba') > -1;10};11var test = function() {12 var test = document.createElement('div');13 test.style.cssText = 'background-color:rgba(150,255,150,.5)';14 return ('' + test.style.backgroundColor).indexOf('rgba') > -1;15};16var test = function() {17 var test = document.createElement('div');18 test.style.cssText = 'background-color:rgba(150,255,150,.5)';19 return ('' + test.style.backgroundColor).indexOf('rgba') > -1;20};21var test = function() {22 var test = document.createElement('div');23 test.style.cssText = 'background-color:rgba(150,255,150,.5)';24 return ('' + test.style.backgroundColor).indexOf('rgba') > -1;25};26var test = function() {27 var test = document.createElement('div');28 test.style.cssText = 'background-color:rgba(150,255,150,.5)';29 return ('' + test.style.backgroundColor).indexOf('rgba') > -1;30};31var test = function() {32 var test = document.createElement('div');33 test.style.cssText = 'background-color:rgba(150
Using AI Code Generation
1var epsilon = getEpsilon();2if (epsilon < 1) {3 reportResult(true, 'The test passed');4} else {5 reportResult(false, 'The test failed');6}
Using AI Code Generation
1var f = function(x){2 return x*x - 2;3};4var df = function(x){5 return 2*x;6};7var a = 1;8var b = 2;9var epsilon = 0.00001;10var root;11var x;12var fx;13var dfx;14var x;15var fx;16var dfx;17var x;18var fx;19var dfx;20var x;21var fx;22var dfx;23var x;24var fx;25var dfx;26var x;27var fx;28var dfx;29var x;30var fx;31var dfx;32var x;33var fx;
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!