Best JavaScript code snippet using playwright-internal
MetadataViewModel.js
Source:MetadataViewModel.js
...208 field.value = value;209 if (mmdField.use_value_as_label != null) 210 {211 field.value_as_label =212 ViewModeler.getValueForProperty(mmdField.use_value_as_label,213 metadata, mmdKids, depth);214 }215 if(mmdField.field_as_count != null){216 field.field_as_count = ViewModeler.getValueForProperty(mmdField.field_as_count, metadata, mmdKids, depth+1);217 }218 219 field.scalar_type = mmdField.scalar_type;220 field.parentMDType = metadata.meta_metadata_name; 221 222 // Does the field have a navigation link?223 if (mmdField.navigates_to != null)224 {225 var navigationLink = metadata[mmdField.navigates_to];226 227 // Is there a value for the navigation link228 if (navigationLink != null229 && (navigationLink.toLowerCase() != taskUrl || depth == 0))230 {231 field.navigatesTo = navigationLink;232 }233 }234 235 if (mmdField.concatenates_to)236 {237 ViewModeler.concatenateField(field, metadataViewModel, mmdKids);238 }239 240 if (metadataViewModel.indexOf(field) == -1)241 {242 metadataViewModel.push(field);243 }244 }245 }246}247ViewModeler.getCompositeMetadataViewModel = function(metadataViewModel,248 parentField,249 mmdField,250 mmdKids,251 metadata,252 depth,253 child_value_as_label,254 taskUrl, field_as_count)255{256 mmdField = mmdField.composite;257 258 if(mmdField.name == 'keywords'){259 console.log('gagnam style')260 }261 // Is this a visible field?262 if (ViewModeler.isFieldVisible(mmdField, metadata, taskUrl, parentField))263 { 264 // Is there a metadata value for this field? 265 var value = ViewModeler.getFieldValue(mmdField, metadata); 266 if (value)267 { 268 if (child_value_as_label != null)269 {270 mmdField.use_value_as_label = child_value_as_label;271 }272 if(field_as_count != null){273 mmdField.field_as_count = field_as_count;274 }275 // If there is an array of values 276 if (value.length != null)277 { 278 for (var i = 0; i < value.length; i++)279 {280 var field = new MetadataViewModel(mmdField);281 282 field.value =283 ViewModeler.getMetadataViewModel(mmdField, mmdField["kids"], value[i],284 depth + 1, null, taskUrl);285 286 287 if (mmdField.use_value_as_label != null)288 {289 field.value_as_label =290 ViewModeler.getValueForProperty(mmdField.use_value_as_label,291 value[i], mmdField["kids"],292 depth + 1);293 }294 295 field.composite_type = mmdField.type;296 field.parentMDType = metadata.meta_metadata_name;297 ViewModeler.checkAndSetChildAtributes(parentField, field);298 //if no value, just ignore field299 if(field.value != null && field.value.length >0){300 metadataViewModel.push(field);301 }302 }303 }304 else305 {306 var field = new MetadataViewModel(mmdField);307 308 field.value =309 ViewModeler.getMetadataViewModel(mmdField, mmdField["kids"], value,310 depth + 1, null, taskUrl);311 if (mmdField.use_value_as_label != null)312 {313 if (mmdField.child_value_as_label != null)314 {315 field.value_as_label =316 ViewModeler.getValueForProperty(mmdField.use_value_as_label,317 value, mmdField["kids"],318 depth + 1);319 }320 else321 {322 field.value_as_label =323 ViewModeler.getValueForProperty(mmdField.use_value_as_label,324 metadata, mmdKids, depth + 1);325 }326 }327 if(mmdField.field_as_count != null){328 field.field_as_count = ViewModeler.getValueForProperty(mmdField.field_as_count, metadata, mmdKids, depth+1);329 }330 331 field.composite_type = mmdField.type;332 field.parentMDType = metadata.meta_metadata_name;333 ViewModeler.checkAndSetChildAtributes(parentField, field);334 335 if(field.value != null && field.value.length >0){336 metadataViewModel.push(field);337 } }338 }339 }340 else341 {342 if (value)343 {344 }345 }346}347ViewModeler.getCollectionMetadataViewModel = function(metadataViewModel,348 parentField,349 mmdField,350 mmdKids,351 metadata,352 depth,353 child_value_as_label,354 taskUrl, field_as_count)355{356 mmdField = mmdField.collection; 357 if(mmdField.name == "companion_products"){358 359 }360 // Is this a visible field?361 if (ViewModeler.isFieldVisible(mmdField, metadata, taskUrl, parentField))362 { 363 // Is there a metadata value for this field? 364 var value = ViewModeler.getFieldValue(mmdField, metadata); 365 if (value)366 { 367 if (child_value_as_label != null)368 {369 mmdField.use_value_as_label = child_value_as_label;370 }371 if(field_as_count != null){372 mmdField.field_as_count = field_as_count;373 }374 var field = new MetadataViewModel(mmdField);375 376 field.child_type = (mmdField.child_tag != null) ? mmdField.child_tag377 : mmdField.child_type;378 field.parentMDType = metadata.meta_metadata_name;379 380 // If scalar collection381 if (mmdField.child_scalar_type != null)382 { 383 field.child_type = mmdField.child_scalar_type; 384 385 var newList = [];386 for (var k = 0; k < value.length; k++)387 {388 var scalarField = new MetadataViewModel(mmdField);389 scalarField.value = value[k]; 390 scalarField.hide_label = true;391 scalarField.scalar_type = mmdField.child_scalar_type;392 newList.push(scalarField);393 }394 field.value = newList;395 } 396 // Else if it's a polymorphic collection397 else if (mmdField.polymorphic_scope != null)398 { 399 var newObject = {};400 var newArray = [];401 402 for (var i = 0; i < value.length; i++)403 { 404 for (k in value[i])405 {406 newArray.push(value[i][k]);407 continue;408 }409 }410 411 newObject[field.child_type] = newArray;412 value = newObject; 413 }414 // Else, it must be a monomorphic collection415 else416 {417 var newObject = {};418 newObject[field.child_type] = value;419 value = newObject; 420 }421 422 if (mmdField.child_use_value_as_label != null)423 {424 field.value =425 ViewModeler.getMetadataViewModel(mmdField,426 mmdField["kids"],427 value,428 depth + 1,429 mmdField.child_use_value_as_label,430 taskUrl, field_as_count431 );432 }433 else if (mmdField.child_scalar_type == null)434 {435 field.value =436 ViewModeler.getMetadataViewModel(mmdField, mmdField["kids"], value,437 depth + 1, null, taskUrl);438 }439 if (mmdField.use_value_as_label != null) 440 {441 field.value_as_label =442 ViewModeler.getValueForProperty(mmdField.use_value_as_label,443 metadata, mmdKids);444 }445 if(mmdField.field_as_count != null){446 field.field_as_count = ViewModeler.getValueForProperty(mmdField.field_as_count, metadata, mmdKids);447 }448 449 metadataViewModel.push(field);450 }451 }452}453ViewModeler.collapseEmptyLabelSet = function(metadataViewModel, parentField)454{455 var deleteLabelCol = true;456 // make deleteLabelCol false if any child label is visible457 for (var i = 0; i < metadataViewModel.length; i++)458 {459 if (ViewModeler.isLabelVisible(metadataViewModel[i], parentField))460 {...
sys-info.js
Source:sys-info.js
...23 this.monoVerRegExp = /version (\d+[.]\d+[.]\d+) /gm;24 this.shouldCache = true;25 }26 getJavaVersion() {27 return this.getValueForProperty(() => this.javaVerCache, () => __awaiter(this, void 0, void 0, function* () {28 try {29 const spawnResult = yield this.childProcess.spawnFromEvent("java", ["-version"], "exit");30 const matches = spawnResult && SysInfo.JAVA_VERSION_REGEXP.exec(spawnResult.stderr);31 return matches && matches[1];32 }33 catch (err) {34 return null;35 }36 }));37 }38 getJavaCompilerVersion() {39 return this.getValueForProperty(() => this.javaCompilerVerCache, () => __awaiter(this, void 0, void 0, function* () {40 const javaCompileExecutableName = "javac";41 const javaHome = process.env.JAVA_HOME;42 const pathToJavaCompilerExecutable = javaHome ? path.join(javaHome, "bin", javaCompileExecutableName) : javaCompileExecutableName;43 try {44 const output = yield this.childProcess.exec(`"${pathToJavaCompilerExecutable}" -version`);45 return SysInfo.JAVA_COMPILER_VERSION_REGEXP.exec(output.stderr)[1];46 }47 catch (err) {48 return null;49 }50 }));51 }52 getXcodeVersion() {53 return this.getValueForProperty(() => this.xCodeVerCache, () => __awaiter(this, void 0, void 0, function* () {54 if (this.hostInfo.isDarwin) {55 const output = yield this.execCommand("xcodebuild -version");56 const xcodeVersionMatch = output && output.match(SysInfo.XCODE_VERSION_REGEXP);57 if (xcodeVersionMatch) {58 return this.getVersionFromString(output);59 }60 }61 }));62 }63 getNodeVersion() {64 return __awaiter(this, void 0, void 0, function* () {65 return this.getValueForProperty(() => this.nodeVerCache, () => __awaiter(this, void 0, void 0, function* () {66 const output = yield this.execCommand("node -v");67 if (output) {68 const version = this.getVersionFromString(output);69 return version || output;70 }71 return null;72 }));73 });74 }75 getNpmVersion() {76 return this.getValueForProperty(() => this.npmVerCache, () => __awaiter(this, void 0, void 0, function* () {77 const output = yield this.execCommand("npm -v");78 return output ? output.split("\n")[0] : null;79 }));80 }81 getNodeGypVersion() {82 return this.getValueForProperty(() => this.nodeGypVerCache, () => __awaiter(this, void 0, void 0, function* () {83 const output = yield this.execCommand("node-gyp -v");84 return output ? this.getVersionFromString(output) : null;85 }));86 }87 getXcodeprojGemLocation() {88 return this.getValueForProperty(() => this.xCodeprojGemLocationCache, () => __awaiter(this, void 0, void 0, function* () {89 const output = yield this.execCommand("gem which xcodeproj");90 return output ? output.trim() : null;91 }));92 }93 isITunesInstalled() {94 return this.getValueForProperty(() => this.iTunesInstalledCache, () => __awaiter(this, void 0, void 0, function* () {95 if (this.hostInfo.isLinux) {96 return false;97 }98 let coreFoundationDir;99 let mobileDeviceDir;100 if (this.hostInfo.isWindows) {101 const commonProgramFiles = this.hostInfo.isWindows64 ? process.env["CommonProgramFiles(x86)"] : process.env.CommonProgramFiles;102 coreFoundationDir = path.join(commonProgramFiles, "Apple", "Apple Application Support");103 mobileDeviceDir = path.join(commonProgramFiles, "Apple", "Mobile Device Support");104 }105 else if (this.hostInfo.isDarwin) {106 coreFoundationDir = "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation";107 mobileDeviceDir = "/System/Library/PrivateFrameworks/MobileDevice.framework/MobileDevice";108 }109 return (yield this.fileSystem.exists(coreFoundationDir)) && (yield this.fileSystem.exists(mobileDeviceDir));110 }));111 }112 getCocoaPodsVersion() {113 return this.getValueForProperty(() => this.cocoaPodsVerCache, () => __awaiter(this, void 0, void 0, function* () {114 if (this.hostInfo.isDarwin) {115 if (this.hostInfo.isDarwin) {116 const output = yield this.execCommand("pod --version");117 const cocoaPodsVersionMatch = output && output.match(SysInfo.VERSION_REGEXP);118 if (cocoaPodsVersionMatch && cocoaPodsVersionMatch[0]) {119 return cocoaPodsVersionMatch[0].trim();120 }121 }122 }123 }));124 }125 getOs() {126 return this.getValueForProperty(() => this.osCache, () => __awaiter(this, void 0, void 0, function* () {127 return yield (this.hostInfo.isWindows ? this.winVer() : this.unixVer());128 }));129 }130 getAdbVersion() {131 return this.getValueForProperty(() => this.adbVerCache, () => __awaiter(this, void 0, void 0, function* () {132 let output = null;133 const pathToAdbFromAndroidHome = yield this.androidToolsInfo.getPathToAdbFromAndroidHome();134 if (pathToAdbFromAndroidHome) {135 output = yield this.childProcess.spawnFromEvent(pathToAdbFromAndroidHome, ["version"], "close", { ignoreError: true });136 }137 return output && output.stdout ? this.getVersionFromString(output.stdout) : null;138 }));139 }140 isAndroidInstalled() {141 return this.getValueForProperty(() => this.androidInstalledCache, () => __awaiter(this, void 0, void 0, function* () {142 try {143 const errors = this.androidToolsInfo.validateAndroidHomeEnvVariable();144 return errors.length === 0;145 }146 catch (err) {147 return false;148 }149 }));150 }151 isAndroidSdkConfiguredCorrectly() {152 return __awaiter(this, void 0, void 0, function* () {153 return this.getValueForProperty(() => this.isAndroidSdkConfiguredCorrectlyCache, () => __awaiter(this, void 0, void 0, function* () {154 const output = yield this.childProcess.spawnFromEvent(this.androidToolsInfo.getPathToEmulatorExecutable(), ["-help"], "close", { ignoreError: true });155 return output && output.stdout.indexOf("usage: emulator") >= 0;156 }));157 });158 }159 getMonoVersion() {160 return this.getValueForProperty(() => this.monoVerCache, () => __awaiter(this, void 0, void 0, function* () {161 const output = yield this.execCommand("mono --version");162 const match = this.monoVerRegExp.exec(output);163 return match ? match[1] : null;164 }));165 }166 getGitVersion() {167 return this.getValueForProperty(() => this.gitVerCache, () => __awaiter(this, void 0, void 0, function* () {168 const gitPath = yield this.getGitPath();169 if (!gitPath) {170 return null;171 }172 const output = yield this.execCommand(`${this.helpers.quoteString(gitPath)} --version`);173 const matches = SysInfo.GIT_VERSION_REGEXP.exec(output);174 return matches && matches[1];175 }));176 }177 getGradleVersion() {178 return this.getValueForProperty(() => this.gradleVerCache, () => __awaiter(this, void 0, void 0, function* () {179 const output = yield this.execCommand("gradle -v");180 const matches = SysInfo.GRADLE_VERSION_REGEXP.exec(output);181 return matches && matches[1];182 }));183 }184 getSysInfo() {185 return this.getValueForProperty(() => this.sysInfoCache, () => __awaiter(this, void 0, void 0, function* () {186 const result = Object.create(null);187 result.platform = os_1.platform();188 result.shell = osenv.shell();189 result.os = yield this.getOs();190 result.procArch = process.arch;191 result.nodeVer = yield this.getNodeVersion();192 result.npmVer = yield this.getNpmVersion();193 result.nodeGypVer = yield this.getNodeGypVersion();194 result.dotNetVer = yield this.hostInfo.dotNetVersion();195 result.javaVer = yield this.getJavaVersion();196 result.javacVersion = yield this.getJavaCompilerVersion();197 result.xcodeVer = yield this.getXcodeVersion();198 result.xcodeprojGemLocation = yield this.getXcodeprojGemLocation();199 result.itunesInstalled = yield this.isITunesInstalled();200 result.cocoaPodsVer = yield this.getCocoaPodsVersion();201 result.adbVer = yield this.getAdbVersion();202 result.androidInstalled = yield this.isAndroidInstalled();203 result.monoVer = yield this.getMonoVersion();204 result.gitVer = yield this.getGitVersion();205 result.gradleVer = yield this.getGradleVersion();206 result.isCocoaPodsWorkingCorrectly = yield this.isCocoaPodsWorkingCorrectly();207 result.nativeScriptCliVersion = yield this.getNativeScriptCliVersion();208 result.nativeScriptCloudVersion = yield this.getNativeScriptCloudVersion();209 result.isCocoaPodsUpdateRequired = yield this.isCocoaPodsUpdateRequired();210 result.isAndroidSdkConfiguredCorrectly = yield this.isAndroidSdkConfiguredCorrectly();211 return result;212 }));213 }214 isCocoaPodsWorkingCorrectly() {215 return this.getValueForProperty(() => this.isCocoaPodsWorkingCorrectlyCache, () => __awaiter(this, void 0, void 0, function* () {216 if (this.hostInfo.isDarwin) {217 temp.track();218 const tempDirectory = temp.mkdirSync("nativescript-check-cocoapods");219 const pathToXCodeProjectZip = path.join(__dirname, "..", "resources", "cocoapods-verification", "cocoapods.zip");220 yield this.fileSystem.extractZip(pathToXCodeProjectZip, tempDirectory);221 const xcodeProjectDir = path.join(tempDirectory, "cocoapods");222 try {223 let spawnResult = yield this.childProcess.spawnFromEvent("pod", ["install"], "exit", { spawnOptions: { cwd: xcodeProjectDir } });224 if (spawnResult.exitCode) {225 return false;226 }227 else {228 return yield this.fileSystem.exists(path.join(xcodeProjectDir, "cocoapods.xcworkspace"));229 }230 }231 catch (err) {232 return null;233 }234 }235 else {236 return false;237 }238 }));239 }240 getNativeScriptCliVersion() {241 return this.getValueForProperty(() => this.nativeScriptCliVersionCache, () => __awaiter(this, void 0, void 0, function* () {242 const output = yield this.execCommand("tns --version");243 return output ? output.trim() : output;244 }));245 }246 getNativeScriptCloudVersion() {247 return this.getValueForProperty(() => this.nativeScriptCloudVersionCache, () => __awaiter(this, void 0, void 0, function* () {248 const output = yield this.execCommand("tns cloud lib version");249 return output ? this.getVersionFromString(output.trim()) : output;250 }));251 }252 getXcprojInfo() {253 return this.getValueForProperty(() => this.xcprojInfoCache, () => __awaiter(this, void 0, void 0, function* () {254 const cocoaPodsVersion = yield this.getCocoaPodsVersion();255 const xcodeVersion = yield this.getXcodeVersion();256 const shouldUseXcproj = cocoaPodsVersion && !!(semver.lt(cocoaPodsVersion, "1.0.0") && semver.gte(xcodeVersion, "7.3.0"));257 let xcprojAvailable;258 if (shouldUseXcproj) {259 xcprojAvailable = !!(yield this.exec("xcproj --version"));260 }261 return { shouldUseXcproj, xcprojAvailable };262 }));263 }264 isCocoaPodsUpdateRequired() {265 return this.getValueForProperty(() => this.isCocoaPodsUpdateRequiredCache, () => __awaiter(this, void 0, void 0, function* () {266 let xcprojInfo = yield this.getXcprojInfo();267 if (xcprojInfo.shouldUseXcproj && !xcprojInfo.xcprojAvailable) {268 return true;269 }270 else {271 return false;272 }273 }));274 }275 setShouldCacheSysInfo(shouldCache) {276 this.shouldCache = shouldCache;277 }278 getGitPath() {279 return this.hostInfo.isWindows ? this.findGitWin32() : this.findGitUnix();280 }281 findGitWin32() {282 return __awaiter(this, void 0, void 0, function* () {283 let result;284 const win32Paths = [process.env["ProgramFiles"], process.env["ProgramFiles(x86)"]];285 for (const win32Path of win32Paths) {286 result = this.findSystemGitWin32(win32Path);287 if (result) {288 return result;289 }290 }291 result = this.findGitHubGitWin32();292 return result ? result : yield this.findGitCore("where");293 });294 }295 findSystemGitWin32(base) {296 if (!base) {297 return null;298 }299 return this.findSpecificGit(path.join(base, "Git", "cmd", "git.exe"));300 }301 findGitHubGitWin32() {302 const github = path.join(process.env["LOCALAPPDATA"], "GitHub");303 if (!this.fileSystem.exists(github)) {304 return null;305 }306 const children = this.fileSystem.readDirectory(github);307 const git = children.filter(child => /^PortableGit/.test(child))[0];308 if (!this.fileSystem.exists(git)) {309 return null;310 }311 return this.findSpecificGit(path.join(github, git, "cmd", "git.exe"));312 }313 findSpecificGit(gitPath) {314 return this.fileSystem.exists(gitPath) ? gitPath : null;315 }316 findGitUnix() {317 return __awaiter(this, void 0, void 0, function* () {318 return yield this.findGitCore("which");319 });320 }321 findGitCore(command, options) {322 return __awaiter(this, void 0, void 0, function* () {323 const result = yield this.execCommand(`${command} git`);324 return result && result.split("\n")[0].trim();325 });326 }327 getValueForProperty(property, getValueMethod) {328 return __awaiter(this, void 0, void 0, function* () {329 if (this.shouldCache) {330 const propertyName = this.helpers.getPropertyName(property);331 const cachedValue = this[propertyName];332 if (cachedValue === undefined) {333 const result = yield getValueMethod();334 this[propertyName] = result;335 return result;336 }337 else {338 return cachedValue;339 }340 }341 else {
...
ReviewForm.js
Source:ReviewForm.js
...24 }25 onChangeOther(value) {26 this.props.editActiveCase(`evaluation_description_other`, value);27 }28 getValueForProperty(property) {29 if(this.props.caseEdited && this.props.caseEdited.data.hasOwnProperty(property)) {30 return this.props.caseEdited.data[property];31 } else if(this.props.case && this.props.case.data.hasOwnProperty(property)) {32 return this.props.case.data[property];33 } else {34 return "";35 }36 }37 render() {38 if (this.props.case) {39 if (40 (this.props.case && this.props.case.status === LpisCaseStatuses.CREATED.database)41 && (this.props.userGroup === 'gisatUsers' || this.props.userGroup === 'gisatAdmins')42 ) {43 return (44 <div>45 <EditableText46 value={this.getValueForProperty(`evaluation_description`)}47 disabled={!(this.props.userGroup && this.props.userGroup.toLowerCase().includes("gisat"))}48 editing={(this.props.userGroup && this.props.userGroup.toLowerCase().includes("gisat"))}49 onChange={this.onChangeDescription}50 onFocus={this.props.onFocusInput}51 onBlur={this.props.onBlurInput}52 inverted53 />54 <label>55 <span>DalÅ¡Ã komentáÅ</span>56 <EditableText57 value={this.getValueForProperty(`evaluation_description_other`)}58 disabled={!(this.props.userGroup && this.props.userGroup.toLowerCase().includes("gisat"))}59 editing={(this.props.userGroup && this.props.userGroup.toLowerCase().includes("gisat"))}60 onChange={this.onChangeOther}61 onFocus={this.props.onFocusInput}62 onBlur={this.props.onBlurInput}63 inverted64 />65 </label>66 </div>67 );68 } else if (this.props.case.status !== LpisCaseStatuses.EVALUATION_CREATED) {69 let otherInsert, userInsert;70 if (this.getValueForProperty(`evaluation_description_other`)) {71 otherInsert = (72 <div>73 <div className='ptr-dromasLpisChangeReviewHeader-property'>DalÅ¡Ã komentáÅ</div>74 {utils.renderParagraphWithSeparatedLines(this.getValueForProperty(`evaluation_description_other`))}75 </div>76 );77 }78 if (this.props.userApprovedEvaluation){79 let user = this.props.userApprovedEvaluation;80 userInsert = (81 <div>82 <div className='ptr-dromasLpisChangeReviewHeader-property'>Vyhodnocenà schválil</div>83 <p>{user.name} ({user.email})</p>84 </div>85 );86 }87 return (88 <div>89 {utils.renderParagraphWithSeparatedLines(this.getValueForProperty(`evaluation_description`))}90 {otherInsert}91 {userInsert}92 </div>93 );94 }95 } else {96 return null;97 }98 }99}...
AssetManager.js
Source:AssetManager.js
1define(['postal', 'InternalScene'], function (bus, internalScene) {2 var source = "Efficio Asset Manager"3 function CreateAsset(asset) {4 bus.publish({5 channel: "UserNotification",6 topic: "AssetCreated",7 source: source,8 data: {9 message: "Asset created with data: " + asset10 }11 });12 internalScene.Scene.add(asset);13 };14 function CreateAssets(assets) {15 };16 function RetrieveAsset(assetID) {17 };18 function RetrieveAssets(assetIDs) {19 };20 function RetrieveAllAssets() {21 };22 function RetrieveAllAssetIDs() {23 };24 function UpdateAsset(asset) {25 var oldAsset = internalScene.Scene.getObjectById(asset.id);26 internalScene.Scene.remove(oldAsset);27 internalScene.Scene.add(asset);28 asset = internalScene.Scene.getObjectById(asset.id);29 bus.publish({30 channel: "UserNotification",31 topic: "AssetUpdated",32 source: source,33 data: {34 message: source + " - Asset Updated: \nID: " + asset.id + "\nPosition: (" + asset.position.x + " , " + asset.position.y + ", " + asset.position.z + ")" + "\nScale: (" + asset.scale.x + " , " + asset.scale.y + ", " + asset.scale.z + ")"35 }36 });37 };38 function UpdateAssets(assets) {39 };40 function DeleteAsset(assetID) {41 };42 function DeleteAssets(assetIDs) {43 };44 function DeleteAllAssets() {45 };46 function GetValueForProperty(property, data) {47 switch (property) {48 case "ClosestAsset":49 {50 return GetClosestAsset(data);51 }52 }53 }54 function GetClosestAsset(data) {55 if (data.location === null) {56 bus.publish({57 channel: "Exception.Efficio",58 topic: "GetClosestAsset",59 source: source,60 data: {61 message: "GetClosestAsset function requires location argument"62 }63 });64 }65 return "Asset closest to point (" + data.Location.x + ", " + data.Location.y + ", " + data.Location.z + ")"66 }67 return {68 Initialize: function () {69 if (typeof window != 'undefined') {70 //var http = new XMLHttpRequest();71 //http.open('HEAD', '/debug.html', false);72 //http.send();73 //if (http.status != 404) {74 // var params = [75 // 'height=' + screen.height,76 // 'width=' + screen.width,77 // 'fullscreen=yes' // only works in IE, but here for completeness78 // ].join(',');79 // window.open('/debug.html', 'AMI Debugger', params);80 //}81 }82 },83 CreateAsset: CreateAsset,84 CreateAssets: CreateAssets,85 RetrieveAsset: RetrieveAsset,86 RetrieveAssets: RetrieveAssets,87 RetrieveAllAssets: RetrieveAllAssets,88 RetrieveAllAssetIDs: RetrieveAllAssetIDs,89 UpdateAsset: UpdateAsset,90 UpdateAssets: UpdateAssets,91 DeleteAsset: DeleteAsset,92 DeleteAssets: DeleteAssets,93 DeleteAllAssets: DeleteAllAssets,94 GetValueForProperty: GetValueForProperty,95 }...
panel.js
Source:panel.js
...71 72 jQuery.each(object, function(propertyName, propertyValue)73 {74 var element = form.find("#" + propertyName);75 var value = myself.getValueForProperty(propertyName, propertyValue);76 element.val(value);77 });78};79Panel.prototype.getValueForProperty = function(propertyName, propertyValue)80{81 return propertyValue;82};83Panel.prototype.open = function(title)84{85 var container = jQuery(this.parent);86 87 container.dialog88 (89 {...
download-config.js
Source:download-config.js
...12 'rt-profile-{retweeted_status.user.id}';13saveKeyTemplates[twitterProperties.linkedSiteImage] = 'preview-{id_str}';14saveKeyTemplates[twitterProperties.uploadedMedia] = 'photo-{id_str}';15saveKeyTemplates[twitterProperties.retweetedUploadedMedia] = 'retweeted-photo-{id_str}';16function getValueForProperty(tweet, property) {17 return get(tweet, property, '');18}19function getSaveKey(tweet, saveKeyTemplate) {20 if (!saveKeyTemplate.includes('{') || !saveKeyTemplate.includes('}'))21 return saveKeyTemplate;22 const curlyBracketStartParts = saveKeyTemplate.split('{');23 const prefix = curlyBracketStartParts[0];24 const curlyBracketEndParts = curlyBracketStartParts[1].split('}');25 const toReplace = curlyBracketEndParts[0];26 const value = getValueForProperty(tweet, toReplace);27 return prefix + value;28}29module.exports = {30 twitterProperties,31 saveKeyTemplates,32 getSaveKey,33 getValueForProperty,...
holiday-panel.js
Source:holiday-panel.js
...48 result = this.getDateAsYYYYMMDD(date);49 }50 else51 {52 result = this._super.getValueForProperty(propertyName, propertyValue);53 }54 55 return result;...
create-css-translate-string.js
Source:create-css-translate-string.js
1var addUnit = require('./add-unit')2function getValueForProperty(val, prop) {3 if (val.hasOwnProperty(prop)) {4 return val[prop]5 }6 return 07}8function createCssTranslateString(val) {9 var res = []10 // array of values is assumed to be [x,y,(z)]11 if (angular.isArray(val)) {12 if (val.length === 2) {13 res = res.concat(val, 0)14 } else {15 res = val16 }17 } else {18 res.push(getValueForProperty(val, 'x'))19 res.push(getValueForProperty(val, 'y'))20 res.push(getValueForProperty(val, 'z'))21 }22 res = res.map(function (val) {23 return addUnit(val, 'px')24 })25 return 'translate3d(' + res.join(',') + ')'26}...
Using AI Code Generation
1const { getValueForProperty } = require('playwright/lib/internal/inspectorInstrumentation');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.waitForTimeout(1000);8 const input = await page.$('input[name="q"]');9 const value = await getValueForProperty(input, 'value');10 console.log(value);11 await browser.close();12})();13const { getValueForProperty } = require('playwright/lib/internal/inspectorInstrumentation');14const { chromium } = require('playwright');15(async () => {16 const browser = await chromium.launch();17 const context = await browser.newContext();18 const page = await context.newPage();19 await page.waitForTimeout(1000);20 const input = await page.$('input[name="q"]');21 const value = await getValueForProperty(input, 'value');22 console.log(value);23 await browser.close();24})();25const { getValueForProperty } = require('playwright/lib/internal/inspectorInstrumentation');26const { chromium } = require('playwright');27(async () => {28 const browser = await chromium.launch();29 const context = await browser.newContext();30 const page = await context.newPage();31 await page.waitForTimeout(1000);32 const input = await page.$('input[name="q"]');
Using AI Code Generation
1const {getValueForProperty} = require("playwright/lib/utils/utils");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 const title = await page.evaluate(() => document.title);8 console.log(getValueForProperty(title, "length"));9 await browser.close();10})();11const {chromium} = require("playwright");12(async () => {13 const browser = await chromium.launch();14 const context = await browser.newContext();15 const page = await context.newPage();16 const title = await page.evaluate(() => document.title);17 await browser.close();18})();
Using AI Code Generation
1const { getValueForProperty } = require('playwright/lib/server/dom');2const { parseSelector } = require('playwright/lib/server/selectors/selectorEngine');3const { Page } = require('playwright/lib/server/page');4const { JSHandle } = require('playwright/lib/server/jsHandle');5const elementHandle = await page.$(selector);6const parsedSelector = parseSelector(selector);7const pageObject = (await elementHandle.executionContext()).frame.page;8const value = await getValueForProperty(pageObject, elementHandle, parsedSelector, propertyName);9const { setValueForProperty } = require('playwright/lib/server/dom');10const { parseSelector } = require('playwright/lib/server/selectors/selectorEngine');11const { Page } = require('playwright/lib/server/page');12const { JSHandle } = require('playwright/lib/server/jsHandle');13const elementHandle = await page.$(selector);14const parsedSelector = parseSelector(selector);15const pageObject = (await elementHandle.executionContext()).frame.page;16await setValueForProperty(pageObject, elementHandle, parsedSelector, propertyName, value);17const { getAttribute } = require('playwright/lib/server/dom');18const { parseSelector } = require('playwright/lib/server/selectors/selectorEngine');19const { Page } = require('playwright/lib/server/page');20const { JSHandle } = require('playwright/lib/server/jsHandle');21const elementHandle = await page.$(selector);22const parsedSelector = parseSelector(selector);23const pageObject = (await elementHandle.executionContext()).frame.page;24const value = await getAttribute(pageObject, elementHandle, parsedSelector, attributeName);25const { setAttribute } = require('playwright/lib/server/dom');26const { parseSelector } = require('playwright/lib/server/selectors/selectorEngine');27const { Page } = require('playwright/lib/server/page');28const { JSHandle } =
Using AI Code Generation
1const { getValueForProperty } = require('playwright/lib/client/selectorEngine');2const { expect } = require('chai');3const { test, expect } = require('@playwright/test');4test('test', async ({ page }) => {5 const elementHandle = await page.$('text=Get Started');6 const value = await getValueForProperty(elementHandle, 'href');7});8const { waitForValueForProperty } = require('playwright/lib/client/selectorEngine');9const { expect } = require('chai');10const { test, expect } = require('@playwright/test');11test('test', async ({ page }) => {12 const elementHandle = await page.$('text=Get Started');13});14const locator = await page.$('css=div.some-class');15#### locator.asElement()16#### locator.asElementHandle()17#### locator.check(options)
Using AI Code Generation
1const { getValueForProperty } = require('@playwright/test/lib/server/frames');2const elementHandle = await page.$('div');3const value = await getValueForProperty(elementHandle, 'innerHTML');4console.log(value);5const { setValueForProperty } = require('@playwright/test/lib/server/frames');6const elementHandle = await page.$('div');7await setValueForProperty(elementHandle, 'innerHTML', 'Hello World');8const { getTextContent } = require('@playwright/test/lib/server/frames');9const elementHandle = await page.$('div');10const textContent = await getTextContent(elementHandle);11console.log(textContent);12const { getInputValue } = require('@playwright/test/lib/server/frames');13const elementHandle = await page.$('input');14const inputValue = await getInputValue(elementHandle);15console.log(inputValue);16const { setInputValue } = require('@playwright/test/lib/server/frames');17const elementHandle = await page.$('input');18await setInputValue(elementHandle, 'Hello World');19const { getBoundingBox } = require('@playwright/test/lib/server/frames');20const elementHandle = await page.$('div');21const boundingBox = await getBoundingBox(elementHandle);22console.log(boundingBox);23const { getContentFrame } = require('@playwright/test/lib/server/frames');24const elementHandle = await page.$('iframe');
Using AI Code Generation
1const { getValueForProperty } = require('playwright/lib/server/dom.js');2const element = await page.$('body');3const value = getValueForProperty(element, 'innerText');4console.log(value);5await browser.close();6const value = await page.evaluate(() => {7 return document.body.innerText;8});9console.log(value);10await browser.close();11const value = await page.evaluate(() => {12 return document.querySelector('body').innerText;13});14console.log(value);15await browser.close();16const value = await page.evaluate(() => {17 return document.querySelector('body').innerText;18});19console.log(value);20await browser.close();21const value = await page.evaluate(() => {22 return document.querySelector('body').innerText;23});24console.log(value);25await browser.close();26const value = await page.evaluate(() => {27 return document.querySelector('body').innerText;28});29console.log(value);30await browser.close();31const value = await page.evaluate(() => {32 return document.querySelector('body').innerText;33});34console.log(value);35await browser.close();36const value = await page.evaluate(() => {37 return document.querySelector('body').innerText;38});39console.log(value);40await browser.close()
Using AI Code Generation
1const { getValueForProperty } = require('playwright/lib/server/dom.js');2const value = await getValueForProperty(page, elementHandle, 'value');3console.log(value);4const { evaluateHandle } = require('playwright/lib/server/dom.js');5const value = await evaluateHandle(page, elementHandle, 'value');6console.log(value);
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!!