Best JavaScript code snippet using puppeteer
graph.js
Source:graph.js
1function Graph(frame) {2 //ä¿å7ç§å¾å½¢ç¸å¯¹åæ çæ°ç»3// var arr = "0,1,0,2,1,2,2,2;0,1,1,1,1,2,2,2;0,1,0,2,1,1,2,1;0,2,1,1,1,2,2,1;1,0,1,1,1,2,1,3;1,1,1,2,2,1,2,2;1,1,2,0,2,1,2,2".split(";");4 //ä¿å4个å°å¾å½¢çæ°ç»5 this.divs = [];6 //å¤é¨å®¹å¨divçæ°ç»7 this.parentFrame = frame;8 //å¾å½¢æ¨ªçºµå移9 this.x = 0;10 this.y = 0;11 //è®°å½å¾å½¢çåæ æ°ç»12 this.zb = [];13 //è®°å½æ¶é¤çè¡æ°14 this.line=0;15 16 17 //åå§åå°å¾å½¢çæ¹æ³18 this.init = function(rand,color) {19 //计ç®å¾å½¢å
¶å®åæ çåä½20 var startleft = (this.parentFrame.row - 4) / 2;21 this.x = startleft;22 //éæºçæå¾å½¢æ°ç»ä¸æ 23// var rand = Math.floor(Math.random() * arr.length);24 //å解å¾å½¢çåæ 25 var smallarr = this.parentFrame.arr[rand].split(",");26 this.zb = smallarr;27 //循ç¯è®¾ç½®å°divç leftåtop28 for (var i = 0; i < 8; i += 2) {29 //å建å°div30 var smalldiv = document.createElement("div");31 //è®¾ç½®æ ·å¼32 smalldiv.className = "smallDiv";33 //设置é¢è²34 smalldiv.style.backgroundColor=color;35 //å®ä¹é«å®½36 smalldiv.style.width = (this.parentFrame.unit - 2) + "px";37 smalldiv.style.height = (this.parentFrame.unit - 2) + "px";38 //设置å°divçtop39 smalldiv.style.top = ((smallarr[i] - 0) * this.parentFrame.unit) + "px";40 //设置å°divçleft41 smalldiv.style.left = (((smallarr[i + 1] - 0) + startleft) * this.parentFrame.unit) + "px";42 //ä¿åå°divçå¼ç¨43 this.divs.push(smalldiv); 44 //å å
¥å°å¤é¨å®¹å¨45 document.getElementById("MainFrame").appendChild(smalldiv);46 }47 //æ§è¡èªå¨åä¸ç§»å¨48 //this.parentFrame.intervalid = setInterval(autoMoveDown, this.parentFrame.speed);49 }50 //左移å¨51 this.moveleft = function() {52 // var canmove = true;53 // //å¤æè½å¦å·¦ç§»å¨54 // 55 // for(var i=0;i<this.divs.length;i++)56 // {57 // var left=parseInt(this.divs[i].style.left); //divç®åçleft58 // if(left - this.parentFrame.unit <0) //åå»ä¸ä¸ªåä½çåç´ æ¯å¦å°äº059 // {60 // canmove = false; //ä¸è½å左移å¨äº61 // break;62 // }63 // }64 if (canMove(this.zb, this.x, this.y, this.parentFrame, 2)) //å¯ä»¥ç§»å¨65 {66 this.x -= 1;67 for (var i = 0; i < this.divs.length; i++) //循ç¯å°divï¼ææ¯ä¸ªdivçleftåå»ä¸ä¸ªåä½çåç´ 68 {69 var left = parseInt(this.divs[i].style.left);70 this.divs[i].style.left = (left - this.parentFrame.unit) + "px";71 }72 }73 }74 //å³ç§»å¨75 this.moveright = function() {76 // var canmove = true;77 // //å¤æè½å¦å³ç§»å¨78 // for(var i=0;i<this.divs.length;i++)79 // {80 // var left=parseInt(this.divs[i].style.left);81 // if(left + this.parentFrame.unit >=parseInt(this.parentFrame.Content.style.width))82 // {83 // canmove = false;84 // break;85 // }86 // }87 var temp = canMove(this.zb, this.x, this.y, this.parentFrame, 1);88// alert(temp);89 console.log(temp);90 if (canMove(this.zb, this.x, this.y, this.parentFrame, 1)) {91 this.x += 1;92 for (var i = 0; i < this.divs.length; i++) {93 var left = parseInt(this.divs[i].style.left);94 this.divs[i].style.left = (left + this.parentFrame.unit) + "px";95 }96 }97 }98 //åå½¢99 this.change = function() {100 //åå½¢çå
¬å¼101 //å°divç2个ç¸å¯¹åæ ç¹æ¹å x = y ; y= 3-x; æ¯å¦ ï¼0ï¼1ï¼ ååä¹å å°±æ¯ x=1ï¼y=3-0 -> (1,3)102 //循ç¯4个å°div103 if (!canMove(this.zb, this.x, this.y, this.parentFrame, 4)) {104 if (this.x < 0) {105 this.x += 1;106 } else {107 this.x -= 1;108 }109 }110 for (var i = 0; i < this.divs.length; i++) {111 //æ ¹æ®å
¬å¼æ¹åæ¯ä¸ªdivçç¸å¯¹å移éï¼2个ä¸æ¹112 var temp = this.zb[i * 2]113 this.zb[i * 2] = this.zb[i * 2 + 1];114 this.zb[i * 2 + 1] = 3 - temp;115 //æ ¹æ®æ¹ååçå移é计ç®å¾å½¢çå½åleftåtop116 this.divs[i].style.top = ((this.y + parseInt(this.zb[i * 2])) * this.parentFrame.unit) + "px";117 this.divs[i].style.left = ((this.x + parseInt(this.zb[i * 2 + 1])) * this.parentFrame.unit) + "px";118 }119 }120 this.movedown = function() {121 122 var $this = this =="window" ? this.frame.samlldiv : this;123 124 if (canMove($this.zb, $this.x, $this.y, $this.parentFrame, 3)) {125 $this.y += 1;126 for (var i = 0; i < $this.divs.length; i++) {127 var top = parseInt($this.divs[i].style.top);128 $this.divs[i].style.top = (top + $this.parentFrame.unit) + "px";129 }130 return false;131 } else {132 clearInterval($this.parentFrame.intervalid);133// var temp = $this.parentFrame.Content.getElementsByTagName("div");134 for (var i=0;i<$this.divs.length;i++) {135 //divåç°136 //$this.divs[i].className ="smallDivblack";137 var $y = $this.y + parseInt($this.zb[i*2]);138 var $x = $this.x+parseInt($this.zb[i*2+1]);139// debugger;140 $this.parentFrame.datas[$y*$this.parentFrame.row+ $x] =1;141 $this.divs[i].dataset.row=$y; //è®°å½divæå¨çè¡142 $this.divs[i].dataset.col=$x; //è®°å½divæå¨çå143 $this.divs[i].className="smallDivblack";144 $this.divs[i].style.backgroundColor="black";145 //$this.parentFrame.datas[]146 }147 148 149 //æ¶è¡å¹¶è®¡å150 for (var i= 0;i<$this.parentFrame.col;i++) { //i为è¡151 //å¤ææ¯å¦æ»¡è¶³æ¶è¡æ¡ä»¶152 for (var j=0;j<$this.parentFrame.row;j++) { //j为å153 if($this.parentFrame.datas[i*$this.parentFrame.row+ j] !=1){154 break;155 }156 }157 //æ¶è¡ï¼å°è¯¥è¡ä¸é¢çæædivä¸ç§»ä¸è¡158 if(j==$this.parentFrame.row){159 var x; //è®°å½divå¨åªä¸å160 var y; //è®°å½divå¨åªä¸è¡161 var getsmalldiv=document.getElementById("TFrime").getElementsByClassName("smallDivblack");//å¾å°å°div162 for (var a=0;a<getsmalldiv.length;a++){163 y=parseInt(getsmalldiv[a].dataset.row);164 x=parseInt(getsmalldiv[a].dataset.col);165 if(y==i){ //æ¶é¤è¯¥è¡166 debugger;167 $this.parentFrame.datas[y*$this.parentFrame.row+ x]=0;168 getsmalldiv[a].remove();169 a--;170 }171 }172 173 for (var a=i-1;a>0;a--) {174 for (var b=0;b<getsmalldiv.length;b++) {175 y=parseInt(getsmalldiv[b].dataset.row);176 x=parseInt(getsmalldiv[b].dataset.col);177 if(y==a){ //å°ä¸é¢çdivä¸ç§»ä¸è¡178// debugger;179 var divtop=parseInt(getsmalldiv[b].style.top);180 getsmalldiv[b].style.top=(divtop+$this.parentFrame.unit)+"px";181 getsmalldiv[b].dataset.row++;182 $this.parentFrame.datas[y*$this.parentFrame.row+ x]=0;183 $this.parentFrame.datas[(y+1)*$this.parentFrame.row+ x]=1;184 }185 }186 187 }188 $this.line++;189 190// for (var a=0;a<getsmalldiv.length;a++) {191// y=parseInt(getsmalldiv[a].dataset.row);192// x=parseInt(getsmalldiv[a].dataset.col);193//// alert(getsmalldiv[a].dataset.row);194// if(y<i){ //å°ä¸é¢çdivä¸ç§»ä¸è¡195//// debugger;196// var divtop=parseInt(getsmalldiv[a].style.top);197//// alert(getsmalldiv[a].style.top);198// getsmalldiv[a].style.top=(divtop+$this.parentFrame.unit)+"px";199// getsmalldiv[a].dataset.row++;200// debugger;201// $this.parentFrame.datas[y*$this.parentFrame.row+ x]=0;202// $this.parentFrame.datas[(y+1)*$this.parentFrame.row+ x]=1;203// }204//// }else if(y==i){ //æ¶é¤è¯¥è¡205//// debugger;206//// $this.parentFrame.datas[y*$this.parentFrame.row+ x]=0;207//// getsmalldiv[a].className="MainFramediv";208//// }209// }210 }211 }212 213 return true;214 }215 }216// function autoMoveDown() {217// 218// var small = this.frame.samlldiv;219// var f = this.frame;220// 221// if (canMove(small.zb, small.x, small.y, 0, f.col, 3)) {222// small.y += 1;223// for (var i = 0; i < small.divs.length; i++) {224// var top = parseInt(small.divs[i].style.top);225// small.divs[i].style.top = (top + f.unit) + "px";226// }227// } else {228// clearInterval(f.intervalid);229// }230//231// }232 //é¢å¤è½å¦ç§»å¨æååï¼action:1.å³ç§»ï¼2.左移ï¼3.ä¸ç§»ï¼4.åå233 //zbæ¯4个å°å¾å½¢çç¸å¯¹å移ï¼xæ¯å¾å½¢å·¦å移ï¼yæ¯topå移,fæ¯å¤é¨frame234 function canMove(zb, x, y, f, action) {235 //datas[parseInt(zb[i + 1]) + x + 1)+(this.y-1)*row] !=0236 237 switch (action) {238 case 1:239// debugger;240 for (var i = 0; i < zb.length; i += 2) {241 if (parseInt(zb[i + 1]) + x + 1 >= f.row)242 {243 return false;244 }else if(f.datas[(parseInt(zb[i + 1]) + x + 1)+(y+parseInt(zb[i]))*f.row] !=0)245 {246 return false;247 }248 }249 break;250 case 2:251 for (var i = 0; i < zb.length; i += 2) {252 if (parseInt(zb[i + 1]) + x - 1 < 0 ) {253 return false;254 }else if(f.datas[(parseInt(zb[i + 1]) + x - 1)+(y+parseInt(zb[i]))*f.row] !=0)255 {256 return false;257 }258 }259 break;260 case 3:261 for (var i = 0; i < zb.length; i += 2) {262 if (parseInt(zb[i]) + y + 1 >= f.col ||263 f.datas[(parseInt(zb[i + 1]) + x)+(parseInt(zb[i]) + y+1)*f.row] !=0) {264 return false;265 }266 }267 break;268 case 4:269 for (var i = 0; i < zb.length; i += 2) {270 var temp = 3 - zb[i];271 if (temp + x < 0 || temp + x >= f.row) {272 return false;273 }274 }275 break;276 }277 return true;278 }279 280 this.rescore=function(){281 var gamescore=document.getElementById("score");282 gamescore.innerHTML=parseInt(gamescore.innerHTML)+this.parentFrame.score[this.line];283 }...
teacherList.js
Source:teacherList.js
1var parentFrame;2var singleChecks;3var modifyModal;4var resetPwdModal;5var deleteItemModal;6$(function () {7 parentFrame = parent.$(window.parent.document);8 singleChecks = $(".single .form-check-sign");9 modifyModal = {10 modal: $("#modifyModal"),11 id: $("#id"),12 teacherNum: $("#teacherNum"),13 name: $("#teacherName"),14 email: $("#email")15 };16 resetPwdModal = $("#resetPwdModal");17 deleteItemModal = $("#deleteItemModal");18 singleChecks.click(function () {19 //A little messed...20 // 确认èªå·±ä¸ºcheckedï¼å¹¶ä¿®æ¹æå¨åçæ¾ç¤ºææ21 var item = $(this).parent().parent().parent().parent();22 var check = $(this);23 if (check.hasClass("checked")) {24 item.removeClass("chosen");25 check.removeClass("checked");26 } else {27 item.addClass("chosen");28 check.addClass("checked");29 }30 });31 modifyModal.modal.on("show.bs.modal", function (event) {32 var item = $(event.relatedTarget).parent().parent();33 modifyModal.id.val(item.attr("data-id"));34 modifyModal.name.val(item.find(".name").html());35 modifyModal.name.parent().addClass("is-filled");36 modifyModal.teacherNum.val(item.find(".teacherNum").html());37 modifyModal.teacherNum.parent().addClass("is-filled");38 modifyModal.email.val(item.find(".email").html());39 modifyModal.email.parent().addClass("is-filled");40 });41 resetPwdModal.on("show.bs.modal", function (event) {42 $(this).find(".confirm").attr("data-gist", $(event.relatedTarget).attr("data-gist"));43 });44 deleteItemModal.on("show.bs.modal", function (event) {45 $(this).find(".confirm").attr("data-gist", $(event.relatedTarget).attr("data-gist"));46 });47 modifyModal.modal.find(".confirm").click(function () {48 var btn = $(this);49 var form = modifyModal.modal.find(".form");50 if (util.verifyWithPop(form)) {51 $.ajax({52 type: "patch",53 url: "/admin/teacher",54 contentType: "application/json; charset=utf-8",55 data: JSON.stringify(form.serializeObject()),56 success: function (result, status, xhr) {57 if (xhr.status === 200) {58 modifyModal.modal.modal("hide");59 parentFrame.trigger("showNotification", ["ä¿®æ¹æå", "success"]);60 location.reload();61 }62 },63 error: function () {64 if (xhr.status === 409) {65 btn.delayedPop("ä¿®æ¹å¤±è´¥ï¼å·¥å·ä¸åå¨", 3);66 } else {67 btn.delayedPop("ä¿®æ¹å¤±è´¥ï¼æªç¥é误", 3);68 }69 }70 });71 }72 });73 resetPwdModal.find(".confirm").click(function () {74 $.ajax({75 type: "patch",76 url: "/admin/teacher/" + $(this).attr("data-gist") + "/resetPwd",77 success: function () {78 resetPwdModal.modal("hide");79 parentFrame.trigger("showNotification", ["éç½®å¯ç æå", "success"]);80 location.reload();81 },82 error: function () {83 $(resetPwdModal.find(".confirm")).delayedPop("éç½®å¯ç 失败", 3);84 }85 });86 });87 deleteItemModal.find(".confirm").click(function () {88 $.ajax({89 type: "delete",90 url: "/admin/teacher/" + $(this).attr("data-gist"),91 success: function () {92 deleteItemModal.modal("hide");93 parentFrame.trigger("showNotification", ["å é¤æå", "success"]);94 location.reload();95 },96 error: function () {97 $(deleteItemModal.find(".confirm")).delayedPop("å é¤å¤±è´¥", 3);98 }99 });100 });101 var table = $(".table");102 if (table.attr("data-new") === "true") {103 parentFrame.trigger("pageReset", [table.attr("data-pages"), 1]);104 }105 var page = table.attr("data-page");106 if (page !== parent.$("#pagination").find(".active>a").html()) {107 parentFrame.trigger("pageReset", [table.attr("data-pages"), page]);108 }...
studentList.js
Source:studentList.js
1var parentFrame;2var singleChecks;3var modifyModal;4var resetPwdModal;5var deleteItemModal;6$(function () {7 parentFrame = parent.$(window.parent.document);8 singleChecks = $(".single .form-check-sign");9 modifyModal = {10 modal: $("#modifyModal"),11 id: $("#id"),12 studentNum: $("#studentNum"),13 name: $("#name"),14 email: $("#email")15 };16 resetPwdModal = $("#resetPwdModal");17 deleteItemModal = $("#deleteItemModal");18 singleChecks.click(function () {19 //A little messed...20 // 确认èªå·±ä¸ºcheckedï¼å¹¶ä¿®æ¹æå¨åçæ¾ç¤ºææ21 var item = $(this).parent().parent().parent().parent();22 var check = $(this);23 if (check.hasClass("checked")) {24 item.removeClass("chosen");25 check.removeClass("checked");26 } else {27 item.addClass("chosen");28 check.addClass("checked");29 }30 });31 modifyModal.modal.on("show.bs.modal", function (event) {32 var item = $(event.relatedTarget).parent().parent();33 modifyModal.id.val(item.attr("data-id"));34 modifyModal.name.val(item.find(".name").html());35 modifyModal.name.parent().addClass("is-filled");36 modifyModal.studentNum.val(item.find(".studentNum").html());37 modifyModal.studentNum.parent().addClass("is-filled");38 modifyModal.email.val(item.find(".email").html());39 modifyModal.email.parent().addClass("is-filled");40 });41 resetPwdModal.on("show.bs.modal", function (event) {42 $(this).find(".confirm").attr("data-gist", $(event.relatedTarget).attr("data-gist"));43 });44 deleteItemModal.on("show.bs.modal", function (event) {45 $(this).find(".confirm").attr("data-gist", $(event.relatedTarget).attr("data-gist"));46 });47 modifyModal.modal.find(".confirm").click(function () {48 var btn = $(this);49 var form = modifyModal.modal.find(".form");50 if (util.verifyWithPop(form)) {51 $.ajax({52 type: "patch",53 url: "/admin/student",54 contentType: "application/json; charset=utf-8",55 data: JSON.stringify(form.serializeObject()),56 success: function (result, status, xhr) {57 if (xhr.status === 200) {58 modifyModal.modal.modal("hide");59 parentFrame.trigger("showNotification", ["ä¿®æ¹æå", "success"]);60 location.reload();61 } else if (xhr.status === 204) {62 btn.delayedPop("ä¿®æ¹å¤±è´¥ï¼å¦å·ä¸åå¨", 3);63 }64 },65 error: function () {66 btn.delayedPop("ä¿®æ¹å¤±è´¥ï¼æªç¥é误", 3);67 }68 });69 }70 });71 resetPwdModal.find(".confirm").click(function () {72 $.ajax({73 type: "patch",74 url: "/admin/student/" + $(this).attr("data-gist") + "/resetPwd",75 success: function () {76 resetPwdModal.modal("hide");77 parentFrame.trigger("showNotification", ["éç½®å¯ç æå", "success"]);78 location.reload();79 },80 error: function () {81 $(resetPwdModal.find(".confirm")).delayedPop("å é¤å¤±è´¥", 3);82 }83 });84 });85 deleteItemModal.find(".confirm").click(function () {86 $.ajax({87 type: "delete",88 url: "/admin/student/" + $(this).attr("data-gist"),89 success: function () {90 deleteItemModal.modal("hide");91 parentFrame.trigger("showNotification", ["å é¤æå", "success"]);92 location.reload();93 },94 error: function () {95 $(deleteItemModal.find(".confirm")).delayedPop("å é¤å¤±è´¥", 3);96 }97 });98 });99 var table = $(".table");100 if (table.attr("data-new") === "true") {101 parentFrame.trigger("pageReset", [table.attr("data-pages"), 1]);102 }103 var page = table.attr("data-page");104 if (page !== parent.$("#pagination").find(".active>a").html()) {105 parentFrame.trigger("pageReset", [table.attr("data-pages"), page]);106 }...
app.js
Source:app.js
1/**2 * UI v1.1.03 * Copyright 2017-2018 Muyao4 * Licensed under the Muyao License 1.0 5 */6(function (window, document, $) {7 'use strict';8 // ç¶çº§domèç¹9 $.parentFrame = $(window.parent.document);10 // ç¶çº§æ¹æ³&å±æ§11 var parentFrame = window.parentFrame = window.parent;12 // 项ç®å称13 $.ctx = parentFrame.$.ctx;14 // é
ç½®é¢è²è·åæ¹æ³15 $.colors = parentFrame.$.colors;16 // 注åç»ä»¶é»è®¤é
ç½®åæ°è·åæ¹æ³17 $.po = parentFrame.$.po;18 // æ¬å°åå¨å¯¹è±¡æä½19 $.storage = parentFrame.$.storage;20 $.sessionStorage = parentFrame.$.sessionStorage;21 // ç½ååºç¡è®¾ç½®å¯¹è±¡22 $.site = parentFrame.$.site;23 if ($.site && $.site.contentTabs)24 $.site.contentTabs.ifameTabs(document);25 // é
置信æ¯åå¨ç®¡ç26 $.configs = parentFrame.$.configs;27 // 注åç»ä»¶åå§å28 if (parentFrame.$.components)29 parentFrame.$.components.init(document, window);30 // å
¬ç¨å¯¹è±¡31 window.Breakpoints = parentFrame.Breakpoints;32 window.toastr = parentFrame.toastr;33 window.layer = parentFrame.layer;34 window.haoutil = parentFrame.haoutil;35 window.notifyFn = parentFrame.$.notifyFn;36 // èªå®ä¹æ©å±å¯¹è±¡37 var _objExtend = _objExtend || {};38 $.extend(_objExtend, {39 _queue: {40 prepare: [],41 run: [],42 complete: []43 },44 run: function () {45 var self = this;46 this._dequeue('prepare', function () {47 self._trigger('before.run', self);48 });49 this._dequeue('run', function () {50 self._dequeue('complete', function () {51 self._trigger('after.run', self);52 });53 });54 },55 _dequeue: function (name, done) { // éåå½åç¶æ离éï¼è¿è¡ä¸ä¸æ¥æä½56 var self = this,57 queue = this._getQueue(name),58 fn = queue.shift(),59 next = function () {60 self._dequeue(name, done);61 };62 if (fn) {63 fn.call(this, next);64 } else if ($.isFunction(done)) {65 done.call(this);66 }67 },68 _getQueue: function (name) { // è·åéåç¶æä¿¡æ¯69 if (!$.isArray(this._queue[name])) {70 this._queue[name] = [];71 }72 return this._queue[name];73 },74 extend: function (obj) { // å
¬ç¨æ¨¡å对象æ©å±æ¹æ³75 $.each(this._queue, function (name, queue) {76 if ($.isFunction(obj[name])) {77 queue.unshift(obj[name]);78 delete obj[name];79 }80 });81 $.extend(this, obj);82 return this;83 },84 _trigger: function (name, data, $el) { // 离éç¶ææ§è¡å¨ä½85 if (typeof name === 'undefined') {86 return;87 }88 if (typeof $el === 'undefined') {89 $el = $("#admui-pageContent");90 }91 $el.trigger(name + '.app', data);92 }93 });94 // éç¨åè½å¯¹è±¡ï¼å¯é
ç½®å¢å ï¼ä¹å¯æ©å±ï¼95 var _app = {96 pageAside: function () { // å°å±å¹ä¸ä¾§è¾¹æ ï¼å±å¼&æ¶èµ·ï¼æä½97 var pageAside = $(".page-aside"),98 isOpen = pageAside.hasClass('open');99 pageAside.toggleClass('open', !isOpen);100 },101 run: function (next) {102 var self = this;103 // 侧边æ å¼å
³104 $(document).on('click', '.page-aside-switch', function (e) {105 self.pageAside();106 e.stopPropagation();107 });108 next();109 }110 };111 window.App = $.extend({}, _objExtend);112 App.extend(_app);...
cpTemp.js
Source:cpTemp.js
1/*******************************************************************************2 * Copyright ©2015. IT Services Jacek Kurasiewicz, Warsaw, Poland. All Rights3 * Reserved.4 *5 * Republication, redistribution, granting a license to other parties, using,6 * copying, modifying this software and its documentation is prohibited without the7 * prior written consent of IT Services Jacek Kurasiewicz.8 * Contact The Office of IT Services Jacek Kurasiewicz, ul. Koszykowa 60/62 lok.9 * 43, 00-673 Warszawa, jk@softpro.pl, +48 512-25-67-67, for commercial licensing10 * opportunities.11 *12 * IN NO EVENT SHALL IT SERVICES JACEK KURASIEWICZ BE LIABLE TO ANY PARTY FOR13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST14 * PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF15 * IT SERVICES JACEK KURASIEWICZ HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH16 * DAMAGE.17 *18 * IT SERVICES JACEK KURASIEWICZ SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A20 * PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY,21 * PROVIDED HEREUNDER IS PROVIDED "AS IS". IT SERVICES JACEK KURASIEWICZ HAS NO22 * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR23 * MODIFICATIONS.24 *******************************************************************************/25/*26 * This file is to be delete when the port of the apps to fulcrum is complete27 */2829var currentPanel;3031function hover(tab)32{33 tab.style.backgroundColor = '#ffffc0';34 tab.style.color = '#1D5EAA';35}3637function getCurrentPanel(parentFrame)38{39 if (parentFrame != null && typeof(parentFrame) != "undefined")40 {41 return parentFrame.currentPanel;42 }43 return currentPanel;44}4546function setCurrentPanel(newpanel, parentFrame)47{48 if (parentFrame != null && typeof(parentFrame) != "undefined")49 {50 parentFrame.currentPanel = newpanel;51 }52 else53 {54 currentPanel = newpanel;55 }56}5758function setState(tabNum, parentFrame)59{60 var documentToUse = document;6162 if (parentFrame != null && typeof(parentFrame) != "undefined")63 {64 documentToUse = parentFrame.document;65 }66 if (tabNum == getCurrentPanel(parentFrame))67 {68 documentToUse.getElementById('tab' + tabNum).style.backgroundColor = '#ddddff';69 documentToUse.getElementById('tab' + tabNum).style.color = 'navy';70 }71 else72 {73 documentToUse.getElementById('tab' + tabNum).style.backgroundColor = '#FFFFF4';74 documentToUse.getElementById('tab' + tabNum).style.color = '#1D5EAA';75 }76}7778function showPanel(newpanel, parentFrame)79{80 var documentToUse = document;8182 if (parentFrame != null && typeof(parentFrame) != "undefined")83 {84 documentToUse = parentFrame.document;85 }86 var panel = getCurrentPanel(parentFrame);8788 // Hide the current panel.89 if (panel != null && typeof(panel) != "undefined")90 {91 hidePanel(parentFrame);92 }9394 // Show the selected panel.95 documentToUse.getElementById('tabpanel' + newpanel).style.display = 'block';9697 // Update current panel.98 setCurrentPanel(newpanel, parentFrame);99100 // Set current panel state.101 setState(newpanel, parentFrame);102}103104function hidePanel(parentFrame)105{106 var documentToUse = document;107108 if (parentFrame != null && typeof(parentFrame) != "undefined")109 {110 documentToUse = parentFrame.document;111 }112 var curPanel = getCurrentPanel(parentFrame);113114 // Hide visible panel and unhighlight tab.115 if (documentToUse != null)116 {117 var tabpanel = getDocumentObjectFromObject(documentToUse, 'tabpanel' + curPanel);118 if (tabpanel != null)119 {120 tabpanel.style.display = 'none';121 }122123 var tab = getDocumentObjectFromObject(documentToUse, 'tab' + curPanel);124 if (tab != null)125 {126 tab.style.backgroundColor = '#FFFFF4';127 tab.style.color = '#1D5EAA';128 }129130 }131}132133function addOverFlow()134{135 dojo.byId("mainFrame").style.overflow = 'auto';
...
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({headless: false});4 const page = await browser.newPage();5 await page.click('a[href="/search?q=google&source=hp&ei=5aX9XcT4D4bA4-EPjZ6U4A4&iflsig=AINFCbYAAAAAYKXQ7VvY2YlQ8z0nL1b3KqBpDZI0g1Rf"]');6 await page.waitForNavigation();7 await page.waitForTimeout(1000);8 await page.click('a[href="/search?q=google&source=hp&ei=5aX9XcT4D4bA4-EPjZ6U4A4&iflsig=AINFCbYAAAAAYKXQ7VvY2YlQ8z0nL1b3KqBpDZI0g1Rf"]');9 await page.waitForNavigation();10 await page.waitForTimeout(1000);11 await page.click('a[href="/search?q=google&source=hp&ei=5aX9XcT4D4bA4-EPjZ6U4A4&iflsig=AINFCbYAAAAAYKXQ7VvY2YlQ8z0nL1b3KqBpDZI0g1Rf"]');12 await page.waitForNavigation();13 await page.waitForTimeout(1000);14 await page.click('a[href="/search?q=google&source=hp&ei=5aX9XcT4D4bA4-EPjZ6U4A4&iflsig=AINFCbYAAAAAYKXQ7VvY2YlQ8z0nL1b3KqBpDZI0g1Rf"]');15 await page.waitForNavigation();16 await page.waitForTimeout(1000);17 await page.click('a[href="/search?q=google&source=hp&ei=5aX9XcT4D4bA4-EPjZ6U4A4&iflsig=AINFCbYAAAAAYKXQ
Using AI Code Generation
1const puppeteer = require('puppeteer');2const fs = require('fs');3(async () => {4 const browser = await puppeteer.launch({ headless: false });5 const page = await browser.newPage();6 await page.type('input[name="q"]', 'puppeteer');7 await page.click('input[name="btnK"]');8 await page.waitForNavigation();9 await page.waitForSelector('div[id="result-stats"]');10 const pageContent = await page.content();11 fs.writeFileSync('google.html', pageContent);12 await browser.close();13})();14const puppeteer = require('puppeteer');15const fs = require('fs');16(async () => {17 const browser = await puppeteer.launch({ headless: false });18 const page = await browser.newPage();19 await page.type('input[name="q"]', 'puppeteer');20 await page.click('input[name="btnK"]');21 await page.waitForNavigation();22 await page.waitForSelector('div[id="result-stats"]');23 const pageContent = await page.content();24 fs.writeFileSync('google.html', pageContent);25 await browser.close();26})();27const puppeteer = require('puppeteer');28const fs = require('fs');29(async () => {30 const browser = await puppeteer.launch({ headless: false });31 const page = await browser.newPage();32 await page.type('input[name="q"]', 'puppeteer');33 await page.click('input[name="btnK"]');34 await page.waitForNavigation();35 await page.waitForSelector('div[id="result-stats"]');36 const pageContent = await page.content();37 fs.writeFileSync('google.html', pageContent);38 await browser.close();39})();40const puppeteer = require('puppeteer');41const fs = require('fs');42(async () => {43 const browser = await puppeteer.launch({ headless: false });44 const page = await browser.newPage();45 await page.type('input[name="q"]', '
Using AI Code Generation
1const puppeteer = require('puppeteer');2const path = require('path');3const fs = require('fs');4(async () => {5 const browser = await puppeteer.launch();6 const page = await browser.newPage();7 await page.screenshot({ path: 'google.png' });8 await browser.close();9})();10const puppeteer = require('puppeteer');11const path = require('path');12const fs = require('fs');13(async () => {14 const browser = await puppeteer.launch();15 const page = await browser.newPage();16 await page.screenshot({ path: 'google.png' });17 await browser.close();18})();19const puppeteer = require('puppeteer');20const path = require('path');21const fs = require('fs');22(async () => {23 const browser = await puppeteer.launch();24 const page = await browser.newPage();25 await page.screenshot({ path: 'google.png' });26 await browser.close();27})();28const puppeteer = require('puppeteer');29const path = require('path');30const fs = require('fs');31(async () => {32 const browser = await puppeteer.launch();33 const page = await browser.newPage();34 await page.screenshot({ path: 'google.png' });35 await browser.close();36})();37const puppeteer = require('puppeteer');38const path = require('path');39const fs = require('fs');40(async () => {41 const browser = await puppeteer.launch();42 const page = await browser.newPage();43 await page.screenshot({ path: 'google.png' });44 await browser.close();45})();46const puppeteer = require('puppeteer');47const path = require('path');48const fs = require('fs');49(async () => {
Using AI Code Generation
1var puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({headless: false});4 const page = await browser.newPage();5 await page.waitFor(5000);6 await page.evaluate(() => {7 var frame = document.getElementById('iframeId');8 frame.contentWindow.parentFrame();9 });10 await page.waitFor(5000);11 await browser.close();12})();13function parentFrame() {14 alert('parentFrame');15}
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({headless: false});4 const page = await browser.newPage();5 await page.waitForSelector('input[aria-label="Search Google Maps"]');6 await page.type('input[aria-label="Search Google Maps"]', 'pizza');7 await page.waitForSelector('button[aria-label="Search Google Maps"]');8 await page.click('button[aria-label="Search Google Maps"]');9 await page.waitFor(1000);10 await page.waitForSelector('div.section-result-text-content');11 await page.click('div.section-result-text-content');12 await page.waitFor(1000);13 await page.waitForSelector('button[aria-label="Directions"]');14 await page.click('button[aria-label="Directions"]');15 await page.waitFor(1000);16 await page.waitForSelector('div.section-directions-trip-description');17 await page.click('div.section-directions-trip-description');18 await page.waitFor(1000);19 await page.waitForSelector('div.section-directions-trip-description');20 await page.click('div.section-directions-trip-description');21 await page.waitFor(1000);22 await page.waitForSelector('div.section-directions-trip-description');23 await page.click('div.section-directions-trip-description');24 await page.waitFor(1000);25 await page.waitForSelector('div.section-directions-trip-description');26 await page.click('div.section-directions-trip-description');27 await page.waitFor(1000);28 await page.waitForSelector('div.section-directions-trip-description');29 await page.click('div.section-directions-trip-description');30 await page.waitFor(1000);31 await page.waitForSelector('div.section-directions-trip-description');32 await page.click('div.section-directions-trip-description');33 await page.waitFor(1000);34 await page.waitForSelector('div.section-directions-trip-description');35 await page.click('div.section-directions-trip-description');36 await page.waitFor(1000);37 await page.waitForSelector('div.section-directions-trip-description');38 await page.click('div.section-directions-trip-description');39 await page.waitFor(1000);40 await page.waitForSelector('div.section-directions-trip-description');41 await page.click('div.section-directions-trip-description');42 await page.waitFor(1000);
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await page.waitFor(5000);6 await page.screenshot({path: 'example.png'});7 await browser.close();8})();
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 const frame = page.frames().find(frame => frame.name() === 'gsft_main');6 const parentFrame = frame.parentFrame();7 console.log(parentFrame);8 await browser.close();9})();
Using AI Code Generation
1const frame = await page.mainFrame().childFrames()[0];2const parentFrame = frame.parentFrame();3const childFrame = await parentFrame.childFrames()[0];4await page.waitForSelector('#myId');5await page.waitForSelector('#myId');6await page.click('#myId');7await page.waitForSelector('#myId');8await page.type('#myId', 'my text');9const text = await page.waitForSelector('#myId');10const text = await page.$eval('#myId', (el) => el.textContent);
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!!