How to use closeBlock method in Playwright Internal

Best JavaScript code snippet using playwright-internal

PDFGraphics.js

Source:PDFGraphics.js Github

copy

Full Screen

1(function(){var P$=Clazz.newPackage("gnu.jpdf"),p$1={},I$=[[0,'java.awt.geom.AffineTransform','java.awt.BasicStroke','java.text.DecimalFormat','java.awt.image.BufferedImage','java.awt.RenderingHints','java.awt.geom.Area','java.awt.Rectangle',['java.awt.geom.Point2D','.Double'],'gnu.jpdf.PDFImage','java.util.Hashtable','gnu.jpdf.PDFStringHelper','java.awt.Color','java.awt.Font','java.awt.font.FontRenderContext','gnu.jpdf.PDFStream',['java.awt.geom.Point2D','.Float']]],$I$=function(i){return I$[i]||(I$[i]=Clazz.load(I$[0][i]))};2var C$=Clazz.newClass(P$, "PDFGraphics", null, 'java.awt.Graphics2D', 'java.io.Serializable');3C$.IDENTITY=null;4C$.DEF_STROKE=null;5C$.df=null;67C$.$clinit$ = function() {Clazz.load(C$, 1);8C$.IDENTITY=Clazz.new_($I$(1));9C$.DEF_STROKE=Clazz.new_($I$(2));10C$.df=Clazz.new_($I$(3).c$$S,["#.###"]);11}1213Clazz.newMeth(C$, '$init0$', function () {14var c;if((c = C$.superclazz) && (c = c.$init0$))c.apply(this);15this.background=null;16this.child=false;17this.clip=null;18this.clipRectangle=null;19this.composite=null;20this.dg2=null;21this.font=null;22this.inStroke=false;23this.inText=false;24this.lineCap=0;25this.lineJoin=0;26this.lineWidth=0;27this.lx=0;28this.ly=0;29this.miterLimit=0;30this.newFont=false;31this.originalStroke=null;32this.oTransform=null;33this.page=null;34this.paint=null;35this.pdffont=null;36this.pre_np=null;37this.pTransform=null;38this.pw=null;39this.rhints=null;40this.stroke=null;41this.transform=null;42this.trax=0;43this.tray=0;44this.tx=0;45this.ty=0;46}, 1);4748Clazz.newMeth(C$, '$init$', function () {49this.dg2=Clazz.new_($I$(4).c$$I$I$I,[2, 2, 1]).createGraphics$();50this.lineCap=0;51this.lineJoin=0;52this.lineWidth=1.0;53this.miterLimit=10.0;54this.rhints=Clazz.new_($I$(5).c$$java_util_Map,[null]);55}, 1);5657Clazz.newMeth(C$, 'addRenderingHints$java_util_Map', function (hints) {58this.rhints.putAll$java_util_Map(hints);59});6061Clazz.newMeth(C$, 'arc$D$D$D$D$D$D$Z', function (axc, ayc, width, height, ang1, ang2, clockwise) {62var adiff;63var x0;64var y0;65var x3r;66var y3r;67var first=true;68var ang1r=(ang1 % 360.0) * 0.017453292519943295;69var sin0=Math.sin(ang1r);70var cos0=Math.cos(ang1r);71x0=axc + width * cos0;72y0=ayc + height * sin0;73if (!clockwise) {74while (ang1 < ang2 )ang2 -= 360.0;7576while ((adiff=ang2 - ang1) < -90.0 ){77var w=sin0;78sin0=-cos0;79cos0=w;80x3r=axc + width * cos0;81y3r=ayc + height * sin0;82p$1.arc_add$Z$D$D$D$D$D$D$D$D.apply(this, [first, width, height, x0, y0, x3r, y3r, (x0 + width * cos0), (y0 + height * sin0)]);83x0=x3r;84y0=y3r;85ang1 -= 90.0;86first=false;87}88} else {89while (ang2 < ang1 )ang2 += 360.0;9091while ((adiff=ang2 - ang1) > 90.0 ){92var w=cos0;93cos0=-sin0;94sin0=w;95x3r=axc + width * cos0;96y3r=ayc + height * sin0;97p$1.arc_add$Z$D$D$D$D$D$D$D$D.apply(this, [first, width, height, x0, y0, x3r, y3r, (x0 + width * cos0), (y0 + height * sin0)]);98x0=x3r;99y0=y3r;100ang1 += 90.0;101first=false;102}103}var trad=Math.tan(adiff * (0.008726646259971648));104var ang2r=ang2 * 0.017453292519943295;105var xt=x0 - trad * width * sin0 ;106var yt=y0 + trad * height * cos0 ;107p$1.arc_add$Z$D$D$D$D$D$D$D$D.apply(this, [first, width, height, x0, y0, (axc + width * Math.cos(ang2r)), (ayc + height * Math.sin(ang2r)), xt, yt]);108});109110Clazz.newMeth(C$, 'arc_add$Z$D$D$D$D$D$D$D$D', function (first, w, h, x0, y0, x3, y3, xt, yt) {111var dx=xt - x0;112var dy=yt - y0;113var dist=dx * dx + dy * dy;114var w2=w * w;115var h2=h * h;116var r2=w2 + h2;117var fw=0.0;118var fh=0.0;119if (dist < (r2 * 1.0E8) ) {120fw=(w2 != 0.0 ) ? ((1.3333333333333333) / (1 + Math.sqrt(1 + dist / w2))) : 0.0;121fh=(h2 != 0.0 ) ? ((1.3333333333333333) / (1 + Math.sqrt(1 + dist / h2))) : 0.0;122}if (first) this.moveto$D$D(x0, y0);123var x=x0 + ((xt - x0) * fw);124var y=y0 + ((yt - y0) * fh);125x0=x3 + ((xt - x3) * fw);126y0=y3 + ((yt - y3) * fh);127this.curveto$D$D$D$D$D$D(x, y, x0, y0, x3, y3);128}, p$1);129130Clazz.newMeth(C$, 'clearRect$I$I$I$I', function (x, y, w, h) {131this.closeBlock$();132this.pw.print$S("q 1 1 1 RG ");133this.drawRect$I$I$I$I(x, y, w, h);134this.closeBlock$S("B Q");135});136137Clazz.newMeth(C$, 'clip$java_awt_Shape', function (s) {138if (s == null ) {139this.setClip$java_awt_Shape(null);140return;141}s=this.transform.createTransformedShape$java_awt_Shape(s);142if (this.clip == null ) this.clip=Clazz.new_($I$(6).c$$java_awt_Shape,[s]);143 else this.clip.intersect$java_awt_geom_Area(Clazz.new_($I$(6).c$$java_awt_Shape,[s]));144});145146Clazz.newMeth(C$, 'clipPolygon$java_awt_Polygon', function (p) {147this.closeBlock$();148this.polygon$IA$IA$I(p.xpoints, p.ypoints, p.npoints);149this.closeBlock$S("W");150this.clipRectangle=p.getBounds$();151});152153Clazz.newMeth(C$, 'clipRect$I$I$I$I', function (x, y, w, h) {154this.setClip$I$I$I$I(x, y, w, h);155});156157Clazz.newMeth(C$, 'closeBlock$', function () {158this.closeBlock$S("S");159});160161Clazz.newMeth(C$, 'closeBlock$S', function (code) {162if (this.inText) {163this.pw.println$S("ET Q");164}if (this.inStroke) {165this.pw.println$S(code);166}this.inStroke=this.inText=false;167});168169Clazz.newMeth(C$, 'copyArea$I$I$I$I$I$I', function (x, y, w, h, dx, dy) {170});171172Clazz.newMeth(C$, 'create$', function () {173this.closeBlock$();174var g=this.createGraphic$gnu_jpdf_PDFPage$java_io_PrintWriter(this.page, this.pw);175g.trax=this.trax;176g.tray=this.tray;177g.clipRectangle=Clazz.new_($I$(7).c$$java_awt_Rectangle,[this.clipRectangle]);178return g;179});180181Clazz.newMeth(C$, 'createGraphic$gnu_jpdf_PDFPage$java_io_PrintWriter', function (page, pw) {182var g=Clazz.new_(C$);183g.init$gnu_jpdf_PDFPage$java_io_PrintWriter(page, pw);184return g;185});186187Clazz.newMeth(C$, 'curveto$D$D$D$D', function (x1, y1, x2, y2) {188this.newPath$();189this.pw.println$S(p$1.cxy$D$D.apply(this, [x1, y1]) + p$1.cxy$D$D.apply(this, [x2, y2]) + "v" );190this.lx=x2;191this.ly=y2;192});193194Clazz.newMeth(C$, 'curveto$I$I$I$I', function (x1, y1, x2, y2) {195this.newPath$();196this.pw.println$S(p$1.cxy$D$D.apply(this, [x1, y1]) + p$1.cxy$D$D.apply(this, [x2, y2]) + "v" );197this.lx=x2;198this.ly=y2;199});200201Clazz.newMeth(C$, 'curveto$D$D$D$D$D$D', function (x1, y1, x2, y2, x3, y3) {202this.newPath$();203this.pw.println$S(p$1.cxy$D$D.apply(this, [x1, y1]) + p$1.cxy$D$D.apply(this, [x2, y2]) + p$1.cxy$D$D.apply(this, [x3, y3]) + "c" );204this.lx=x3;205this.ly=y3;206});207208Clazz.newMeth(C$, 'curveto$I$I$I$I$I$I', function (x1, y1, x2, y2, x3, y3) {209this.newPath$();210this.pw.println$S(p$1.cxy$D$D.apply(this, [x1, y1]) + p$1.cxy$D$D.apply(this, [x2, y2]) + p$1.cxy$D$D.apply(this, [x3, y3]) + "c" );211this.lx=x3;212this.ly=y3;213});214215Clazz.newMeth(C$, 'curveto2$D$D$D$D', function (x1, y1, x2, y2) {216this.newPath$();217this.pw.println$S(p$1.cxy$D$D.apply(this, [x1, y1]) + p$1.cxy$D$D.apply(this, [x2, y2]) + "y" );218this.lx=x2;219this.ly=y2;220});221222Clazz.newMeth(C$, 'curveto2$I$I$I$I', function (x1, y1, x2, y2) {223this.newPath$();224this.pw.println$S(p$1.cxy$D$D.apply(this, [x1, y1]) + p$1.cxy$D$D.apply(this, [x2, y2]) + "y" );225this.lx=x2;226this.ly=y2;227});228229Clazz.newMeth(C$, 'cwh$D$D', function (w, h) {230var nw=w;231var nh=h;232nh=-h;233return "" + C$.df.format$D(nw) + " " + C$.df.format$D(nh) + " " ;234}, p$1);235236Clazz.newMeth(C$, 'cxy$D$D', function (x, y) {237var ptSrc=Clazz.new_($I$(8).c$$D$D,[x, y]);238var ptDst=Clazz.new_($I$(8));239this.transform.transform$java_awt_geom_Point2D$java_awt_geom_Point2D(ptSrc, ptDst);240return "" + C$.df.format$D(ptDst.getX$()) + " " + C$.df.format$D(ptDst.getY$()) + " " ;241}, p$1);242243Clazz.newMeth(C$, 'dispose$', function () {244this.closeBlock$();245if (this.child) {246this.pw.println$S("Q");247} else {248this.pw.close$();249}});250251Clazz.newMeth(C$, 'draw$java_awt_Shape', function (s) {252p$1.followPath$java_awt_Shape$I.apply(this, [s, 2]);253});254255Clazz.newMeth(C$, 'draw3DRect$I$I$I$I$Z', function (x, y, width, height, raised) {256});257258Clazz.newMeth(C$, 'drawArc$I$I$I$I$I$I', function (x, y, w, h, sa, aa) {259w=w >> 1;260h=h >> 1;261x+=w;262y+=h;263this.arc$D$D$D$D$D$D$Z(x, y, w, h, -sa, (-sa - aa), false);264});265266Clazz.newMeth(C$, 'drawBytes$BA$I$I$I$I', function (data, offset, length, x, y) {267});268269Clazz.newMeth(C$, 'drawImage$java_awt_image_BufferedImage$java_awt_image_BufferedImageOp$I$I', function (img, op, x, y) {270var result=img;271if (op != null ) {272result=op.createCompatibleDestImage$java_awt_image_BufferedImage$java_awt_image_ColorModel(img, img.getColorModel$());273result=op.filter$java_awt_image_BufferedImage$java_awt_image_BufferedImage(img, result);274}this.drawImage$java_awt_Image$I$I$java_awt_image_ImageObserver(result, x, y, null);275});276277Clazz.newMeth(C$, 'drawImage$java_awt_Image$java_awt_geom_AffineTransform$java_awt_image_ImageObserver', function (img, xform, obs) {278return true;279});280281Clazz.newMeth(C$, 'drawImage$java_awt_Image$I$I$java_awt_Color$java_awt_image_ImageObserver', function (img, x, y, bgcolor, obs) {282return this.drawImage$java_awt_Image$I$I$I$I$java_awt_Color$java_awt_image_ImageObserver(img, x, y, img.getWidth$java_awt_image_ImageObserver(obs), img.getHeight$java_awt_image_ImageObserver(obs), bgcolor, obs);283});284285Clazz.newMeth(C$, 'drawImage$java_awt_Image$I$I$java_awt_image_ImageObserver', function (img, x, y, obs) {286return this.drawImage$java_awt_Image$I$I$I$I$java_awt_image_ImageObserver(img, x, y, img.getWidth$java_awt_image_ImageObserver(obs), img.getHeight$java_awt_image_ImageObserver(obs), obs);287});288289Clazz.newMeth(C$, 'drawImage$java_awt_Image$I$I$I$I$java_awt_Color$java_awt_image_ImageObserver', function (img, x, y, w, h, bgcolor, obs) {290this.closeBlock$();291this.pw.print$S("q ");292var c=this.getColor$();293this.setColor$java_awt_Color(bgcolor);294this.drawRect$I$I$I$I(x, y, w, h);295this.closeBlock$S("B Q");296this.paint=c;297return this.drawImage$java_awt_Image$I$I$I$I$java_awt_image_ImageObserver(img, x, y, img.getWidth$java_awt_image_ImageObserver(obs), img.getHeight$java_awt_image_ImageObserver(obs), obs);298});299300Clazz.newMeth(C$, 'drawImage$java_awt_Image$I$I$I$I$java_awt_image_ImageObserver', function (img, x, y, w, h, obs) {301this.closeBlock$();302var image=Clazz.new_($I$(9).c$$java_awt_Image$I$I$I$I$java_awt_image_ImageObserver,[img, x, y, w, h, obs]);303this.page.getPDFDocument$().setImageName$gnu_jpdf_PDFImage(image);304this.page.getPDFDocument$().add$gnu_jpdf_PDFObject(image);305this.page.addToProcset$S("/ImageC");306this.page.addImageResource$S(image.getName$() + " " + image.getSerialID$() + " 0 R" );307this.pw.print$S("q " + image.getWidth$() + " 0 0 " + image.getHeight$() + " " + x + " " + ((this.page.getDimension$().getHeight$()|0) - y - image.getHeight$() ) + " cm \n" + image.getName$() + " Do\nQ\n" );308return false;309});310311Clazz.newMeth(C$, 'drawImage$java_awt_Image$I$I$I$I$I$I$I$I$java_awt_Color$java_awt_image_ImageObserver', function (img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, obs) {312return false;313});314315Clazz.newMeth(C$, 'drawImage$java_awt_Image$I$I$I$I$I$I$I$I$java_awt_image_ImageObserver', function (img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, obs) {316return false;317});318319Clazz.newMeth(C$, 'drawLine$I$I$I$I', function (x1, y1, x2, y2) {320this.moveto$D$D(x1, y1);321this.lineto$D$D(x2, y2);322});323324Clazz.newMeth(C$, 'drawOval$I$I$I$I', function (x, y, w, h) {325this.drawArc$I$I$I$I$I$I(x, y, w, h, 0, 360);326});327328Clazz.newMeth(C$, 'drawPolygon$IA$IA$I', function (xp, yp, np) {329this.polygon$IA$IA$I(xp, yp, np);330this.closeBlock$S("s");331});332333Clazz.newMeth(C$, 'drawPolyline$IA$IA$I', function (xp, yp, np) {334this.polygon$IA$IA$I(xp, yp, np);335});336337Clazz.newMeth(C$, 'drawRect$I$I$I$I', function (x, y, w, h) {338this.newPath$();339this.pw.print$S(p$1.cxy$D$D.apply(this, [x, y]) + p$1.cwh$D$D.apply(this, [w, h]) + "re " );340this.lx=x;341this.ly=y;342});343344Clazz.newMeth(C$, 'drawRenderableImage$java_awt_image_renderable_RenderableImage$java_awt_geom_AffineTransform', function (img, xform) {345this.drawRenderedImage$java_awt_image_RenderedImage$java_awt_geom_AffineTransform(img.createDefaultRendering$(), xform);346});347348Clazz.newMeth(C$, 'drawRenderedImage$java_awt_image_RenderedImage$java_awt_geom_AffineTransform', function (img, xform) {349var image=null;350if (Clazz.instanceOf(img, "java.awt.image.BufferedImage")) {351image=img;352} else {353var cm=img.getColorModel$();354var width=img.getWidth$();355var height=img.getHeight$();356var raster=cm.createCompatibleWritableRaster$I$I(width, height);357var isAlphaPremultiplied=cm.isAlphaPremultiplied$();358var properties=Clazz.new_($I$(10));359var keys=img.getPropertyNames$();360if (keys != null ) {361for (var i=0; i < keys.length; i++) {362properties.put$TK$TV(keys[i], img.getProperty$S(keys[i]));363}364}var result=Clazz.new_($I$(4).c$$java_awt_image_ColorModel$java_awt_image_WritableRaster$Z$java_util_Hashtable,[cm, raster, isAlphaPremultiplied, properties]);365img.copyData$java_awt_image_WritableRaster(raster);366image=result;367}this.drawImage$java_awt_Image$java_awt_geom_AffineTransform$java_awt_image_ImageObserver(image, xform, null);368});369370Clazz.newMeth(C$, 'drawRoundRect$I$I$I$I$I$I', function (x, y, w, h, aw, ah) {371});372373Clazz.newMeth(C$, 'drawString$java_text_AttributedCharacterIterator$F$F', function (aci, x, y) {374});375376Clazz.newMeth(C$, 'drawString$java_text_AttributedCharacterIterator$I$I', function (aci, x, y) {377});378379Clazz.newMeth(C$, 'drawString$S$F$F', function (s, x, y) {380this.newTextBlock$F$F(x, y);381this.pw.println$S($I$(11).makePDFString$S(s) + " Tj");382});383384Clazz.newMeth(C$, 'drawString$S$I$I', function (s, x, y) {385this.newTextBlock$F$F(x, y);386this.pw.println$S($I$(11).makePDFString$S(s) + " Tj");387});388389Clazz.newMeth(C$, 'fill$java_awt_Shape', function (s) {390p$1.followPath$java_awt_Shape$I.apply(this, [s, 1]);391});392393Clazz.newMeth(C$, 'fill3DRect$I$I$I$I$Z', function (x, y, width, height, raised) {394});395396Clazz.newMeth(C$, 'fillArc$I$I$I$I$I$I', function (x, y, w, h, sa, aa) {397this.closeBlock$();398this.drawArc$I$I$I$I$I$I(x, y, w, h, sa, aa);399this.lineto$D$D(x + (w >> 1), y + (h >> 1));400this.closeBlock$S("b");401});402403Clazz.newMeth(C$, 'fillOval$I$I$I$I', function (x, y, w, h) {404this.fillArc$I$I$I$I$I$I(x, y, w, h, 0, 360);405});406407Clazz.newMeth(C$, 'fillPolygon$IA$IA$I', function (xp, yp, np) {408this.closeBlock$();409this.polygon$IA$IA$I(xp, yp, np);410this.closeBlock$S("b");411});412413Clazz.newMeth(C$, 'fillRect$I$I$I$I', function (x, y, w, h) {414this.closeBlock$();415this.drawRect$I$I$I$I(x, y, w, h);416this.closeBlock$S("B");417});418419Clazz.newMeth(C$, 'fillRoundRect$I$I$I$I$I$I', function (x, y, w, h, aw, ah) {420});421422Clazz.newMeth(C$, 'followPath$java_awt_Shape$I', function (s, drawType) {423var points;424if (s == null ) return;425if (drawType == 2) {426if (!(Clazz.instanceOf(this.stroke, "java.awt.BasicStroke"))) {427s=this.stroke.createStrokedShape$(s);428p$1.followPath$java_awt_Shape$I.apply(this, [s, 1]);429return;430}}points=s.getPathIterator$java_awt_geom_AffineTransform(C$.IDENTITY);431var segments=0;432var coords=Clazz.array(Float.TYPE, [6]);433while (!points.isDone$()){434segments++;435var segtype=points.currentSegment$FA(coords);436switch (segtype) {437case 4:438this.pw.print$S("h ");439break;440case 3:441this.curveto$D$D$D$D$D$D(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);442break;443case 1:444this.lineto$D$D(coords[0], coords[1]);445break;446case 0:447this.moveto$D$D(coords[0], coords[1]);448break;449case 2:450this.curveto$D$D$D$D(coords[0], coords[1], coords[2], coords[3]);451break;452}453points.next$();454}455switch (drawType) {456case 1:457if (segments > 0) {458if (points.getWindingRule$() == 0) this.closeBlock$S("B*");459 else this.closeBlock$S("B");460}break;461case 2:462if (segments > 0) this.closeBlock$S("S");463break;464case 3:465default:466if (segments == 0) this.drawRect$I$I$I$I(0, 0, 0, 0);467if (points.getWindingRule$() == 0) this.closeBlock$S("W*");468 else this.closeBlock$S("W");469}470}, p$1);471472Clazz.newMeth(C$, 'getBackground$', function () {473return this.background;474});475476Clazz.newMeth(C$, 'getClip$', function () {477return null;478});479480Clazz.newMeth(C$, 'getClipBounds$', function () {481return this.clipRectangle;482});483484Clazz.newMeth(C$, 'getColor$', function () {485return (Clazz.instanceOf(this.paint, "java.awt.Color")) ? this.paint : $I$(12).black;486});487488Clazz.newMeth(C$, 'getDeviceConfiguration$', function () {489return this.dg2.getDeviceConfiguration$();490});491492Clazz.newMeth(C$, 'getFont$', function () {493if (this.font == null ) this.setFont$java_awt_Font(Clazz.new_($I$(13).c$$S$I$I,["SansSerif", 0, 12]));494return this.font;495});496497Clazz.newMeth(C$, 'getFontMetrics$java_awt_Font', function (font) {498return font.getFontMetrics$();499});500501Clazz.newMeth(C$, 'getFontRenderContext$', function () {502var antialias=$I$(5).VALUE_TEXT_ANTIALIAS_ON.equals$O(this.getRenderingHint$java_awt_RenderingHints_Key($I$(5).KEY_TEXT_ANTIALIASING));503var fractions=$I$(5).VALUE_FRACTIONALMETRICS_ON.equals$O(this.getRenderingHint$java_awt_RenderingHints_Key($I$(5).KEY_FRACTIONALMETRICS));504return Clazz.new_($I$(14).c$$java_awt_geom_AffineTransform$Z$Z,[Clazz.new_($I$(1)), antialias, fractions]);505});506507Clazz.newMeth(C$, 'getPage$', function () {508return this.page;509});510511Clazz.newMeth(C$, 'getPaint$', function () {512return this.paint;513});514515Clazz.newMeth(C$, 'getRenderingHint$java_awt_RenderingHints_Key', function (arg0) {516return this.rhints.get$O(arg0);517});518519Clazz.newMeth(C$, 'getRenderingHints$', function () {520return this.rhints;521});522523Clazz.newMeth(C$, 'getStroke$', function () {524return this.originalStroke;525});526527Clazz.newMeth(C$, 'getTransform$', function () {528return Clazz.new_($I$(1).c$$java_awt_geom_AffineTransform,[this.oTransform]);529});530531Clazz.newMeth(C$, 'getWriter$', function () {532return this.pw;533});534535Clazz.newMeth(C$, 'hit$java_awt_Rectangle$java_awt_Shape$Z', function (rect, s, onStroke) {536if (onStroke) {537s=this.stroke.createStrokedShape$(s);538}s=this.transform.createTransformedShape$java_awt_Shape(s);539var area=Clazz.new_($I$(6).c$$java_awt_Shape,[s]);540if (this.clip != null ) area.intersect$java_awt_geom_Area(this.clip);541return area.intersects$D$D$D$D(rect.x, rect.y, rect.width, rect.height);542});543544Clazz.newMeth(C$, 'init', function () {545var pf=this.page.getPageFormat$();546if (this.child) {547this.pw.print$S("q ");548}this.paint=$I$(12).black;549this.oTransform=Clazz.new_($I$(1));550this.pTransform=Clazz.new_($I$(1));551this.pTransform.translate$D$D(0, pf.getHeight$());552this.pTransform.scale$D$D(1.0, -1.0);553this.transform=Clazz.new_($I$(1).c$$java_awt_geom_AffineTransform,[this.oTransform]);554this.transform.concatenate$java_awt_geom_AffineTransform(this.pTransform);555this.setStroke$java_awt_Stroke(C$.DEF_STROKE);556}, p$1);557558Clazz.newMeth(C$, 'init$gnu_jpdf_PDFPage', function (page) {559this.page=page;560this.child=false;561var stream=Clazz.new_($I$(15));562stream.setDeflate$Z(true);563page.getPDFDocument$().add$gnu_jpdf_PDFObject(stream);564page.add$gnu_jpdf_PDFObject(stream);565this.pw=stream.getWriter$();566this.clipRectangle=page.getImageableArea$();567p$1.init.apply(this, []);568});569570Clazz.newMeth(C$, 'init$gnu_jpdf_PDFPage$java_io_PrintWriter', function (page, pw) {571this.page=page;572this.pw=pw;573this.child=true;574p$1.init.apply(this, []);575});576577Clazz.newMeth(C$, 'lineto$D$D', function (x, y) {578this.newPath$();579if (x != (x|0) || y != (y|0) || this.lx != x || this.ly != y ) this.pw.print$S(p$1.cxy$D$D.apply(this, [x, y]) + "l ");580this.lx=x;581this.ly=y;582});583584Clazz.newMeth(C$, 'moveto$D$D', function (x, y) {585this.newPath$();586if (x != (x|0) || y != (y|0) || this.lx != x || this.ly != y ) this.pw.print$S(p$1.cxy$D$D.apply(this, [x, y]) + "m ");587this.lx=x;588this.ly=y;589});590591Clazz.newMeth(C$, 'newPath$', function () {592if (this.inText) {593this.closeBlock$();594}if (!this.inStroke) {595if (this.pre_np != null ) {596this.pw.print$S(this.pre_np);597this.pre_np=null;598}this.pw.print$S("n ");599}this.inText=false;600this.inStroke=true;601this.lx=this.ly=-9999;602});603604Clazz.newMeth(C$, 'newTextBlock$F$F', function (x, y) {605if (this.inStroke) {606this.closeBlock$();607}if (!this.inText) {608this.getFont$();609this.pw.print$S("q BT ");610this.tx=this.ty=0;611this.pw.print$S(p$1.txy$F$F.apply(this, [x, y]) + "Td ");612} else {613this.pw.print$S(p$1.twh$F$F$F$F.apply(this, [x, y, this.tx, this.ty]) + "Td ");614}this.tx=x;615this.ty=y;616if (this.newFont || !this.inText ) this.pw.print$S(this.pdffont.getName$() + " " + this.font.getSize$() + " Tf " );617this.inStroke=this.newFont=false;618this.inText=true;619});620621Clazz.newMeth(C$, 'polygon$IA$IA$I', function (xp, yp, np) {622this.moveto$D$D(xp[0], yp[0]);623for (var i=1; i < np; i++) this.lineto$D$D(xp[i], yp[i]);624625});626627Clazz.newMeth(C$, 'rotate$D', function (theta) {628this.transform.rotate$D(theta);629});630631Clazz.newMeth(C$, 'rotate$D$D$D', function (theta, x, y) {632this.transform.rotate$D$D$D(theta, x, y);633});634635Clazz.newMeth(C$, 'scale$D$D', function (sx, sy) {636this.transform.scale$D$D(sx, sy);637this.stroke=p$1.transformStroke$java_awt_Stroke.apply(this, [this.originalStroke]);638});639640Clazz.newMeth(C$, 'setBackground$java_awt_Color', function (color) {641this.background=color;642});643644Clazz.newMeth(C$, 'setClip$I$I$I$I', function (x, y, w, h) {645this.clipRectangle=Clazz.new_($I$(7).c$$I$I$I$I,[x, y, w, h]);646this.closeBlock$();647this.drawRect$I$I$I$I(x, y, w, h);648this.closeBlock$S("W n");649});650651Clazz.newMeth(C$, 'setClip$java_awt_Shape', function (s) {652var r=s.getBounds$();653this.setClip$I$I$I$I(r.x, r.y, r.width, r.height);654});655656Clazz.newMeth(C$, 'setColor$java_awt_Color', function (c) {657this.setPaint$java_awt_Paint(c);658});659660Clazz.newMeth(C$, 'setComposite$java_awt_Composite', function (comp) {661this.composite=comp;662});663664Clazz.newMeth(C$, 'setDefaultLineWidth$', function () {665this.closeBlock$();666this.pw.println$S("1 w");667});668669Clazz.newMeth(C$, 'setFont$java_awt_Font', function (f) {670if (this.font !== f ) {671this.font=f;672this.pdffont=this.page.getFont$S$S$I("/Type1", f.getName$(), f.getStyle$());673this.newFont=true;674}});675676Clazz.newMeth(C$, 'setLineCap$I', function (cap) {677var lineCap=0;678switch (cap) {679case 0:680lineCap=0;681break;682case 1:683lineCap=1;684break;685case 2:686lineCap=2;687break;688}689if (this.lineCap != lineCap) {690this.closeBlock$();691this.lineCap=lineCap;692this.pw.println$S("" + lineCap + " J" );693}}, p$1);694695Clazz.newMeth(C$, 'setLineJoin$I', function (join) {696var lineJoin=0;697switch (join) {698case 0:699lineJoin=0;700break;701case 1:702lineJoin=1;703break;704case 2:705lineJoin=2;706break;707}708if (this.lineJoin != lineJoin) {709this.closeBlock$();710this.lineJoin=lineJoin;711this.pw.println$S("" + lineJoin + " j" );712}}, p$1);713714Clazz.newMeth(C$, 'setLineWidth$F', function (width) {715if (width != this.lineWidth ) {716this.closeBlock$();717this.lineWidth=width;718this.pw.println$S("" + new Float(width).toString() + " w" );719}});720721Clazz.newMeth(C$, 'setMiterLimit$F', function (limit) {722if (limit != this.miterLimit ) {723this.closeBlock$();724this.miterLimit=limit;725this.pw.println$S("" + new Float(limit).toString() + " M" );726}}, p$1);727728Clazz.newMeth(C$, 'setPaint$java_awt_Paint', function (paint) {729this.paint=paint;730if (Clazz.instanceOf(paint, "java.awt.Color")) {731var c=paint;732var r=(c.getRed$()) / 255.0;733var g=(c.getGreen$()) / 255.0;734var b=(c.getBlue$()) / 255.0;735this.closeBlock$();736this.pw.println$S("" + new Double(r).toString() + " " + new Double(g).toString() + " " + new Double(b).toString() + " rg " + new Double(r).toString() + " " + new Double(g).toString() + " " + new Double(b).toString() + " RG" );737}});738739Clazz.newMeth(C$, 'setPaintMode$', function () {740});741742Clazz.newMeth(C$, 'setRenderingHint$java_awt_RenderingHints_Key$O', function (arg0, arg1) {743if (arg1 != null ) {744this.rhints.put$O$O(arg0, arg1);745} else {746this.rhints.remove$O(arg0);747}});748749Clazz.newMeth(C$, 'setRenderingHints$java_util_Map', function (hints) {750this.rhints.clear$();751this.rhints.putAll$java_util_Map(hints);752});753754Clazz.newMeth(C$, 'setStroke$java_awt_Stroke', function (s) {755this.originalStroke=s;756this.stroke=p$1.transformStroke$java_awt_Stroke.apply(this, [s]);757if (Clazz.instanceOf(this.stroke, "java.awt.BasicStroke")) {758var bs=this.stroke;759p$1.setLineCap$I.apply(this, [bs.getEndCap$()]);760p$1.setLineJoin$I.apply(this, [bs.getLineJoin$()]);761this.setLineWidth$F(bs.getLineWidth$());762p$1.setMiterLimit$F.apply(this, [bs.getMiterLimit$()]);763}});764765Clazz.newMeth(C$, 'setTransform$java_awt_geom_AffineTransform', function (t) {766this.oTransform=t;767this.transform=Clazz.new_($I$(1).c$$java_awt_geom_AffineTransform,[t]);768this.transform.concatenate$java_awt_geom_AffineTransform(this.pTransform);769this.stroke=p$1.transformStroke$java_awt_Stroke.apply(this, [this.originalStroke]);770});771772Clazz.newMeth(C$, 'setXORMode$java_awt_Color', function (c1) {773});774775Clazz.newMeth(C$, 'shear$D$D', function (shx, shy) {776this.transform.shear$D$D(shx, shy);777});778779Clazz.newMeth(C$, 'transform$java_awt_geom_AffineTransform', function (tx) {780this.transform.concatenate$java_awt_geom_AffineTransform(tx);781this.stroke=p$1.transformStroke$java_awt_Stroke.apply(this, [this.originalStroke]);782});783784Clazz.newMeth(C$, 'transformStroke$java_awt_Stroke', function (stroke) {785if (!(Clazz.instanceOf(stroke, "java.awt.BasicStroke"))) return stroke;786var st=stroke;787var scale=Math.sqrt(Math.abs(this.transform.getDeterminant$()));788var dash=st.getDashArray$();789if (dash != null ) {790for (var k=0; k < dash.length; ++k) dash[k] *= scale;791792}return Clazz.new_($I$(2).c$$F$I$I$F$FA$F,[st.getLineWidth$() * scale, st.getEndCap$(), st.getLineJoin$(), st.getMiterLimit$(), dash, st.getDashPhase$() * scale]);793}, p$1);794795Clazz.newMeth(C$, 'translate$D$D', function (tx, ty) {796this.transform.translate$D$D(tx, ty);797this.trax=tx;798this.tray=ty;799});800801Clazz.newMeth(C$, 'translate$I$I', function (x, y) {802this.translate$D$D(x, y);803});804805Clazz.newMeth(C$, 'twh$F$F$F$F', function (x, y, tx, ty) {806var nx=x;807var ny=y;808var ntx=tx;809var nty=ty;810var mh=(this.page.getPageFormat$().getHeight$()|0);811var sx=1;812var sy=1;813ny=mh - y;814nty=mh - ty;815nx=sx * (nx - ntx);816ny=sy * (ny - nty);817return "" + C$.df.format$D(nx) + " " + C$.df.format$D(ny) + " " ;818}, p$1);819820Clazz.newMeth(C$, 'txy$F$F', function (x, y) {821var ptSrc=Clazz.new_($I$(16).c$$F$F,[x, y]);822var ptDst=Clazz.new_($I$(16));823this.transform.transform$java_awt_geom_Point2D$java_awt_geom_Point2D(ptSrc, ptDst);824return "" + C$.df.format$D(ptDst.getX$()) + " " + C$.df.format$D(ptDst.getY$()) + " " ;825}, p$1);826827Clazz.newMeth(C$);828})(); ...

