Best JavaScript code snippet using wpt
model.js
Source:model.js
...116 frappe.model.sync(cached_doc);117 } else {118 localStorage["_doctype:" + doctype] = JSON.stringify(r.docs);119 }120 frappe.model.init_doctype(doctype);121 if(r.user_settings) {122 // remember filters and other settings from last view123 frappe.model.user_settings[doctype] = JSON.parse(r.user_settings);124 frappe.model.user_settings[doctype].updated_on = moment().toString();125 }126 callback && callback(r);127 }128 });129 }130 },131 init_doctype: function(doctype) {132 var meta = locals.DocType[doctype];133 if(meta.__list_js) {134 eval(meta.__list_js);...
error-codes.js
Source:error-codes.js
1'use strict';2module.exports = {3 controlCharacterInInputStream: 'control-character-in-input-stream',4 noncharacterInInputStream: 'noncharacter-in-input-stream',5 surrogateInInputStream: 'surrogate-in-input-stream',6 nonVoidHtmlElementStartTagWithTrailingSolidus: 'non-void-html-element-start-tag-with-trailing-solidus',7 endTagWithAttributes: 'end-tag-with-attributes',8 endTagWithTrailingSolidus: 'end-tag-with-trailing-solidus',9 unexpectedSolidusInTag: 'unexpected-solidus-in-tag',10 unexpectedNullCharacter: 'unexpected-null-character',11 unexpectedQuestionMarkInsteadOfTagName: 'unexpected-question-mark-instead-of-tag-name',12 invalidFirstCharacterOfTagName: 'invalid-first-character-of-tag-name',13 unexpectedEqualsSignBeforeAttributeName: 'unexpected-equals-sign-before-attribute-name',14 missingEndTagName: 'missing-end-tag-name',15 unexpectedCharacterInAttributeName: 'unexpected-character-in-attribute-name',16 unknownNamedCharacterReference: 'unknown-named-character-reference',17 missingSemicolonAfterCharacterReference: 'missing-semicolon-after-character-reference',18 unexpectedCharacterAfterDoctypeSystemIdentifier: 'unexpected-character-after-doctype-system-identifier',19 unexpectedCharacterInUnquotedAttributeValue: 'unexpected-character-in-unquoted-attribute-value',20 eofBeforeTagName: 'eof-before-tag-name',21 eofInTag: 'eof-in-tag',22 missingAttributeValue: 'missing-attribute-value',23 missingWhitespaceBetweenAttributes: 'missing-whitespace-between-attributes',24 missingWhitespaceAfterDoctypePublicKeyword: 'missing-whitespace-after-doctype-public-keyword',25 missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers:26 'missing-whitespace-between-doctype-public-and-system-identifiers',27 missingWhitespaceAfterDoctypeSystemKeyword: 'missing-whitespace-after-doctype-system-keyword',28 missingQuoteBeforeDoctypePublicIdentifier: 'missing-quote-before-doctype-public-identifier',29 missingQuoteBeforeDoctypeSystemIdentifier: 'missing-quote-before-doctype-system-identifier',30 missingDoctypePublicIdentifier: 'missing-doctype-public-identifier',31 missingDoctypeSystemIdentifier: 'missing-doctype-system-identifier',32 abruptDoctypePublicIdentifier: 'abrupt-doctype-public-identifier',33 abruptDoctypeSystemIdentifier: 'abrupt-doctype-system-identifier',34 cdataInHtmlContent: 'cdata-in-html-content',35 incorrectlyOpenedComment: 'incorrectly-opened-comment',36 eofInScriptHtmlCommentLikeText: 'eof-in-script-html-comment-like-text',37 eofInDoctype: 'eof-in-doctype',38 nestedComment: 'nested-comment',39 abruptClosingOfEmptyComment: 'abrupt-closing-of-empty-comment',40 eofInComment: 'eof-in-comment',41 incorrectlyClosedComment: 'incorrectly-closed-comment',42 eofInCdata: 'eof-in-cdata',43 absenceOfDigitsInNumericCharacterReference: 'absence-of-digits-in-numeric-character-reference',44 nullCharacterReference: 'null-character-reference',45 surrogateCharacterReference: 'surrogate-character-reference',46 characterReferenceOutsideUnicodeRange: 'character-reference-outside-unicode-range',47 controlCharacterReference: 'control-character-reference',48 noncharacterCharacterReference: 'noncharacter-character-reference',49 missingWhitespaceBeforeDoctypeName: 'missing-whitespace-before-doctype-name',50 missingDoctypeName: 'missing-doctype-name',51 invalidCharacterSequenceAfterDoctypeName: 'invalid-character-sequence-after-doctype-name',52 duplicateAttribute: 'duplicate-attribute',53 nonConformingDoctype: 'non-conforming-doctype',54 missingDoctype: 'missing-doctype',55 misplacedDoctype: 'misplaced-doctype',56 endTagWithoutMatchingOpenElement: 'end-tag-without-matching-open-element',57 closingOfElementWithOpenChildElements: 'closing-of-element-with-open-child-elements',58 disallowedContentInNoscriptInHead: 'disallowed-content-in-noscript-in-head',59 openElementsLeftAfterEof: 'open-elements-left-after-eof',60 abandonedHeadElementChild: 'abandoned-head-element-child',61 misplacedStartTagForHeadElement: 'misplaced-start-tag-for-head-element',62 nestedNoscriptInHead: 'nested-noscript-in-head',63 eofInElementThatCanContainOnlyText: 'eof-in-element-that-can-contain-only-text'...
workflow.js
Source:workflow.js
1// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors2// MIT License. See license.txt3frappe.provide("frappe.workflow");4frappe.workflow = {5 state_fields: {},6 workflows: {},7 setup: function(doctype) {8 var wf = frappe.get_list("Workflow", {document_type: doctype});9 if(wf.length) {10 frappe.workflow.workflows[doctype] = wf[0];11 frappe.workflow.state_fields[doctype] = wf[0].workflow_state_field;12 } else {13 frappe.workflow.state_fields[doctype] = null;14 }15 },16 get_state_fieldname: function(doctype) {17 if(frappe.workflow.state_fields[doctype]===undefined) {18 frappe.workflow.setup(doctype);19 }20 return frappe.workflow.state_fields[doctype];21 },22 get_default_state: function(doctype, docstatus) {23 frappe.workflow.setup(doctype);24 var value = null;25 $.each(frappe.workflow.workflows[doctype].states, function(i, workflow_state) {26 if(cint(workflow_state.doc_status)===cint(docstatus)) {27 value = workflow_state.state;28 return false;29 }30 });31 return value;32 },33 get_transitions: function(doc) {34 frappe.workflow.setup(doc.doctype);35 return frappe.xcall('frappe.model.workflow.get_transitions', {doc: doc});36 },37 get_document_state: function(doctype, state) {38 frappe.workflow.setup(doctype);39 return frappe.get_children(frappe.workflow.workflows[doctype], "states", {state:state})[0];40 },41 is_self_approval_enabled: function(doctype) {42 return frappe.workflow.workflows[doctype].allow_self_approval;43 },44 is_read_only: function(doctype, name) {45 var state_fieldname = frappe.workflow.get_state_fieldname(doctype);46 if(state_fieldname) {47 var doc = locals[doctype][name];48 if(!doc)49 return false;50 if(doc.__islocal)51 return false;52 var state = doc[state_fieldname] ||53 frappe.workflow.get_default_state(doctype, doc.docstatus);54 var allow_edit = state ? frappe.workflow.get_document_state(doctype, state) && frappe.workflow.get_document_state(doctype, state).allow_edit : null;55 if(!frappe.user_roles.includes(allow_edit)) {56 return true;57 }58 }59 return false;60 },61 get_update_fields: function(doctype) {62 var update_fields = $.unique($.map(frappe.workflow.workflows[doctype].states || [],63 function(d) {64 return d.update_field;65 }));66 return update_fields;67 },68 get_state(doc) {69 const state_field = this.get_state_fieldname(doc.doctype);70 let state = doc[state_field];71 if (!state) {72 state = this.get_default_state(doc.doctype, doc.docstatus);73 }74 return state;75 },76 get_all_transitions(doctype) {77 return frappe.workflow.workflows[doctype].transitions || [];78 },79 get_all_transition_actions(doctype) {80 const transitions = this.get_all_transitions(doctype);81 return transitions.map(transition => {82 return transition.action;83 });84 },...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4};5 if (err) return console.error(err);6 console.log('Test submitted. Polling for results...');7 wpt.getTestResults(data.data.testId, function(err, data) {8 if (err) return console.error(err);9 console.log('Test completed!');10 console.log(data);11 });12});
Using AI Code Generation
1function test() {2 var wpt = new WebPageTest('www.webpagetest.org');3 wpt.runTest(url, function(err, data) {4 console.log(data);5 });6}7function test() {8 var wpt = new WebPageTest('www.webpagetest.org');9 wpt.runTest(url, function(err, data) {10 console.log(data);11 });12}13function test() {14 var wpt = new WebPageTest('www.webpagetest.org');15 wpt.runTest(url, function(err, data) {16 console.log(data);17 });18}19function test() {20 var wpt = new WebPageTest('www.webpagetest.org');21 wpt.runTest(url, function(err, data) {22 console.log(data);23 });24}25function test() {26 var wpt = new WebPageTest('www.webpagetest.org');27 wpt.runTest(url, function(err, data) {28 console.log(data);29 });30}31function test() {32 var wpt = new WebPageTest('www.webpagetest.org');33 wpt.runTest(url, function(err, data) {34 console.log(data);35 });36}37function test() {38 var wpt = new WebPageTest('www.webpagetest.org');39 wpt.runTest(url, function(err, data) {40 console.log(data);41 });42}
Using AI Code Generation
1const wpt = require('webpagetest');2const test = wpt('API_KEY');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9const wpt = require('webpagetest');10const test = wpt('API_KEY');11 if (err) {12 console.log(err);13 } else {14 console.log(data);15 }16});17const wpt = require('webpagetest');18const test = wpt('API_KEY');19 if (err) {20 console.log(err);21 } else {22 console.log(data);23 }24});25const wpt = require('webpagetest');26const test = wpt('API_KEY');27 if (err) {28 console.log(err);29 } else {30 console.log(data);31 }32});33const wpt = require('webpagetest');34const test = wpt('API_KEY');35 if (err) {36 console.log(err);37 } else {38 console.log(data);
Using AI Code Generation
1var doctype = wpt.doctype();2if(doctype == null) {3 wpt.log("No doctype found");4} else {5 wpt.log("Doctype found: " + doctype);6}7var doctype = wpt.doctype();8if(doctype == null) {9 wpt.log("No doctype found");10} else {11 wpt.log("Doctype found: " + doctype);12}13var doctype = wpt.doctype();14if(doctype == null) {15 wpt.log("No doctype found");16} else {17 wpt.log("Doctype found: " + doctype);18}19var doctype = wpt.doctype();20if(doctype == null) {21 wpt.log("No doctype found");22} else {23 wpt.log("Doctype found: " + doctype);24}25var doctype = wpt.doctype();26if(doctype == null) {27 wpt.log("No doctype found");28} else {29 wpt.log("Doctype found: " + doctype);30}31var doctype = wpt.doctype();32if(doctype == null) {33 wpt.log("No doctype found");34} else {35 wpt.log("Doctype found: " + doctype);36}37var doctype = wpt.doctype();38if(doctype == null) {39 wpt.log("No doctype found");40} else {41 wpt.log("Doctype found: " + doctype);42}43var doctype = wpt.doctype();44if(doctype == null) {45 wpt.log("No doctype found");46} else {47 wpt.log("Doctype found: " + doctype);48}49var doctype = wpt.doctype();
Using AI Code Generation
1var wpt = require('wpt-api');2var options = {3};4wpt.doctype(options, function(err, data) {5 console.log(data);6});7var wpt = require('wpt-api');8var options = {9};10wpt.domElements(options, function(err, data) {11 console.log(data);12});13var wpt = require('wpt-api');14var options = {15};16wpt.domElements(options, function(err, data) {17 console.log(data);18});19var wpt = require('wpt-api');20var options = {21};22wpt.domElements(options, function(err, data) {23 console.log(data);24});25var wpt = require('wpt-api');26var options = {27};28wpt.domElements(options, function(err, data) {29 console.log(data);30});
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!!