Best JavaScript code snippet using playwright-internal
skins.js
Source:skins.js
12/*3 * PERGOLA - JAVASCRIPT SVG FRAMEWORK AND LIBRARIES4 *5 * SKINS LIBRARY6 *7 * Copyright (C) 2009-2013 Dotuscomus8 * info@dotuscomus.com9 * http://www.dotuscomus.com/pergola/licenses10*/111213pergola.skins = {14 rubber : function () {15 var defs = pergola.defs,16 shade = pergola.color.shade,17 gradient,18 pattern,19 luminosity;2021 pergola.color.lab(pergola.color.convert(pergola.theme));22 luminosity = pergola.themeLuminosity;2324 pergola.presentationAttributes = {25 all : {26 'font-family' : "'Segoe UI', 'Trebuchet MS', 'Lucida Grande', 'Deja Vu'",27 'font-size' : 13,28 stroke : "#7F7F7F"29 },30 background : {31 fill : "white",32 stroke : "none",33 opacity : .5,34 'xlink:href' : ""35 },36 button : {37 fill : "url(#buttonGrad)",38 stroke : "#878787",39 maskFill : "url(#buttonMaskGrad)",40 large : {41 width : 20,42 height : 2043 },44 small : {45 width : 14,46 height : 1447 }48 },49 checkBox : {50 width : 13,51 height : 13,52 fill : "white"53 },54 colorBoxSelector : {55 fill : "#FFFFFF",56 stroke : "#B0B0B0",57 width : 216,58 height : 2159 },60 comboBox : {61 width : 220,62 height : 160,63 listItemHeight : 21,64 listMargin : 865 },66 commandButton : {67 width : 15,68 height : 13,69 rx : 370 },71 coordinates : {72 "font-size" : 1273 },74 dialogButton : {75 width : 64,76 height : 25,77 rx : 378 },79 frame : {80 width : 200,81 height : 200,82 fill : shade([90, 90, 90]),83 stroke : shade([90, 90, 90], -24),84 'fill-opacity' : function () {85 var c = pergola.color.hexToRGB(pergola.presentationAttributes.background.fill);86 var lum = pergola.color.luminosity(c[0], c[1], c[2]);87 return (.2 + .15 * (lum < luminosity));88 },89 'stroke-opacity' : function () {90 var c = pergola.color.hexToRGB(pergola.presentationAttributes.background.fill);91 var lum = pergola.color.luminosity(c[0], c[1], c[2]);92 return (.3 + .3 * (lum < luminosity));93 },94 rx : 395 },96 input : {97 width : 36,98 height : 20,99 fill : "#FFFFFF",100 stroke : "#A0A0A0",101 hasButtons : true102 },103 inputCursor : {104 blinkRate : 750105 },106 legend : {107 'font-size' : '12px'108 },109 listItem : {110 fill : "url(#listItemGrad)",111 maskFill : "#FBFBFB"112 },113 menu : {114 'font-size' : '12px',115 fill : "url(#menuGrad)",116 stroke : shade([100, 100, 100], -4),117 rx : 3,118 opacity : 0.4119 },120 menuBar : {121 "font-size" : "12px",122 height : 19,123 fill : "url(#menubarGrad)"124 },125 menuItem : {126 height : 19,127 fill : "url(#listItemGrad)"128 },129 menuList : {130 margin : 15,131 filter : pergola.filter.blur({stdDeviation : 1.4, dx : 2.8, dy : 2.8, "flood-opacity" : .42})132 },133 notification : {134 x : 440,135 y : 340,136 width : 360,137 height : 220,138 fill : "white"139 },140 panel : {141 x : 150,142 y : 120,143 width : 440,144 height : 360,145 margin : 4,146 fill : "#ebecec",147 footerFill : "#ebecec",148 footerHeight : 60,149 filter : pergola.filter.blur()150 },151 popupList : {152 width : 200,153 listItemHeight : 20,154 listMargin : 8155 },156 preview : {157 rx : 2,158 width : 150,159 height : 120,160 opacity : .5161 },162 progress : {163 fill : "#F0F0F0",164 stroke : "#E0E0E0",165 statusFill : "url(#progressGrad)",166 width : 300,167 height : 12168 },169 quickTip : {170 'font-size' : '8pt',171 rx : 6,172 fill : "url(#quickTipGrad)",173 stroke : "#989898",174 textFill : "#242424",175 delay : 700176 },177 radioButton : {178 r : 7,179 dotR : 3,180 fill : "url(#radioButtonGrad)",181 stroke : "#808080",182 dotFill : "#303030"183 },184 rubberBox : {185 stroke : "black",186 'stroke-width' : 1,187 'stroke-dasharray' : "1,2",188 maskStroke : "white"189 },190 scrollBar : {191 fill : shade([100, 100, 100], 40),192 stroke : "#D0D0D0",193 horTrackFill : "url(#hTrackGrad)",194 vertTrackFill : "url(#vTrackGrad)",195 rx : 0,196 size : 15,197 padding : 1.5,198 delay : 250,199 stepFrequence : 50,200 step : 40,201 pageFrequence : 100,202 mapPageFrequence : 500203 },204 scrollSlider : {205 fill : {206 horizontal : "url(#sliderPattern)",207 vertical : "url(#sliderPattern)"208 },209 rx : 0,210 stroke : {211 horizontal : shade([100, 100, 100]),212 vertical : shade([100, 100, 100])213 }214 },215 selector : {216 'font-size' : "9pt",217 fill : "#F5F5F6",218 stroke : "#B0B0B0",219 maskFill : "#B0B0B0",220 'stroke-width' : 2,221 rx : 5,222 width : 216,223 height : 21224 },225 separator : {226 width : 13,227 height : 5228 },229 slider : {230 'font-size' : "7pt",231 rx : 2,232 fill : "url(#sliderButtonGrad)",233 stroke : "#FFFFFF",234 trackFill : "#C0C0C0",235 trackStroke : "none",236 trackOpacity : .05,237 slotStroke : "#606060",238 slotSize : 1,239 shape : "round",240 size : 16,241 type : "linear",242 initial : "middle",243 valueTip : false244 },245 statusBar : {246 fill : "url(#statusBarGrad)",247 height : 20,248 "font-size" : "10px",249 advanceX : 10250 },251 tab : {252 'font-size' : '8pt',253 fill : "url(#tabGrad)",254 'fill-opacity' : .5,255 width : 120,256 height : 18.5257 },258 taskBar : {259 fill : "url(#taskbarGrad)",260 maskFill : shade([100, 100, 100], 20),261 width : "100%",262 height : 32,263 position : "top",264 hasMenu : false265 },266 text : {267 fill : (luminosity < 128)? "white" : "#000000",268 fillInverse : (luminosity < 128)? "#000000" : "#FFFFFF",269 shadow : (luminosity < 128)? "#000000" : shade([82, 84, 85.5], luminosity / 4)270 },271 toolBar : {272 fill : "url(#toolbarGrad)",273 height : 29,274 rx : 0,275 spacing : 5276 },277 toolButton : {278 fill : "url(#buttonGrad)",279 stroke : "url(#toolButtonStrokeGrad)",280 maskFill : "url(#toolButtonMaskGrad)",281 rx : 6282 },283 topBar : {284 fill : {285 panel : "url(#topBarGrad)",286 window : "url(#winTopBarGrad)",287 messageBox : "url(#alertTopBarGrad)"288 },289 maskFill : shade([100, 100, 100], 25),290 height : {291 panel : 32,292 window : 44293 }294 },295 window : {296 fill : "#FFFFFF",297 scrollSize : 17298 },299 windowTab : {300 'font-size' : 11,301 width : 100,302 fill : "url(#windowTabGrad)",303 maskFill : "url(#windowTabMaskGrad)",304 maskStroke : shade([100, 100, 100], 75)305 }306 };307308 gradient = $C({element : "linearGradient", id : "taskbarGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});309 $C({element : "stop", offset : "0%", "stop-color" : "#FFFFFF", "stop-opacity" : .9, appendTo : gradient});310 $C({element : "stop", offset : "4%", "stop-color" : "#D8D8D8", "stop-opacity" : .65, appendTo : gradient});311 $C({element : "stop", offset : "95%", "stop-color" : "#606060", "stop-opacity" : .4, appendTo : gradient});312 $C({element : "stop", offset : "100%", "stop-color" : "#000000", appendTo : gradient});313314 gradient = $C({element : "linearGradient", id : "windowTabGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});315 $C({element : "stop", offset : "0%", "stop-color" : shade([90, 90, 90], 20), appendTo : gradient});316 $C({element : "stop", offset : "100%", "stop-color" : shade([90, 90, 90], 50), appendTo : gradient});317318 gradient = $C({element : "linearGradient", id : "windowTabMaskGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});319 $C({element : "stop", offset : "0%", "stop-color" : shade([90, 90, 90], 20), appendTo : gradient});320 $C({element : "stop", offset : "100%", "stop-color" : shade([90, 90, 90], 0), appendTo : gradient});321322 gradient = $C({element : "linearGradient", id : "topBarGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});323 $C({element : "stop", offset : "0%", "stop-color" : shade([100, 100, 100], -18), appendTo : gradient});324 $C({element : "stop", offset : "10%", "stop-color" : shade([100, 100, 100]), appendTo : gradient});325 $C({element : "stop", offset : "94%", "stop-color" : shade([100, 100, 100], 10), appendTo : gradient});326 $C({element : "stop", offset : "100%", "stop-color" : shade([100, 100, 100], 60), appendTo : gradient});327328 gradient = $C({element : "linearGradient", id : "alertTopBarGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});329 $C({element : "stop", offset : "0%", "stop-color" : shade([100, 100, 100], -36), appendTo : gradient});330 $C({element : "stop", offset : "10%", "stop-color" : shade([100, 100, 100], -16), appendTo : gradient});331 $C({element : "stop", offset : "95%", "stop-color" : shade([100, 100, 100], -8), appendTo : gradient});332 $C({element : "stop", offset : "100%", "stop-color" : shade([100, 100, 100], 80), appendTo : gradient});333334 gradient = $C({element : "linearGradient", id : "winTopBarGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});335 $C({element : "stop", offset : "0%", "stop-color" : shade([100, 100, 100], -40), appendTo : gradient});336 $C({element : "stop", offset : "1%", "stop-color" : shade([100, 100, 100], -18), appendTo : gradient});337 $C({element : "stop", offset : "12%", "stop-color" : shade([100, 100, 100]), appendTo : gradient});338 $C({element : "stop", offset : "92%", "stop-color" : shade([100, 100, 100], 10), appendTo : gradient});339 $C({element : "stop", offset : "100%", "stop-color" : shade([100, 100, 100], 32), appendTo : gradient});340341 gradient = $C({element : "linearGradient", id : "menuGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});342 $C({element : "stop", offset : "0%", "stop-color" : shade([100, 100, 100], 50), appendTo : gradient});343 $C({element : "stop", offset : "100%", "stop-color" : shade([100, 100, 100], 45), appendTo : gradient});344345 gradient = $C({element : "linearGradient", id : "menubarGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});346 $C({element : "stop", offset : "0%", "stop-color" : shade([103.333, 98.514, 92.934]), appendTo : gradient});347 $C({element : "stop", offset : "44%", "stop-color" : shade([104.761, 99.009, 91.847]), appendTo : gradient});348 $C({element : "stop", offset : "100%", "stop-color" : shade([102.38, 91.584, 80.434]), appendTo : gradient});349350 gradient = $C({element : "radialGradient", id : "radioButtonGrad", cx : "65%", cy : "65%", r : "100%", fx : "65%", fy : "65%", gradientUnits : "objectBoundingBox", appendTo : defs});351 $C({element : "stop", offset : "0%", "stop-color" : "#F0F0F0", appendTo : gradient});352 $C({element : "stop", offset : "100%", "stop-color" : "#A8B0B8", appendTo : gradient});353354 gradient = $C({element : "linearGradient", id : "tabGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});355 $C({element : "stop", offset : "0%", "stop-color" : "#C0C0C0", appendTo : gradient});356 $C({element : "stop", offset : "15%", "stop-color" : "#ECECEC", appendTo : gradient});357 $C({element : "stop", offset : "50%", "stop-color" : "white", appendTo : gradient});358359 gradient = $C({element : "linearGradient", id : "toolbarGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});360 $C({element : "stop", offset : "0%", "stop-color" : shade([102.333, 100, 96.934]), appendTo : gradient});361 $C({element : "stop", offset : "44%", "stop-color" : shade([103.761, 100.009, 97.847]), appendTo : gradient});362 $C({element : "stop", offset : "100%", "stop-color" : shade([99.38, 92.584, 88.434]), appendTo : gradient});363364 gradient = $C({element : "linearGradient", id : "statusBarGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});365 $C({element : "stop", offset : "0%", "stop-color" : shade([100, 100, 100], 70), appendTo : gradient});366 $C({element : "stop", offset : "8%", "stop-color" : shade([100, 100, 100], 10), appendTo : gradient});367 $C({element : "stop", offset : "94%", "stop-color" : shade([100, 100, 100], 10), appendTo : gradient});368 $C({element : "stop", offset : "100%", "stop-color" : shade([100, 100, 100], -30), appendTo : gradient});369370 gradient = $C({element : "linearGradient", id : "toolButtonMaskGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});371 $C({element : "stop", offset : "0%", "stop-color" : shade([104.761, 99.009, 91.847], 30), appendTo : gradient});372 $C({element : "stop", offset : "44%", "stop-color" : shade([104.761, 99.009, 91.847], 36), appendTo : gradient});373 $C({element : "stop", offset : "100%", "stop-color" : shade([104.761, 99.009, 91.847], 21), appendTo : gradient});374375 gradient = $C({element : "linearGradient", id : "toolButtonStrokeGrad", x1 : "0%", y1 : "0%", x2 : "33%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});376 $C({element : "stop", offset : "0%", "stop-color" : shade([100, 100, 100], 100), appendTo : gradient});377 $C({element : "stop", offset : "100%", "stop-color" : shade([100, 100, 100], 60), appendTo : gradient});378379 gradient = $C({element : "linearGradient", id : "hTrackGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});380 $C({element : "stop", offset : "0%", "stop-color" : shade([100, 100, 100], -35), appendTo : gradient});381 $C({element : "stop", offset : "12%", "stop-color" : shade([100, 100, 100], 78), appendTo : gradient});382 $C({element : "stop", offset : "88%", "stop-color" : shade([100, 100, 100], 78), appendTo : gradient});383 $C({element : "stop", offset : "100%", "stop-color" : "#FFFFFF", appendTo : gradient});384385 gradient = $C({element : "linearGradient", id : "listItemGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});386 $C({element : "stop", offset : "0%", "stop-color" : shade([120.283, 61.538, 47.058], 9), appendTo : gradient});387 $C({element : "stop", offset : "45%", "stop-color" : shade([120.283, 61.538, 47.058], 11), appendTo : gradient});388 $C({element : "stop", offset : "55%", "stop-color" : shade([120.283, 61.538, 47.058], 10), appendTo : gradient});389 $C({element : "stop", offset : "100%", "stop-color" : shade([120.283, 61.538, 47.058], -5), appendTo : gradient});390391 gradient = $C({element : "linearGradient", id : "vTrackGrad", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "0%", gradientUnits : "objectBoundingBox", appendTo : defs});392 $C({element : "stop", offset : "0%", "stop-color" : shade([100, 100, 100], -35), appendTo : gradient});393 $C({element : "stop", offset : "12%", "stop-color" : shade([100, 100, 100], 78), appendTo : gradient});394 $C({element : "stop", offset : "88%", "stop-color" : shade([100, 100, 100], 78), appendTo : gradient});395 $C({element : "stop", offset : "100%", "stop-color" : "#FFFFFF", appendTo : gradient});396397 gradient = $C({element : "linearGradient", id : "hScrollSliderStrokeGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});398 $C({element : "stop", offset : "0%", "stop-color" : shade([100, 100, 100], 74), appendTo : gradient});399 $C({element : "stop", offset : "10%", "stop-color" : shade([100, 100, 100]), appendTo : gradient});400 $C({element : "stop", offset : "88%", "stop-color" : shade([100, 100, 100]), appendTo : gradient});401 $C({element : "stop", offset : "100%", "stop-color" : shade([100, 100, 100], -25), appendTo : gradient});402403 gradient = $C({element : "linearGradient", id : "vScrollSliderStrokeGrad", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "0%", gradientUnits : "objectBoundingBox", appendTo : defs});404 $C({element : "stop", offset : "0%", "stop-color" : shade([100, 100, 100], 74), appendTo : gradient});405 $C({element : "stop", offset : "10%", "stop-color" : shade([100, 100, 100]), appendTo : gradient});406 $C({element : "stop", offset : "88%", "stop-color" : shade([100, 100, 100]), appendTo : gradient});407 $C({element : "stop", offset : "100%", "stop-color" : shade([100, 100, 100], -25), appendTo : gradient});408409 gradient = $C({element : "linearGradient", id : "buttonMaskGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});410 $C({element : "stop", offset : "0%", "stop-color" : shade([100, 100, 100], 76), appendTo : gradient});411 $C({element : "stop", offset : "8%", "stop-color" : shade([100, 100, 100], 55), appendTo : gradient});412 $C({element : "stop", offset : "88%", "stop-color" : shade([100, 100, 100], 55), appendTo : gradient});413 $C({element : "stop", offset : "100%", "stop-color" : shade([100, 100, 100], -12), appendTo : gradient});414415 gradient = $C({element : "linearGradient", id : "buttonGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});416 $C({element : "stop", offset : "0%", "stop-color" : shade([100, 100, 100], -20), appendTo : gradient});417 $C({element : "stop", offset : "20%", "stop-color" : shade([100, 100, 100], 10), appendTo : gradient});418 $C({element : "stop", offset : "80%", "stop-color" : shade([100, 100, 100], 10), appendTo : gradient});419 $C({element : "stop", offset : "100%", "stop-color" : shade([100, 100, 100], 55), appendTo : gradient});420421 gradient = $C({element : "linearGradient", id : "neutralButtonMaskGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});422 $C({element : "stop", offset : "0%", "stop-color" : "#F8F8F8", appendTo : gradient});423 $C({element : "stop", offset : "20%", "stop-color" : "#DADCDE", appendTo : gradient});424 $C({element : "stop", offset : "80%", "stop-color" : "#DADCDE", appendTo : gradient});425 $C({element : "stop", offset : "100%", "stop-color" : "#9EA0A2", appendTo : gradient});426427 gradient = $C({element : "linearGradient", id : "neutralButtonGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});428 $C({element : "stop", offset : "0%", "stop-color" : "#8A8C8E", appendTo : gradient});429 $C({element : "stop", offset : "20%", "stop-color" : "#B4B6B8", appendTo : gradient});430 $C({element : "stop", offset : "80%", "stop-color" : "#B4B6B8", appendTo : gradient});431 $C({element : "stop", offset : "100%", "stop-color" : "#FFFFFF", appendTo : gradient});432433 gradient = $C({element : "linearGradient", id : "sliderButtonGrad", x1 : "0%", y1 : "0%", x2 : "40%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});434 $C({element : "stop", offset : "0%", "stop-color" : shade([100, 100, 100], 80), appendTo : gradient});435 $C({element : "stop", offset : "100%", "stop-color" : shade([100, 100, 100], -8), appendTo : gradient});436437 gradient = $C({element : "linearGradient", id : "sliderPatternGrad", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});438 $C({element : "stop", offset : "0%", "stop-color" : shade([100, 100, 100], 20), appendTo : gradient});439 $C({element : "stop", offset : "100%", "stop-color" : shade([100, 100, 100], -20), appendTo : gradient});440441 pattern = $C({element : "pattern", id : "sliderPattern", x : 2.5, y : 2.5, width : 5, height : 5, patternUnits : "userSpaceOnUse", appendTo : defs});442 $C({element : "rect", x : 0, y : 0, width : 5, height : 5, fill : "url(#sliderPatternGrad)", appendTo : pattern});443 $C({element : "circle", cx : 2.5, cy : 2.5, r : 1.5, fill : shade([100, 100, 100]), appendTo : pattern});444445 gradient = $C({element : "linearGradient", id : "horScrollSliderGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});446 $C({element : "stop", offset : "0%", "stop-color" : shade([102.333, 100, 96.934], 20), appendTo : gradient});447 $C({element : "stop", offset : "44%", "stop-color" : shade([103.761, 100.009, 97.847]), appendTo : gradient});448 $C({element : "stop", offset : "100%", "stop-color" : shade([99.38, 92.584, 88.434]), appendTo : gradient});449450 gradient = $C({element : "linearGradient", id : "vertScrollSliderGrad", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "0%", gradientUnits : "objectBoundingBox", appendTo : defs});451 $C({element : "stop", offset : "0%", "stop-color" : shade([102.333, 100, 96.934], 20), appendTo : gradient});452 $C({element : "stop", offset : "44%", "stop-color" : shade([103.761, 100.009, 97.847]), appendTo : gradient});453 $C({element : "stop", offset : "100%", "stop-color" : shade([99.38, 92.584, 88.434]), appendTo : gradient});454455 gradient = $C({element : "linearGradient", id : "resizeGrad", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});456 $C({element : "stop", offset : "40%", "stop-color" : "#FFFFFF", "stop-opacity" : .05, appendTo : gradient});457 $C({element : "stop", offset : "100%", "stop-color" : "#000000", "stop-opacity" : .25, appendTo : gradient});458459 gradient = $C({element : "radialGradient", id : "lensGrad", cx : "28%", cy : "20%", r : "54.6%", gradientUnits : "objectBoundingBox", appendTo : defs});460 $C({element : "stop", offset : "12%", "stop-color" : "#FAFAFA", appendTo : gradient});461 $C({element : "stop", offset : "34%", "stop-color" : "#D8E0E2", appendTo : gradient});462 $C({element : "stop", offset : "100%", "stop-color" : "#ACB9BD", appendTo : gradient});463464 gradient = $C({element : "radialGradient", id : "handGrad", cx : "55%", cy : "65%", r : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});465 $C({element : "stop", offset : "20%", "stop-color" : "#FFFFFF", appendTo : gradient});466 $C({element : "stop", offset : "100%", "stop-color" : "#ACB9BD", appendTo : gradient});467468 gradient = $C({element : "linearGradient", id : "progressGrad", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "0%", gradientUnits : "objectBoundingBox", appendTo : defs});469 $C({element : "stop", offset : "50%", "stop-color" : "#d00030", appendTo : gradient});470 $C({element : "stop", offset : "100%", "stop-color" : "#ffc030", appendTo : gradient});471472 gradient = $C({element : "linearGradient", id : "quickTipGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});473 $C({element : "stop", offset : "10%", "stop-color" : shade([100, 100, 100], 100), appendTo : gradient});474 $C({element : "stop", offset : "100%", "stop-color" : shade([100, 100, 100], 72), appendTo : gradient});475476 gradient = $C({element : "linearGradient", id : "insetStroke", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});477 $C({element : "stop", offset : "0%", "stop-color" : "#c0c0c0", appendTo : gradient});478 $C({element : "stop", offset : "49.9%", "stop-color" : "#c0c0c0", appendTo : gradient});479 $C({element : "stop", offset : "50%", "stop-color" : "#f0f0f0", appendTo : gradient});480481 gradient = $C({element : "linearGradient", id : "marker1", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "75%", gradientUnits : "objectBoundingBox", appendTo : defs});482 $C({element : "stop", offset : "0%", "stop-color" : "#001030", appendTo : gradient});483 $C({element : "stop", offset : "100%", "stop-color" : "#FAFAFF", appendTo : gradient});484485 gradient = $C({element : "linearGradient", id : "marker2", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "75%", gradientUnits : "objectBoundingBox", appendTo : defs});486 $C({element : "stop", offset : "40%", "stop-color" : "#001030", appendTo : gradient});487 $C({element : "stop", offset : "66%", "stop-color" : "#FAFAFF", appendTo : gradient});488489 gradient = $C({element : "linearGradient", id : "marker3", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "75%", gradientUnits : "objectBoundingBox", appendTo : defs});490 $C({element : "stop", offset : "0%", "stop-color" : "#003090", appendTo : gradient});491 $C({element : "stop", offset : "94%", "stop-color" : "#E0F0FF", appendTo : gradient});492493 gradient = $C({element : "linearGradient", id : "LonGutter", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});494 $C({element : "stop", offset : "0%", "stop-color" : "#00040A", appendTo : gradient});495 $C({element : "stop", offset : "100%", "stop-color" : "#00040A", "stop-opacity" : 0, appendTo : gradient});496497 gradient = $C({element : "linearGradient", id : "LatGutter", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "0%", gradientUnits : "objectBoundingBox", appendTo : defs});498 $C({element : "stop", offset : "0%", "stop-color" : "#00040A", appendTo : gradient});499 $C({element : "stop", offset : "100%", "stop-color" : "#00040A", "stop-opacity" : 0, appendTo : gradient});500501 gradient = $C({element : "radialGradient", id : "paddleGrad", cx : "50%", cy : "50%", r : "69%", fx : "50%", fy : "50%", gradientUnits : "objectBoundingBox", appendTo : defs});502 $C({element : "stop", offset : "55%", "stop-color" : "#F02424", appendTo : gradient});503 $C({element : "stop", offset : "78%", "stop-color" : "#F06060", appendTo : gradient});504 $C({element : "stop", offset : "100%", "stop-color" : "#FF1010", appendTo : gradient});505506 gradient = $C({element : "radialGradient", id : "pushpinGrad_red", cx : "50%", cy : "50%", r : "69%", fx : "50%", fy : "50%", gradientUnits : "objectBoundingBox", appendTo : defs});507 $C({element : "stop", offset : "55%", "stop-color" : "#F02424", appendTo : gradient});508 $C({element : "stop", offset : "78%", "stop-color" : "#F06060", appendTo : gradient});509 $C({element : "stop", offset : "100%", "stop-color" : "#FF1010", appendTo : gradient});510511 gradient = $C({element : "radialGradient", id : "pushpinGrad_green", cx : "50%", cy : "50%", r : "69%", fx : "50%", fy : "50%", gradientUnits : "objectBoundingBox", appendTo : defs});512 $C({element : "stop", offset : "55%", "stop-color" : "#00C000", appendTo : gradient});513 $C({element : "stop", offset : "78%", "stop-color" : "#20C020", appendTo : gradient});514 $C({element : "stop", offset : "100%", "stop-color" : "#00C000", appendTo : gradient});515516 gradient = $C({element : "radialGradient", id : "pushpinGrad_blue", cx : "50%", cy : "50%", r : "69%", fx : "50%", fy : "50%", gradientUnits : "objectBoundingBox", appendTo : defs});517 $C({element : "stop", offset : "55%", "stop-color" : "#4040FF", appendTo : gradient});518 $C({element : "stop", offset : "78%", "stop-color" : "#6868FF", appendTo : gradient});519 $C({element : "stop", offset : "100%", "stop-color" : "#4040FF", appendTo : gradient});520521 gradient = $C({element : "linearGradient", id : "chiaroscuro", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "0%", gradientUnits : "objectBoundingBox", appendTo : defs});522 $C({element : "stop", offset : "25%", "stop-color" : "#FFFFFF", appendTo : gradient});523 $C({element : "stop", offset : "100%", "stop-color" : "#A8A8A8", appendTo : gradient});524525 gradient = $C({element : "linearGradient", id : "chrome", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "0%", gradientUnits : "objectBoundingBox", appendTo : defs});526 $C({element : "stop", offset : "20%", "stop-color" : "#787878", appendTo : gradient});527 $C({element : "stop", offset : "32%", "stop-color" : "#FFFFFF", appendTo : gradient});528 $C({element : "stop", offset : "58%", "stop-color" : "#FFFFFF", appendTo : gradient});529 $C({element : "stop", offset : "58%", "stop-color" : "#686868", appendTo : gradient});530 $C({element : "stop", offset : "78%", "stop-color" : "#686868", appendTo : gradient});531 $C({element : "stop", offset : "96%", "stop-color" : "#808080", appendTo : gradient});532533 gradient = $C({element : "linearGradient", id : "paddleReflection", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});534 $C({element : "stop", offset : "16%", "stop-color" : "#FFC0C0", appendTo : gradient});535 $C({element : "stop", offset : "32%", "stop-color" : "#F06060", appendTo : gradient});536537 gradient = $C({element : "linearGradient", id : "pinReflection_red", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});538 $C({element : "stop", offset : "16%", "stop-color" : "#FFC0C0", appendTo : gradient});539 $C({element : "stop", offset : "32%", "stop-color" : "#F06060", appendTo : gradient});540541 gradient = $C({element : "linearGradient", id : "pinReflection_green", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});542 $C({element : "stop", offset : "16%", "stop-color" : "#C0FFC0", appendTo : gradient});543 $C({element : "stop", offset : "32%", "stop-color" : "#20CE20", appendTo : gradient});544545 gradient = $C({element : "linearGradient", id : "pinReflection_blue", x1 : "0%", y1 : "0%", x2 : "100%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});546 $C({element : "stop", offset : "16%", "stop-color" : "#C8C8FF", appendTo : gradient});547 $C({element : "stop", offset : "32%", "stop-color" : "#6868FF", appendTo : gradient});548549 gradient = $C({element : "radialGradient", id : "leg_diskGrad", cx : "50%", cy : "50%", r : "69%", fx : "50%", fy : "50%", gradientUnits : "objectBoundingBox", appendTo : defs});550 $C({element : "stop", offset : "45%", "stop-color" : "#1050AF", appendTo : gradient});551 $C({element : "stop", offset : "84%", "stop-color" : "#B0D0F0", appendTo : gradient});552 $C({element : "stop", offset : "100%", "stop-color" : "#0000E0", appendTo : gradient});553554 gradient = $C({element : "linearGradient", id : "D3ButtonMaskGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});555 $C({element : "stop", offset : "0%", "stop-color" : "#5C5C5C", appendTo : gradient});556 $C({element : "stop", offset : "100%", "stop-color" : "#282828", appendTo : gradient});557558 gradient = $C({element : "linearGradient", id : "D3ButtonGrad", x1 : "0%", y1 : "0%", x2 : "0%", y2 : "100%", gradientUnits : "objectBoundingBox", appendTo : defs});559 $C({element : "stop", offset : "0%", "stop-color" : "#4682B4", appendTo : gradient});560 $C({element : "stop", offset : "100%", "stop-color" : "#3670A4", appendTo : gradient});561 }562563};564565566pergola.customColorNames = {567 nürburgring : "#B8CAD2",568 city : "#CCD0D4",569 rustica : "#7B961E",570 suburban : "#DDFF58",571 frostica : "#F8FDFE",572 tropica : "#FF4200",573 herman : "#5E0200",574 glockenspiel : "#EDF4F4",575 black_diamond : "#293032",576 lightslategray : "rgb(144, 160, 176)"577};578579580581pergola.skins[skin]();582
...
ViewController.js
Source:ViewController.js
1/*2 * Copyright (C) 2011 Apple Inc. All rights reserved.3 *4 * Redistribution and use in source and binary forms, with or without5 * modification, are permitted provided that the following conditions6 * are met:7 * 1. Redistributions of source code must retain the above copyright8 * notice, this list of conditions and the following disclaimer.9 * 2. Redistributions in binary form must reproduce the above copyright10 * notice, this list of conditions and the following disclaimer in the11 * documentation and/or other materials provided with the distribution.12 *13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF23 * THE POSSIBILITY OF SUCH DAMAGE.24 */25function ViewController(buildbot) {26 this._buildbot = buildbot;27 this._navigationID = 0;28 var self = this;29 addEventListener('load', function() { self.loaded() }, false);30 addEventListener('hashchange', function() { self.parseHash(location.hash) }, false);31}32ViewController.prototype = {33 loaded: function() {34 this._header = document.createElement('h1');35 document.body.appendChild(this._header);36 this._mainContentElement = document.createElement('div');37 document.body.appendChild(this._mainContentElement);38 document.body.appendChild(this._domForAuxiliaryUIElements());39 this.parseHash(location.hash);40 },41 parseHash: function(hash) {42 ++this._navigationID;43 var match = /#\/(.*)/.exec(hash);44 if (match)45 this._displayBuilder(this._buildbot.builderNamed(decodeURIComponent(match[1])));46 else47 this._displayTesters();48 },49 _displayBuilder: function(builder) {50 this._setTitle(builder.name);51 this._mainContentElement.removeAllChildren();52 var navigationID = this._navigationID;53 var self = this;54 (new LayoutTestHistoryAnalyzer(builder)).start(function(data, stillFetchingData) {55 if (self._navigationID !== navigationID) {56 // The user has navigated somewhere else. Stop loading data about this tester.57 return false;58 }59 var list = document.createElement('ol');60 list.id = 'failure-history';61 var buildNames = Object.keys(data.history)62 buildNames.forEach(function(buildName, buildIndex, buildNameArray) {63 var failingTestNames = Object.keys(data.history[buildName].tests);64 if (!failingTestNames.length)65 return;66 var item = document.createElement('li');67 list.appendChild(item);68 var testList = document.createElement('ol');69 item.appendChild(testList);70 testList.className = 'test-list';71 for (var testName in data.history[buildName].tests) {72 var testItem = document.createElement('li');73 testItem.appendChild(self._domForFailedTest(builder, buildName, testName, data.history[buildName].tests[testName]));74 testList.appendChild(testItem);75 }76 if (data.history[buildName].tooManyFailures) {77 var p = document.createElement('p');78 p.className = 'info';79 p.appendChild(document.createTextNode('run-webkit-tests exited early due to too many failures/crashes/timeouts'));80 item.appendChild(p);81 }82 var passingBuildName;83 if (buildIndex + 1 < buildNameArray.length)84 passingBuildName = buildNameArray[buildIndex + 1];85 item.appendChild(self._domForRegressionRange(builder, buildName, passingBuildName, failingTestNames));86 if (passingBuildName || !stillFetchingData) {87 var bugForm = new FailingTestsBugForm(builder, buildName, passingBuildName, failingTestNames);88 item.appendChild(self._domForNewAndExistingBugs(builder, failingTestNames, bugForm))89 }90 });91 self._mainContentElement.removeAllChildren();92 self._mainContentElement.appendChild(list);93 self._mainContentElement.appendChild(self._domForPossiblyFlakyTests(builder, data.possiblyFlaky, buildNames));94 if (!stillFetchingData)95 PersistentCache.prune();96 return true;97 });98 },99 _displayTesters: function() {100 this._setTitle('Testers');101 this._mainContentElement.removeAllChildren();102 var list = document.createElement('ul');103 this._mainContentElement.appendChild(list);104 var latestBuildInfos = [];105 var navigationID = this._navigationID;106 function updateList() {107 latestBuildInfos.sort(function(a, b) { return a.tester.name.localeCompare(b.tester.name) });108 list.removeAllChildren();109 latestBuildInfos.forEach(function(buildInfo) {110 var link = document.createElement('a');111 link.href = '#/' + buildInfo.tester.name;112 link.appendChild(document.createTextNode(buildInfo.tester.name));113 var item = document.createElement('li');114 item.appendChild(link);115 if (buildInfo.tooManyFailures)116 item.appendChild(document.createTextNode(' (too many failures/crashes/timeouts)'));117 else118 item.appendChild(document.createTextNode(' (' + buildInfo.failureCount + ' failing test' + (buildInfo.failureCount > 1 ? 's' : '') + ')'));119 list.appendChild(item);120 });121 }122 var self = this;123 this._buildbot.getTesters(function(testers) {124 if (self._navigationID !== navigationID) {125 // The user has navigated somewhere else.126 return;127 }128 testers.forEach(function(tester) {129 tester.getMostRecentCompletedBuildNumber(function(buildNumber) {130 if (self._navigationID !== navigationID)131 return;132 if (buildNumber < 0)133 return;134 tester.getNumberOfFailingTests(buildNumber, function(failureCount, tooManyFailures) {135 if (self._navigationID !== navigationID)136 return;137 if (failureCount <= 0)138 return;139 latestBuildInfos.push({ tester: tester, failureCount: failureCount, tooManyFailures: tooManyFailures });140 updateList();141 });142 });143 });144 });145 },146 _domForRegressionRange: function(builder, failingBuildName, passingBuildName, failingTestNames) {147 var result = document.createDocumentFragment();148 var dlItems = [149 [document.createTextNode('Failed'), this._domForBuildName(builder, failingBuildName)],150 ];151 if (passingBuildName)152 dlItems.push([document.createTextNode('Passed'), this._domForBuildName(builder, passingBuildName)]);153 result.appendChild(createDefinitionList(dlItems));154 if (!passingBuildName)155 return result;156 var firstSuspectRevision = this._buildbot.parseBuildName(passingBuildName).revision + 1;157 var lastSuspectRevision = this._buildbot.parseBuildName(failingBuildName).revision;158 if (firstSuspectRevision === lastSuspectRevision)159 return result;160 var suspectsContainer = document.createElement('div');161 result.appendChild(suspectsContainer);162 var link = document.createElement('a');163 result.appendChild(link);164 link.href = trac.logURL('trunk', firstSuspectRevision, lastSuspectRevision, true);165 link.appendChild(document.createTextNode('View regression range in Trac'));166 suspectsContainer.appendChild(document.createTextNode('Searching for suspect revisions\u2026'));167 // FIXME: Maybe some of this code should go in LayoutTestHistoryAnalyzer, or some other class?168 var self = this;169 trac.commitDataForRevisionRange('trunk', firstSuspectRevision, lastSuspectRevision, function(commits) {170 var failingTestNamesWithoutExtensions = failingTestNames.map(removePathExtension);171 var suspectCommits = commits.filter(function(commit) {172 return failingTestNamesWithoutExtensions.some(function(testName) {173 return commit.message.contains(testName);174 });175 });176 suspectsContainer.removeAllChildren();177 if (!suspectCommits.length)178 return;179 var title = 'Suspect revision' + (suspectCommits.length > 1 ? 's' : '') + ':';180 suspectsContainer.appendChild(document.createTextNode(title));181 var list = document.createElement('ul');182 suspectsContainer.appendChild(list);183 list.className = 'suspect-revisions-list';184 function compareCommits(a, b) {185 return b.revision - a.revision;186 }187 list.appendChildren(sorted(suspectCommits, compareCommits).map(function(commit) {188 var item = document.createElement('li');189 var link = document.createElement('a');190 item.appendChild(link);191 link.href = trac.changesetURL(commit.revision);192 link.appendChild(document.createTextNode(commit.title))193 return item;194 }));195 });196 return result;197 },198 _domForAuxiliaryUIElements: function() {199 var aside = document.createElement('aside');200 aside.appendChild(document.createTextNode('Something not working? Have an idea to improve this page? '));201 var link = document.createElement('a');202 aside.appendChild(link);203 link.appendChild(document.createTextNode('File a bug!'));204 var queryParameters = {205 product: 'WebKit',206 component: 'Tools / Tests',207 version: '528+ (Nightly build)',208 bug_file_loc: location.href,209 cc: 'aroben@apple.com',210 short_desc: 'TestFailures page needs more unicorns!',211 };212 link.href = addQueryParametersToURL(config.kBugzillaURL + '/enter_bug.cgi', queryParameters);213 link.target = '_blank';214 return aside;215 },216 _domForBuildName: function(builder, buildName) {217 var parsed = this._buildbot.parseBuildName(buildName);218 var sourceLink = document.createElement('a');219 sourceLink.href = 'http://trac.webkit.org/changeset/' + parsed.revision;220 sourceLink.appendChild(document.createTextNode('r' + parsed.revision));221 var buildLink = document.createElement('a');222 buildLink.href = builder.buildURL(parsed.buildNumber);223 buildLink.appendChild(document.createTextNode(parsed.buildNumber));224 var resultsLink = document.createElement('a');225 resultsLink.href = builder.resultsPageURL(buildName);226 resultsLink.appendChild(document.createTextNode('results.html'));227 var result = document.createDocumentFragment();228 result.appendChild(sourceLink);229 result.appendChild(document.createTextNode(' ('));230 result.appendChild(buildLink);231 result.appendChild(document.createTextNode(') ('));232 result.appendChild(resultsLink);233 result.appendChild(document.createTextNode(')'));234 return result;235 },236 _domForFailedTest: function(builder, buildName, testName, testResult) {237 var result = document.createDocumentFragment();238 result.appendChild(document.createTextNode(testName + ': '));239 result.appendChild(this._domForFailureDiagnosis(builder, buildName, testName, testResult));240 return result;241 },242 _domForFailureDiagnosis: function(builder, buildName, testName, testResult) {243 var diagnosticInfo = builder.failureDiagnosisTextAndURL(buildName, testName, testResult);244 if (!diagnosticInfo)245 return document.createTextNode(testResult.failureType);246 var textAndCrashingSymbol = document.createDocumentFragment();247 textAndCrashingSymbol.appendChild(document.createTextNode(diagnosticInfo.text));248 if (testResult.crashingSymbol) {249 var code = document.createElement('code');250 code.appendChild(document.createTextNode(testResult.crashingSymbol));251 textAndCrashingSymbol.appendChild(document.createTextNode(' ('));252 textAndCrashingSymbol.appendChild(code);253 textAndCrashingSymbol.appendChild(document.createTextNode(')'));254 }255 if (!('url' in diagnosticInfo))256 return textAndCrashingSymbol;257 var link = document.createElement('a');258 link.href = diagnosticInfo.url;259 link.appendChild(textAndCrashingSymbol);260 return link;261 },262 _domForNewAndExistingBugs: function(tester, failingTests, bugForm) {263 var result = document.createDocumentFragment();264 var container = document.createElement('p');265 result.appendChild(container);266 container.className = 'existing-and-new-bugs';267 var bugsContainer = document.createElement('div');268 container.appendChild(bugsContainer);269 bugsContainer.appendChild(document.createTextNode('Searching for bugs related to ' + (failingTests.length > 1 ? 'these tests' : 'this test') + '\u2026'));270 bugzilla.quickSearch('ALL ' + failingTests.join('|'), function(bugs) {271 if (!bugs.length) {272 bugsContainer.parentNode.removeChild(bugsContainer);273 return;274 }275 while (bugsContainer.firstChild)276 bugsContainer.removeChild(bugsContainer.firstChild);277 bugsContainer.appendChild(document.createTextNode('Existing bugs related to ' + (failingTests.length > 1 ? 'these tests' : 'this test') + ':'));278 var list = document.createElement('ul');279 bugsContainer.appendChild(list);280 list.className = 'existing-bugs-list';281 function bugToListItem(bug) {282 var link = document.createElement('a');283 link.href = bug.url;284 link.appendChild(document.createTextNode(bug.title));285 var item = document.createElement('li');286 item.appendChild(link);287 return item;288 }289 var openBugs = bugs.filter(function(bug) { return bugzilla.isOpenStatus(bug.status) });290 var closedBugs = bugs.filter(function(bug) { return !bugzilla.isOpenStatus(bug.status) });291 list.appendChildren(openBugs.map(bugToListItem));292 if (!closedBugs.length)293 return;294 var item = document.createElement('li');295 list.appendChild(item);296 item.appendChild(document.createTextNode('Closed bugs:'));297 var closedList = document.createElement('ul');298 item.appendChild(closedList);299 closedList.appendChildren(closedBugs.map(bugToListItem));300 });301 var form = bugForm.domElement();302 result.appendChild(form);303 var link = document.createElement('a');304 container.appendChild(link);305 link.addEventListener('click', function(event) { form.submit(); event.preventDefault(); });306 link.href = '#';307 link.appendChild(document.createTextNode('File bug for ' + (failingTests.length > 1 ? 'these failures' : 'this failure')));308 return result;309 },310 _domForPossiblyFlakyTests: function(builder, possiblyFlakyTestData, allBuilds) {311 var result = document.createDocumentFragment();312 var flakyTests = Object.keys(possiblyFlakyTestData);313 if (!flakyTests.length)314 return result;315 var flakyHeader = document.createElement('h2');316 result.appendChild(flakyHeader);317 flakyHeader.appendChild(document.createTextNode('Possibly Flaky Tests'));318 var flakyList = document.createElement('ol');319 result.appendChild(flakyList);320 flakyList.id = 'possibly-flaky-tests';321 var self = this;322 flakyList.appendChildren(sorted(flakyTests).map(function(testName) {323 var item = document.createElement('li');324 var disclosureTriangle = document.createElement('span');325 item.appendChild(disclosureTriangle);326 disclosureTriangle.className = 'disclosure-triangle';327 const blackRightPointingSmallTriangle = '\u25b8';328 disclosureTriangle.appendChild(document.createTextNode(blackRightPointingSmallTriangle));329 var failures = possiblyFlakyTestData[testName];330 item.appendChild(document.createTextNode(testName + ' (failed ' + failures.length + ' out of ' + allBuilds.length + ' times)'));331 var container = document.createElement('div');332 item.appendChild(container);333 container.className = 'expandable';334 disclosureTriangle.addEventListener('click', function() {335 item.toggleStyleClass('expanded');336 if (!item.hasStyleClass('expanded'))337 return;338 if (!container.firstChild) {339 var failureList = document.createElement('ol');340 container.appendChild(failureList);341 failureList.className = 'flakiness-examples-list';342 failureList.appendChildren(failures.map(function(historyItem) {343 var item = document.createElement('li');344 item.appendChild(self._domForBuildName(builder, historyItem.build));345 item.appendChild(document.createTextNode(': '));346 item.appendChild(self._domForFailureDiagnosis(builder, historyItem.build, testName, historyItem.result));347 return item;348 }));349 var failingBuildNames = failures.map(function(historyItem) { return historyItem.build });350 var bugForm = new FlakyTestBugForm(builder, failingBuildNames, testName, allBuilds.last(), allBuilds[0], allBuilds.length);351 container.appendChild(self._domForNewAndExistingBugs(builder, [testName], bugForm));352 }353 });354 return item;355 }));356 return result;357 },358 _setTitle: function(title) {359 document.title = title;360 this._header.textContent = title;361 },...
CesiumInspector.js
Source:CesiumInspector.js
1define([2 '../../Core/defined',3 '../../Core/defineProperties',4 '../../Core/destroyObject',5 '../../Core/DeveloperError',6 '../../ThirdParty/knockout',7 '../getElement',8 './CesiumInspectorViewModel'9 ], function(10 defined,11 defineProperties,12 destroyObject,13 DeveloperError,14 knockout,15 getElement,16 CesiumInspectorViewModel) {17 'use strict';1819 /**20 * Inspector widget to aid in debugging21 *22 * @alias CesiumInspector23 * @constructor24 *25 * @param {Element|String} container The DOM element or ID that will contain the widget.26 * @param {Scene} scene The Scene instance to use.27 *28 * @demo {@link http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Cesium%20Inspector.html|Cesium Sandcastle Cesium Inspector Demo}29 */30 function CesiumInspector(container, scene) {31 //>>includeStart('debug', pragmas.debug);32 if (!defined(container)) {33 throw new DeveloperError('container is required.');34 }3536 if (!defined(scene)) {37 throw new DeveloperError('scene is required.');38 }39 //>>includeEnd('debug');4041 container = getElement(container);4243 var performanceContainer = document.createElement('div');4445 var viewModel = new CesiumInspectorViewModel(scene, performanceContainer);46 this._viewModel = viewModel;47 this._container = container;4849 var element = document.createElement('div');50 this._element = element;51 var text = document.createElement('div');52 text.textContent = 'Cesium Inspector';53 text.className = 'cesium-cesiumInspector-button';54 text.setAttribute('data-bind', 'click: toggleDropDown');55 element.appendChild(text);56 element.className = 'cesium-cesiumInspector';57 element.setAttribute('data-bind', 'css: { "cesium-cesiumInspector-visible" : dropDownVisible, "cesium-cesiumInspector-hidden" : !dropDownVisible }');58 container.appendChild(this._element);5960 var panel = document.createElement('div');61 this._panel = panel;62 panel.className = 'cesium-cesiumInspector-dropDown';63 element.appendChild(panel);6465 // General66 var general = document.createElement('div');67 general.className = 'cesium-cesiumInspector-sectionHeader';68 var plus = document.createElement('span');69 plus.className = 'cesium-cesiumInspector-toggleSwitch';70 plus.setAttribute('data-bind', 'click: toggleGeneral, text: generalSwitchText');71 general.appendChild(plus);72 general.appendChild(document.createTextNode('General'));73 panel.appendChild(general);7475 var generalSection = document.createElement('div');76 generalSection.className = 'cesium-cesiumInspector-section';77 generalSection.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-show" : generalVisible, "cesium-cesiumInspector-hide" : !generalVisible}');78 panel.appendChild(generalSection);7980 var debugShowFrustums = document.createElement('div');81 generalSection.appendChild(debugShowFrustums);82 var frustumStatistics = document.createElement('div');83 frustumStatistics.className = 'cesium-cesiumInspector-frustumStatistics';84 frustumStatistics.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-show" : frustums, "cesium-cesiumInspector-hide" : !frustums}, html: frustumStatisticText');85 var frustumsCheckbox = document.createElement('input');86 frustumsCheckbox.type = 'checkbox';87 frustumsCheckbox.setAttribute('data-bind', 'checked: frustums');88 debugShowFrustums.appendChild(frustumsCheckbox);89 debugShowFrustums.appendChild(document.createTextNode('Show Frustums'));90 debugShowFrustums.appendChild(frustumStatistics);9192 var debugShowFrustumPlanes = document.createElement('div');93 generalSection.appendChild(debugShowFrustumPlanes);94 var frustumPlanesCheckbox = document.createElement('input');95 frustumPlanesCheckbox.type = 'checkbox';96 frustumPlanesCheckbox.setAttribute('data-bind', 'checked: frustumPlanes');97 debugShowFrustumPlanes.appendChild(frustumPlanesCheckbox);98 debugShowFrustumPlanes.appendChild(document.createTextNode('Show Frustum Planes'));99100 var performanceDisplay = document.createElement('div');101 generalSection.appendChild(performanceDisplay);102 var pdCheckbox = document.createElement('input');103 pdCheckbox.type = 'checkbox';104 pdCheckbox.setAttribute('data-bind', 'checked: performance');105 performanceDisplay.appendChild(pdCheckbox);106 performanceDisplay.appendChild(document.createTextNode('Performance Display'));107108 performanceContainer.className = 'cesium-cesiumInspector-performanceDisplay';109 generalSection.appendChild(performanceContainer);110111 var shaderCacheDisplay = document.createElement('div');112 shaderCacheDisplay.className = 'cesium-cesiumInspector-shaderCache';113 shaderCacheDisplay.setAttribute('data-bind', 'html: shaderCacheText');114 generalSection.appendChild(shaderCacheDisplay);115116 var globeDepth = document.createElement('div');117 generalSection.appendChild(globeDepth);118 var gCheckbox = document.createElement('input');119 gCheckbox.type = 'checkbox';120 gCheckbox.setAttribute('data-bind', 'checked: globeDepth');121 globeDepth.appendChild(gCheckbox);122 globeDepth.appendChild(document.createTextNode('Show globe depth'));123124 var globeDepthFrustum = document.createElement('div');125 globeDepth.appendChild(globeDepthFrustum);126127 var pickDepth = document.createElement('div');128 generalSection.appendChild(pickDepth);129 var pCheckbox = document.createElement('input');130 pCheckbox.type = 'checkbox';131 pCheckbox.setAttribute('data-bind', 'checked: pickDepth');132 pickDepth.appendChild(pCheckbox);133 pickDepth.appendChild(document.createTextNode('Show pick depth'));134135 var depthFrustum = document.createElement('div');136 generalSection.appendChild(depthFrustum);137138 // Use a span with HTML binding so that we can indent with non-breaking spaces.139 var gLabel = document.createElement('span');140 gLabel.setAttribute('data-bind', 'html: " Frustum:"');141 depthFrustum.appendChild(gLabel);142143 var gText = document.createElement('span');144 gText.setAttribute('data-bind', 'text: depthFrustumText');145 depthFrustum.appendChild(gText);146147 var gMinusButton = document.createElement('input');148 gMinusButton.type = 'button';149 gMinusButton.value = '-';150 gMinusButton.className = 'cesium-cesiumInspector-pickButton';151 gMinusButton.setAttribute('data-bind', 'click: decrementDepthFrustum');152 depthFrustum.appendChild(gMinusButton);153154 var gPlusButton = document.createElement('input');155 gPlusButton.type = 'button';156 gPlusButton.value = '+';157 gPlusButton.className = 'cesium-cesiumInspector-pickButton';158 gPlusButton.setAttribute('data-bind', 'click: incrementDepthFrustum');159 depthFrustum.appendChild(gPlusButton);160161 // Primitives162 var prim = document.createElement('div');163 prim.className = 'cesium-cesiumInspector-sectionHeader';164 plus = document.createElement('span');165 plus.className = 'cesium-cesiumInspector-toggleSwitch';166 plus.setAttribute('data-bind', 'click: togglePrimitives, text: primitivesSwitchText');167 prim.appendChild(plus);168 prim.appendChild(document.createTextNode('Primitives'));169 panel.appendChild(prim);170171 var primitivesSection = document.createElement('div');172 primitivesSection.className = 'cesium-cesiumInspector-section';173 primitivesSection.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-show" : primitivesVisible, "cesium-cesiumInspector-hide" : !primitivesVisible}');174 panel.appendChild(primitivesSection);175 var pickPrimRequired = document.createElement('div');176 pickPrimRequired.className = 'cesium-cesiumInspector-pickSection';177 primitivesSection.appendChild(pickPrimRequired);178179 var pickPrimitiveButton = document.createElement('input');180 pickPrimitiveButton.type = 'button';181 pickPrimitiveButton.value = 'Pick a primitive';182 pickPrimitiveButton.className = 'cesium-cesiumInspector-pickButton';183 pickPrimitiveButton.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-pickButtonHighlight" : pickPrimitiveActive}, click: pickPrimitive');184 var buttonWrap = document.createElement('div');185 buttonWrap.className = 'cesium-cesiumInspector-center';186 buttonWrap.appendChild(pickPrimitiveButton);187 pickPrimRequired.appendChild(buttonWrap);188189 var debugSphere = document.createElement('div');190 pickPrimRequired.appendChild(debugSphere);191 var bsCheckbox = document.createElement('input');192 bsCheckbox.type = 'checkbox';193 bsCheckbox.setAttribute('data-bind', 'checked: primitiveBoundingSphere, enable: hasPickedPrimitive');194 debugSphere.appendChild(bsCheckbox);195 debugSphere.appendChild(document.createTextNode('Show bounding sphere'));196197 var refFrame = document.createElement('div');198 pickPrimRequired.appendChild(refFrame);199 var rfCheckbox = document.createElement('input');200 rfCheckbox.type = 'checkbox';201 rfCheckbox.setAttribute('data-bind', 'checked: primitiveReferenceFrame, enable: hasPickedPrimitive');202 refFrame.appendChild(rfCheckbox);203 refFrame.appendChild(document.createTextNode('Show reference frame'));204205 var primitiveOnly = document.createElement('div');206 this._primitiveOnly = primitiveOnly;207 pickPrimRequired.appendChild(primitiveOnly);208 var primitiveOnlyCheckbox = document.createElement('input');209 primitiveOnlyCheckbox.type = 'checkbox';210 primitiveOnlyCheckbox.setAttribute('data-bind', 'checked: filterPrimitive, enable: hasPickedPrimitive');211 primitiveOnly.appendChild(primitiveOnlyCheckbox);212 primitiveOnly.appendChild(document.createTextNode('Show only selected'));213214 // Terrain215 var terrain = document.createElement('div');216 terrain.className = 'cesium-cesiumInspector-sectionHeader';217 plus = document.createElement('span');218 plus.className = 'cesium-cesiumInspector-toggleSwitch';219 plus.setAttribute('data-bind', 'click: toggleTerrain, text: terrainSwitchText');220 terrain.appendChild(plus);221 terrain.appendChild(document.createTextNode('Terrain'));222 panel.appendChild(terrain);223224 var terrainSection = document.createElement('div');225 terrainSection.className = 'cesium-cesiumInspector-section';226 terrainSection.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-show" : terrainVisible, "cesium-cesiumInspector-hide" : !terrainVisible}');227 panel.appendChild(terrainSection);228 var pickTileRequired = document.createElement('div');229 pickTileRequired.className = 'cesium-cesiumInspector-pickSection';230 terrainSection.appendChild(pickTileRequired);231 var pickTileButton = document.createElement('input');232 pickTileButton.type = 'button';233 pickTileButton.value = 'Pick a tile';234 pickTileButton.className = 'cesium-cesiumInspector-pickButton';235 pickTileButton.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-pickButtonHighlight" : pickTileActive}, click: pickTile');236 buttonWrap = document.createElement('div');237 buttonWrap.appendChild(pickTileButton);238 buttonWrap.className = 'cesium-cesiumInspector-center';239 pickTileRequired.appendChild(buttonWrap);240 var tileInfo = document.createElement('div');241 pickTileRequired.appendChild(tileInfo);242 var parentTile = document.createElement('input');243 parentTile.type = 'button';244 parentTile.value = 'Parent';245 parentTile.className = 'cesium-cesiumInspector-pickButton';246 parentTile.setAttribute('data-bind', 'click: selectParent');247 var nwTile = document.createElement('input');248 nwTile.type = 'button';249 nwTile.value = 'NW';250 nwTile.className = 'cesium-cesiumInspector-pickButton';251 nwTile.setAttribute('data-bind', 'click: selectNW');252 var neTile = document.createElement('input');253 neTile.type = 'button';254 neTile.value = 'NE';255 neTile.className = 'cesium-cesiumInspector-pickButton';256 neTile.setAttribute('data-bind', 'click: selectNE');257 var swTile = document.createElement('input');258 swTile.type = 'button';259 swTile.value = 'SW';260 swTile.className = 'cesium-cesiumInspector-pickButton';261 swTile.setAttribute('data-bind', 'click: selectSW');262 var seTile = document.createElement('input');263 seTile.type = 'button';264 seTile.value = 'SE';265 seTile.className = 'cesium-cesiumInspector-pickButton';266 seTile.setAttribute('data-bind', 'click: selectSE');267268 var tileText = document.createElement('div');269 tileText.className = 'cesium-cesiumInspector-tileText';270 tileInfo.className = 'cesium-cesiumInspector-frustumStatistics';271 tileInfo.appendChild(tileText);272 tileInfo.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-show" : hasPickedTile, "cesium-cesiumInspector-hide" : !hasPickedTile}');273 tileText.setAttribute('data-bind', 'html: tileText');274275 var relativeText = document.createElement('div');276 relativeText.className = 'cesium-cesiumInspector-relativeText';277 relativeText.textContent = 'Select relative:';278 tileInfo.appendChild(relativeText);279280 var table = document.createElement('table');281 var tr1 = document.createElement('tr');282 var tr2 = document.createElement('tr');283 var td1 = document.createElement('td');284 td1.appendChild(parentTile);285 var td2 = document.createElement('td');286 td2.appendChild(nwTile);287 var td3 = document.createElement('td');288 td3.appendChild(neTile);289 tr1.appendChild(td1);290 tr1.appendChild(td2);291 tr1.appendChild(td3);292 var td4 = document.createElement('td');293 var td5 = document.createElement('td');294 td5.appendChild(swTile);295 var td6 = document.createElement('td');296 td6.appendChild(seTile);297 tr2.appendChild(td4);298 tr2.appendChild(td5);299 tr2.appendChild(td6);300 table.appendChild(tr1);301 table.appendChild(tr2);302303 tileInfo.appendChild(table);304305 var tileBoundingSphere = document.createElement('div');306 pickTileRequired.appendChild(tileBoundingSphere);307 var tbsCheck = document.createElement('input');308 tbsCheck.type = 'checkbox';309 tbsCheck.setAttribute('data-bind', 'checked: tileBoundingSphere, enable: hasPickedTile');310 tileBoundingSphere.appendChild(tbsCheck);311 tileBoundingSphere.appendChild(document.createTextNode('Show bounding volume'));312313 var renderTile = document.createElement('div');314 pickTileRequired.appendChild(renderTile);315 var rCheck = document.createElement('input');316 rCheck.type = 'checkbox';317 rCheck.setAttribute('data-bind', 'checked: filterTile, enable: hasPickedTile');318 renderTile.appendChild(rCheck);319 renderTile.appendChild(document.createTextNode('Show only selected'));320321 var wireframe = document.createElement('div');322 terrainSection.appendChild(wireframe);323 var wCheckbox = document.createElement('input');324 wCheckbox.type = 'checkbox';325 wCheckbox.setAttribute('data-bind', 'checked: wireframe');326 wireframe.appendChild(wCheckbox);327 wireframe.appendChild(document.createTextNode('Wireframe'));328329 var suspendUpdates = document.createElement('div');330 terrainSection.appendChild(suspendUpdates);331 var upCheckbox = document.createElement('input');332 upCheckbox.type = 'checkbox';333 upCheckbox.setAttribute('data-bind', 'checked: suspendUpdates');334 suspendUpdates.appendChild(upCheckbox);335 suspendUpdates.appendChild(document.createTextNode('Suspend LOD update'));336337 var tileCoords = document.createElement('div');338 terrainSection.appendChild(tileCoords);339 var coordCheck = document.createElement('input');340 coordCheck.type = 'checkbox';341 coordCheck.setAttribute('data-bind', 'checked: tileCoordinates');342 tileCoords.appendChild(coordCheck);343 tileCoords.appendChild(document.createTextNode('Show tile coordinates'));344345 knockout.applyBindings(viewModel, this._element);346 }347348 defineProperties(CesiumInspector.prototype, {349 /**350 * Gets the parent container.351 * @memberof CesiumInspector.prototype352 *353 * @type {Element}354 */355 container : {356 get : function() {357 return this._container;358 }359 },360361 /**362 * Gets the view model.363 * @memberof CesiumInspector.prototype364 *365 * @type {CesiumInspectorViewModel}366 */367 viewModel : {368 get : function() {369 return this._viewModel;370 }371 }372 });373374 /**375 * @returns {Boolean} true if the object has been destroyed, false otherwise.376 */377 CesiumInspector.prototype.isDestroyed = function() {378 return false;379 };380381 /**382 * Destroys the widget. Should be called if permanently383 * removing the widget from layout.384 */385 CesiumInspector.prototype.destroy = function() {386 knockout.cleanNode(this._element);387 this._container.removeChild(this._element);388 this.viewModel.destroy();389390 return destroyObject(this);391 };392393 return CesiumInspector;
...
Cesium3DTilesInspector.js
Source:Cesium3DTilesInspector.js
1define([2 '../../Core/Check',3 '../../Core/defaultValue',4 '../../Core/defined',5 '../../Core/defineProperties',6 '../../Core/destroyObject',7 '../../ThirdParty/knockout',8 '../getElement',9 './Cesium3DTilesInspectorViewModel'10 ], function(11 Check,12 defaultValue,13 defined,14 defineProperties,15 destroyObject,16 knockout,17 getElement,18 Cesium3DTilesInspectorViewModel) {19 'use strict';2021 /**22 * Inspector widget to aid in debugging 3D Tiles23 *24 * @alias Cesium3DTilesInspector25 * @constructor26 *27 * @param {Element|String} container The DOM element or ID that will contain the widget.28 * @param {Scene} scene the Scene instance to use.29 */30 function Cesium3DTilesInspector(container, scene) {31 //>includeStart('debug', pragmas.debug);32 Check.defined('container', container);33 Check.typeOf.object('scene', scene);34 //>>includeEnd('debug');3536 container = getElement(container);37 var element = document.createElement('div');38 var performanceContainer = document.createElement('div');39 performanceContainer.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-show" : performance, "cesium-cesiumInspector-hide" : !performance}');40 var viewModel = new Cesium3DTilesInspectorViewModel(scene, performanceContainer);4142 this._viewModel = viewModel;43 this._container = container;44 this._element = element;4546 var text = document.createElement('div');47 text.textContent = '3D Tiles Inspector';48 text.className = 'cesium-cesiumInspector-button';49 text.setAttribute('data-bind', 'click: toggleInspector');50 element.appendChild(text);51 element.className = 'cesium-cesiumInspector cesium-3DTilesInspector';52 element.setAttribute('data-bind', 'css: { "cesium-cesiumInspector-visible" : inspectorVisible, "cesium-cesiumInspector-hidden" : !inspectorVisible}');53 container.appendChild(element);5455 var tilesetPanelContents = document.createElement('div');56 var displayPanelContents = document.createElement('div');57 var updatePanelContents = document.createElement('div');58 var loggingPanelContents = document.createElement('div');59 var tileDebugLabelsPanelContents = document.createElement('div');60 var stylePanelContents = document.createElement('div');61 var optimizationPanelContents = document.createElement('div');6263 var properties = document.createElement('div');64 properties.className = 'field-group';65 var propertiesLabel = document.createElement('label');66 propertiesLabel.className = 'field-label';67 propertiesLabel.appendChild(document.createTextNode('Properties: '));68 var propertiesField = document.createElement('div');69 propertiesField.setAttribute('data-bind', 'text: properties');70 properties.appendChild(propertiesLabel);71 properties.appendChild(propertiesField);72 tilesetPanelContents.appendChild(properties);73 tilesetPanelContents.appendChild(makeButton('togglePickTileset', 'Pick Tileset', 'pickActive'));74 tilesetPanelContents.appendChild(makeButton('trimTilesCache', 'Trim Tiles Cache'));75 tilesetPanelContents.appendChild(makeCheckbox('picking', 'Enable Picking'));7677 displayPanelContents.appendChild(makeCheckbox('colorize', 'Colorize'));78 displayPanelContents.appendChild(makeCheckbox('wireframe', 'Wireframe'));79 displayPanelContents.appendChild(makeCheckbox('showBoundingVolumes', 'Bounding Volumes'));80 displayPanelContents.appendChild(makeCheckbox('showContentBoundingVolumes', 'Content Volumes'));81 displayPanelContents.appendChild(makeCheckbox('showRequestVolumes', 'Request Volumes'));8283 updatePanelContents.appendChild(makeCheckbox('freezeFrame', 'Freeze Frame'));84 updatePanelContents.appendChild(makeCheckbox('dynamicScreenSpaceError', 'Dynamic Screen Space Error'));85 var sseContainer = document.createElement('div');86 sseContainer.appendChild(makeRangeInput('maximumScreenSpaceError', 0, 128, 1, 'Maximum Screen Space Error'));87 updatePanelContents.appendChild(sseContainer);88 var dynamicScreenSpaceErrorContainer = document.createElement('div');89 dynamicScreenSpaceErrorContainer.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-show" : dynamicScreenSpaceError, "cesium-cesiumInspector-hide" : !dynamicScreenSpaceError}');90 dynamicScreenSpaceErrorContainer.appendChild(makeRangeInput('dynamicScreenSpaceErrorDensitySliderValue', 0, 1, 0.005, 'Screen Space Error Density', 'dynamicScreenSpaceErrorDensity'));91 dynamicScreenSpaceErrorContainer.appendChild(makeRangeInput('dynamicScreenSpaceErrorFactor', 1, 10, 0.1, 'Screen Space Error Factor'));92 updatePanelContents.appendChild(dynamicScreenSpaceErrorContainer);9394 loggingPanelContents.appendChild(makeCheckbox('performance', 'Performance'));95 loggingPanelContents.appendChild(performanceContainer);96 loggingPanelContents.appendChild(makeCheckbox('showStatistics', 'Statistics'));97 var statistics = document.createElement('div');98 statistics.className = 'cesium-3dTilesInspector-statistics';99 statistics.setAttribute('data-bind', 'html: statisticsText, visible: showStatistics');100 loggingPanelContents.appendChild(statistics);101 loggingPanelContents.appendChild(makeCheckbox('showPickStatistics', 'Pick Statistics'));102 var pickStatistics = document.createElement('div');103 pickStatistics.className = 'cesium-3dTilesInspector-statistics';104 pickStatistics.setAttribute('data-bind', 'html: pickStatisticsText, visible: showPickStatistics');105 loggingPanelContents.appendChild(pickStatistics);106107 stylePanelContents.appendChild(document.createTextNode('Color Blend Mode: '));108 var blendDropdown = document.createElement('select');109 blendDropdown.setAttribute('data-bind', 'options: colorBlendModes, ' +110 'optionsText: "text", ' +111 'optionsValue: "value", ' +112 'value: colorBlendMode');113 stylePanelContents.appendChild(blendDropdown);114 var styleEditor = document.createElement('textarea');115 styleEditor.setAttribute('data-bind', 'textInput: styleString, event: { keydown: styleEditorKeyPress }');116 stylePanelContents.className = 'cesium-cesiumInspector-styleEditor';117 stylePanelContents.appendChild(styleEditor);118 var closeStylesBtn = makeButton('compileStyle', 'Compile (Ctrl+Enter)');119 stylePanelContents.appendChild(closeStylesBtn);120 var errorBox = document.createElement('div');121 errorBox.className = 'cesium-cesiumInspector-error';122 errorBox.setAttribute('data-bind', 'text: editorError');123 stylePanelContents.appendChild(errorBox);124125 tileDebugLabelsPanelContents.appendChild(makeCheckbox('showOnlyPickedTileDebugLabel', 'Show Picked Only'));126 tileDebugLabelsPanelContents.appendChild(makeCheckbox('showGeometricError', 'Geometric Error'));127 tileDebugLabelsPanelContents.appendChild(makeCheckbox('showRenderingStatistics', 'Rendering Statistics'));128 tileDebugLabelsPanelContents.appendChild(makeCheckbox('showMemoryUsage', 'Memory Usage (MB)'));129 tileDebugLabelsPanelContents.appendChild(makeCheckbox('showUrl', 'Url'));130131 optimizationPanelContents.appendChild(makeCheckbox('skipLevelOfDetail', 'Skip Tile LODs'));132 var skipScreenSpaceErrorFactorContainer = document.createElement('div');133 skipScreenSpaceErrorFactorContainer.appendChild(makeRangeInput('skipScreenSpaceErrorFactor', 1, 50, 1, 'Skip SSE Factor'));134 optimizationPanelContents.appendChild(skipScreenSpaceErrorFactorContainer);135 var baseScreenSpaceError = document.createElement('div');136 baseScreenSpaceError.appendChild(makeRangeInput('baseScreenSpaceError', 0, 4096, 1, 'SSE before skipping LOD'));137 optimizationPanelContents.appendChild(baseScreenSpaceError);138 var skipLevelsContainer = document.createElement('div');139 skipLevelsContainer.appendChild(makeRangeInput('skipLevels', 0, 10, 1, 'Min. levels to skip'));140 optimizationPanelContents.appendChild(skipLevelsContainer);141 optimizationPanelContents.appendChild(makeCheckbox('immediatelyLoadDesiredLevelOfDetail', 'Load only tiles that meet the max. SSE.'));142 optimizationPanelContents.appendChild(makeCheckbox('loadSiblings', 'Load siblings of visible tiles.'));143144 var tilesetPanel = makeSection('Tileset', 'tilesetVisible', 'toggleTileset', tilesetPanelContents);145 var displayPanel = makeSection('Display', 'displayVisible', 'toggleDisplay', displayPanelContents);146 var updatePanel = makeSection('Update', 'updateVisible', 'toggleUpdate', updatePanelContents);147 var loggingPanel = makeSection('Logging', 'loggingVisible', 'toggleLogging', loggingPanelContents);148 var tileDebugLabelsPanel = makeSection('Tile Debug Labels', 'tileDebugLabelsVisible', 'toggleTileDebugLabels', tileDebugLabelsPanelContents);149 var stylePanel = makeSection('Style', 'styleVisible', 'toggleStyle', stylePanelContents);150 var optimizationPanel = makeSection('Optimization', 'optimizationVisible', 'toggleOptimization', optimizationPanelContents);151152 // first add and bind all the toggleable panels153 element.appendChild(tilesetPanel);154 element.appendChild(displayPanel);155 element.appendChild(updatePanel);156 element.appendChild(loggingPanel);157 element.appendChild(tileDebugLabelsPanel);158 element.appendChild(stylePanel);159 element.appendChild(optimizationPanel);160161 knockout.applyBindings(viewModel, element);162 }163164 defineProperties(Cesium3DTilesInspector.prototype, {165 /**166 * Gets the parent container.167 * @memberof Cesium3DTilesInspector.prototype168 *169 * @type {Element}170 */171 container : {172 get : function() {173 return this._container;174 }175 },176177 /**178 * Gets the view model.179 * @memberof Cesium3DTilesInspector.prototype180 *181 * @type {Cesium3DTilesInspectorViewModel}182 */183 viewModel : {184 get : function() {185 return this._viewModel;186 }187 }188 });189190 /**191 * @returns {Boolean} true if the object has been destroyed, false otherwise.192 */193 Cesium3DTilesInspector.prototype.isDestroyed = function() {194 return false;195 };196197 /**198 * Destroys the widget. Should be called if permanently199 * removing the widget from layout.200 */201 Cesium3DTilesInspector.prototype.destroy = function() {202 knockout.cleanNode(this._element);203 this._container.removeChild(this._element);204 this.viewModel.destroy();205206 return destroyObject(this);207 };208209 function makeSection(name, visibleProp, toggleProp, contents) {210 var toggle = document.createElement('span');211 toggle.className = 'cesium-cesiumInspector-toggleSwitch';212 toggle.setAttribute('data-bind', 'text: ' + visibleProp + ' ? "-" : "+", click: ' + toggleProp);213214 var header = document.createElement('div');215 header.className = 'cesium-cesiumInspector-sectionHeader';216 header.appendChild(toggle);217 header.appendChild(document.createTextNode(name));218219 var section = document.createElement('div');220 section.className = 'cesium-cesiumInspector-section';221 section.setAttribute('data-bind', 'css: {"cesium-cesiumInspector-show" : ' + visibleProp + ', "cesium-cesiumInspector-hide" : !' + visibleProp + '}');222 section.appendChild(contents);223224 var panel = document.createElement('div');225 panel.className = 'cesium-cesiumInspector-dropDown';226 panel.appendChild(header);227 panel.appendChild(section);228229 return panel;230 }231232 function makeCheckbox(property, text) {233 var checkbox = document.createElement('input');234 checkbox.type = 'checkbox';235 checkbox.setAttribute('data-bind', 'checked: ' + property);236237 var container = document.createElement('div');238 container.appendChild(checkbox);239 container.appendChild(document.createTextNode(text));240241 return container;242 }243244 function makeRangeInput(property, min, max, step, text, displayProperty) {245 displayProperty = defaultValue(displayProperty, property);246 var input = document.createElement('input');247 input.setAttribute('data-bind', 'value: ' + displayProperty);248 input.type = 'number';249250 var slider = document.createElement('input');251 slider.type = 'range';252 slider.min = min;253 slider.max = max;254 slider.step = step;255 slider.setAttribute('data-bind', 'valueUpdate: "input", value: ' + property);256257 var wrapper = document.createElement('div');258 wrapper.appendChild(slider);259260 var container = document.createElement('div');261 container.className = 'cesium-cesiumInspector-slider';262 container.appendChild(document.createTextNode(text));263 container.appendChild(input);264 container.appendChild(wrapper);265266 return container;267 }268269 function makeButton(action, text, active) {270 var button = document.createElement('button');271 button.type = 'button';272 button.textContent = text;273 button.className = 'cesium-cesiumInspector-pickButton';274 var binding = 'click: ' + action;275 if (defined(active)) {276 binding += ', css: {"cesium-cesiumInspector-pickButtonHighlight" : ' + active + '}';277 }278 button.setAttribute('data-bind', binding);279280 return button;281 }282283 return Cesium3DTilesInspector;
...
XMLViewer.js
Source:XMLViewer.js
1/*2 * Copyright (C) 2011 Google Inc. All rights reserved.3 *4 * Redistribution and use in source and binary forms, with or without5 * modification, are permitted provided that the following conditions are6 * met:7 *8 * 1. Redistributions of source code must retain the above copyright9 * notice, this list of conditions and the following disclaimer.10 *11 * 2. Redistributions in binary form must reproduce the above12 * copyright notice, this list of conditions and the following disclaimer13 * in the documentation and/or other materials provided with the14 * distribution.15 *16 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. AND ITS CONTRIBUTORS17 * âAS ISâ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC.20 * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.27 */28var nodeParentPairs = [];29// Script entry point.30function prepareWebKitXMLViewer(noStyleMessage)31{32 var html = createHTMLElement('html');33 var head = createHTMLElement('head');34 html.appendChild(head);35 var style = createHTMLElement('style');36 style.id = 'xml-viewer-style';37 head.appendChild(style);38 var body = createHTMLElement('body');39 html.appendChild(body);40 var sourceXML = createHTMLElement('div');41 sourceXML.id = 'webkit-xml-viewer-source-xml';42 body.appendChild(sourceXML);43 var child;44 while (child = document.firstChild) {45 document.removeChild(child);46 if (child.nodeType != Node.DOCUMENT_TYPE_NODE)47 sourceXML.appendChild(child);48 }49 document.appendChild(html);50 var header = createHTMLElement('div');51 body.appendChild(header);52 header.classList.add('header');53 var headerSpan = createHTMLElement('span');54 header.appendChild(headerSpan);55 headerSpan.textContent = noStyleMessage;56 header.appendChild(createHTMLElement('br'));57 var tree = createHTMLElement('div');58 body.appendChild(tree);59 tree.classList.add('pretty-print');60 tree.id = 'tree';61 window.onload = sourceXMLLoaded;62}63function sourceXMLLoaded()64{65 var sourceXML = document.getElementById('webkit-xml-viewer-source-xml');66 if (!sourceXML)67 return; // Stop if some XML tree extension is already processing this document68 //var style = document.head.firstChild;69 //document.head.removeChild(style);70 //document.head.appendChild(style);71 var root = document.getElementById('tree');72 for (var child = sourceXML.firstChild; child; child = child.nextSibling)73 nodeParentPairs.push({parentElement: root, node: child});74 for (var i = 0; i < nodeParentPairs.length; i++)75 processNode(nodeParentPairs[i].parentElement, nodeParentPairs[i].node);76 drawArrows();77 initButtons();78 if (typeof(onAfterWebkitXMLViewerLoaded) == 'function')79 onAfterWebkitXMLViewerLoaded();80}81// Tree processing.82function processNode(parentElement, node)83{84 if (!processNode.processorsMap) {85 processNode.processorsMap = {};86 processNode.processorsMap[Node.PROCESSING_INSTRUCTION_NODE] = processProcessingInstruction;87 processNode.processorsMap[Node.ELEMENT_NODE] = processElement;88 processNode.processorsMap[Node.COMMENT_NODE] = processComment;89 processNode.processorsMap[Node.TEXT_NODE] = processText;90 processNode.processorsMap[Node.CDATA_SECTION_NODE] = processCDATA;91 }92 if (processNode.processorsMap[node.nodeType])93 processNode.processorsMap[node.nodeType].call(this, parentElement, node);94}95function processElement(parentElement, node)96{97 if (!node.firstChild)98 processEmptyElement(parentElement, node);99 else {100 var child = node.firstChild;101 if (child.nodeType == Node.TEXT_NODE && isShort(child.nodeValue) && !child.nextSibling)102 processShortTextOnlyElement(parentElement, node);103 else104 processComplexElement(parentElement, node);105 }106}107function processEmptyElement(parentElement, node)108{109 var line = createLine();110 line.appendChild(createTag(node, false, true));111 parentElement.appendChild(line);112}113function processShortTextOnlyElement(parentElement, node)114{115 var line = createLine();116 line.appendChild(createTag(node, false, false));117 for (var child = node.firstChild; child; child = child.nextSibling)118 line.appendChild(createText(child.nodeValue));119 line.appendChild(createTag(node, true, false));120 parentElement.appendChild(line);121}122function processComplexElement(parentElement, node)123{124 var collapsible = createCollapsible();125 collapsible.expanded.start.appendChild(createTag(node, false, false));126 for (var child = node.firstChild; child; child = child.nextSibling)127 nodeParentPairs.push({parentElement: collapsible.expanded.content, node: child});128 collapsible.expanded.end.appendChild(createTag(node, true, false));129 collapsible.collapsed.content.appendChild(createTag(node, false, false));130 collapsible.collapsed.content.appendChild(createText('...'));131 collapsible.collapsed.content.appendChild(createTag(node, true, false));132 parentElement.appendChild(collapsible);133}134function processComment(parentElement, node)135{136 if (isShort(node.nodeValue)) {137 var line = createLine();138 line.appendChild(createComment('<!-- ' + node.nodeValue + ' -->'));139 parentElement.appendChild(line);140 } else {141 var collapsible = createCollapsible();142 collapsible.expanded.start.appendChild(createComment('<!--'));143 collapsible.expanded.content.appendChild(createComment(node.nodeValue));144 collapsible.expanded.end.appendChild(createComment('-->'));145 collapsible.collapsed.content.appendChild(createComment('<!--'));146 collapsible.collapsed.content.appendChild(createComment('...'));147 collapsible.collapsed.content.appendChild(createComment('-->'));148 parentElement.appendChild(collapsible);149 }150}151function processCDATA(parentElement, node)152{153 if (isShort(node.nodeValue)) {154 var line = createLine();155 line.appendChild(createText('<![CDATA[ ' + node.nodeValue + ' ]]>'));156 parentElement.appendChild(line);157 } else {158 var collapsible = createCollapsible();159 collapsible.expanded.start.appendChild(createText('<![CDATA['));160 collapsible.expanded.content.appendChild(createText(node.nodeValue));161 collapsible.expanded.end.appendChild(createText(']]>'));162 collapsible.collapsed.content.appendChild(createText('<![CDATA['));163 collapsible.collapsed.content.appendChild(createText('...'));164 collapsible.collapsed.content.appendChild(createText(']]>'));165 parentElement.appendChild(collapsible);166 }167}168function processProcessingInstruction(parentElement, node)169{170 if (isShort(node.nodeValue)) {171 var line = createLine();172 line.appendChild(createComment('<?' + node.nodeName + ' ' + node.nodeValue + '?>'));173 parentElement.appendChild(line);174 } else {175 var collapsible = createCollapsible();176 collapsible.expanded.start.appendChild(createComment('<?' + node.nodeName));177 collapsible.expanded.content.appendChild(createComment(node.nodeValue));178 collapsible.expanded.end.appendChild(createComment('?>'));179 collapsible.collapsed.content.appendChild(createComment('<?' + node.nodeName));180 collapsible.collapsed.content.appendChild(createComment('...'));181 collapsible.collapsed.content.appendChild(createComment('?>'));182 parentElement.appendChild(collapsible);183 }184}185function processText(parentElement, node)186{187 parentElement.appendChild(createText(node.nodeValue));188}189// Processing utils.190function trim(value)191{192 return value.replace(/^\s\s*/, '').replace(/\s\s*$/, '');193}194function isShort(value)195{196 return trim(value).length <= 50;197}198// Tree rendering.199function createHTMLElement(elementName)200{201 return document.createElementNS('http://www.w3.org/1999/xhtml', elementName)202}203function createCollapsible()204{205 var collapsible = createHTMLElement('div');206 collapsible.classList.add('collapsible');207 collapsible.expanded = createHTMLElement('div');208 collapsible.expanded.classList.add('expanded');209 collapsible.appendChild(collapsible.expanded);210 collapsible.expanded.start = createLine();211 collapsible.expanded.start.appendChild(createCollapseButton());212 collapsible.expanded.appendChild(collapsible.expanded.start);213 collapsible.expanded.content = createHTMLElement('div');214 collapsible.expanded.content.classList.add('collapsible-content');215 collapsible.expanded.appendChild(collapsible.expanded.content);216 collapsible.expanded.end = createLine();217 collapsible.expanded.appendChild(collapsible.expanded.end);218 collapsible.collapsed = createHTMLElement('div');219 collapsible.collapsed.classList.add('collapsed');220 collapsible.collapsed.classList.add('hidden');221 collapsible.appendChild(collapsible.collapsed);222 collapsible.collapsed.content = createLine();223 collapsible.collapsed.content.appendChild(createExpandButton());224 collapsible.collapsed.appendChild(collapsible.collapsed.content);225 return collapsible;226}227function createButton()228{229 var button = createHTMLElement('span');230 button.classList.add('button');231 return button;232}233function createCollapseButton(str)234{235 var button = createButton();236 button.classList.add('collapse-button');237 return button;238}239function createExpandButton(str)240{241 var button = createButton();242 button.classList.add('expand-button');243 return button;244}245function createComment(commentString)246{247 var comment = createHTMLElement('span');248 comment.classList.add('webkit-html-comment');249 comment.textContent = commentString;250 return comment;251}252function createText(value)253{254 var text = createHTMLElement('span');255 text.textContent = trim(value);256 text.classList.add('text');257 return text;258}259function createLine()260{261 var line = createHTMLElement('div');262 line.classList.add('line');263 return line;264}265function createTag(node, isClosing, isEmpty)266{267 var tag = createHTMLElement('span');268 tag.classList.add('webkit-html-tag');269 var stringBeforeAttrs = '<';270 if (isClosing)271 stringBeforeAttrs += '/';272 stringBeforeAttrs += node.nodeName;273 var textBeforeAttrs = document.createTextNode(stringBeforeAttrs);274 tag.appendChild(textBeforeAttrs);275 if (!isClosing) {276 for (var i = 0; i < node.attributes.length; i++)277 tag.appendChild(createAttribute(node.attributes[i]));278 }279 var stringAfterAttrs = '';280 if (isEmpty)281 stringAfterAttrs += '/';282 stringAfterAttrs += '>';283 var textAfterAttrs = document.createTextNode(stringAfterAttrs);284 tag.appendChild(textAfterAttrs);285 return tag;286}287function createAttribute(attributeNode)288{289 var attribute = createHTMLElement('span');290 attribute.classList.add('webkit-html-attribute');291 var attributeName = createHTMLElement('span');292 attributeName.classList.add('webkit-html-attribute-name');293 attributeName.textContent = attributeNode.name;294 var textBefore = document.createTextNode(' ');295 var textBetween = document.createTextNode('="');296 var attributeValue = createHTMLElement('span');297 attributeValue.classList.add('webkit-html-attribute-value');298 attributeValue.textContent = attributeNode.value;299 var textAfter = document.createTextNode('"');300 attribute.appendChild(textBefore);301 attribute.appendChild(attributeName);302 attribute.appendChild(textBetween);303 attribute.appendChild(attributeValue);304 attribute.appendChild(textAfter);305 return attribute;306}307// Tree behaviour.308function drawArrows()309{310 var ctx = document.getCSSCanvasContext("2d", "arrowRight", 10, 11);311 ctx.fillStyle = "rgb(90,90,90)";312 ctx.beginPath();313 ctx.moveTo(0, 0);314 ctx.lineTo(0, 8);315 ctx.lineTo(7, 4);316 ctx.lineTo(0, 0);317 ctx.fill();318 ctx.closePath();319 var ctx = document.getCSSCanvasContext("2d", "arrowDown", 10, 10);320 ctx.fillStyle = "rgb(90,90,90)";321 ctx.beginPath();322 ctx.moveTo(0, 0);323 ctx.lineTo(8, 0);324 ctx.lineTo(4, 7);325 ctx.lineTo(0, 0);326 ctx.fill();327 ctx.closePath();328}329function expandFunction(sectionId)330{331 return function()332 {333 document.querySelector('#' + sectionId + ' > .expanded').className = 'expanded';334 document.querySelector('#' + sectionId + ' > .collapsed').className = 'collapsed hidden';335 };336}337function collapseFunction(sectionId)338{339 return function()340 {341 document.querySelector('#' + sectionId + ' > .expanded').className = 'expanded hidden';342 document.querySelector('#' + sectionId + ' > .collapsed').className = 'collapsed';343 };344}345function initButtons()346{347 var sections = document.querySelectorAll('.collapsible');348 for (var i = 0; i < sections.length; i++) {349 var sectionId = 'collapsible' + i;350 sections[i].id = sectionId;351 var expandedPart = sections[i].querySelector('#' + sectionId + ' > .expanded');352 var collapseButton = expandedPart.querySelector('.collapse-button');353 collapseButton.onclick = collapseFunction(sectionId);354 collapseButton.onmousedown = handleButtonMouseDown;355 var collapsedPart = sections[i].querySelector('#' + sectionId + ' > .collapsed');356 var expandButton = collapsedPart.querySelector('.expand-button');357 expandButton.onclick = expandFunction(sectionId);358 expandButton.onmousedown = handleButtonMouseDown;359 }360}361function handleButtonMouseDown(e)362{363 // To prevent selection on double click364 e.preventDefault();...
createTables.js
Source:createTables.js
1// JavaScript Document23 function createTables(parent,chartDiv,number,prefix){ 4 5 var cetFlag = false ,tabFlag = false , tbdFlag = false , trFlag = false ,tdFlag = false ;6 var count = number%2>0 ? Math.floor(number/2 +1) : number/2; 7 var center = null, table = null ,tbody = null, tr = null , td = null ;8 9 center = document.getElementById(prefix+"center");10 if(center == null || "undefined" == typeof(center)){11 center = document.createElement("center");12 center.setAttribute('id',prefix+'center');13 cetFlag = true;14 }15 16 table = document.getElementById(prefix+"table");17 if(table == null || "undefined" == typeof(table)){18 table = document.createElement("table");19 table.setAttribute('id',prefix+'table');20 table.style.tableLayout='fixed';21 table.style.width='96%';22 table.style.border='0';23 table.setAttribute('cellspacing','4');24 tabFlag = true;25 }26 27 tbody = document.getElementById(prefix+"tbody");28 if(tbody == null || "undefined" == typeof(tbody)){29 tbody = document.createElement("tbody");30 tbody.setAttribute('id',prefix+'tbody');31 tbdFlag = true;32 }33 34 tr = document.getElementById(prefix+'tr'+count); 35 td = document.getElementById(prefix+'td'+number);36 var td2 = null ;37 38 if(tr == null || "undefined" == typeof(tr)){39 tr = document.createElement("tr");40 tr.setAttribute('id',prefix+'tr'+count);41 trFlag = true;42 43 if(number%2 == 1){ 44 if(td == null || "undefined" == typeof(td)){45 td = document.createElement("td");46 td.setAttribute('id',prefix+'td'+number);47 td.style.verticalAlign="top"; 48 tdFlag = true; 49 50 td2 = document.createElement('td');51 td2.setAttribute('id',prefix+'td'+(((count-1)*2+2)));52 td2.style.verticalAlign="top"; 53 54 td.appendChild(chartDiv); 55 if(tdFlag)tr.appendChild(td);56 57 tr.appendChild(td2);58 }else {59 td.appendChild(chartDiv); 60 if(tdFlag)tr.appendChild(td);61 }62 }else if(number%2 == 0){ 63 if(td == null || "undefined" == typeof(td)){64 td = document.createElement("td");65 td.setAttribute('id',prefix+'td'+number);66 td.style.verticalAlign="top";67 tdFlag = true;68 69 td2 = document.createElement('td');70 td2.setAttribute('id',prefix+'td'+(((count-1)*2+1)));71 td2.style.verticalAlign="top"; 72 73 tr.appendChild(td2);74 75 td.appendChild(chartDiv); 76 if(tdFlag)tr.appendChild(td);77 }else {78 td.appendChild(chartDiv); 79 if(tdFlag)tr.appendChild(td);80 }81 } 82 } else {83 if(number%2 == 1){ 84 if(td == null || "undefined" == typeof(td)){85 td = document.createElement("td");86 td.setAttribute('id',prefix+'td'+number);87 td.style.verticalAlign="top";88 tdFlag = true; 89 90 td2 = document.createElement('td');91 td2.setAttribute('id',prefix+'td'+(((count-1)*2+2)));92 td2.style.verticalAlign="top"; 93 94 td.appendChild(chartDiv); 95 if(tdFlag)tr.appendChild(td);96 97 tr.appendChild(td2);98 }else {99 td.appendChild(chartDiv); 100 if(tdFlag)tr.appendChild(td);101 }102 }else if(number%2 == 0){ 103 if(td == null || "undefined" == typeof(td)){104 td = document.createElement("td");105 td.setAttribute('id',prefix+'td'+number);106 td.style.verticalAlign="top";107 tdFlag = true;108 109 td2 = document.createElement('td');110 td2.setAttribute('id',prefix+'td'+(((count-1)*2+1)));111 td2.style.verticalAlign="top";112 113 tr.appendChild(td2); 114 td.appendChild(chartDiv); 115 if(tdFlag)tr.appendChild(td);116 }else {117 td.appendChild(chartDiv); 118 if(tdFlag)tr.appendChild(td);119 }120 } 121 }122 123 124 if(trFlag)tbody.appendChild(tr);125 if(tbdFlag)table.appendChild(tbody);126 if(tabFlag)center.appendChild(table);127 if(cetFlag)parent.appendChild(center); 128 }129 130 function hostTables(chartDiv,number,parent){131 132 var cetFlag = false ,tabFlag = false , tbdFlag = false , trFlag = false ,tdFlag = false ;133 var count = number%4>0 ? Math.floor(number/4 +1) : number/4; 134 var center = null, table = null ,tbody = null, tr = null , td = null ;135 136 center = document.getElementById("center1");137 if(center == null || "undefined" == typeof(center)){138 center = document.createElement("center");139 center.setAttribute('id','center1');140 cetFlag = true;141 }142 143 table = document.getElementById("graph_metric");144 if(table == null || "undefined" == typeof(table)){145 table = document.createElement("table");146 table.setAttribute('id','graph_metric');147 table.style.tableLayout='fixed';148 table.style.width='96%';149 table.style.border='0';150 table.setAttribute('cellspacing','4'); 151 tabFlag = true;152 } 153 154 tbody = document.getElementById("tbody1");155 if(tbody == null || "undefined" == typeof(tbody)){156 tbody = document.createElement("tbody");157 tbody.setAttribute('id','tbody1');158 tbdFlag = true;159 }160 161 tr = document.getElementById('tr'+count); 162 td = document.getElementById('td'+number); 163 164 var td2 = null ,td3 = null , td3 = null ;165 166 if(tr == null || "undefined" == typeof(tr)){167 tr = document.createElement("tr");168 tr.setAttribute('id','tr'+count);169 trFlag = true;170 171 if(number%4 == 1){ 172 if(td == null || "undefined" == typeof(td)){173 td = document.createElement("td");174 td.setAttribute('id','td'+number);175 td.style.verticalAlign="top";176 tdFlag = true;177 178 td2 = document.createElement('td');179 td2.style.verticalAlign="top";180 td2.setAttribute('id','td'+((count-1)*4+2));181 182 td3 = document.createElement('td');183 td3.style.verticalAlign="top";184 td3.setAttribute('id','td'+(((count-1)*4+3)));185 186 td4 = document.createElement('td');187 td4.style.verticalAlign="top";188 td4.setAttribute('id','td'+(((count-1)*4+4))); 189 190 td.appendChild(chartDiv); 191 if(tdFlag)tr.appendChild(td); 192 193 tr.appendChild(td2);194 tr.appendChild(td3);195 tr.appendChild(td4); 196 }else {197 td.appendChild(chartDiv); 198 if(tdFlag)tr.appendChild(td);199 } 200 }else if(number%4 == 2){ 201 if(td == null || "undefined" == typeof(td)){202 td = document.createElement("td");203 td.setAttribute('id','td'+number);204 td.style.verticalAlign="top";205 tdFlag = true;206 207 td2 = document.createElement('td');208 td2.style.verticalAlign="top";209 td2.setAttribute('id','td'+(((count-1)*4+1)));210 211 td3 = document.createElement('td');212 td3.style.verticalAlign="top";213 td3.setAttribute('id','td'+(((count-1)*4+3)));214 215 td4 = document.createElement('td');216 td4.style.verticalAlign="top";217 td4.setAttribute('id','td'+(((count-1)*4+4)));218 //219 tr.appendChild(td2);220 221 td.appendChild(chartDiv); 222 if(tdFlag)tr.appendChild(td); 223 224 tr.appendChild(td3);225 tr.appendChild(td4);226 }else {227 td.appendChild(chartDiv); 228 if(tdFlag)tr.appendChild(td);229 } 230 }else if(number%4 == 3){ 231 if(td == null || "undefined" == typeof(td)){232 td = document.createElement("td");233 td.setAttribute('id','td'+number);234 td.style.verticalAlign="top";235 tdFlag = true;236 237 td2 = document.createElement('td');238 td2.style.verticalAlign="top";239 td2.setAttribute('id','td'+(((count-1)*4+1)));240 241 td3 = document.createElement('td');242 td3.style.verticalAlign="top";243 td3.setAttribute('id','td'+(((count-1)*4+2)));244 245 td4 = document.createElement('td');246 td4.style.verticalAlign="top";247 td4.setAttribute('id','td'+(((count-1)*4+4))); 248 249 tr.appendChild(td2);250 tr.appendChild(td3);251 252 td.appendChild(chartDiv); 253 if(tdFlag)tr.appendChild(td); 254 255 tr.appendChild(td4); 256 }else {257 td.appendChild(chartDiv); 258 if(tdFlag)tr.appendChild(td);259 } 260 }else if(number%4 == 0){ 261 if(td == null || "undefined" == typeof(td)){262 td = document.createElement("td");263 td.setAttribute('id','td'+number);264 td.style.verticalAlign="top";265 tdFlag = true;266 267 td2 = document.createElement('td');268 td2.style.verticalAlign="top";269 td2.setAttribute('id','td'+(((count-1)*4+1)));270 271 td3 = document.createElement('td');272 td3.style.verticalAlign="top";273 td3.setAttribute('id','td'+(((count-1)*4+2)));274 275 td4 = document.createElement('td');276 td4.style.verticalAlign="top";277 td4.setAttribute('id','td'+(((count-1)*4+3)));278 279 tr.appendChild(td2);280 tr.appendChild(td3);281 tr.appendChild(td4);282 283 td.appendChild(chartDiv); 284 if(tdFlag)tr.appendChild(td); 285 }else {286 td.appendChild(chartDiv); 287 if(tdFlag)tr.appendChild(td);288 }289 } 290 } else {291 if(number%4 == 1){ 292 if(td == null || "undefined" == typeof(td)){293 td = document.createElement("td");294 td.setAttribute('id','td'+number);295 td.style.verticalAlign="top";296 tdFlag = true;297 298 td2 = document.createElement('td');299 td2.style.verticalAlign="top";300 td2.setAttribute('id','td'+(((count-1)*4+2)));301 302 td3 = document.createElement('td');303 td3.style.verticalAlign="top";304 td3.setAttribute('id','td'+(((count-1)*4+3)));305 306 td4 = document.createElement('td');307 td4.style.verticalAlign="top";308 td4.setAttribute('id','td'+(((count-1)*4+4)));309 310 td.appendChild(chartDiv); 311 if(tdFlag)tr.appendChild(td); 312 313 tr.appendChild(td2);314 tr.appendChild(td3);315 tr.appendChild(td4); 316 } else {317 td.appendChild(chartDiv); 318 if(tdFlag)tr.appendChild(td);319 } 320 }else if(number%4 == 2){ 321 if(td == null || "undefined" == typeof(td)){322 td = document.createElement("td");323 td.setAttribute('id','td'+number);324 td.style.verticalAlign="top";325 tdFlag = true;326 327 td2 = document.createElement('td');328 td2.style.verticalAlign="top";329 td2.setAttribute('id','td'+(((count-1)*4+1)));330 331 td3 = document.createElement('td');332 td3.style.verticalAlign="top";333 td3.setAttribute('id','td'+(((count-1)*4+3)));334 335 td4 = document.createElement('td');336 td4.style.verticalAlign="top";337 td4.setAttribute('id','td'+(((count-1)*4+4)));338 339 tr.appendChild(td2);340 341 td.appendChild(chartDiv); 342 if(tdFlag)tr.appendChild(td); 343 344 tr.appendChild(td3);345 tr.appendChild(td4);346 } else {347 td.appendChild(chartDiv); 348 if(tdFlag)tr.appendChild(td);349 } 350 }else if(number%4 == 3){ 351 if(td == null || "undefined" == typeof(td)){352 td = document.createElement("td");353 td.setAttribute('id','td'+number);354 td.style.verticalAlign="top";355 tdFlag = true;356 357 td2 = document.createElement('td');358 td2.style.verticalAlign="top";359 td2.setAttribute('id','td'+(((count-1)*4+1)));360 361 td3 = document.createElement('td');362 td3.style.verticalAlign="top";363 td3.setAttribute('id','td'+(((count-1)*4+2)));364 365 td4 = document.createElement('td');366 td4.style.verticalAlign="top";367 td4.setAttribute('id','td'+(((count-1)*4+4)));368 369 tr.appendChild(td2);370 tr.appendChild(td3);371 372 td.appendChild(chartDiv);373 if(tdFlag)tr.appendChild(td);374 375 tr.appendChild(td4);376 } else {377 td.appendChild(chartDiv); 378 if(tdFlag)tr.appendChild(td); 379 } 380 }else if(number%4 == 0){ 381 if(td == null || "undefined" == typeof(td)){382 td = document.createElement("td");383 td.setAttribute('id','td'+number);384 td.style.verticalAlign="top";385 tdFlag = true;386 387 td2 = document.createElement('td');388 td2.setAttribute('id','td'+(((count-1)*4+1)));389 td2.style.verticalAlign="top";390 391 td3 = document.createElement('td');392 td3.style.verticalAlign="top";393 td3.setAttribute('id','td'+(((count-1)*4+2)));394 395 td4 = document.createElement('td');396 td4.style.verticalAlign="top";397 td4.setAttribute('id','td'+(((count-1)*4+3)));398 399 tr.appendChild(td2);400 tr.appendChild(td3);401 tr.appendChild(td4);402 403 td.appendChild(chartDiv); 404 if(tdFlag)tr.appendChild(td); 405 }else {406 td.appendChild(chartDiv); 407 if(tdFlag)tr.appendChild(td); 408 }409 }410 }411 412 if(trFlag)tbody.appendChild(tr);413 if(tbdFlag)table.appendChild(tbody);414 if(tabFlag)center.appendChild(table);415 if(cetFlag)parent.appendChild(center); 416
...
table.js
Source:table.js
...34 rows : $('<input type="text" />').attr('size', 5).val(2),35 cols : $('<input type="text" />').attr('size', 5).val(2),36 width : $('<input type="text" />').attr('size', 5),37 wunit : $('<select />')38 .append($('<option />').val('%').text('%'))39 .append($('<option />').val('px').text('px')), 40 height : $('<input type="text" />').attr('size', 5), 41 hunit : $('<select />')42 .append($('<option />').val('%').text('%'))43 .append($('<option />').val('px').text('px')), 44 align : $('<select />')45 .append($('<option />').val('').text(self.rte.i18n('Not set')))46 .append($('<option />').val('left').text(self.rte.i18n('Left')))47 .append($('<option />').val('center').text(self.rte.i18n('Center'))) 48 .append($('<option />').val('right').text(self.rte.i18n('Right'))), 49 spacing : $('<input type="text" />').attr('size', 5), 50 padding : $('<input type="text" />').attr('size', 5),51 border : $('<div />'),52 // frame : $('<select />')53 // .append($('<option />').val('void').text(self.rte.i18n('No')))54 // .append($('<option />').val('border').text(self.rte.i18n('Yes'))),55 rules : $('<select />')56 .append($('<option />').val('none').text(self.rte.i18n('No')))57 .append($('<option />').val('all').text(self.rte.i18n('Cells')))58 .append($('<option />').val('groups').text(self.rte.i18n('Groups')))59 .append($('<option />').val('rows').text(self.rte.i18n('Rows')))60 .append($('<option />').val('cols').text(self.rte.i18n('Columns'))),61 margin : $('<div />'),62 bg : $('<div />'),63 bgimg : $('<input type="text" />').css('width', '90%')64 },65 66 adv : {67 id : $('<input type="text" />'),68 summary : $('<input type="text" />'),69 'class' : $('<input type="text" />'),70 style : $('<input type="text" />'),71 dir : $('<select />')72 .append($('<option />').text(self.rte.i18n('Not set')).val(''))73 .append($('<option />').text(self.rte.i18n('Left to right')).val('ltr'))74 .append($('<option />').text(self.rte.i18n('Right to left')).val('rtl')),75 lang : $('<input type="text" />')76 },77 78 events : {}79 }80 81 $.each(self.src, function() {82 for (var n in this) {83 this[n].attr('name', n);84 var t = this[n].get(0).nodeName; 85 if (t == 'INPUT' && n != 'bgimg') {86 this[n].css(this[n].attr('size') ? {'text-align' : 'right'} : {width : '100%'});87 } else if (t == 'SELECT' && n!='wunit' && n!='hunit') {88 this[n].css('width', '100%');89 }90 }91 });92 93 $.each(94 ['onblur', 'onfocus', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmouseout', 'onmouseleave', 'onkeydown', 'onkeypress', 'onkeyup'], 95 function() {96 self.src.events[this] = $('<input type="text" />').css('width', '100%');97 });98 99 self.src.main.align.change(function() {100 var v = $(this).val();101 if (v == 'center') {102 self.src.main.margin.val({left : 'auto', right : 'auto'});103 } else {104 var m = self.src.main.margin.val();105 if (m.left == 'auto' && m.right == 'auto') {106 self.src.main.margin.val({left : '', right : ''});107 }108 }109 });110 111 self.src.main.bgimg.change(function() {112 var t = $(this);113 t.val(self.rte.utils.absoluteURL(t.val()));114 })115 116 }117 118 this.command = function() {119 var n = this.rte.dom.selfOrParent(this.rte.selection.getNode(), /^TABLE$/);120 121 if (this.name == 'table') {122 this.table = $(this.rte.doc.createElement('table')); 123 } else {124 this.table = n ? $(n) : $(this.rte.doc.createElement('table')); 125 }126 127 !this.src && init();128 this.src.main.border.elBorderSelect({styleHeight : 117});129 this.src.main.bg.elColorPicker({palettePosition : 'outer', 'class' : 'el-colorpicker ui-icon ui-icon-pencil'});130 this.src.main.margin.elPaddingInput({ type : 'margin', value : this.table});131 132 if (this.table.parents().length) {133 this.src.main.rows.val('').attr('disabled', true);134 this.src.main.cols.val('').attr('disabled', true);135 } else {136 this.src.main.rows.val(2).removeAttr('disabled');137 this.src.main.cols.val(2).removeAttr('disabled');138 }139 140 var w = this.table.css('width') || this.table.attr('width');141 this.src.main.width.val(parseInt(w)||'');142 this.src.main.wunit.val(w.indexOf('px') != -1 ? 'px' : '%');143 144 var h = this.table.css('height') || this.table.attr('height'); 145 this.src.main.height.val(parseInt(h)||'');146 this.src.main.hunit.val(h && h.indexOf('px') != -1 ? 'px' : '%');147 var f = this.table.css('float');148 this.src.main.align.val('');149 if (f == 'left' || f == 'right') {150 this.src.main.align.val(f);151 } else {152 var ml = this.table.css('margin-left');153 var mr = this.table.css('margin-right');154 if (ml == 'auto' && mr == 'auto') {155 this.src.main.align.val('center');156 }157 }158 this.src.main.border.val(this.table);159 //this.src.main.frame.val(this.table.attr('frame'));160 this.src.main.rules.val(this.rte.dom.attr(this.table.get(0), 'rules'));161 this.src.main.bg.val(this.table.css('background-color'));162 var bgimg = (this.table.css('background-image')||'').replace(/url\(([^\)]+)\)/i, "$1");163 this.src.main.bgimg.val(bgimg!='none' ? bgimg : '');164 var opts = {165 rtl : this.rte.rtl,166 submit : function(e, d) { e.stopPropagation(); e.preventDefault(); self.set(); d.close(); },167 dialog : {168 width : 530,169 title : this.rte.i18n('Table')170 }171 }172 var d = new elDialogForm(opts);173 174 for (var tab in this.src) {175 d.tab(tab, this.rte.i18n(this.labels[tab]));176 if (tab == 'main') {177 var t1 = $('<table />')178 .append($('<tr />').append('<td>'+this.rte.i18n('Rows')+'</td>').append($('<td />').append(this.src.main.rows)))179 .append($('<tr />').append('<td>'+this.rte.i18n('Columns')+'</td>').append($('<td />').append(this.src.main.cols)));180 var t2 = $('<table />')181 .append($('<tr />').append('<td>'+this.rte.i18n('Width')+'</td>').append($('<td />').append(this.src.main.width).append(this.src.main.wunit)))182 .append($('<tr />').append('<td>'+this.rte.i18n('Height')+'</td>').append($('<td />').append(this.src.main.height).append(this.src.main.hunit)));183 var t3 = $('<table />')184 .append($('<tr />').append('<td>'+this.rte.i18n('Spacing')+'</td>').append($('<td />').append(this.src.main.spacing.val(this.table.attr('cellspacing')||''))))185 .append($('<tr />').append('<td>'+this.rte.i18n('Padding')+'</td>').append($('<td />').append(this.src.main.padding.val(this.table.attr('cellpadding')||''))));186 187 d.append([this.rte.i18n('Caption'), this.src.main.caption.val(this.table.find('caption').eq(0).text() || '')], 'main', true)188 .separator('main')189 .append([t1, t2, t3], 'main', true)190 .separator('main')191 .append([this.rte.i18n('Border'), this.src.main.border], 'main', true)192 //.append([this.rte.i18n('Frame'), this.src.main.frame], 'main', true)193 .append([this.rte.i18n('Inner borders'), this.src.main.rules], 'main', true)194 .append([this.rte.i18n('Alignment'), this.src.main.align], 'main', true)195 .append([this.rte.i18n('Margins'), this.src.main.margin], 'main', true)196 .append([this.rte.i18n('Background'), $('<span />').append($('<span />').css({'float' : 'left', 'margin-right' : '3px'}).append(this.src.main.bg)).append(this.src.main.bgimg)], 'main', true)197 } else {198 for (var name in this.src[tab]) {199 var v = this.rte.dom.attr(this.table, name);200 if (tab == 'events') {201 v = this.rte.utils.trimEventCallback(v);202 } 203 d.append([this.rte.i18n(this.labels[name] ? this.labels[name] : name), this.src[tab][name].val(v)], tab, true);204 }205 }206 }207 208 d.open();209 }210 211 this.set = function() {212 213 if (!this.table.parents().length) {214 var r = parseInt(this.src.main.rows.val()) || 0;215 var c = parseInt(this.src.main.cols.val()) || 0;216 if (r<=0 || c<=0) {217 return;218 }219 this.rte.history.add(); 220 var b = $(this.rte.doc.createElement('tbody')).appendTo(this.table);221 222 for (var i=0; i < r; i++) {223 var tr = '<tr>';224 for (var j=0; j < c; j++) {225 tr += '<td> </td>';226 }227 b.append(tr+'</tr>');228 };229 230 // var tr = $(this.rte.doc.createElement('tr'));231 // 232 // for (var i=0; i < c; i++) {233 // tr.append($(this.rte.doc.createElement('td')).html(' '));234 // };235 // 236 // for (var i=0; i<r; i++) {237 // b.append(tr.clone(true));238 // };239 240 // this.rte.selection.insertNode(this.table.get(0), true);241 } else {242 this.table243 .removeAttr('width')244 .removeAttr('height')245 .removeAttr('border')246 .removeAttr('align')247 .removeAttr('bordercolor')248 .removeAttr('bgcolor')249 .removeAttr('cellspacing')250 .removeAttr('cellpadding')251 .removeAttr('frame')...
XmlUtil.js
Source:XmlUtil.js
1Clazz.declarePackage ("JU");2Clazz.load (null, "JU.XmlUtil", ["JU.PT"], function () {3c$ = Clazz.declareType (JU, "XmlUtil");4Clazz.makeConstructor (c$, 5function () {6});7c$.openDocument = Clazz.defineMethod (c$, "openDocument", 8function (data) {9data.append ("<?xml version=\"1.0\"?>\n");10}, "JU.SB");11c$.openTag = Clazz.defineMethod (c$, "openTag", 12function (sb, name) {13sb.append ("<").append (name).append (">\n");14}, "JU.SB,~S");15c$.openTagAttr = Clazz.defineMethod (c$, "openTagAttr", 16function (sb, name, attributes) {17JU.XmlUtil.appendTagAll (sb, name, attributes, null, false, false);18sb.append ("\n");19}, "JU.SB,~S,~A");20c$.closeTag = Clazz.defineMethod (c$, "closeTag", 21function (sb, name) {22sb.append ("</").append (name).append (">\n");23}, "JU.SB,~S");24c$.appendTagAll = Clazz.defineMethod (c$, "appendTagAll", 25function (sb, name, attributes, data, isCdata, doClose) {26var closer = ">";27if (name.endsWith ("/")) {28name = name.substring (0, name.length - 1);29if (data == null) {30closer = "/>\n";31doClose = false;32}}sb.append ("<").append (name);33if (attributes != null) for (var i = 0; i < attributes.length; i++) {34var o = attributes[i];35if (o == null) continue;36if (Clazz.instanceOf (o, Array)) for (var j = 0; j < (o).length; j += 2) JU.XmlUtil.appendAttrib (sb, (o)[j], (o)[j + 1]);37 else JU.XmlUtil.appendAttrib (sb, o, attributes[++i]);38}39sb.append (closer);40if (data != null) {41if (isCdata) data = JU.XmlUtil.wrapCdata (data);42sb.appendO (data);43}if (doClose) JU.XmlUtil.closeTag (sb, name);44}, "JU.SB,~S,~A,~O,~B,~B");45c$.wrapCdata = Clazz.defineMethod (c$, "wrapCdata", 46function (data) {47var s = "" + data;48return (s.indexOf ("&") < 0 && s.indexOf ("<") < 0 ? (s.startsWith ("\n") ? "" : "\n") + s : "<![CDATA[" + JU.PT.rep (s, "]]>", "]]]]><![CDATA[>") + "]]>");49}, "~O");50c$.appendTagObj = Clazz.defineMethod (c$, "appendTagObj", 51function (sb, name, attributes, data) {52JU.XmlUtil.appendTagAll (sb, name, attributes, data, false, true);53}, "JU.SB,~S,~A,~O");54c$.appendTag = Clazz.defineMethod (c$, "appendTag", 55function (sb, name, data) {56if (Clazz.instanceOf (data, Array)) JU.XmlUtil.appendTagAll (sb, name, data, null, false, true);57 else JU.XmlUtil.appendTagAll (sb, name, null, data, false, true);58}, "JU.SB,~S,~O");59c$.appendCdata = Clazz.defineMethod (c$, "appendCdata", 60function (sb, name, attributes, data) {61JU.XmlUtil.appendTagAll (sb, name, attributes, data, true, true);62}, "JU.SB,~S,~A,~S");63c$.appendAttrib = Clazz.defineMethod (c$, "appendAttrib", 64function (sb, name, value) {65if (value == null) return;66sb.append (" ").appendO (name).append ("=\"").appendO (value).append ("\"");67}, "JU.SB,~O,~O");...
Using AI Code Generation
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('input[name="q"]');7 await page.fill('input[name="q"]', 'Hello World');8 await page.keyboard.press('Enter');9 await page.screenshot({ path: `example.png` });10 await browser.close();11})();12const { chromium } = require('playwright');13(async () => {14 const browser = await chromium.launch();15 const context = await browser.newContext();16 const page = await context.newPage();17 await page.click('input[name="q"]');18 await page.fill('input[name="q"]', 'Hello World');19 await page.keyboard.press('Enter');20 await page.screenshot({ path: `example.png` });21 await browser.close();22})();23const { chromium } = require('playwright');24(async () => {25 const browser = await chromium.launch();26 const context = await browser.newContext();27 const page = await context.newPage();28 await page.click('input[name="q"]');29 await page.fill('input[name="q"]', 'Hello World');30 await page.keyboard.press('Enter');31 await page.screenshot({ path: `example.png` });32 await browser.close();33})();34const { chromium } = require('playwright');35(async () => {36 const browser = await chromium.launch();37 const context = await browser.newContext();38 const page = await context.newPage();39 await page.click('input[name="q"]');40 await page.fill('input[name="q"]', 'Hello World');41 await page.keyboard.press('Enter');42 await page.screenshot({ path: `example.png` });43 await browser.close();44})();45const { chromium } = require('playwright');
Using AI Code Generation
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.screenshot({path: 'example.png'});7 await browser.close();8})();9const { chromium } = require('playwright');10(async () => {11 const browser = await chromium.launch();12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.screenshot({path: 'example.png'});15 await browser.close();16})();17const { chromium } = require('playwright');18(async () => {19 const browser = await chromium.launch();20 const context = await browser.newContext();21 const page = await context.newPage();22 await page.screenshot({path: 'example.png'});23 await browser.close();24})();25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch();28 const context = await browser.newContext();29 const page = await context.newPage();30 await page.screenshot({path: 'example.png'});31 await browser.close();32})();33const { chromium } = require('playwright');34(async () => {35 const browser = await chromium.launch();36 const context = await browser.newContext();37 const page = await context.newPage();38 await page.screenshot({path: 'example.png'});39 await browser.close();40})();41const { chromium } = require('playwright');42(async () => {43 const browser = await chromium.launch();44 const context = await browser.newContext();45 const page = await context.newPage();46 await page.screenshot({path: 'example.png'});47 await browser.close();48})();
Using AI Code Generation
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.evaluate(() => {7 const script = document.createElement('script');8 document.body.appendChild(script);9 });10 await page.fill('input[name="q"]', 'playwright');11 await page.click('input[value="Google Search"]');12 await page.waitForNavigation();13 await page.waitForNavigation();14 await page.click('text=Docs');15 await page.waitForNavigation();16 await page.click('text=API');17 await page.waitForNavigation();18 await page.click('text=class: Page');19 await page.waitForNavigation();20 await page.click('text=method: Page.evaluate');21 await page.waitForNavigation();22 await page.click('text=method: Page.evaluateHandle');23 await page.waitForNavigation();24 await page.click('text=method: Page.fill');25 await page.waitForNavigation();26 await page.click('text=method: Page.click');27 await page.waitForNavigation();28 await page.click('text=method: Page.waitForNavigation');29 await page.waitForNavigation();30 await page.click('text=method: Page.waitForSelector');31 await page.waitForNavigation();32 await page.click('text=method: Page.waitForLoadState');33 await page.waitForNavigation();34 await page.click('text=method: Page.waitForRequest');35 await page.waitForNavigation();36 await page.click('text=method: Page.waitForResponse');37 await page.waitForNavigation();38 await page.click('text=method: Page.waitForEvent');39 await page.waitForNavigation();40 await page.click('text=method: Page.waitForFunction');41 await page.waitForNavigation();42 await page.click('text=method: Page.screenshot');43 await page.waitForNavigation();44 await page.click('text=method: Page.pdf');45 await page.waitForNavigation();46 await page.click('text=method: Page.title');47 await page.waitForNavigation();48 await page.click('text=method: Page.close');49 await page.waitForNavigation();50 await page.click('text=method: Page.bringToFront');
Using AI Code Generation
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.screenshot({ path: `example.png` });7 await browser.close();8})();9const { chromium } = require('playwright');10(async () => {11 const browser = await chromium.launch();12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.screenshot({ path: `example.png` });15 await browser.close();16})();17const { chromium } = require('playwright');18(async () => {19 const browser = await chromium.launch();20 const context = await browser.newContext();21 const page = await context.newPage();22 await page.screenshot({ path: `example.png` });23 await browser.close();24})();25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch();28 const context = await browser.newContext();29 const page = await context.newPage();30 await page.screenshot({ path: `example.png` });31 await browser.close();32})();33const { chromium } = require('playwright');34(async () => {35 const browser = await chromium.launch();36 const context = await browser.newContext();37 const page = await context.newPage();38 await page.screenshot({ path: `example.png` });39 await browser.close();40})();41const { chromium } = require('playwright');42(async () => {
Using AI Code Generation
1const { appendTestInfo } = require('@playwright/test');2const { test } = require('@playwright/test');3test('test', async ({ page }) => {4 await appendTestInfo('I am a test info');5});6{7 "stats": {8 },9 {10 "err": {},11 "ctx": {12 },13 "annotations": {},
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 const element = await page.$('text=Get started');6 await element.evaluate(element => {7 const newElement = document.createElement('div');8 newElement.textContent = 'New Element';9 element.append(newElement);10 });11 await page.screenshot({ path: 'append.png' });12 await browser.close();13})();14const { chromium } = require('playwright');15(async () => {16 const browser = await chromium.launch();17 const page = await browser.newPage();18 const element = await page.$('text=Get started');19 await element.evaluate(element => {20 element.remove();21 });22 await page.screenshot({ path: 'remove.png' });23 await browser.close();24})();25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch();28 const page = await browser.newPage();29 const element = await page.$('text=Get started');30 await element.evaluate(element => {31 const newElement = document.createElement('div');32 newElement.textContent = 'New Element';33 element.replaceWith(newElement);34 });35 await page.screenshot({ path: 'replace-with.png' });36 await browser.close();37})();38const { chromium } = require('playwright');39(async () => {40 const browser = await chromium.launch();41 const page = await browser.newPage();42 const element = await page.$('text=Get started');43 await element.evaluate(element => {44 element.setAttribute('data-test', 'test-value');45 });46 await page.screenshot({ path: 'set-attribute.png' });
Using AI Code Generation
1await page.evaluate(() => {2 const script = document.createElement('script');3 document.body.appendChild(script);4});5await page.evaluate(() => {6 const script = document.createElement('script');7 document.body.appendChild(script);8});9await page.evaluate(() => {10 const script = document.createElement('script');11 document.body.appendChild(script);12});13await page.evaluate(() => {14 const script = document.createElement('script');15 document.body.appendChild(script);16});17await page.evaluate(() => {18 const script = document.createElement('script');19 document.body.appendChild(script);20});21await page.evaluate(() => {22 const script = document.createElement('script');23 document.body.appendChild(script);24});25await page.evaluate(() => {26 const script = document.createElement('script');27 document.body.appendChild(script);28});29await page.evaluate(() => {30 const script = document.createElement('script');31 document.body.appendChild(script);32});33await page.evaluate(() => {34 const script = document.createElement('script');35 document.body.appendChild(script);36});37await page.evaluate(() => {38 const script = document.createElement('script');39 document.body.appendChild(script);40});
Using AI Code Generation
1const { append } = require('playwright');2append('test.log', 'Hello World!');3const { append } = require('playwright');4append('test.log', 'Hello World!');5const { append } = require('playwright');6append('test.log', 'Hello World!');7const { append } = require('playwright');8append('test.log', 'Hello World!');9const { append } = require('playwright');10append('test.log', 'Hello World!');11const { append } = require('playwright');12append('test.log', 'Hello World!');13const { append } = require('playwright');14append('test.log', 'Hello World!');15const { append } = require('playwright');16append('test.log', 'Hello World!');17const { append } = require('playwright');18append('test.log', 'Hello World!');19const { append } = require('playwright');20append('test.log', 'Hello World!');21const { append } = require('playwright');22append('test.log', 'Hello World!');23const { append } = require('playwright');24append('test.log', 'Hello World!');25const { append } = require('playwright');26append('test.log', 'Hello World!');27const { append
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!