Full Screen

Full Screen

code.js

Source:code.js Github

copy

Full Screen

...71 if (t2.type === 'table_close') {72 let replaceTokens = [73 openBlock('table', t.level),74 ...tokens.slice(i, j + 1),75 closeBlock(t.level)76 ];77 tokens.splice(i, (j - i), ...replaceTokens);78 // skip ahead79 i += replaceTokens.length - 1;80 break;81 }82 }83 }84 }85}86function split(tokens) {87 for (let i = 0; i < tokens.length; i++) {88 let t = tokens[i];89 if (t.type === 'hr') {90 let leftContentStart = 0,91 rightContentEnd = tokens.length - 1;92 // see if there's a previous h2/h393 for (let j = i - 1; j >= 0; j--) {94 if (isHeading(tokens[j], 'heading_close')) {95 leftContentStart = j + 1;96 break;97 }98 }99 // see if there's another h2/h3 afterwards100 for (let j = i + 1; j < rightContentEnd; j++) {101 if (isHeading(tokens[j], 'heading_open')) {102 rightContentEnd = j - 1;103 break;104 }105 }106 let leftTokens = tokens.slice(leftContentStart, i);107 let rightTokens = tokens.slice(i + 1, rightContentEnd + 1);108 let replaceTokens = [109 openBlock('split'),110 openBlock('left'),111 ...leftTokens,112 closeBlock(),113 openBlock('right'),114 ...rightTokens,115 closeBlock(),116 closeBlock()117 ];118 tokens.splice(leftContentStart, (rightContentEnd - leftContentStart) + 1, ...replaceTokens);119 // skip ahead120 i = leftContentStart + replaceTokens.length;121 }122 }123}124function codeToggles(tokens) {125 for (let i = 0; i < tokens.length; i++) {126 let t = tokens[i]127 if (t.type === 'container_code_open') {128 // find the close tag129 for (let j = i + 1; j < tokens.length; j++) {130 if (tokens[j].type === 'container_code_close') {131 let innerTokens = tokens.slice(i + 1, j)132 let slotNames = [];133 let labels = {};134 codeBlocks(innerTokens, (t, i) => {135 let slotName;136 // does the slot have a custom label?137 let labelMatch = t.info.match(/([^ ]) +(.*)/);138 if (labelMatch) {139 // give the slot a random slot name140 slotName = 'slot'+i;141 labels[slotName] = labelMatch[2];142 // remove the label from the code info143 t.info = t.info.replace(labelMatch[0], labelMatch[1]);144 } else {145 // set the slot name to the language (w/out line numbers)146 slotName = t.info.replace(/\{.*\}/, '').trim();147 }148 slotNames.push(slotName);149 return [150 block(`<template slot="${slotName}">`, t.level),151 t,152 block('</template>', t.level)153 ]154 });155 let openBlock = block(`<code-toggle :languages='${JSON.stringify(slotNames)}' :labels='${JSON.stringify(labels)}'>`, tokens[i].level);156 let closeBlock = block('</code-toggle>', tokens[j].level);157 openBlock.nesting = tokens[i].nesting;158 closeBlock.nesting = tokens[j].nesting;159 let replaceTokens = [160 openBlock,161 ...innerTokens,162 closeBlock163 ]164 tokens.splice(i, j - i, ...replaceTokens);165 // skip ahead166 i += (replaceTokens.length - 1)167 break;168 }169 }170 }171 }172}173function codeBlocks(tokens, replace) {174 for (let i = 0; i < tokens.length; i++) {175 let t = tokens[i]176 if (t.type === 'fence' && t.info) {177 let replaceTokens = replace(t, i)178 tokens.splice(i, 1, ...replaceTokens)179 // skip ahead180 i += (replaceTokens.length - 1)181 }182 }183}184function isHeading(t, type) {185 return t.type === type && (t.tag === 'h1' || t.tag === 'h2' || t.tag === 'h3');186}187function block(tag, level) {188 var t = new Token('html_block', '', 0);189 t.content = `${tag}\n`;190 t.block = true;191 t.level = level || 0;192 return t;193}194function openBlock(klass, level) {195 return block(`<div class="${klass}">`, level);196}197function closeBlock(level) {198 return block('</div>', level);199}200module.exports = (md) => {201 // override parse()202 const parse = md.parse203 md.parse = (...args) => {204 const tokens = parse.call(md, ...args)205 vPres(tokens);206 tables(tokens);207 codeToggles(tokens);208 split(tokens);209 return tokens;210 }211 md.use(container, 'code', {...

Full Screen

Full Screen

markup.js

Source:markup.js Github

copy

Full Screen

...35 if (t2.type === 'table_close') {36 let replaceTokens = [37 openBlock('table', t.level),38 ...tokens.slice(i, j + 1),39 closeBlock(t.level)40 ];41 tokens.splice(i, (j - i), ...replaceTokens);42 // skip ahead43 i += replaceTokens.length - 1;44 break;45 }46 }47 }48 }49}50function split(tokens) {51 for (let i = 0; i < tokens.length; i++) {52 let t = tokens[i];53 if (t.type === 'hr') {54 let leftContentStart = 0,55 rightContentEnd = tokens.length - 1;56 // see if there's a previous h2/h357 for (let j = i - 1; j >= 0; j--) {58 if (isHeading(tokens[j], 'heading_close')) {59 leftContentStart = j + 1;60 break;61 }62 }63 // see if there's another h2/h3 afterwards64 for (let j = i + 1; j < rightContentEnd; j++) {65 if (isHeading(tokens[j], 'heading_open')) {66 rightContentEnd = j - 1;67 break;68 }69 }70 let leftTokens = tokens.slice(leftContentStart, i);71 let rightTokens = tokens.slice(i + 1, rightContentEnd + 1);72 let replaceTokens = [73 openBlock('split'),74 openBlock('left'),75 ...leftTokens,76 closeBlock(),77 openBlock('right'),78 ...rightTokens,79 closeBlock(),80 closeBlock()81 ];82 tokens.splice(leftContentStart, (rightContentEnd - leftContentStart) + 1, ...replaceTokens);83 // skip ahead84 i = leftContentStart + replaceTokens.length;85 }86 }87}88function codeToggles(tokens) {89 for (let i = 0; i < tokens.length; i++) {90 let t = tokens[i]91 if (t.type === 'container_code_open') {92 // find the close tag93 for (let j = i + 1; j < tokens.length; j++) {94 if (tokens[j].type === 'container_code_close') {95 let innerTokens = tokens.slice(i + 1, j)96 let slotNames = [];97 let labels = {};98 codeBlocks(innerTokens, (t, i) => {99 let slotName;100 // does the slot have a custom label?101 let labelMatch = t.info.match(/([^ ]) +(.*)/);102 if (labelMatch) {103 // give the slot a random slot name104 slotName = 'slot'+i;105 labels[slotName] = labelMatch[2];106 // remove the label from the code info107 t.info = t.info.replace(labelMatch[0], labelMatch[1]);108 } else {109 // set the slot name to the language (w/out line numbers)110 slotName = t.info.replace(/\{.*\}/, '').trim();111 }112 slotNames.push(slotName);113 return [114 block(`<template slot="${slotName}">`, t.level),115 t,116 block('</template>', t.level)117 ]118 });119 let openBlock = block(`<code-toggle :languages='${JSON.stringify(slotNames)}' :labels='${JSON.stringify(labels)}'>`, tokens[i].level);120 let closeBlock = block('</code-toggle>', tokens[j].level);121 openBlock.nesting = tokens[i].nesting;122 closeBlock.nesting = tokens[j].nesting;123 let replaceTokens = [124 openBlock,125 ...innerTokens,126 closeBlock127 ]128 tokens.splice(i, j - i, ...replaceTokens);129 // skip ahead130 i += (replaceTokens.length - 1)131 break;132 }133 }134 }135 }136}137function codeBlocks(tokens, replace) {138 for (let i = 0; i < tokens.length; i++) {139 let t = tokens[i]140 if (t.type === 'fence' && t.info) {141 let replaceTokens = replace(t, i)142 tokens.splice(i, 1, ...replaceTokens)143 // skip ahead144 i += (replaceTokens.length - 1)145 }146 }147}148function isHeading(t, type) {149 return t.type === type && (t.tag === 'h1' || t.tag === 'h2' || t.tag === 'h3');150}151function block(tag, level) {152 var t = new Token('html_block', '', 0);153 t.content = `${tag}\n`;154 t.block = true;155 t.level = level || 0;156 return t;157}158function openBlock(klass, level) {159 return block(`<div class="${klass}">`, level);160}161function closeBlock(level) {162 return block('</div>', level);163}164module.exports = (md) => {165 // Custom <code> renders166 md.renderer.rules.code_inline = renderInlineCode;167 // override parse()168 const parse = md.parse169 md.parse = (...args) => {170 const tokens = parse.call(md, ...args)171 tables(tokens);172 codeToggles(tokens);173 split(tokens);174 return tokens;175 }...

Full Screen

Full Screen

js.js

Source:js.js Github

copy

Full Screen

1window.onload=function(){2 var oImg=document.getElementById('bottom');3 var aImg=oImg.getElementsByTagName('img'); //关卡图片4 for(var i=0; i<aImg.length; i++){ //给图片添加关卡5 (function(index){6 aImg[index].onclick=function(){7 var n=index+1;8 start(n);9 }10 })(i);11 }12 start('1'); //默认初始化第一关卡13}14function start(n){15 var oCont=document.getElementById('wall'); //拼图容器16 oCont.className='start'+n; //通过给容器加class切换关卡17 oCont.style.cssText='';18 oCont.innerHTML='';19 //创建拼图块20 var aLi=document.createDocumentFragment();21 var arr=[];22 while(arr.length<24){23 var n=rnd(1,24);24 if(isInArry(n,arr)){25 continue;26 }else{27 var oLi=document.createElement('li');28 arr.push(n);29 oLi.className='b'+n;30 aLi.appendChild(oLi);31 }32 }33 oCont.appendChild(aLi);34 //布局转换,添加拖拽和换位35 var aDiv=oCont.children;36 for(var i=0; i<aDiv.length; i++){37 aDiv[i].style.top=aDiv[i].offsetTop+1+'px';38 aDiv[i].style.left=aDiv[i].offsetLeft+1+'px';39 drag(aDiv[i]);40 }41 for(var i=0; i<aDiv.length; i++){42 aDiv[i].style.position='absolute';43 }44 function getClosed(arr){ //找到距离最小块的索引45 var index=0;46 for(var i=0;i<arr.length; i++){47 if(arr[index].dis>arr[i].dis){48 index=i;49 }50 }51 return index;52 }53 function isDown(){ //是否完成拼图54 var arr=oCont.children;55 for(var i=0;i<arr.length;i++){56 var s=arr[i].className;57 if(!(s.substring(1)==i+1)){58 return false;59 }60 }61 return true;62 }63 var dragable=true;64 function drag(obj){ //拖拽和换位65 var oBlock=obj;//当前拖拽的block66 oBlock.onmousedown=function(e){67 if(!dragable) return;68 var oEvent=e||event;69 //当前拖拽块的状态(鼠标按下)70 oBlock.style.zIndex='2';71 oBlock.style.opacity='0.7';72 var oldL=oBlock.offsetLeft;73 var oldT=oBlock.offsetTop;74 var disX=oEvent.clientX-oBlock.offsetLeft;75 var disY=oEvent.clientY-oBlock.offsetTop;76 //其他块的状态77 var aOthers=[];78 for(var i=0; i<aDiv.length; i++){79 if(aDiv[i]==oBlock)continue;80 aDiv[i].left=aDiv[i].offsetLeft;81 aDiv[i].top=aDiv[i].offsetTop;82 aDiv[i].right=aDiv[i].offsetLeft+aDiv[i].offsetWidth;83 aDiv[i].bottom=aDiv[i].offsetTop+aDiv[i].offsetHeight;84 aDiv[i].cY=aDiv[i].offsetTop+aDiv[i].offsetHeight/2;85 aDiv[i].cX=aDiv[i].offsetLeft+aDiv[i].offsetWidth/2;86 aOthers.push(aDiv[i]);87 }88 var closeBlock; //定义距离最小的块89 document.onmousemove=function(e){90 //计算当前托拽块的状态(拖动)91 var oEvent=e||event;92 var l=oEvent.clientX-disX;93 var t=oEvent.clientY-disY;94 oBlock.style.left=l+'px';95 oBlock.style.top=t+'px';96 var thisBlock={97 left:oBlock.offsetLeft,98 top:oBlock.offsetTop,99 right:oBlock.offsetLeft+oBlock.offsetWidth,100 bottom:oBlock.offsetTop+oBlock.offsetHeight,101 cY:oBlock.offsetTop+oBlock.offsetHeight/2,102 cX:oBlock.offsetLeft+oBlock.offsetWidth/2103 };104 //获得所有有接触的块105 var tachArr=[];106 for(var i=0; i<aOthers.length; i++){107 if(thisBlock.left>aOthers[i].right-30||thisBlock.top>aOthers[i].bottom-30||thisBlock.right<aOthers[i].left+30||thisBlock.bottom<aOthers[i].top+30){108 //FALSE109 // aOthers[i].style.cssText='';110 aOthers[i].style.boxShadow='';111 aOthers[i].style.zIndex='';112 }else{113 //TRUE114 var y=thisBlock.cY-aOthers[i].cY;115 var x=thisBlock.cX-aOthers[i].cX;116 aOthers[i].dis=Math.sqrt(y*y+x*x);117 tachArr.push(aOthers[i]);118 }119 }120 //在有接触的块里,获得距离最小的块closeBlock121 if(tachArr.length){122 for(var j=0; j<tachArr.length; j++){123 // tachArr[j].style.cssText=''124 tachArr[j].style.boxShadow='';125 tachArr[j].style.zIndex='';126 }127 closeBlock=tachArr[getClosed(tachArr)];128 closeBlock.style.boxShadow='0 0 20px #02FF6D';129 closeBlock.style.zIndex='1';130 }else{131 closeBlock=null;132 }133 };134 document.onmouseup=function(){135 //存在距离最小块,则交换位置136 if(closeBlock){137 var oI=document.createElement('i');138 oCont.insertBefore(oI,oBlock);139 oCont.insertBefore(oBlock,closeBlock);140 oCont.insertBefore(closeBlock,oI);141 oCont.removeChild(oI);142 // closeBlock.style.cssText='';143 var t=closeBlock.offsetTop;144 var l=closeBlock.offsetLeft;145 dragable=false;146 startMove(oBlock,{top:t+1,left:l+1})147 startMove(closeBlock,{top:oldT+1,left:oldL+1},{end:function(){148 closeBlock.style.zIndex='';149 oBlock.style.opacity='';150 oBlock.style.zIndex='';151 dragable=true;152 //是否完成拼图153 if(isDown()){154 alert('恭喜!!\n拼图已经完成')155 oCont.style.background='url(img/img'+oCont.className.substring(5)+'.jpg) center center no-repeat #000'156 oCont.style.boxShadow='0 0 10px #02FF6D'157 oCont.style.padding='0'158 oCont.style.height=602+'px'159 oCont.style.width=902+'px'160 oCont.innerHTML=''161 }162 }})163 closeBlock.style.boxShadow='';164 // closeBlock.style.zIndex='1';165 oBlock.style.opacity=1;166 }else{167 dragable=false;168 startMove(oBlock,{top:oldT+1,left:oldL+1},{end:function(){169 dragable=true;170 }});171 oBlock.style.opacity='';172 oBlock.style.zIndex='';173 }174 // oBlock.style.cssText='';175 document.onmousemove=null;176 document.onmouseup=null;177 oBlock.releaseCapture&&oBlock.releaseCapture();178 179 };180 oBlock.setCapture&&oBlock.setCapture();181 return false;182 }183 }...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1import './style2.css';2// import './img';3//проверка работы вебпака и бабеля4var moment = require('moment');5console.log(moment().startOf('day').fromNow());6var name = "Bogdan",7 time = "todayy";8console.log(`Hello ${name}, how are you ${time}?`);9//проверка работы вебпака и бабеля10const keyLetters = document.querySelectorAll('.keyletter');11const conceptLogo = document.querySelector('.concept-logo');12const heading = document.querySelector('.heading');13const conceptWrapper = document.querySelector('.concept-wrapper');14const closeblocks = document.querySelectorAll('.closeblock');15let left = document.querySelector('.closeblock-left');16let right = document.querySelector('.closeblock-right');17function animateObject(objectName, animationName, duration) {18 objectName.style.animationName = animationName;19 objectName.style.animationDuration = duration;20 objectName.style.animationFillMode = 'forwards'; //чтобы позиция фиксировалась в конце анимации21}22function deleteObject(objectName) {23 objectName.classList.add('d-none');24}25function restoreObject(objectName) {26 objectName.classList.remove('d-none');27}28function removeAnimation(objectName) {29 objectName.style.animationName = null;30 objectName.style.animationDuration = null;31 objectName.style.animationFillMode = null;32}33function showHiddenConcepts(keyLetterSpecificClassName, conceptClassName, regExpMask) {34 let specialClasses = document.querySelectorAll(conceptClassName);35 for (let specialClass of specialClasses) {36 let conceptSpecificClassName = specialClass.className.match(regExpMask);37 if (String(keyLetterSpecificClassName) === String(conceptSpecificClassName)) {38 restoreObject(specialClass);39 if (conceptClassName === '.clipped') {40 animateObject(specialClass, 'unclipping', '1s');41 }42 else if (conceptClassName === '.concept') {43 animateObject(specialClass, 'fontDance', '1s');44 }45 } else {46 deleteObject(specialClass);47 }48 }49}50function hideShownObjects(classToHide) {51 let specialObjects = document.querySelectorAll(classToHide);52 for (let specialObject of specialObjects) {53 deleteObject(specialObject);54 }55}56function closeConcepts(whatToShrink, animOne, animTwo) {57 animateObject(whatToShrink, 'shrinkConcepts', '1s');58 animateObject(animOne, 'moveLeftBlock', '1s');59 animateObject(animTwo, 'moveRightBlock', '1s');60 hideShownObjects('.clipped');61}62for (let keyLetter of keyLetters) {63 keyLetter.onclick = function() {64 animateObject(conceptLogo, 'toLeft', '1s');65 animateObject(conceptWrapper, 'testing', '1s');66 for (let closeblock of closeblocks) {67 restoreObject(closeblock);68 if (closeblock.classList.contains('closeblock-left')) {69 animateObject(closeblock, 'showLeftBlock', '1s');70 } else {71 animateObject(closeblock, 'showRightBlock', '1s');72 }73 };74 // heading.classList.add('d-none');75 deleteObject(heading);76 let kLClassName = keyLetter.className.match(/\bconcept-\w+\b/);77 let kLClassName2 = keyLetter.className.match(/\bkl-\w+\b/);78 //------79 showHiddenConcepts(kLClassName, '.concept', /\bconcept-\w+\b/);80 showHiddenConcepts(kLClassName2, '.clipped', /\bkl-\w+\b/);81 }82}83function bombThis() {84 left.classList.add('d-none');85 right.classList.add('d-none');86}87for (let closeblock of closeblocks) {88 closeblock.onclick = function() {89 closeConcepts(conceptWrapper, left, right);90 setTimeout(bombThis, 1000);91 setTimeout(hideShownObjects, 500, '.concept');92 setTimeout(removeAnimation, 500, conceptLogo);93 setTimeout(restoreObject, 500, heading);94 }95}...

Full Screen

Full Screen

projects.js

Source:projects.js Github

copy

Full Screen

1'use strict';2angular.module('projectsDirective', [])3 .directive('projDir', function() {4 return{5 restrict: 'E',6 templateUrl: 'app/pages/projects.html',7 8 link: function(scope, element){9// $('.closeblock').click(function(){10// var clicked = $(this);11// 12// $('.openblock').not(clicked).toggleClass('openblock closeblock');13//14// clicked.toggleClass('closeblock openblock');15// 16// });17 18 19 20 $('.closeblock').hover(function(){21 $(this).find('.launch').css({22 'visibility':'visible',23 'opacity':'1'24 });25 });26 27 $('.closeblock').mouseleave(function(){28 $(this).find('.launch').css({29 'opacity':'0'30 });31 });32 33 $('.launch').click(function(){34 35 setTimeout(function(){36 var h = $('.fade').height();37 $('#view-wrapper').css({'height': h-100});38 }, 400);39 setTimeout(function(){40 var topH = $("#view-wrapper").offset().top;41 var ttop = topH - 50;42 $('html, body').animate({43 scrollTop: ttop44 }, 500);45 },500);46 });47 48 49 50 }51 }...

Full Screen

Full Screen

close-lk-block.js

Source:close-lk-block.js Github

copy

Full Screen

1// var close = $('.icon_delete-cross');2//3// close.on('click', function () {4// var closed_block = $(this).parent().parent('.block_js'),5// /*closed_block2 = $(this).parent().parent('.lk-user-stats'),*/6// closed_col = $(this).parent().parent().parent('.lk-col-3');7//8//9// closed_block.addClass('closeblock');10//11// if (closed_block.siblings('.closeblock').length > 0) {12//13// closed_col.addClass('closeblock');14// setTimeout(function () {15// $(closed_col).hide(200);16// }, 300);17// }18//19// else if (closed_block.siblings('.closeblock').length == 0) {20//21// closed_block.addClass('closeblock');22// setTimeout(function () {23// $(closed_block).hide(200);24// }, 300);25// }26// });27var close = $('.icon_delete-cross');28close.on('click', function () {29 var closed_block = $(this).parent().parent('.block_js'),30 blocksLength = $('.lk-right-block').filter(':visible').length - 1,31 closed_col = $(this).parent().parent().parent('.lk-col-3');32 closed_block.addClass('closeblock');33 if (blocksLength > 0) {34 closed_block.addClass('closeblock');35 setTimeout(function () {36 $(closed_block).hide(200);37 }, 300);38 } else {39 closed_col.addClass('closeblock');40 setTimeout(function () {41 $(closed_col).hide(200);42 }, 300);43 }...

Full Screen

Full Screen

closeblock.js

Source:closeblock.js Github

copy

Full Screen

1Drupal.behaviors.closeblock = function (context) {2 var i, length, block,3 closeblock = Drupal.settings.closeblock;4 length = closeblock.length;5 for (i = 0; i < length; i++) {6 block = jQuery('#block-' + closeblock[i].replace('_', '-'), context);7 if (block.length === 0) {8 continue;9 }10 if (block.find('a.closeblock').length === 0) {11 jQuery('<a></a>').text(Drupal.t('Close')).attr('href', '#').addClass('closeblock').appendTo(block.children()).click((function (name, box) {12 return function () {13 if (!jQuery.cookies.get('closeblock[' + name + ']')) {14 jQuery.cookies.set('closeblock[' + name + ']', 1, {hoursToLive : 31536000});15 }16 block.remove();17 return false;18 };19 })(closeblock[i], block));20 }21 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4const brcontext = await owser =.newContext();5 const page a await context.newPage();6 awaitwpage.closeBlock();7 await browser.close();8})();9## **How to use the `(loseBlock` met{od?**

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch headless: false });4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.closeBlock();7 await browser.close();8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.closeBlock('ads');7 await page.screenshot({ path: 'google.png' });8 await browser.close();9})();10const { chromium } = require('playwright');11const { closeBlock } = require('playwright-internal-api');12(async () => {13 const browser = await chromium.launch();14 const context = await browser.newContext();15 const page = await context.newPage();16 await closeBlock(page, 'ads');17 await page.screenshot({ path: 'google.png' });18 await browser.close();19})();20closeBlock(page, blockName, options)21| options | Object | An object that has the following properties: <br> - **timeout** - The time (in milliseconds) to wait for the block. |

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.closeBlock('ads');7 await page.screenshot({ path: 'google.png' });8 await browser.close();9})();10const { chromium } = require('playwright');11const { closeBlock } = require('playwright-internal-api');12(async () => {13 const browser = await chromium.launch();14 const context = await browser.newContext();15 const page = await context.newPage();16 await closeBlock(page, 'ads');17 await page.screenshot({ path: 'google.png' });18 await browser.close();19})();20closeBlock(page, blockName, options)21| options | Object | An object that has the following properties: <br> - **timeout** - The time (in milliseconds) to wait for the block. |

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.closeBlock('www.google.com');7 await browser.close();8})();9#### page.closeBlock(url)10#### page.closeBlock([options])11ocs');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { closeBlock } = require('@playwright/test');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 await page.screenshot({ path: `example.png` });8 await browser.close();9})();10closeBlock('test block');11const { closeBlock } = require('@playwright/test');12const { chromium } = require('playwright');13(async () => {14 const browser = await chromium.launch();15 const context = await brwser.newContext();16 const page = await ontext.newPage();17## Licensescreenshot({ path: `example.png` });18 await browser.close();19})();20loseBlock('test block');21const { closeBlock } = require('@playwright/test');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 await page.screenshot({ path: `example.png` });28 await browser.close();29})();30closeBlock('test block');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require("playwright");2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const elementHandle = await page.$("h1");7 await page.evaluate((element) => element.remove(), elementHandle);8 await page.close();9 await browser.close();10})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.click('text=Docs');6 await page.click('text=API');7 await page.click('text=Page');8 await page.click('text=close');9 await page.closeBlock();10 await browser.close();11})();12const { chromium } = require('playwright');13(async () => {14 const browser = await chromium.launch();15 const page = await browser.newPage();16 await page.click('text=Docs');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.click('text=Docs');7 await page.click('text=API');8 await page.click('text=class: Page');9 await page.click('text=close');10 await page.click('text=class: Page');11 await page.click('text=close');12 await browser.close();13})();lick('text=API');14 await page.click('text=Page');15 await page.clickBlock('text=Page', 'text=close');16 await browser.close();17})();18const { chromium } = require('playwright');19(async () => {20 const browser = await chromium.launch();21 const page = await browser.newPage();22 await page.click('text=Docs');23 await page.click('text=API');24 await page.click('text=Page');25 await page.hoverBlock('text=Page', 'text=close');26 await browser.close();27})();28const { chromium }

Full Screen

Using AI Code Generation

copy

Full Screen

1const { test, expect } = require('@playwright/test');2const { closeBlock } = require('@playwright/test');3test('My first test', async ({ page }) => {4 const title = page.locator('.navbar__inner .navbar__title');5 await expect(title).toHaveText('Playwright');6 await page.screenshot({ path: `example.png` });7 await page.click('text=Docs');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.click('text=Docs');7 await page.click('text=API');8 await page.click('text=class: Page');9 await page.click('text=close');10 await page.click('text=class: Page');11 await page.click('text=close');12 await browser.close();13})();

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful