How to use updateElement method in Playwright Internal

Best JavaScript code snippet using playwright-internal

outputfactory.js

Source:outputfactory.js Github

copy

Full Screen

...36 // Initialize node.37 ov.outputNode.call(this, properties);38 39 this.$contents = this.$element.find('.contents');40 this.updateElement();41};42widgets.view.prototype = $.extend(new ov.outputNode(), {43});44/**45 * Widget: Text output46 */47widgets.text = function (properties) {48 49 // Initialize node.50 ov.outputNode.call(this, properties);51 52 this.$contents = this.$element.find('.contents');53 this.updateElement();54};55widgets.text.prototype = $.extend(new ov.outputNode(), {56 57 // Return active markup for this widget.58 $markup: function () {59 var $outputNode = $('<div class="termkitOutputNode widgetText"><div class="contents"></div></div>').data('controller', this);60 var that = this;61 return $outputNode;62 },63 // Update markup to match.64 updateElement: function () {65 this.$contents.text(this.properties.contents);66 this.$element.data('controller', this);67 68// this.notify('view.callback', { raw: 'foo' });69 },70 71});72/**73 * Widget: HTML output74 */75widgets.html = function (properties) {76 77 // Initialize node.78 ov.outputNode.call(this, properties);79 80 this.$contents = this.$element.find('.contents');81 this.updateElement();82};83widgets.html.prototype = $.extend(new ov.outputNode(), {84 85 // Return active markup for this widget.86 $markup: function () {87 var $outputNode = $('<div class="termkitOutputNode widgetHTML"><div class="contents"></div></div>').data('controller', this);88 var that = this;89 return $outputNode;90 },91 // Update markup to match.92 updateElement: function () {93 this.$contents.html(this.properties.contents);94 this.$element.data('controller', this);95 },96 97});98/**99 * Widget: File icon.100 *101 * Icon loading is collectively throttled.102 */103widgets.icon = function (properties) {104 105 // Initialize node.106 ov.outputNode.call(this, properties);107 108 this.updateElement();109 110 this.queue();111};112// Process icon updates.113widgets.icon.queue = [];114widgets.icon.limit = 4;115widgets.icon.process = function () {116 if (widgets.icon.queue.length && widgets.icon.limit > 0) {117 widgets.icon.limit--;118 119 var icon = widgets.icon.queue.shift();120 icon.process();121 }122};123widgets.icon.prototype = $.extend(new ov.outputNode(), {124 125 // Return active markup for this widget.126 $markup: function () {127 var $outputNode = $('<div class="termkitOutputNode widgetIcon"></div>').data('controller', this);128 return $outputNode;129 },130 setDefaultIcon: function (callback) {131 // Set default icon.132 var image = new Image(),133 extension = (this.properties.stats.mode & 0x4000) ? '...' : this.properties.name.split('.').pop(),134 defaultUrl = 'termkit-icon-default:///' + encodeURIComponent(extension);135 image.onload = function () {136 callback && callback();137 };138 image.src = defaultUrl;139 if (!this.noDefault) {140 this.$element.css({141 background: 'url('+ defaultUrl +')',142 backgroundSize: '32px 32px',143 });144 }145 },146 147 setOwnIcon: function (callback) {148 var that = this;149 // Set file-specific icon.150 var image = new Image(),151 path = this.properties.path + '/' + this.properties.name,152 previewUrl = 'termkit-icon-preview:///' + encodeURIComponent(path);153 image.onload = function () {154 this.noDefault = true;155 that.$element.css({156 background: 'url('+ previewUrl +')'157 });158 callback && callback();159 };160 image.src = previewUrl;161 },162 163 // Queue icon updates to avoid choking webkit.164 queue: function () {165 widgets.icon.queue.push(this);166 widgets.icon.process();167 },168 169 // Process the icon update.170 process: function () {171 function yield() {172 widgets.icon.limit++;173 widgets.icon.process();174 }175 176 this.setOwnIcon(yield); 177 },178 179 // Update markup to match.180 updateElement: function () {181 var that = this;182 this.setDefaultIcon();183 this.$element.data('controller', this);184 },185 186});187/**188 * Widget: File reference189 */190widgets.file = function (properties) {191 192 // Initialize node.193 ov.outputNode.call(this, properties);194 195 this.$icon = this.$element.find('.icon');196 this.$name = this.$element.find('.name');197 this.$meta = this.$element.find('.meta');198 this.icon = new widgets.icon(this.properties);199 this.$icon.append(this.icon.$element);200 this.icon.updateElement();201 this.updateElement();202};203widgets.file.prototype = $.extend(new ov.outputNode(), {204 205 // Return active markup for this widget.206 $markup: function () {207 var $outputNode = $('<div class="termkitOutputNode widgetFile" draggable="true"><div class="icon"></div><div class="name"></div><div class="meta"></div></div>').data('controller', this);208 var that = this;209 return $outputNode;210 },211 212 // Update markup to match.213 updateElement: function () {214 var that = this;215 this.$element.data('controller', this);216 // Set text labels.217 this.$name.text(this.properties.name);218 this.$meta.text(formatSize(this.properties.stats.size));219 220 if (this.properties.name[0] == '.') {221 this.$element.addClass('file-hidden');222 }223 },224 225});226/**227 * Widget: Image228 */229widgets.image = function (properties) {230 231 // Initialize node.232 ov.outputNode.call(this, properties);233 234 this.$img = this.$element.find('img');235 236 this.updateElement();237};238widgets.image.prototype = $.extend(new ov.outputNode(), {239 240 // Return active markup for this widget.241 $markup: function () {242 var $outputNode = $('<div class="termkitOutputNode widgetImage termkitLimitHeight" draggable="true"><img></div>').data('controller', this);243 var that = this;244 return $outputNode;245 },246 247 // Update markup to match.248 updateElement: function () {249 var that = this;250 this.$element.data('controller', this);251 if (this.properties.url) {252 this.$img[0].src = this.properties.url;253 }254 },255 256});257/**258 * Container: list259 */260widgets.list = function (properties) {261 262 // Initialize node.263 ov.outputNode.call(this, properties);264 this.updateElement();265};266widgets.list.prototype = $.extend(new ov.outputNode(), {267 268 // Return active markup for this widget.269 $markup: function () {270 var $outputNode = $('<div class="termkitOutputNode widgetList termkitLimitHeight"><div class="children"></div></div>').data('controller', this);271 var that = this;272 return $outputNode;273 },274 // Update markup to match.275 updateElement: function () {276 this.$element.data('controller', this);277 },278 279});280/**281 * Widget: Code output282 */283widgets.code = function (properties) {284 285 // Initialize node.286 ov.outputNode.call(this, properties);287 288 this.$contents = this.$element.find('.contents');289 this.$pre = this.$contents.find('pre');290 291 var brushes = {292 'text/x-applescript': 'applescript',293 'text/x-actionscript': 'as3',294 'text/x-shellscript': 'text',295 'text/x-c': 'c',296 'text/x-c++': 'cpp',297 'text/x-csharpsrc': 'c#',298 'text/css': 'css',299 'text/x-diff': 'diff',300 'text/x-erlang': 'erl',301 'text/x-groovy': 'groovy',302 'text/x-java-source': 'java',303 'application/javascript': 'js',304 'application/json': 'js',305 'text/javascript': 'js',306 'application/x-perl': 'pl',307 'application/x-php': 'php',308 'text/x-python': 'py',309 'text/x-ruby': 'rb',310 'text/x-sass': 'sass',311 'text/x-scala': 'scala',312 'text/x-sql': 'sql',313 'text/xml': 'xml',314 'text/html': 'text',315 };316 this.brush = brushes[properties.language];317 318 this.updateElement();319};320widgets.code.prototype = $.extend(new widgets.text(), {321 322 // Return active markup for this widget.323 $markup: function () {324 var $outputNode = $('<div class="termkitOutputNode widgetText widgetCode"><div class="contents"><pre></pre></div></div>').data('controller', this);325 var that = this;326 return $outputNode;327 },328 // Update markup to match.329 updateElement: function () {330 this.$contents.html('<pre></pre>');331 this.$pre = this.$contents.find('pre');332 this.$pre.text(this.properties.contents);333 if (this.brush) {334 this.$pre.attr('class', 'brush: ' + this.brush);335 SyntaxHighlighter.highlight({}, this.$pre[0]);336 }337 this.$element.data('controller', this);338 },339 340});341/**342 * Widget: Hex output343 */344widgets.hex = function (properties) {345 346 // Initialize node.347 ov.outputNode.call(this, properties);348 349 this.$contents = this.$element.find('.contents');350 this.$measure = this.$element.find('.measure');351 this.$table = this.$element.find('table');352 353 this.updateElement();354 355 // Reflow on resize, throttled @ 300ms.356 var that = this, timer = 0;357 $(window).resize(function () {358 if (!timer) {359 timer = setTimeout(function () {360 timer = null;361 that.updateElement();362 }, 300);363 }364 });365 366 this.lastLength = 0;367 this.lastWidth = 0;368};369widgets.hex.prototype = $.extend(new widgets.text(), {370 371 // Return active markup for this widget.372 $markup: function () {373 var $outputNode = $('<div class="termkitOutputNode widgetHex"><span class="measure"></span><table class="termkitHexTable"></table></div>').data('controller', this);374 var that = this;375 return $outputNode;376 },377 // Update markup to match.378 updateElement: function () {379 380 // Measure character and window.381 this.$measure.text('X');382 var charWidth = this.$measure.width(),383 width = this.$element.width(),384 columns = Math.floor(width / charWidth);385 // Determine size of offsets.386 var length = this.properties.contents.length,387 offsetLength = Math.ceil(length.toString(16).length / 2) * 2,388 bytesLength = 0;389 390 // Determine layout.391 var offsetWidth = offsetLength + 19,392 bytesColumn,393 tryBytes = 0;394 while (offsetWidth + tryBytes < columns) {395 bytesColumn = tryBytes;396 bytesLength += 4;397 tryBytes = 3 + (bytesLength * 2) + (bytesLength - 1) + Math.floor(bytesLength / 4) + 3 + bytesLength;398 }399 if (this.lastLength == length && this.lastWidth == bytesLength) {400 return;401 }402 this.lastLength = length;403 this.lastWidth = bytesLength;404 // Prepare table.405 this.$table.empty();406 // Format a number to hex and pad with zeroes.407 function format(x, l) {408 x = x.toString(16);409 while (x.length < l) {410 x = 0 + x;411 }412 return x;413 }414 415 // Insert data in runs of bytesLength.416 var data = this.properties.contents;417 var length = data.length, n = Math.ceil(length / bytesLength), o = 0;418 419 for (var i = 0; i < n; ++i) {420 421 // Prepare cells.422 var offset = format(o, offsetLength), bytes = '', view = '';423 424 // Format bytes as hex / display.425 for (var j = 0; j < bytesLength; ++j) {426 if (o + j >= length) break;427 var c = data.charCodeAt(o + j),428 b = format(c, 2);429 if ((j % 4) == 0) {430 bytes += '<td class="bytes ' + ((j % 8 >= 4) ? 'even' : 'odd') + '">';431 view += '<td class="view ' + ((j % 8 >= 4) ? 'even' : 'odd') + '">';432 } 433 bytes += b + ' ';434 view += (c >= 32 && c <= 128) ? data.charAt(o + j) : '.';435 if ((j % 4) == 3) {436 bytes = bytes.substring(0, bytes.length - 1) + '</td>';437 view += '</td>';438 }439 }440 if ((j % 4) != 3) {441 bytes = bytes.substring(0, bytes.length - 1) + '</td>';442 view += '</td>';443 j += (4 - (j % 4));444 while (j <= bytesLength) {445 j += 4;446 bytes += '<td class="bytes '+ ((j % 8 >= 4) ? 'even' : 'odd') + '"></td>';447 view += '<td class="view '+ ((j % 8 >= 4) ? 'even' : 'odd') + '"></td>';448 }449 }450 o += bytesLength;451 452 var $row = $('<tr><th>'+ offset + '</th>'+ bytes + '<td class="spacer"></td>' + view + '</td></tr>');453 this.$table.append($row);454 }455 456 this.$element.data('controller', this);457 },458 459});460/**461 * Widget: Progress bar462 */463widgets.progress = function (properties) {464 465 // Initialize node.466 ov.outputNode.call(this, properties);467 this.bar = new termkit.progress();468 this.$element.append(this.bar.$element);469 this.updateElement();470};471widgets.progress.prototype = $.extend(new ov.outputNode(), {472 473 // Return active markup for this widget.474 $markup: function () {475 var $outputNode = $('<div class="termkitOutputNode widgetProgress"></div>').data('controller', this);476 return $outputNode;477 },478 479 // Update markup to match.480 updateElement: function () {481 this.bar.min = this.properties.min || 0;482 this.bar.max = this.properties.max || 100;483 this.bar.value = this.properties.value || 0;484 this.bar.updateElement();485 },486 487});488/**489 * Widget: Spinner490 */491widgets.spinner = function (properties) {492 493 // Initialize node.494 ov.outputNode.call(this, properties);495 this.spinner = new termkit.spinner();496 this.$element.append(this.spinner.$element);497 this.updateElement();498};499widgets.spinner.prototype = $.extend(new ov.outputNode(), {500 501 // Return active markup for this widget.502 $markup: function () {503 var $outputNode = $('<div class="termkitOutputNode widgetSpinner"></div>').data('controller', this);504 return $outputNode;505 },506 507 // Update markup to match.508 updateElement: function () {509 this.spinner.updateElement();510 },511 512});...

