Best JavaScript code snippet using wpt
flexibility.js
Source:flexibility.js
1/**2 * Flexibility is a JavaScript polyfill for Flexbox By Jonathan Neal, 10up. (https://github.com/jonathantneal/flexibility)3 * Licensed under MIT ( https://github.com/jonathantneal/flexibility/blob/master/LICENSE.md )4 */5! function(e) {6 if ("object" == typeof exports && "undefined" != typeof module) module.exports = e();7 else if ("function" == typeof define && define.amd) define([], e);8 else {9 var t;10 t = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this, t.flexibility = e()11 }12}(function() {13 return function e(t, r, l) {14 function n(f, i) {15 if (!r[f]) {16 if (!t[f]) {17 var s = "function" == typeof require && require;18 if (!i && s) return s(f, !0);19 if (o) return o(f, !0);20 var a = new Error("Cannot find module '" + f + "'");21 throw a.code = "MODULE_NOT_FOUND", a22 }23 var c = r[f] = {24 exports: {}25 };26 t[f][0].call(c.exports, function(e) {27 var r = t[f][1][e];28 return n(r ? r : e)29 }, c, c.exports, e, t, r, l)30 }31 return r[f].exports32 }33 for (var o = "function" == typeof require && require, f = 0; f < l.length; f++) n(l[f]);34 return n35 }({36 1: [function(e, t, r) {37 t.exports = function(e) {38 var t, r, l, n = -1;39 if (e.lines.length > 1 && "flex-start" === e.style.alignContent)40 for (t = 0; l = e.lines[++n];) l.crossStart = t, t += l.cross;41 else if (e.lines.length > 1 && "flex-end" === e.style.alignContent)42 for (t = e.flexStyle.crossSpace; l = e.lines[++n];) l.crossStart = t, t += l.cross;43 else if (e.lines.length > 1 && "center" === e.style.alignContent)44 for (t = e.flexStyle.crossSpace / 2; l = e.lines[++n];) l.crossStart = t, t += l.cross;45 else if (e.lines.length > 1 && "space-between" === e.style.alignContent)46 for (r = e.flexStyle.crossSpace / (e.lines.length - 1), t = 0; l = e.lines[++n];) l.crossStart = t, t += l.cross + r;47 else if (e.lines.length > 1 && "space-around" === e.style.alignContent)48 for (r = 2 * e.flexStyle.crossSpace / (2 * e.lines.length), t = r / 2; l = e.lines[++n];) l.crossStart = t, t += l.cross + r;49 else50 for (r = e.flexStyle.crossSpace / e.lines.length, t = e.flexStyle.crossInnerBefore; l = e.lines[++n];) l.crossStart = t, l.cross += r, t += l.cross51 }52 }, {}],53 2: [function(e, t, r) {54 t.exports = function(e) {55 for (var t, r = -1; line = e.lines[++r];)56 for (t = -1; child = line.children[++t];) {57 var l = child.style.alignSelf;58 "auto" === l && (l = e.style.alignItems), "flex-start" === l ? child.flexStyle.crossStart = line.crossStart : "flex-end" === l ? child.flexStyle.crossStart = line.crossStart + line.cross - child.flexStyle.crossOuter : "center" === l ? child.flexStyle.crossStart = line.crossStart + (line.cross - child.flexStyle.crossOuter) / 2 : (child.flexStyle.crossStart = line.crossStart, child.flexStyle.crossOuter = line.cross, child.flexStyle.cross = child.flexStyle.crossOuter - child.flexStyle.crossBefore - child.flexStyle.crossAfter)59 }60 }61 }, {}],62 3: [function(e, t, r) {63 t.exports = function l(e, l) {64 var t = "row" === l || "row-reverse" === l,65 r = e.mainAxis;66 if (r) {67 var n = t && "inline" === r || !t && "block" === r;68 n || (e.flexStyle = {69 main: e.flexStyle.cross,70 cross: e.flexStyle.main,71 mainOffset: e.flexStyle.crossOffset,72 crossOffset: e.flexStyle.mainOffset,73 mainBefore: e.flexStyle.crossBefore,74 mainAfter: e.flexStyle.crossAfter,75 crossBefore: e.flexStyle.mainBefore,76 crossAfter: e.flexStyle.mainAfter,77 mainInnerBefore: e.flexStyle.crossInnerBefore,78 mainInnerAfter: e.flexStyle.crossInnerAfter,79 crossInnerBefore: e.flexStyle.mainInnerBefore,80 crossInnerAfter: e.flexStyle.mainInnerAfter,81 mainBorderBefore: e.flexStyle.crossBorderBefore,82 mainBorderAfter: e.flexStyle.crossBorderAfter,83 crossBorderBefore: e.flexStyle.mainBorderBefore,84 crossBorderAfter: e.flexStyle.mainBorderAfter85 })86 } else t ? e.flexStyle = {87 main: e.style.width,88 cross: e.style.height,89 mainOffset: e.style.offsetWidth,90 crossOffset: e.style.offsetHeight,91 mainBefore: e.style.marginLeft,92 mainAfter: e.style.marginRight,93 crossBefore: e.style.marginTop,94 crossAfter: e.style.marginBottom,95 mainInnerBefore: e.style.paddingLeft,96 mainInnerAfter: e.style.paddingRight,97 crossInnerBefore: e.style.paddingTop,98 crossInnerAfter: e.style.paddingBottom,99 mainBorderBefore: e.style.borderLeftWidth,100 mainBorderAfter: e.style.borderRightWidth,101 crossBorderBefore: e.style.borderTopWidth,102 crossBorderAfter: e.style.borderBottomWidth103 } : e.flexStyle = {104 main: e.style.height,105 cross: e.style.width,106 mainOffset: e.style.offsetHeight,107 crossOffset: e.style.offsetWidth,108 mainBefore: e.style.marginTop,109 mainAfter: e.style.marginBottom,110 crossBefore: e.style.marginLeft,111 crossAfter: e.style.marginRight,112 mainInnerBefore: e.style.paddingTop,113 mainInnerAfter: e.style.paddingBottom,114 crossInnerBefore: e.style.paddingLeft,115 crossInnerAfter: e.style.paddingRight,116 mainBorderBefore: e.style.borderTopWidth,117 mainBorderAfter: e.style.borderBottomWidth,118 crossBorderBefore: e.style.borderLeftWidth,119 crossBorderAfter: e.style.borderRightWidth120 }, "content-box" === e.style.boxSizing && ("number" == typeof e.flexStyle.main && (e.flexStyle.main += e.flexStyle.mainInnerBefore + e.flexStyle.mainInnerAfter + e.flexStyle.mainBorderBefore + e.flexStyle.mainBorderAfter), "number" == typeof e.flexStyle.cross && (e.flexStyle.cross += e.flexStyle.crossInnerBefore + e.flexStyle.crossInnerAfter + e.flexStyle.crossBorderBefore + e.flexStyle.crossBorderAfter));121 e.mainAxis = t ? "inline" : "block", e.crossAxis = t ? "block" : "inline", "number" == typeof e.style.flexBasis && (e.flexStyle.main = e.style.flexBasis + e.flexStyle.mainInnerBefore + e.flexStyle.mainInnerAfter + e.flexStyle.mainBorderBefore + e.flexStyle.mainBorderAfter), e.flexStyle.mainOuter = e.flexStyle.main, e.flexStyle.crossOuter = e.flexStyle.cross, "auto" === e.flexStyle.mainOuter && (e.flexStyle.mainOuter = e.flexStyle.mainOffset), "auto" === e.flexStyle.crossOuter && (e.flexStyle.crossOuter = e.flexStyle.crossOffset), "number" == typeof e.flexStyle.mainBefore && (e.flexStyle.mainOuter += e.flexStyle.mainBefore), "number" == typeof e.flexStyle.mainAfter && (e.flexStyle.mainOuter += e.flexStyle.mainAfter), "number" == typeof e.flexStyle.crossBefore && (e.flexStyle.crossOuter += e.flexStyle.crossBefore), "number" == typeof e.flexStyle.crossAfter && (e.flexStyle.crossOuter += e.flexStyle.crossAfter)122 }123 }, {}],124 4: [function(e, t, r) {125 var l = e("../reduce");126 t.exports = function(e) {127 if (e.mainSpace > 0) {128 var t = l(e.children, function(e, t) {129 return e + parseFloat(t.style.flexGrow)130 }, 0);131 t > 0 && (e.main = l(e.children, function(r, l) {132 return "auto" === l.flexStyle.main ? l.flexStyle.main = l.flexStyle.mainOffset + parseFloat(l.style.flexGrow) / t * e.mainSpace : l.flexStyle.main += parseFloat(l.style.flexGrow) / t * e.mainSpace, l.flexStyle.mainOuter = l.flexStyle.main + l.flexStyle.mainBefore + l.flexStyle.mainAfter, r + l.flexStyle.mainOuter133 }, 0), e.mainSpace = 0)134 }135 }136 }, {137 "../reduce": 12138 }],139 5: [function(e, t, r) {140 var l = e("../reduce");141 t.exports = function(e) {142 if (e.mainSpace < 0) {143 var t = l(e.children, function(e, t) {144 return e + parseFloat(t.style.flexShrink)145 }, 0);146 t > 0 && (e.main = l(e.children, function(r, l) {147 return l.flexStyle.main += parseFloat(l.style.flexShrink) / t * e.mainSpace, l.flexStyle.mainOuter = l.flexStyle.main + l.flexStyle.mainBefore + l.flexStyle.mainAfter, r + l.flexStyle.mainOuter148 }, 0), e.mainSpace = 0)149 }150 }151 }, {152 "../reduce": 12153 }],154 6: [function(e, t, r) {155 var l = e("../reduce");156 t.exports = function(e) {157 var t;158 e.lines = [t = {159 main: 0,160 cross: 0,161 children: []162 }];163 for (var r, n = -1; r = e.children[++n];) "nowrap" === e.style.flexWrap || 0 === t.children.length || "auto" === e.flexStyle.main || e.flexStyle.main - e.flexStyle.mainInnerBefore - e.flexStyle.mainInnerAfter - e.flexStyle.mainBorderBefore - e.flexStyle.mainBorderAfter >= t.main + r.flexStyle.mainOuter ? (t.main += r.flexStyle.mainOuter, t.cross = Math.max(t.cross, r.flexStyle.crossOuter)) : e.lines.push(t = {164 main: r.flexStyle.mainOuter,165 cross: r.flexStyle.crossOuter,166 children: []167 }), t.children.push(r);168 e.flexStyle.mainLines = l(e.lines, function(e, t) {169 return Math.max(e, t.main)170 }, 0), e.flexStyle.crossLines = l(e.lines, function(e, t) {171 return e + t.cross172 }, 0), "auto" === e.flexStyle.main && (e.flexStyle.main = Math.max(e.flexStyle.mainOffset, e.flexStyle.mainLines + e.flexStyle.mainInnerBefore + e.flexStyle.mainInnerAfter + e.flexStyle.mainBorderBefore + e.flexStyle.mainBorderAfter)), "auto" === e.flexStyle.cross && (e.flexStyle.cross = Math.max(e.flexStyle.crossOffset, e.flexStyle.crossLines + e.flexStyle.crossInnerBefore + e.flexStyle.crossInnerAfter + e.flexStyle.crossBorderBefore + e.flexStyle.crossBorderAfter)), e.flexStyle.crossSpace = e.flexStyle.cross - e.flexStyle.crossInnerBefore - e.flexStyle.crossInnerAfter - e.flexStyle.crossBorderBefore - e.flexStyle.crossBorderAfter - e.flexStyle.crossLines, e.flexStyle.mainOuter = e.flexStyle.main + e.flexStyle.mainBefore + e.flexStyle.mainAfter, e.flexStyle.crossOuter = e.flexStyle.cross + e.flexStyle.crossBefore + e.flexStyle.crossAfter173 }174 }, {175 "../reduce": 12176 }],177 7: [function(e, t, r) {178 function l(t) {179 for (var r, l = -1; r = t.children[++l];) e("./flex-direction")(r, t.style.flexDirection);180 e("./flex-direction")(t, t.style.flexDirection), e("./order")(t), e("./flexbox-lines")(t), e("./align-content")(t), l = -1;181 for (var n; n = t.lines[++l];) n.mainSpace = t.flexStyle.main - t.flexStyle.mainInnerBefore - t.flexStyle.mainInnerAfter - t.flexStyle.mainBorderBefore - t.flexStyle.mainBorderAfter - n.main, e("./flex-grow")(n), e("./flex-shrink")(n), e("./margin-main")(n), e("./margin-cross")(n), e("./justify-content")(n, t.style.justifyContent, t);182 e("./align-items")(t)183 }184 t.exports = l185 }, {186 "./align-content": 1,187 "./align-items": 2,188 "./flex-direction": 3,189 "./flex-grow": 4,190 "./flex-shrink": 5,191 "./flexbox-lines": 6,192 "./justify-content": 8,193 "./margin-cross": 9,194 "./margin-main": 10,195 "./order": 11196 }],197 8: [function(e, t, r) {198 t.exports = function(e, t, r) {199 var l, n, o, f = r.flexStyle.mainInnerBefore,200 i = -1;201 if ("flex-end" === t)202 for (l = e.mainSpace, l += f; o = e.children[++i];) o.flexStyle.mainStart = l, l += o.flexStyle.mainOuter;203 else if ("center" === t)204 for (l = e.mainSpace / 2, l += f; o = e.children[++i];) o.flexStyle.mainStart = l, l += o.flexStyle.mainOuter;205 else if ("space-between" === t)206 for (n = e.mainSpace / (e.children.length - 1), l = 0, l += f; o = e.children[++i];) o.flexStyle.mainStart = l, l += o.flexStyle.mainOuter + n;207 else if ("space-around" === t)208 for (n = 2 * e.mainSpace / (2 * e.children.length), l = n / 2, l += f; o = e.children[++i];) o.flexStyle.mainStart = l, l += o.flexStyle.mainOuter + n;209 else210 for (l = 0, l += f; o = e.children[++i];) o.flexStyle.mainStart = l, l += o.flexStyle.mainOuter211 }212 }, {}],213 9: [function(e, t, r) {214 t.exports = function(e) {215 for (var t, r = -1; t = e.children[++r];) {216 var l = 0;217 "auto" === t.flexStyle.crossBefore && ++l, "auto" === t.flexStyle.crossAfter && ++l;218 var n = e.cross - t.flexStyle.crossOuter;219 "auto" === t.flexStyle.crossBefore && (t.flexStyle.crossBefore = n / l), "auto" === t.flexStyle.crossAfter && (t.flexStyle.crossAfter = n / l), "auto" === t.flexStyle.cross ? t.flexStyle.crossOuter = t.flexStyle.crossOffset + t.flexStyle.crossBefore + t.flexStyle.crossAfter : t.flexStyle.crossOuter = t.flexStyle.cross + t.flexStyle.crossBefore + t.flexStyle.crossAfter220 }221 }222 }, {}],223 10: [function(e, t, r) {224 t.exports = function(e) {225 for (var t, r = 0, l = -1; t = e.children[++l];) "auto" === t.flexStyle.mainBefore && ++r, "auto" === t.flexStyle.mainAfter && ++r;226 if (r > 0) {227 for (l = -1; t = e.children[++l];) "auto" === t.flexStyle.mainBefore && (t.flexStyle.mainBefore = e.mainSpace / r), "auto" === t.flexStyle.mainAfter && (t.flexStyle.mainAfter = e.mainSpace / r), "auto" === t.flexStyle.main ? t.flexStyle.mainOuter = t.flexStyle.mainOffset + t.flexStyle.mainBefore + t.flexStyle.mainAfter : t.flexStyle.mainOuter = t.flexStyle.main + t.flexStyle.mainBefore + t.flexStyle.mainAfter;228 e.mainSpace = 0229 }230 }231 }, {}],232 11: [function(e, t, r) {233 var l = /^(column|row)-reverse$/;234 t.exports = function(e) {235 e.children.sort(function(e, t) {236 return e.style.order - t.style.order || e.index - t.index237 }), l.test(e.style.flexDirection) && e.children.reverse()238 }239 }, {}],240 12: [function(e, t, r) {241 function l(e, t, r) {242 for (var l = e.length, n = -1; ++n < l;) n in e && (r = t(r, e[n], n));243 return r244 }245 t.exports = l246 }, {}],247 13: [function(e, t, r) {248 function l(e) {249 i(f(e))250 }251 var n = e("./read"),252 o = e("./write"),253 f = e("./readAll"),254 i = e("./writeAll");255 t.exports = l, t.exports.read = n, t.exports.write = o, t.exports.readAll = f, t.exports.writeAll = i256 }, {257 "./read": 15,258 "./readAll": 16,259 "./write": 17,260 "./writeAll": 18261 }],262 14: [function(e, t, r) {263 function l(e, t, r) {264 var l = e[t],265 f = String(l).match(o);266 if (!f) {267 var a = t.match(s);268 if (a) {269 var c = e["border" + a[1] + "Style"];270 return "none" === c ? 0 : i[l] || 0271 }272 return l273 }274 var y = f[1],275 x = f[2];276 return "px" === x ? 1 * y : "cm" === x ? .3937 * y * 96 : "in" === x ? 96 * y : "mm" === x ? .3937 * y * 96 / 10 : "pc" === x ? 12 * y * 96 / 72 : "pt" === x ? 96 * y / 72 : "rem" === x ? 16 * y : n(l, r)277 }278279 function n(e, t) {280 f.style.cssText = "border:none!important;clip:rect(0 0 0 0)!important;display:block!important;font-size:1em!important;height:0!important;margin:0!important;padding:0!important;position:relative!important;width:" + e + "!important", t.parentNode.insertBefore(f, t.nextSibling);281 var r = f.offsetWidth;282 return t.parentNode.removeChild(f), r283 }284 t.exports = l;285 var o = /^([-+]?\d*\.?\d+)(%|[a-z]+)$/,286 f = document.createElement("div"),287 i = {288 medium: 4,289 none: 0,290 thick: 6,291 thin: 2292 },293 s = /^border(Bottom|Left|Right|Top)Width$/294 }, {}],295 15: [function(e, t, r) {296 function l(e) {297 var t = {298 alignContent: "stretch",299 alignItems: "stretch",300 alignSelf: "auto",301 borderBottomStyle: "none",302 borderBottomWidth: 0,303 borderLeftStyle: "none",304 borderLeftWidth: 0,305 borderRightStyle: "none",306 borderRightWidth: 0,307 borderTopStyle: "none",308 borderTopWidth: 0,309 boxSizing: "content-box",310 display: "inline",311 flexBasis: "auto",312 flexDirection: "row",313 flexGrow: 0,314 flexShrink: 1,315 flexWrap: "nowrap",316 justifyContent: "flex-start",317 height: "auto",318 marginTop: 0,319 marginRight: 0,320 marginLeft: 0,321 marginBottom: 0,322 paddingTop: 0,323 paddingRight: 0,324 paddingLeft: 0,325 paddingBottom: 0,326 maxHeight: "none",327 maxWidth: "none",328 minHeight: 0,329 minWidth: 0,330 order: 0,331 position: "static",332 width: "auto"333 },334 r = e instanceof Element;335 if (r) {336 var l = e.hasAttribute("data-style"),337 i = l ? e.getAttribute("data-style") : e.getAttribute("style") || "";338 l || e.setAttribute("data-style", i);339 var s = window.getComputedStyle && getComputedStyle(e) || {};340 f(t, s);341 var c = e.currentStyle || {};342 n(t, c), o(t, i);343 for (var y in t) t[y] = a(t, y, e);344 var x = e.getBoundingClientRect();345 t.offsetHeight = x.height || e.offsetHeight, t.offsetWidth = x.width || e.offsetWidth346 }347 var S = {348 element: e,349 style: t350 };351 return S352 }353354 function n(e, t) {355 for (var r in e) {356 var l = r in t;357 if (l) e[r] = t[r];358 else {359 // Replace uppercase characters with lowercase.360 var n = r.replace(/[A-Z]/g, "-$&").toLowerCase(),361 o = n in t;362 o && (e[r] = t[n])363 }364 }365 var f = "-js-display" in t;366 f && (e.display = t["-js-display"])367 }368369 function o(e, t) {370 for (var r; r = i.exec(t);) {371 // Replace lowercase characters with uppercase.372 var l = r[1].toLowerCase().replace(/-[a-z]/g, function(e) {373 return e.slice(1).toUpperCase()374 });375 e[l] = r[2]376 }377 }378379 function f(e, t) {380 for (var r in e) {381 var l = r in t;382 l && !s.test(r) && (e[r] = t[r])383 }384 }385 t.exports = l;386 var i = /([^\s:;]+)\s*:\s*([^;]+?)\s*(;|$)/g,387 s = /^(alignSelf|height|width)$/,388 a = e("./getComputedLength")389 }, {390 "./getComputedLength": 14391 }],392 16: [function(e, t, r) {393 function l(e) {394 var t = [];395 return n(e, t), t396 }397398 function n(e, t) {399 for (var r, l = o(e), i = [], s = -1; r = e.childNodes[++s];) {400 var a = 3 === r.nodeType && !/^\s*$/.test(r.nodeValue);401 if (l && a) {402 var c = r;403 r = e.insertBefore(document.createElement("flex-item"), c), r.appendChild(c)404 }405 var y = r instanceof Element;406 if (y) {407 var x = n(r, t);408 if (l) {409 var S = r.style;410 S.display = "inline-block", S.position = "absolute", x.style = f(r).style, i.push(x)411 }412 }413 }414 var m = {415 element: e,416 children: i417 };418 return l && (m.style = f(e).style, t.push(m)), m419 }420421 function o(e) {422 var t = e instanceof Element,423 r = t && e.getAttribute("data-style"),424 l = t && e.currentStyle && e.currentStyle["-js-display"],425 n = i.test(r) || s.test(l);426 return n427 }428 t.exports = l;429 var f = e("../read"),430 i = /(^|;)\s*display\s*:\s*(inline-)?flex\s*(;|$)/i,431 s = /^(inline-)?flex$/i432 }, {433 "../read": 15434 }],435 17: [function(e, t, r) {436 function l(e) {437 o(e);438 var t = e.element.style,439 r = "inline" === e.mainAxis ? ["main", "cross"] : ["cross", "main"];440 t.boxSizing = "content-box", t.display = "block", t.position = "relative", t.width = n(e.flexStyle[r[0]] - e.flexStyle[r[0] + "InnerBefore"] - e.flexStyle[r[0] + "InnerAfter"] - e.flexStyle[r[0] + "BorderBefore"] - e.flexStyle[r[0] + "BorderAfter"]), t.height = n(e.flexStyle[r[1]] - e.flexStyle[r[1] + "InnerBefore"] - e.flexStyle[r[1] + "InnerAfter"] - e.flexStyle[r[1] + "BorderBefore"] - e.flexStyle[r[1] + "BorderAfter"]);441 for (var l, f = -1; l = e.children[++f];) {442 var i = l.element.style,443 s = "inline" === l.mainAxis ? ["main", "cross"] : ["cross", "main"];444 i.boxSizing = "content-box", i.display = "block", i.position = "absolute", "auto" !== l.flexStyle[s[0]] && (i.width = n(l.flexStyle[s[0]] - l.flexStyle[s[0] + "InnerBefore"] - l.flexStyle[s[0] + "InnerAfter"] - l.flexStyle[s[0] + "BorderBefore"] - l.flexStyle[s[0] + "BorderAfter"])), "auto" !== l.flexStyle[s[1]] && (i.height = n(l.flexStyle[s[1]] - l.flexStyle[s[1] + "InnerBefore"] - l.flexStyle[s[1] + "InnerAfter"] - l.flexStyle[s[1] + "BorderBefore"] - l.flexStyle[s[1] + "BorderAfter"])), i.top = n(l.flexStyle[s[1] + "Start"]), i.left = n(l.flexStyle[s[0] + "Start"]), i.marginTop = n(l.flexStyle[s[1] + "Before"]), i.marginRight = n(l.flexStyle[s[0] + "After"]), i.marginBottom = n(l.flexStyle[s[1] + "After"]), i.marginLeft = n(l.flexStyle[s[0] + "Before"])445 }446 }447448 function n(e) {449 return "string" == typeof e ? e : Math.max(e, 0) + "px"450 }451 t.exports = l;452 var o = e("../flexbox")453 }, {454 "../flexbox": 7455 }],456 18: [function(e, t, r) {457 function l(e) {458 for (var t, r = -1; t = e[++r];) n(t)459 }460 t.exports = l;461 var n = e("../write")462 }, {463 "../write": 17464 }]465 }, {}, [13])(13)
...
script.js
Source:script.js
1var x = window.innerWidth / 2;2var y = window.innerHeight / 2;3var cross_size = 0.1*y;4var cross_weight = 2;5var cross_1_left = x + 0.1*x;6var cross_1_bottom = y + 0.1*y;7var cross_2_right = x + 0.1*x;8var cross_2_top = y + 0.1*y;9function set_cross_size(cross_size){10 document.getElementById("cross-1").style.width = cross_size + "px";11 document.getElementById("cross-1").style.height = cross_size + "px";12 document.getElementById("cross-2").style.width = cross_size + "px";13 document.getElementById("cross-2").style.height = cross_size + "px";14}15function set_cross_weight(cross_weight){16 document.getElementById("cross-1").style.borderWidth = cross_weight + "px";17 document.getElementById("cross-1").style.borderWidth = cross_weight + "px";18 document.getElementById("cross-2").style.borderWidth = cross_weight + "px";19 document.getElementById("cross-2").style.borderWidth = cross_weight + "px";20}21function set_init_position(){22 cross_1_left = x + 0.1*x;23 cross_1_bottom = y + 0.1*y;24 cross_2_right = x + 0.1*x;25 cross_2_top = y + 0.1*y;26 document.getElementById("cross-1").style.left = cross_1_left +"px";27 document.getElementById("cross-1").style.bottom = cross_1_bottom +"px";28 document.getElementById("cross-2").style.right = cross_2_right +"px";29 document.getElementById("cross-2").style.top = cross_2_top +"px";30 document.getElementById("center-dot").style.left = x + "px";31 document.getElementById("center-dot").style.bottom = y + "px";32 document.getElementById("cross-1-pos").innerText= "@cross-1 x:" + (cross_1_left - x) + "; y:" +(cross_1_bottom-y)+";";33 document.getElementById("cross-2-pos").innerText= "@cross-2 x: -" + (cross_2_right - x) + "; y: -" +(cross_2_top- y)+";";34}35function set_position(){36 document.getElementById("cross-1").style.left = cross_1_left +"px";37 document.getElementById("cross-1").style.bottom = cross_1_bottom +"px";38 document.getElementById("cross-2").style.right = cross_2_right +"px";39 document.getElementById("cross-2").style.top = cross_2_top +"px";40 document.getElementById("cross-1-pos").innerText= "@cross-1 x:" + (cross_1_left - x) + "; y:" +(cross_1_bottom-y)+";";41 document.getElementById("cross-2-pos").innerText= "@cross-2 x: -" + (cross_2_right - x) + "; y: -" +(cross_2_top- y)+";";42}43$(document).ready(function (){44 set_init_position();45 set_cross_size(cross_size);46 // set_cross_weight(cross_weight);47 document.getElementById("btn-left-1").onclick=(function(){48 cross_1_left = cross_1_left - 0.001 * x;49 // document.getElementById("cross-1").style.left = cross_1_left +"px";50 set_position();51 });52 document.getElementById("btn-right-1").onclick=(function(){53 cross_1_left= cross_1_left + 0.001 * x;54 //document.getElementById("cross-1").style.left = cross_1_left +"px";55 set_position();56 });57 document.getElementById("btn-up-1").onclick=(function(){58 cross_1_bottom = cross_1_bottom + 0.001 * y;59 //document.getElementById("cross-1").style.bottom = cross_1_bottom +"px";60 set_position();61 });62 document.getElementById("btn-down-1").onclick=(function(){63 cross_1_bottom = cross_1_bottom - 0.001 * y;64 //document.getElementById("cross-1").style.bottom = cross_1_bottom +"px";65 set_position();66 });67 document.getElementById("btn-left-2").onclick=(function(){68 cross_2_right = cross_2_right + 0.001 * x;69 //document.getElementById("cross-2").style.right = cross_2_right +"px";70 set_position();71 });72 document.getElementById("btn-right-2").onclick=(function(){73 cross_2_right = cross_2_right - 0.001 * x;74 // document.getElementById("cross-2").style.right = cross_2_right +"px";75 set_position();76 });77 document.getElementById("btn-up-2").onclick=(function(){78 cross_2_top = cross_2_top - 0.001 * y;79 // document.getElementById("cross-2").style.top = cross_2_top +"px";80 set_position();81 });82 document.getElementById("btn-down-2").onclick=(function(){83 cross_2_top = cross_2_top + 0.001 * y;84 //document.getElementById("cross-2").style.top = cross_2_top +"px";85 set_position();86 });87 document.getElementById("btn-size-larger").onclick=(function(){88 cross_size = cross_size + 0.01*y;89 cross_weight = 0.006 * cross_size;90 set_cross_size(cross_size);91 set_init_position();92 //set_cross_weight(cross_weight);93 });94 document.getElementById("btn-size-smaller").onclick=(function(){95 cross_size = cross_size - 0.01*y;96 cross_weight = 0.01 * cross_size;97 set_cross_size(cross_size);98 set_init_position();99 // set_cross_weight(cross_weight);100 });101 document.getElementById("btn-outer").onclick=(function(){102 cross_1_left= cross_1_left + 0.01 * x;103 cross_1_bottom = cross_1_bottom + 0.01 * y;104 cross_2_right = cross_2_right + 0.01 * x;105 cross_2_top = cross_2_top + 0.01 * y;106 set_position();107 // set_cross_weight(cross_weight);108 });109 document.getElementById("btn-inner").onclick=(function(){110 cross_1_left= cross_1_left - 0.01 * x;111 cross_1_bottom = cross_1_bottom - 0.01 * y;112 cross_2_right = cross_2_right - 0.01 * x;113 cross_2_top = cross_2_top - 0.01 * y;114 set_position();115 // set_cross_weight(cross_weight);116 });117 document.getElementById("show-pos").onclick=(function(){118 if(document.getElementById("position-value").style.display == "none")document.getElementById("position-value").style.display= "block";119 else document.getElementById("position-value").style.display = "none";120 document.getElementById("cross-1-pos").innerText= "@cross-1 x:" + (cross_1_left - x) + "; y:" +(cross_1_bottom-y)+";";121 document.getElementById("cross-2-pos").innerText= "@cross-2 x: -" + (cross_2_right - x) + "; y: -" +(cross_2_top- y)+";";122 });...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 console.log('Test status:', data.statusText);5 console.log('View your test results at', data.data.userUrl);6});7var wpt = require('webpagetest');8var wpt = new WebPageTest('www.webpagetest.org');9 if (err) return console.error(err);10 console.log('Test status:', data.statusText);11 console.log('View your test results at', data.data.userUrl);12});13var wpt = require('webpagetest');14var wpt = new WebPageTest('www.webpagetest.org');15 if (err) return console.error(err);16 console.log('Test status:', data.statusText);17 console.log('View your test results at', data.data.userUrl);18});19var wpt = require('webpagetest');20var wpt = new WebPageTest('www.webpagetest.org');21 if (err) return console.error(err);22 console.log('Test status:', data.statusText);23 console.log('View your test results at', data.data.userUrl);24});25var wpt = require('webpagetest');26var wpt = new WebPageTest('www.webpagetest.org');27 if (err) return console.error(err);28 console.log('Test status:', data.statusText);29 console.log('View your test results at',
Using AI Code Generation
1var wpt = require('webpagetest');2var api = new wpt('www.webpagetest.org', 'A.12345678901234567890123456789012');3}, function(err, data) {4 if (err) {5 console.error(err);6 } else {7 console.log('Test Results: ' + data.data.summary);8 }9});10var wpt = require('webpagetest');11var api = new wpt('www.webpagetest.org', 'A.12345678901234567890123456789012');12}, function(err, data) {13 if (err) {14 console.error(err);15 } else {16 console.log('Test Results: ' + data.data.summary);17 }18});19var wpt = require('webpagetest');20var api = new wpt('www.webpagetest.org', 'A.12345678901234567890123456789012');21}, function(err, data) {22 if (err) {23 console.error(err);24 } else {25 console.log('Test Results: ' + data.data.summary);26 }27});28var wpt = require('webpagetest');29var api = new wpt('www.webpagetest.org', 'A.12345678901234567890123456789012');30}, function(err, data) {31 if (err) {
Using AI Code Generation
1var wpt = require('webpagetest');2var test = new wpt('your api key');3 if (err) return console.error(err);4 console.log(data);5});6test.getTestResults(data.data.testId, function(err, data) {7 if (err) return console.error(err);8 console.log(data);9});10test.getTestStatus(data.data.testId, function(err, data) {11 if (err) return console.error(err);12 console.log(data);13});14test.getLocations(function(err, data) {15 if (err) return console.error(err);16 console.log(data);17});18test.getTesters(function(err, data) {19 if (err) return console.error(err);20 console.log(data);21});22test.getTesters('ec2-us-west-1', function(err, data) {23 if (err) return console.error(err);24 console.log(data);25});26test.getTesters('ec2-us-west-1', 'Windows', function(err, data) {27 if (err) return console.error(err);28 console.log(data);29});30test.getTesters('ec2-us-west-1', 'Windows', 'Chrome', function(err, data) {31 if (err) return console.error(err);32 console.log(data);33});34test.getTesters('ec2-us-west-1', 'Windows', 'Chrome', 'Latest', function(err, data) {35 if (err) return console.error(err);36 console.log(data);37});38test.getTesters('ec2-us-west-1', 'Windows', 'Chrome', 'Latest', '3G', function(err, data) {39 if (err) return console.error(err);40 console.log(data);41});42test.getTesters('ec2-us-west-1', 'Windows', 'Chrome', 'Latest', '3G', 'Cable', function(err
Using AI Code Generation
1var wpt = require('wpt');2 console.log(data);3});4var wpt = require('wpt');5 console.log(data);6});7var wpt = require('wpt');8 console.log(data);9});10var wpt = require('wpt');11 console.log(data);12});13var wpt = require('wpt');14 console.log(data);15});16var wpt = require('wpt');17 console.log(data);18});19var wpt = require('wpt');20 console.log(data);21});22var wpt = require('wpt');23 console.log(data);24});25var wpt = require('wpt');26 console.log(data);27});
Using AI Code Generation
1var wptoolkit = require('wptoolkit');2var wpt = new wptoolkit({3});4wpt.cross({5}, function(err, data) {6 console.log(data);7});8var wptoolkit = require('wptoolkit');9var wpt = new wptoolkit({10});11wpt.cross({12}, function(err, data) {13 console.log(data);14});15var wptoolkit = require('wptoolkit');16var wpt = new wptoolkit({17});18wpt.cross({19}, function(err, data) {20 console.log(data);21});22var wptoolkit = require('wptoolkit');23var wpt = new wptoolkit({
Using AI Code Generation
1var wptools = require( 'wptools' );2wptools.cross( 'Albert Einstein' )3 .then( function( data ) {4 console.log( data );5 } );6var wptools = require( 'wptools' );7wptools.cross( 'Albert Einstein' )8 .then( function( data ) {9 console.log( data );10 } );11var wptools = require( 'wptools' );12wptools.cross( 'Albert Einstein' )13 .then( function( data ) {14 console.log( data );15 } );16var wptools = require( 'wptools' );17wptools.cross( 'Albert Einstein' )18 .then( function( data ) {19 console.log( data );20 } );21var wptools = require( 'wptools' );22wptools.cross( 'Albert Einstein' )23 .then( function( data ) {24 console.log( data );25 } );26var wptools = require( 'wptools' );27wptools.cross( 'Albert Einstein' )28 .then( function( data ) {29 console.log( data );30 } );31var wptools = require( 'wptools' );32wptools.cross( 'Albert Einstein' )33 .then( function( data ) {34 console.log( data );35 } );36var wptools = require( 'wptools' );37wptools.cross( 'Albert Einstein' )38 .then( function( data ) {39 console.log( data );40 } );41var wptools = require( 'wptools' );42wptools.cross( 'Albert Einstein' )43 .then( function( data ) {44 console.log( data );45 } );
Using AI Code Generation
1var wptools = require('wptools');2var wiki = wptools.page('San Francisco');3wiki.get(function(err, data) {4 console.log(data);5});6var wptools = require('wptools');7var wiki = wptools.page('San Francisco');8wiki.get(function(err, data) {9 console.log(data);10});
Using AI Code Generation
1var wptoolkit = require('wptoolkit');2var cross = wptoolkit.cross;3var result = cross(1,2);4console.log(result);5var wptoolkit = require('wptoolkit');6var cross = wptoolkit.cross;7var result = cross(1,2);8console.log(result);9var wptoolkit = require('wptoolkit');10var cross = wptoolkit.cross;11var result = cross(1,2);12console.log(result);13var wptoolkit = require('wptoolkit');14var cross = wptoolkit.cross;15var result = cross(1,2);16console.log(result);17var wptoolkit = require('wptoolkit');18var cross = wptoolkit.cross;19var result = cross(1,2);20console.log(result);21var wptoolkit = require('wptoolkit');22var cross = wptoolkit.cross;23var result = cross(1,2);24console.log(result);25var wptoolkit = require('wptoolkit');26var cross = wptoolkit.cross;27var result = cross(1,2);28console.log(result);29var wptoolkit = require('wptoolkit');30var cross = wptoolkit.cross;31var result = cross(1,2);32console.log(result);33var wptoolkit = require('wptoolkit');34var cross = wptoolkit.cross;35var result = cross(1,2);36console.log(result);37var wptoolkit = require('wptoolkit');38var cross = wptoolkit.cross;39var result = cross(1
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!