Full Screen

Full Screen

app.js

Source:app.js Github

copy

Full Screen

...49 var email = document.getElementById("email").value;50 var phone = document.getElementById("phone").value;51 var company = document.getElementById("company").value;52 if(email == "") {53 updateElement("status", "Email field cannot be empty!");54 return;55 }56 var data = {57 'name': name,58 'email': email,59 'phone': phone,60 'company': company61 };62 updateElement("status", "Initiating transaction... (please wait)");63 addDataToIPFS(data, generateRandomString(), true, email);64}65function addDataToIPFS(data, filename, addToBlockchain = false, primaryKey = '') {66 var url = "./php/senddata.php";67 data = JSON.stringify(data)68 var formdata = {'filename': filename, 'data': data};69 var returnOutput = null;70 $.post(url, formdata, function(output) {71 console.log(output);72 ipfs.add({path: filename, content: data}, function(err, result) {73 if (err) {74 console.error('Error sending file: ', err);75 updateElement("status", "IPFS Failed!");76 return null;77 } else if (result && result[0] && result[0].Hash) {78 var fileURL = ipfsDataHost + "/" + result[0].Hash;79 console.log('File Hash: ', result[0].Hash);80 console.log(fileURL);81 82 if(addToBlockchain == true) {83 var fileHash = result[0].Hash;84 var hr = HrSolution.deployed();85 hr.addRecord(fileHash, primaryKey, {from: account}).then(function() {86 updateElement("status", "Transaction complete!");87 }).catch(function(e) {88 console.log(e);89 updateElement("status", "Error adding record. You are low on ether.");90 });91 updateElement("bold-url", "");92 updateElement("show-url", "");93 updateElement("bold-name", "");94 updateElement("show-name", "");95 updateElement("bold-email", "");96 updateElement("show-email", "");97 updateElement("bold-phone", "");98 updateElement("show-phone", "");99 updateElement("bold-company", "");100 updateElement("show-company", "");101 }102 updateElement("bold-url", "URL: ");103 updateElement("show-url", "<a href='"+fileURL+"'>IPFS Gateway</a>");104 } else {105 console.error('No file for you...');106 updateElement("status", "IPFS Failed!");107 return null;108 }109 });110 });111}112function searchRecord() {113 var email = document.getElementById("search-email").value;114 115 if(email == "") {116 updateElement("status", "Email field cannot be empty!");117 return;118 }119 updateElement("status", "Initiating search... (please wait)");120 var hr = HrSolution.deployed();121 updateElement("bold-url", "");122 updateElement("show-url", "")123 updateElement("bold-name", "");124 updateElement("show-name", "");125 updateElement("bold-email", "");126 updateElement("show-email", "");127 updateElement("bold-phone", "");128 updateElement("show-phone", "");129 updateElement("bold-company", "");130 updateElement("show-company", "");131 hr.checkRecord.call(email).then(function(flag) {132 flag = flag.valueOf()133 if(flag == true) {134 hr.fetchRecord.call(email, {from: account}).then(function(record) {135 136 var fileHash = web3.toUtf8(record.valueOf())137 var fileURL = ipfsDataHost + "/" + fileHash138 $.get(fileURL, function(output) {139 output = JSON.parse(output);140 updateElement("status", "");141 updateElement("bold-url", "URL: ");142 updateElement("show-url", "<a href='"+fileURL+"'>IPFS Gateway</a>")143 updateElement("bold-name", "Name: ");144 updateElement("show-name", output.name);145 updateElement("bold-email", "Email: ");146 updateElement("show-email", output.email);147 updateElement("bold-phone", "Phone: ");148 updateElement("show-phone", output.phone);149 updateElement("bold-company", "Company: ");150 updateElement("show-company", output.company);151 })152 }).catch(function(e) {153 console.log(e);154 updateElement("status", "Error retrieving record. You are low on ether.");155 });156 } else {157 updateElement("status", "Record not found.");158 }159 }).catch(function(e) {160 console.log(e);161 updateElement("status", "Error checking for record. You are low on ether.");162 });163}164function updateElement(id, value) {165 var ele = document.getElementById(id);166 ele.innerHTML = value;167}168function decode_base64 (s) {169 var e = {}, i, k, v = [], r = '', w = String.fromCharCode;170 var n = [[65, 91], [97, 123], [48, 58], [43, 44], [47, 48]];171 for (z in n) {172 for (i = n[z][0]; i < n[z][1]; i++) {173 v.push(w(i));174 }175 }176 for (i = 0; i < 64; i++) {177 e[v[i]] = i;178 }...

Full Screen

Full Screen

settings.js

Source:settings.js Github

copy

Full Screen

1function changeColor(color) {2 $("#color").val(color);3 $(".colorPreview").css("background", color);4 $(".colorLabel").text(color)5}6function changeFill(filled, shape) {7 if (filled) {8 $("nonFilled" + shape).hide();9 $("filled" + shape).show();10 } else {11 $("nonFilled" + shape).show();12 $("filled" + shape).hide();13 }14}15function changeLineWidth(lineWidth, shape) {16 $("#" + shape + "Slider").val(lineWidth);17 $("#" + shape + "Linewidth").text(lineWidth + "px");18}19function restoreSettings(target) {20 openTool(null, target.shape);21 changeColor(target.color);22 switch (target.shape) {23 case drawio.availableShapes.CIRCLE:24 changeFill(target.filled, "Circle");25 changeLineWidth(target.lineWidth, target.shape);26 break;27 case drawio.availableShapes.RECTANGLE:28 changeFill(target.filled, "Rectangle");29 changeLineWidth(target.lineWidth, target.shape);30 break;31 case drawio.availableShapes.LINE:32 changeLineWidth(target.lineWidth, target.shape);33 break;34 case drawio.availableShapes.PEN:35 changeLineWidth(target.lineWidth, target.shape);36 break;37 case drawio.availableShapes.TEXT:38 $("#textToolText").val(target.stringText);39 let font = target.font.split(" ").slice(1).join(" ");40 $("#textToolFont").val(font);41 $("#fontSlider").val(target.fontSize);42 $("#fontSize").text(target.fontSize + "pt");43 break;44 }45}46function updateLineWidth(target, lineWidth) {47 if (target) {48 target.lineWidth = lineWidth;49 drawio.redraw();50 }51}52$("#lineSlider").on("input", function () {53 let lineWidth = $("#lineSlider").val();54 $("#lineLinewidth").text(lineWidth + "px");55 updateLineWidth(drawio.updateElement, lineWidth);56});57$("#penSlider").on("input", function () {58 $("#penLinewidth").text($("#penSlider").val() + "px");59 updateLineWidth(drawio.updateElement, $("#penSlider").val());60});61$("#circleSlider").on("input", function () {62 $("#circleLinewidth").text($("#circleSlider").val() + "px");63 updateLineWidth(drawio.updateElement, $("#circleSlider").val());64});65$("#rectangleSlider").on("input", function () {66 $("#rectangleLinewidth").text($("#rectangleSlider").val() + "px");67 updateLineWidth(drawio.updateElement, $("#rectangleSlider").val());68});69$("#fontSlider").on("input", function () {70 $("#fontSize").text($("#fontSlider").val() + "pt");71 drawio.currentTextItem.font = $("#fontSlider").val() + "pt " + $("#textToolFont")[0].value;72 if (drawio.updateElement) {73 drawio.updateElement.fontSize = $("#fontSlider").val();74 drawio.updateElement.font = $("#fontSlider").val() + "pt " + $("#textToolFont")[0].value;75 drawio.updateElement.width = drawio.ctx.measureText(drawio.updateElement.stringText, drawio.updateElement.font).width;76 drawio.updateElement.height = parseInt(drawio.currentTextItem.font);77 drawio.redraw();78 }79});80$("#textToolText").on("keyup", function () {81 if (drawio.updateElement) {82 drawio.updateElement.stringText = $("#textToolText").val();83 drawio.updateElement.width = drawio.ctx.measureText(drawio.updateElement.stringText, drawio.updateElement.font).width;84 drawio.updateElement.height = parseInt(drawio.currentTextItem.font);85 drawio.redraw();86 }87});88$("#textToolFont").on("change", function () {89 if (drawio.updateElement) {90 let oldFont = drawio.updateElement.font;91 drawio.updateElement.font = $("#fontSlider").val() + "pt " + $("#textToolFont")[0].value;92 drawio.updateElement.width = drawio.ctx.measureText(drawio.updateElement.stringText, drawio.updateElement.font).width;93 drawio.updateElement.height = parseInt(drawio.currentTextItem.font);94 drawio.state.unshift(new FontChanged("Font Change", drawio.updateElement, oldFont, drawio.updateElement.font));95 updateHistory();96 drawio.redraw();97 }98});99$("#nonFilledCircle").click(function () {100 $("#nonFilledCircle").hide();101 $("#filledCircle").show();102 $("#circle .slidecontainer").hide();103 drawio.filledCircle = !drawio.filledCircle;104 if (drawio.updateElement) {105 drawio.updateElement.filled = drawio.filledCircle;106 drawio.state.unshift(new ShapeFilled("Shape Filled", drawio.updateElement, drawio.updateElement.filled));107 updateHistory();108 drawio.redraw();109 }110});111$("#filledCircle").click(function () {112 $("#filledCircle").hide();113 $("#nonFilledCircle").show();114 $("#circle .slidecontainer").show();115 drawio.filledCircle = !drawio.filledCircle;116 if (drawio.updateElement) {117 drawio.updateElement.filled = drawio.filledCircle;118 drawio.state.unshift(new ShapeFilled("Shape Filled", drawio.updateElement, drawio.updateElement.filled));119 updateHistory();120 drawio.redraw();121 }122});123$("#nonFilledRectangle").click(function () {124 $("#nonFilledRectangle").hide();125 $("#filledRectangle").show();126 $("#rectangle .slidecontainer").hide();127 drawio.filledRectangle = !drawio.filledRectangle;128 if (drawio.updateElement) {129 drawio.updateElement.filled = drawio.filledRectangle;130 drawio.state.unshift(new ShapeFilled("Shape Filled", drawio.updateElement, drawio.updateElement.filled));131 updateHistory();132 drawio.redraw();133 }134})135$("#filledRectangle").click(function () {136 $("#filledRectangle").hide();137 $("#nonFilledRectangle").show();138 $("#rectangle .slidecontainer").show();139 drawio.filledRectangle = !drawio.filledRectangle;140 if (drawio.updateElement) {141 drawio.updateElement.filled = drawio.filledRectangle;142 drawio.state.unshift(new ShapeFilled("Shape Filled", drawio.updateElement, drawio.updateElement.filled));143 updateHistory();144 drawio.redraw();145 }...

Full Screen

Full Screen

backend.js

Source:backend.js Github

copy

Full Screen

...40}41function updateDashboardExec(data){42 //console.log(typeof data);43 if (checkExitsElement(data, 'last_rain_sensor')){44 updateElement('#last_rain_sensor', data['last_rain_sensor']);45 }46 if (checkExitsElement(data, 'last_rain_online')){47 updateElement('#last_rain_online', data['last_rain_online']);48 }49 if (checkExitsElement(data, 'weather', 'observation_time')){50 updateElement('#observation_time', data['weather']['observation_time']);51 }52 if (checkExitsElement(data, 'weather', 'icon_url')){53 updateElement('#icon_url', data['weather']['icon_url'], 'src');54 }55 if (checkExitsElement(data, 'weather', 'weather')){56 updateElement('#weather', data['weather']['weather']);57 }58 if (checkExitsElement(data, 'weather', 'temp_c')){59 updateElement('#temp_c', data['weather']['temp_c']);60 }61 if (checkExitsElement(data, 'weather', 'feelslike_c')){62 updateElement('#feelslike_c', data['weather']['feelslike_c']);63 }64 if (checkExitsElement(data, 'weather', 'wind_degress_style')){65 updateElement('#windCompass', data['weather']['wind_degress_style'], 'style');66 }67 if (checkExitsElement(data, 'weather', 'wind_kph')){68 updateElement('#wind_kph', data['weather']['wind_kph']);69 }70 if (checkExitsElement(data, 'weather', 'wind_dir')){71 updateElement('#wind_dir', data['weather']['wind_dir']);72 }73 if (checkExitsElement(data, 'weather', 'wind_gust_kph')){74 updateElement('#wind_gust_kph', data['weather']['wind_gust_kph']);75 }76 if (checkExitsElement(data, 'weather', 'pressure_mb')){77 updateElement('#pressure_mb', data['weather']['pressure_mb']);78 }79 if (checkExitsElement(data, 'weather', 'relative_humidity')){80 updateElement('#relative_humidity', data['weather']['relative_humidity']);81 }82 if (checkExitsElement(data, 'weather', 'dewpoint_c')){83 updateElement('#dewpoint_c', data['weather']['dewpoint_c']);84 }...

Full Screen

Full Screen

Behavior.FormRequest.js

Source:Behavior.FormRequest.js Github

copy

Full Screen

1/*2---3description: Makes form elements with a FormRequest data filter automatically update via Ajax.4provides: [Behavior.FormRequest]5requires: [Behavior/Behavior, More/Form.Request]6script: Behavior.FormRequest.js7name: Behavior.FormRequest8...9*/10Behavior.addGlobalFilter('FormRequest', {11 defaults: {12 resetForm: true13 },14 returns: Form.Request,15 setup: function(element, api){16 // figure out which element we're updating, spinning over17 var updateElement,18 update = api.get('update'),19 spinner = api.get('spinner');20 if (update =="self") updateElement = element;21 else updateElement = element.getElement(update);22 // placeholder for response23 var requestTarget = new Element('div');24 // spinner target25 if (spinner == "self") spinner = element;26 else if (spinner) spinner = element.getElement(spinner);27 else spinner = updateElement;28 // no update element? no worky!29 if (!updateElement) api.fail('Could not find target element for form update');30 var sentAt;31 var req = new Form.Request(element, requestTarget, {32 requestOptions: {33 spinnerTarget: spinner34 },35 resetForm: api.get('resetForm')36 }).addEvent('complete', function(){37 // when our placeholder has been updated, get it's inner HTML (i.e. the response)38 var html = requestTarget.get('html');39 // are we filtering that response?40 var elements;41 if (api.get('filter')){42 elements = new Element('div').set('html', html).getElements(api.get('filter'));43 }44 // destroy old DOM45 api.fireEvent('destroyDom', updateElement.getChildren());46 updateElement.empty();47 // did we filter? if so, insert filtered, else just update HTML48 if (elements) updateElement.adopt(elements);49 else updateElement.set('html', html);50 // apply behaviors and whatnot51 api.fireEvent('ammendDom', [updateElement, updateElement.getChildren()]);52 elements = []; //garbage collection53 }).addEvent('send', function(){54 sentAt = new Date().getTime();55 });56 // this bit below is to throttle form submission in case more than one thing57 // is trying to send it58 // remove form.request submit watcher59 element.removeEvent('submit', req.onSubmit);60 // our new submit handler checks that requests to submit are at least 200ms apart61 var submit = function(e){62 if (!sentAt || sentAt + 200 < new Date().getTime()){63 req.onSubmit(e);64 } else {65 // if they aren't, just stop the submit event if it's present66 if (e) e.stop();67 }68 };69 // now monitor submit with our new method70 element.addEvent('submit', submit);71 // and overwrite the submit method on the element72 element.submit = submit;73 api.onCleanup(function(){74 req.detach();75 delete element.submit;76 });77 return req;78 }...

Full Screen

Full Screen

definitions.js

Source:definitions.js Github

copy

Full Screen

1/*****************************************************************************\2* $Id: definitions.js,v 1.3 2009/10/26 19:17:20 paste Exp $3\*****************************************************************************/4function ReloadElement() {5 this.id = null;6 this.reloadFunction = null;7 this.callbackSuccess = null;8 this.callbackError = null;9 this.timeSinceReload = 0;10 this.timeToReload = 10;11 this.timeToError = 60;12 this.stop = false;13 this.lastReloadTime = "";14 function tickFunction(now) {15 var updateElement;16 if (updateElement = $(this.id + "_loadtime")) {17 var min = parseInt(this.timeSinceReload / 60).toString();18 var sec = (this.timeSinceReload % 60).toString();19 if (sec.length == 1) sec = "0" + sec;20 var time = min + ":" + sec;21 if (this.timeSinceReload == 0) {22 var date = new Date();23 this.lastReloadTime = date.toLocaleString();24 }25 if (this.stop) updateElement.update(this.lastReloadTime + " (paused)");26 else updateElement.update(this.lastReloadTime + " (" + time + " ago)");27 }28 this.timeSinceReload++;29 if (this.timeSinceReload > this.timeToError) {30 if (updateElement && !updateElement.hasClassName("Failed")) {31 updateElement.addClassName("Failed");32 }33 } else {34 if (updateElement && updateElement.hasClassName("Failed")) {35 updateElement.removeClassName("Failed");36 }37 }38 if (this.timeSinceReload % this.timeToReload == 0 || now == true) {39 if (this.stop && now != true) return;40 $(this.id + "_loadicon").setAttribute("src", "/emu/emuDCS/FEDApps/images/ajax-loader.gif");41 this.reloadFunction();42 }43 }44 this.tick = tickFunction;45 function resetFunction() {46 var updateElement;47 if (updateElement = $(this.id + "_loadicon")) updateElement.setAttribute("src", "/emu/emuDCS/FEDApps/images/empty.gif");48 this.timeSinceReload = 0;49 this.tick();50 }51 this.reset = resetFunction;52}...

Full Screen

Full Screen

heap.js

Source:heap.js Github

copy

Full Screen

...11 for (let i = Math.floor(len/2-1); i >= 0; i--) maxHeapify(barSizes, len, i)12 let i = len - 113 while (i > 0) {14 swap (barSizes, 0, i)15 updateElement(bars[0], SORTED)16 updateElement(bars[i], SELECTED)17 maxHeapify(barSizes, i, 0)18 updateElement(bars[i], BASE)19 updateElement(bars[i], SORTED)20 i--21 }22 updateElement(bars[i], SORTED)23 }24 25/**26 * Create a max heap in array form27 * @param {Array} barSizes28 * @param {Integer} size29 * @param {Integer} index30 */31function maxHeapify (barSizes, size, index) { 32 let largest = index33 const left = (2 * index) + 134 const right = (2 * index) + 235 if (left < size && barSizes[left] > barSizes[largest]) {36 if (largest != index) updateElement(bars[largest], BASE)37 largest = left38 updateElement(bars[largest], COMPARING)39 }40 if (right < size && barSizes[right] > barSizes[largest]) {41 if (largest != index) updateElement(bars[largest], BASE)42 largest = right43 updateElement(bars[largest], COMPARING)44 }45 if (largest != index) {46 swap (barSizes, index, largest)47 maxHeapify(barSizes, size, largest)48 } 49} ...

Full Screen

Full Screen

bubble.js

Source:bubble.js Github

copy

Full Screen

...9const bubble = (heights) => {10 const len = bars.length - 111 for (let i = 0; i < len; i++) {12 for (var j = 0; j < len-i; j++) {13 updateElement(bars[j], SELECTED)14 if (heights[j] > heights[j+1]) {15 updateElement(bars[j], COMPARING)16 updateElement(bars[j+1], COMPARING)17 const temp = heights[j]18 heights[j] = heights[j+1]19 heights[j+1] = temp20 updateElement(bars[j], COMPARING, heights[j])21 updateElement(bars[j+1], COMPARING, heights[j+1])22 }23 updateElement(bars[j], BASE)24 }25 updateElement(bars[j], SORTED)26 }27 updateElement(bars[0], SORTED)28}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const element = await page.$('text=Get started');7 await element.updateElement('text=Get started', 'text=Try it out');8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.updateElement('#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input', 'test');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.evaluate(async () => {15 await window['playwright'].updateElement('#tsf > div:nth-child(2) > div > div.RNNXgb > div > div.a4bIc > input', 'test');16 });17 await browser.close();18})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { updateElement } = require('@playwright/test/lib/server/dom');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.click('text=Run');8 await page.waitForSelector('iframe');9 const frame = page.frames()[1];10 const element = await frame.$('p');11 await updateElement(await element._elementHandle, 'Updated Paragraph');12 await frame.screenshot({ path: 'updatedElement.png' });13 await browser.close();14})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { updateElement } = require('playwright/lib/internal/page');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await updateElement(page, 'input[name="q"]', 'new value');8 await browser.close();9})();10const updateElement = async (page, selector, value) => {11 const element = await page.$(selector);12 await element.evaluate(element => element.value = 'new value', value);13};

Full Screen

Using AI Code Generation

copy

Full Screen

1const { updateElement } = require('playwright/lib/client/selectorEngine');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch({ headless: false });5 const page = await browser.newPage();6 const element = await page.$('input[name="q"]');7 await updateElement(element, 'new value');8 await browser.close();9})();10const { updateElement } = require('playwright/lib/client/selectorEngine');11const { chromium } = require('playwright');12(async () => {13 const browser = await chromium.launch({ headless: false });14 const page = await browser.newPage();15 const element = await page.$('#foo');16 await updateElement(element, 'bar');17 await browser.close();18})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { updateElement } = require('playwright/lib/server/dom');2const http = require('http');3const server = http.createServer((req, res) => {4 res.end('Hello World!');5});6server.listen(8080, () => {7 console.log('Server started on port 8080');8});9const playwright = require('playwright');10(async () => {11 const browser = await playwright['chromium'].launch();12 const context = await browser.newContext();13 const page = await context.newPage();14 const elementHandle = await page.evaluateHandle(() => {15 const input = document.createElement('input');16 document.body.appendChild(input);17 return input;18 });19 await updateElement(elementHandle, 'new value');20 const value = await page.evaluate(element => element.value, elementHandle);21 console.log(value);22 await browser.close();23})();

Full Screen

Playwright tutorial

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

Chapters:

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

Run Playwright Internal automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful