How to use platform method in taiko

Best JavaScript code snippet using taiko

CharacterMotor.js

Source:CharacterMotor.js Github

copy

Full Screen

1#pragma strict2#pragma implicit3#pragma downcast4// Does this script currently respond to input?5var canControl : boolean = true;6var useFixedUpdate : boolean = true;7// For the next variables, @System.NonSerialized tells Unity to not serialize the variable or show it in the inspector view.8// Very handy for organization!9// The current global direction we want the character to move in.10@System.NonSerialized11var inputMoveDirection : Vector3 = Vector3.zero;12// Is the jump button held down? We use this interface instead of checking13// for the jump button directly so this script can also be used by AIs.14@System.NonSerialized15var inputJump : boolean = false;16class CharacterMotorMovement {17 // The maximum horizontal speed when moving18 var maxForwardSpeed : float = 10.0;19 var maxSidewaysSpeed : float = 10.0;20 var maxBackwardsSpeed : float = 10.0;21 22 // Curve for multiplying speed based on slope (negative = downwards)23 var slopeSpeedMultiplier : AnimationCurve = AnimationCurve(Keyframe(-90, 1), Keyframe(0, 1), Keyframe(90, 0));24 25 // How fast does the character change speeds? Higher is faster.26 var maxGroundAcceleration : float = 30.0;27 var maxAirAcceleration : float = 20.0;28 // The gravity for the character29 var gravity : float = 10.0;30 var maxFallSpeed : float = 20.0;31 32 // For the next variables, @System.NonSerialized tells Unity to not serialize the variable or show it in the inspector view.33 // Very handy for organization!34 // The last collision flags returned from controller.Move35 @System.NonSerialized36 var collisionFlags : CollisionFlags; 37 // We will keep track of the character's current velocity,38 @System.NonSerialized39 var velocity : Vector3;40 41 // This keeps track of our current velocity while we're not grounded42 @System.NonSerialized43 var frameVelocity : Vector3 = Vector3.zero;44 45 @System.NonSerialized46 var hitPoint : Vector3 = Vector3.zero;47 48 @System.NonSerialized49 var lastHitPoint : Vector3 = Vector3(Mathf.Infinity, 0, 0);50}51var movement : CharacterMotorMovement = CharacterMotorMovement();52enum MovementTransferOnJump {53 None, // The jump is not affected by velocity of floor at all.54 InitTransfer, // Jump gets its initial velocity from the floor, then gradualy comes to a stop.55 PermaTransfer, // Jump gets its initial velocity from the floor, and keeps that velocity until landing.56 PermaLocked // Jump is relative to the movement of the last touched floor and will move together with that floor.57}58// We will contain all the jumping related variables in one helper class for clarity.59class CharacterMotorJumping {60 // Can the character jump?61 var enabled : boolean = true;62 // How high do we jump when pressing jump and letting go immediately63 var baseHeight : float = 1.0;64 65 // We add extraHeight units (meters) on top when holding the button down longer while jumping66 var extraHeight : float = 4.1;67 68 // How much does the character jump out perpendicular to the surface on walkable surfaces?69 // 0 means a fully vertical jump and 1 means fully perpendicular.70 var perpAmount : float = 0.0;71 72 // How much does the character jump out perpendicular to the surface on too steep surfaces?73 // 0 means a fully vertical jump and 1 means fully perpendicular.74 var steepPerpAmount : float = 0.5;75 76 // For the next variables, @System.NonSerialized tells Unity to not serialize the variable or show it in the inspector view.77 // Very handy for organization!78 // Are we jumping? (Initiated with jump button and not grounded yet)79 // To see if we are just in the air (initiated by jumping OR falling) see the grounded variable.80 @System.NonSerialized81 var jumping : boolean = false;82 83 @System.NonSerialized84 var holdingJumpButton : boolean = false;85 // the time we jumped at (Used to determine for how long to apply extra jump power after jumping.)86 @System.NonSerialized87 var lastStartTime : float = 0.0;88 89 @System.NonSerialized90 var lastButtonDownTime : float = -100;91 92 @System.NonSerialized93 var jumpDir : Vector3 = Vector3.up;94}95var jumping : CharacterMotorJumping = CharacterMotorJumping();96class CharacterMotorMovingPlatform {97 var enabled : boolean = true;98 99 var movementTransfer : MovementTransferOnJump = MovementTransferOnJump.PermaTransfer;100 101 @System.NonSerialized102 var hitPlatform : Transform;103 104 @System.NonSerialized105 var activePlatform : Transform;106 107 @System.NonSerialized108 var activeLocalPoint : Vector3;109 110 @System.NonSerialized111 var activeGlobalPoint : Vector3;112 113 @System.NonSerialized114 var activeLocalRotation : Quaternion;115 116 @System.NonSerialized117 var activeGlobalRotation : Quaternion;118 119 @System.NonSerialized120 var lastMatrix : Matrix4x4;121 122 @System.NonSerialized123 var platformVelocity : Vector3;124 125 @System.NonSerialized126 var newPlatform : boolean;127}128var movingPlatform : CharacterMotorMovingPlatform = CharacterMotorMovingPlatform();129class CharacterMotorSliding {130 // Does the character slide on too steep surfaces?131 var enabled : boolean = true;132 133 // How fast does the character slide on steep surfaces?134 var slidingSpeed : float = 15;135 136 // How much can the player control the sliding direction?137 // If the value is 0.5 the player can slide sideways with half the speed of the downwards sliding speed.138 var sidewaysControl : float = 1.0;139 140 // How much can the player influence the sliding speed?141 // If the value is 0.5 the player can speed the sliding up to 150% or slow it down to 50%.142 var speedControl : float = 0.4;143}144var sliding : CharacterMotorSliding = CharacterMotorSliding();145@System.NonSerialized146var grounded : boolean = true;147@System.NonSerialized148var groundNormal : Vector3 = Vector3.zero;149private var lastGroundNormal : Vector3 = Vector3.zero;150private var tr : Transform;151private var controller : CharacterController;152function Awake () {153 controller = GetComponent (CharacterController);154 tr = transform;155}156private function UpdateFunction () {157 // We copy the actual velocity into a temporary variable that we can manipulate.158 var velocity : Vector3 = movement.velocity;159 160 // Update velocity based on input161 velocity = ApplyInputVelocityChange(velocity);162 163 // Apply gravity and jumping force164 velocity = ApplyGravityAndJumping (velocity);165 166 // Moving platform support167 var moveDistance : Vector3 = Vector3.zero;168 if (MoveWithPlatform()) {169 var newGlobalPoint : Vector3 = movingPlatform.activePlatform.TransformPoint(movingPlatform.activeLocalPoint);170 moveDistance = (newGlobalPoint - movingPlatform.activeGlobalPoint);171 if (moveDistance != Vector3.zero)172 controller.Move(moveDistance);173 174 // Support moving platform rotation as well:175 var newGlobalRotation : Quaternion = movingPlatform.activePlatform.rotation * movingPlatform.activeLocalRotation;176 var rotationDiff : Quaternion = newGlobalRotation * Quaternion.Inverse(movingPlatform.activeGlobalRotation);177 178 var yRotation = rotationDiff.eulerAngles.y;179 if (yRotation != 0) {180 // Prevent rotation of the local up vector181 tr.Rotate(0, yRotation, 0);182 }183 }184 185 // Save lastPosition for velocity calculation.186 var lastPosition : Vector3 = tr.position;187 188 // We always want the movement to be framerate independent. Multiplying by Time.deltaTime does this.189 var currentMovementOffset : Vector3 = velocity * Time.deltaTime;190 191 // Find out how much we need to push towards the ground to avoid loosing grouning192 // when walking down a step or over a sharp change in slope.193 var pushDownOffset : float = Mathf.Max(controller.stepOffset, Vector3(currentMovementOffset.x, 0, currentMovementOffset.z).magnitude);194 if (grounded)195 currentMovementOffset -= pushDownOffset * Vector3.up;196 197 // Reset variables that will be set by collision function198 movingPlatform.hitPlatform = null;199 groundNormal = Vector3.zero;200 201 // Move our character!202 movement.collisionFlags = controller.Move (currentMovementOffset);203 204 movement.lastHitPoint = movement.hitPoint;205 lastGroundNormal = groundNormal;206 207 if (movingPlatform.enabled && movingPlatform.activePlatform != movingPlatform.hitPlatform) {208 if (movingPlatform.hitPlatform != null) {209 movingPlatform.activePlatform = movingPlatform.hitPlatform;210 movingPlatform.lastMatrix = movingPlatform.hitPlatform.localToWorldMatrix;211 movingPlatform.newPlatform = true;212 }213 }214 215 // Calculate the velocity based on the current and previous position. 216 // This means our velocity will only be the amount the character actually moved as a result of collisions.217 var oldHVelocity : Vector3 = new Vector3(velocity.x, 0, velocity.z);218 movement.velocity = (tr.position - lastPosition) / Time.deltaTime;219 var newHVelocity : Vector3 = new Vector3(movement.velocity.x, 0, movement.velocity.z);220 221 // The CharacterController can be moved in unwanted directions when colliding with things.222 // We want to prevent this from influencing the recorded velocity.223 if (oldHVelocity == Vector3.zero) {224 movement.velocity = new Vector3(0, movement.velocity.y, 0);225 }226 else {227 var projectedNewVelocity : float = Vector3.Dot(newHVelocity, oldHVelocity) / oldHVelocity.sqrMagnitude;228 movement.velocity = oldHVelocity * Mathf.Clamp01(projectedNewVelocity) + movement.velocity.y * Vector3.up;229 }230 231 if (movement.velocity.y < velocity.y - 0.001) {232 if (movement.velocity.y < 0) {233 // Something is forcing the CharacterController down faster than it should.234 // Ignore this235 movement.velocity.y = velocity.y;236 }237 else {238 // The upwards movement of the CharacterController has been blocked.239 // This is treated like a ceiling collision - stop further jumping here.240 jumping.holdingJumpButton = false;241 }242 }243 244 // We were grounded but just loosed grounding245 if (grounded && !IsGroundedTest()) {246 grounded = false;247 248 // Apply inertia from platform249 if (movingPlatform.enabled &&250 (movingPlatform.movementTransfer == MovementTransferOnJump.InitTransfer ||251 movingPlatform.movementTransfer == MovementTransferOnJump.PermaTransfer)252 ) {253 movement.frameVelocity = movingPlatform.platformVelocity;254 movement.velocity += movingPlatform.platformVelocity;255 }256 257 SendMessage("OnFall", SendMessageOptions.DontRequireReceiver);258 // We pushed the character down to ensure it would stay on the ground if there was any.259 // But there wasn't so now we cancel the downwards offset to make the fall smoother.260 tr.position += pushDownOffset * Vector3.up;261 }262 // We were not grounded but just landed on something263 else if (!grounded && IsGroundedTest()) {264 grounded = true;265 jumping.jumping = false;266 SubtractNewPlatformVelocity();267 268 SendMessage("OnLand", SendMessageOptions.DontRequireReceiver);269 }270 271 // Moving platforms support272 if (MoveWithPlatform()) {273 // Use the center of the lower half sphere of the capsule as reference point.274 // This works best when the character is standing on moving tilting platforms. 275 movingPlatform.activeGlobalPoint = tr.position + Vector3.up * (controller.center.y - controller.height*0.5 + controller.radius);276 movingPlatform.activeLocalPoint = movingPlatform.activePlatform.InverseTransformPoint(movingPlatform.activeGlobalPoint);277 278 // Support moving platform rotation as well:279 movingPlatform.activeGlobalRotation = tr.rotation;280 movingPlatform.activeLocalRotation = Quaternion.Inverse(movingPlatform.activePlatform.rotation) * movingPlatform.activeGlobalRotation; 281 }282}283function FixedUpdate () {284 if (movingPlatform.enabled) {285 if (movingPlatform.activePlatform != null) {286 if (!movingPlatform.newPlatform) {287 var lastVelocity : Vector3 = movingPlatform.platformVelocity;288 289 movingPlatform.platformVelocity = (290 movingPlatform.activePlatform.localToWorldMatrix.MultiplyPoint3x4(movingPlatform.activeLocalPoint)291 - movingPlatform.lastMatrix.MultiplyPoint3x4(movingPlatform.activeLocalPoint)292 ) / Time.deltaTime;293 }294 movingPlatform.lastMatrix = movingPlatform.activePlatform.localToWorldMatrix;295 movingPlatform.newPlatform = false;296 }297 else {298 movingPlatform.platformVelocity = Vector3.zero; 299 }300 }301 302 if (useFixedUpdate)303 UpdateFunction();304}305function Update () {306 if (!useFixedUpdate)307 UpdateFunction();308}309private function ApplyInputVelocityChange (velocity : Vector3) { 310 if (!canControl)311 inputMoveDirection = Vector3.zero;312 313 // Find desired velocity314 var desiredVelocity : Vector3;315 if (grounded && TooSteep()) {316 // The direction we're sliding in317 desiredVelocity = Vector3(groundNormal.x, 0, groundNormal.z).normalized;318 // Find the input movement direction projected onto the sliding direction319 var projectedMoveDir = Vector3.Project(inputMoveDirection, desiredVelocity);320 // Add the sliding direction, the spped control, and the sideways control vectors321 desiredVelocity = desiredVelocity + projectedMoveDir * sliding.speedControl + (inputMoveDirection - projectedMoveDir) * sliding.sidewaysControl;322 // Multiply with the sliding speed323 desiredVelocity *= sliding.slidingSpeed;324 }325 else326 desiredVelocity = GetDesiredHorizontalVelocity();327 328 if (movingPlatform.enabled && movingPlatform.movementTransfer == MovementTransferOnJump.PermaTransfer) {329 desiredVelocity += movement.frameVelocity;330 desiredVelocity.y = 0;331 }332 333 if (grounded)334 desiredVelocity = AdjustGroundVelocityToNormal(desiredVelocity, groundNormal);335 else336 velocity.y = 0;337 338 // Enforce max velocity change339 var maxVelocityChange : float = GetMaxAcceleration(grounded) * Time.deltaTime;340 var velocityChangeVector : Vector3 = (desiredVelocity - velocity);341 if (velocityChangeVector.sqrMagnitude > maxVelocityChange * maxVelocityChange) {342 velocityChangeVector = velocityChangeVector.normalized * maxVelocityChange;343 }344 // If we're in the air and don't have control, don't apply any velocity change at all.345 // If we're on the ground and don't have control we do apply it - it will correspond to friction.346 if (grounded || canControl)347 velocity += velocityChangeVector;348 349 if (grounded) {350 // When going uphill, the CharacterController will automatically move up by the needed amount.351 // Not moving it upwards manually prevent risk of lifting off from the ground.352 // When going downhill, DO move down manually, as gravity is not enough on steep hills.353 velocity.y = Mathf.Min(velocity.y, 0);354 }355 356 return velocity;357}358private function ApplyGravityAndJumping (velocity : Vector3) {359 360 if (!inputJump || !canControl) {361 jumping.holdingJumpButton = false;362 jumping.lastButtonDownTime = -100;363 }364 365 if (inputJump && jumping.lastButtonDownTime < 0 && canControl)366 jumping.lastButtonDownTime = Time.time;367 368 if (grounded)369 velocity.y = Mathf.Min(0, velocity.y) - movement.gravity * Time.deltaTime;370 else {371 velocity.y = movement.velocity.y - movement.gravity * Time.deltaTime;372 373 // When jumping up we don't apply gravity for some time when the user is holding the jump button.374 // This gives more control over jump height by pressing the button longer.375 if (jumping.jumping && jumping.holdingJumpButton) {376 // Calculate the duration that the extra jump force should have effect.377 // If we're still less than that duration after the jumping time, apply the force.378 if (Time.time < jumping.lastStartTime + jumping.extraHeight / CalculateJumpVerticalSpeed(jumping.baseHeight)) {379 // Negate the gravity we just applied, except we push in jumpDir rather than jump upwards.380 velocity += jumping.jumpDir * movement.gravity * Time.deltaTime;381 }382 }383 384 // Make sure we don't fall any faster than maxFallSpeed. This gives our character a terminal velocity.385 velocity.y = Mathf.Max (velocity.y, -movement.maxFallSpeed);386 }387 388 if (grounded) {389 // Jump only if the jump button was pressed down in the last 0.2 seconds.390 // We use this check instead of checking if it's pressed down right now391 // because players will often try to jump in the exact moment when hitting the ground after a jump392 // and if they hit the button a fraction of a second too soon and no new jump happens as a consequence,393 // it's confusing and it feels like the game is buggy.394 if (jumping.enabled && canControl && (Time.time - jumping.lastButtonDownTime < 0.2)) {395 grounded = false;396 jumping.jumping = true;397 jumping.lastStartTime = Time.time;398 jumping.lastButtonDownTime = -100;399 jumping.holdingJumpButton = true;400 401 // Calculate the jumping direction402 if (TooSteep())403 jumping.jumpDir = Vector3.Slerp(Vector3.up, groundNormal, jumping.steepPerpAmount);404 else405 jumping.jumpDir = Vector3.Slerp(Vector3.up, groundNormal, jumping.perpAmount);406 407 // Apply the jumping force to the velocity. Cancel any vertical velocity first.408 velocity.y = 0;409 velocity += jumping.jumpDir * CalculateJumpVerticalSpeed (jumping.baseHeight);410 411 // Apply inertia from platform412 if (movingPlatform.enabled &&413 (movingPlatform.movementTransfer == MovementTransferOnJump.InitTransfer ||414 movingPlatform.movementTransfer == MovementTransferOnJump.PermaTransfer)415 ) {416 movement.frameVelocity = movingPlatform.platformVelocity;417 velocity += movingPlatform.platformVelocity;418 }419 420 SendMessage("OnJump", SendMessageOptions.DontRequireReceiver);421 }422 else {423 jumping.holdingJumpButton = false;424 }425 }426 427 return velocity;428}429function OnControllerColliderHit (hit : ControllerColliderHit) {430 if (hit.normal.y > 0 && hit.normal.y > groundNormal.y && hit.moveDirection.y < 0) {431 if ((hit.point - movement.lastHitPoint).sqrMagnitude > 0.001 || lastGroundNormal == Vector3.zero)432 groundNormal = hit.normal;433 else434 groundNormal = lastGroundNormal;435 436 movingPlatform.hitPlatform = hit.collider.transform;437 movement.hitPoint = hit.point;438 movement.frameVelocity = Vector3.zero;439 }440}441private function SubtractNewPlatformVelocity () {442 // When landing, subtract the velocity of the new ground from the character's velocity443 // since movement in ground is relative to the movement of the ground.444 if (movingPlatform.enabled &&445 (movingPlatform.movementTransfer == MovementTransferOnJump.InitTransfer ||446 movingPlatform.movementTransfer == MovementTransferOnJump.PermaTransfer)447 ) {448 // If we landed on a new platform, we have to wait for two FixedUpdates449 // before we know the velocity of the platform under the character450 if (movingPlatform.newPlatform) {451 var platform : Transform = movingPlatform.activePlatform;452 yield WaitForFixedUpdate();453 yield WaitForFixedUpdate();454 if (grounded && platform == movingPlatform.activePlatform)455 yield 1;456 }457 movement.velocity -= movingPlatform.platformVelocity;458 }459}460private function MoveWithPlatform () : boolean {461 return (462 movingPlatform.enabled463 && (grounded || movingPlatform.movementTransfer == MovementTransferOnJump.PermaLocked)464 && movingPlatform.activePlatform != null465 );466}467private function GetDesiredHorizontalVelocity () {468 // Find desired velocity469 var desiredLocalDirection : Vector3 = tr.InverseTransformDirection(inputMoveDirection);470 var maxSpeed : float = MaxSpeedInDirection(desiredLocalDirection);471 if (grounded) {472 // Modify max speed on slopes based on slope speed multiplier curve473 var movementSlopeAngle = Mathf.Asin(movement.velocity.normalized.y) * Mathf.Rad2Deg;474 maxSpeed *= movement.slopeSpeedMultiplier.Evaluate(movementSlopeAngle);475 }476 return tr.TransformDirection(desiredLocalDirection * maxSpeed);477}478private function AdjustGroundVelocityToNormal (hVelocity : Vector3, groundNormal : Vector3) : Vector3 {479 var sideways : Vector3 = Vector3.Cross(Vector3.up, hVelocity);480 return Vector3.Cross(sideways, groundNormal).normalized * hVelocity.magnitude;481}482private function IsGroundedTest () {483 return (groundNormal.y > 0.01);484}485function GetMaxAcceleration (grounded : boolean) : float {486 // Maximum acceleration on ground and in air487 if (grounded)488 return movement.maxGroundAcceleration;489 else490 return movement.maxAirAcceleration;491}492function CalculateJumpVerticalSpeed (targetJumpHeight : float) {493 // From the jump height and gravity we deduce the upwards speed 494 // for the character to reach at the apex.495 return Mathf.Sqrt (2 * targetJumpHeight * movement.gravity);496}497function IsJumping () {498 return jumping.jumping;499}500function IsSliding () {501 return (grounded && sliding.enabled && TooSteep());502}503function IsTouchingCeiling () {504 return (movement.collisionFlags & CollisionFlags.CollidedAbove) != 0;505}506function IsGrounded () {507 return grounded;508}509function TooSteep () {510 return (groundNormal.y <= Mathf.Cos(controller.slopeLimit * Mathf.Deg2Rad));511}512function GetDirection () {513 return inputMoveDirection;514}515function SetControllable (controllable : boolean) {516 canControl = controllable;517}518// Project a direction onto elliptical quater segments based on forward, sideways, and backwards speed.519// The function returns the length of the resulting vector.520function MaxSpeedInDirection (desiredMovementDirection : Vector3) : float {521 if (desiredMovementDirection == Vector3.zero)522 return 0;523 else {524 var zAxisEllipseMultiplier : float = (desiredMovementDirection.z > 0 ? movement.maxForwardSpeed : movement.maxBackwardsSpeed) / movement.maxSidewaysSpeed;525 var temp : Vector3 = new Vector3(desiredMovementDirection.x, 0, desiredMovementDirection.z / zAxisEllipseMultiplier).normalized;526 var length : float = new Vector3(temp.x, 0, temp.z * zAxisEllipseMultiplier).magnitude * movement.maxSidewaysSpeed;527 return length;528 }529}530function SetVelocity (velocity : Vector3) {531 grounded = false;532 movement.velocity = velocity;533 movement.frameVelocity = Vector3.zero;534 SendMessage("OnExternalVelocity");535}536// Require a character controller to be attached to the same game object537@script RequireComponent (CharacterController)...

Full Screen

Full Screen

Api.js

Source:Api.js Github

copy

Full Screen

1/**2Licensed to the Apache Software Foundation (ASF) under one3or more contributor license agreements. See the NOTICE file4distributed with this work for additional information5regarding copyright ownership. The ASF licenses this file6to you under the Apache License, Version 2.0 (the7'License'); you may not use this file except in compliance8with the License. You may obtain a copy of the License at9http://www.apache.org/licenses/LICENSE-2.010Unless required by applicable law or agreed to in writing,11software distributed under the License is distributed on an12'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13KIND, either express or implied. See the License for the14specific language governing permissions and limitations15under the License.16*/17/*18 this file is found by cordova-lib when you attempt to19 'cordova platform add PATH' where path is this repo.20*/21var shell = require('shelljs');22var path = require('path');23var fs = require('fs');24var cdvcmn = require('cordova-common');25var CordovaLogger = cdvcmn.CordovaLogger;26var ConfigParser = cdvcmn.ConfigParser;27var ActionStack = cdvcmn.ActionStack;28var selfEvents = cdvcmn.events;29var xmlHelpers = cdvcmn.xmlHelpers;30var PlatformJson = cdvcmn.PlatformJson;31var PlatformMunger = cdvcmn.ConfigChanges.PlatformMunger;32var PluginInfoProvider = cdvcmn.PluginInfoProvider;33var BrowserParser = require('./browser_parser');34var PLATFORM_NAME = 'browser';35function setupEvents (externalEventEmitter) {36 if (externalEventEmitter) {37 // This will make the platform internal events visible outside38 selfEvents.forwardEventsTo(externalEventEmitter);39 return externalEventEmitter;40 }41 // There is no logger if external emitter is not present,42 // so attach a console logger43 CordovaLogger.get().subscribe(selfEvents);44 return selfEvents;45}46function Api (platform, platformRootDir, events) {47 this.platform = platform || PLATFORM_NAME;48 // MyApp/platforms/browser49 this.root = path.resolve(__dirname, '..');50 this.events = setupEvents(events);51 this.parser = new BrowserParser(this.root);52 this._handler = require('./browser_handler');53 this.locations = {54 platformRootDir: platformRootDir,55 root: this.root,56 www: path.join(this.root, 'www'),57 res: path.join(this.root, 'res'),58 platformWww: path.join(this.root, 'platform_www'),59 configXml: path.join(this.root, 'config.xml'),60 defaultConfigXml: path.join(this.root, 'cordova/defaults.xml'),61 build: path.join(this.root, 'build'),62 // NOTE: Due to platformApi spec we need to return relative paths here63 cordovaJs: 'bin/templates/project/assets/www/cordova.js',64 cordovaJsSrc: 'cordova-js-src'65 };66 this._platformJson = PlatformJson.load(this.root, platform);67 this._pluginInfoProvider = new PluginInfoProvider();68 this._munger = new PlatformMunger(platform, this.root, this._platformJson, this._pluginInfoProvider);69}70Api.createPlatform = function (dest, config, options, events) {71 var creator = require('../../lib/create');72 events = setupEvents(events);73 var name = 'HelloCordova';74 var id = 'io.cordova.hellocordova';75 if (config) {76 name = config.name();77 id = config.packageName();78 }79 var result;80 try {81 // we create the project using our scripts in this platform82 result = creator.createProject(dest, id, name, options)83 .then(function () {84 // after platform is created we return Api instance based on new Api.js location85 // Api.js has been copied to the new project86 // This is required to correctly resolve paths in the future api calls87 var PlatformApi = require(path.resolve(dest, 'cordova/Api'));88 return new PlatformApi('browser', dest, events);89 });90 } catch (e) {91 events.emit('error', 'createPlatform is not callable from the browser project API.');92 throw (e);93 }94 return result;95};96Api.updatePlatform = function (dest, options, events) {97 // console.log("test-platform:Api:updatePlatform");98 // todo?: create projectInstance and fulfill promise with it.99 return Promise.resolve();100};101Api.prototype.getPlatformInfo = function () {102 // console.log("browser-platform:Api:getPlatformInfo");103 // return PlatformInfo object104 return {105 'locations': this.locations,106 'root': this.root,107 'name': this.platform,108 'version': { 'version': '1.0.0' }, // um, todo!109 'projectConfig': this.config110 };111};112Api.prototype.prepare = function (cordovaProject, options) {113 // First cleanup current config and merge project's one into own114 var defaultConfigPath = path.join(this.locations.platformRootDir, 'cordova',115 'defaults.xml');116 var ownConfigPath = this.locations.configXml;117 var sourceCfg = cordovaProject.projectConfig;118 // If defaults.xml is present, overwrite platform config.xml with it.119 // Otherwise save whatever is there as defaults so it can be120 // restored or copy project config into platform if none exists.121 if (fs.existsSync(defaultConfigPath)) {122 this.events.emit('verbose', 'Generating config.xml from defaults for platform "' + this.platform + '"');123 shell.cp('-f', defaultConfigPath, ownConfigPath);124 } else if (fs.existsSync(ownConfigPath)) {125 this.events.emit('verbose', 'Generating defaults.xml from own config.xml for platform "' + this.platform + '"');126 shell.cp('-f', ownConfigPath, defaultConfigPath);127 } else {128 this.events.emit('verbose', 'case 3"' + this.platform + '"');129 shell.cp('-f', sourceCfg.path, ownConfigPath);130 }131 // merge our configs132 this.config = new ConfigParser(ownConfigPath);133 xmlHelpers.mergeXml(cordovaProject.projectConfig.doc.getroot(),134 this.config.doc.getroot(),135 this.platform, true);136 this.config.write();137 // Update own www dir with project's www assets and plugins' assets and js-files138 this.parser.update_www(cordovaProject, options);139 // Copy or Create manifest.json140 // todo: move this to a manifest helper module141 // output path142 var manifestPath = path.join(this.locations.www, 'manifest.json');143 var srcManifestPath = path.join(cordovaProject.locations.www, 'manifest.json');144 if (fs.existsSync(srcManifestPath)) {145 // just blindly copy it to our output/www146 // todo: validate it? ensure all properties we expect exist?147 this.events.emit('verbose', 'copying ' + srcManifestPath + ' => ' + manifestPath);148 shell.cp('-f', srcManifestPath, manifestPath);149 } else {150 var manifestJson = {151 'background_color': '#FFF',152 'display': 'standalone'153 };154 if (this.config) {155 if (this.config.name()) {156 manifestJson.name = this.config.name();157 }158 if (this.config.shortName()) {159 manifestJson.short_name = this.config.shortName();160 }161 if (this.config.packageName()) {162 manifestJson.version = this.config.packageName();163 }164 if (this.config.description()) {165 manifestJson.description = this.config.description();166 }167 if (this.config.author()) {168 manifestJson.author = this.config.author();169 }170 // icons171 var icons = this.config.getStaticResources('browser', 'icon');172 var manifestIcons = icons.map(function (icon) {173 // given a tag like this :174 // <icon src="res/ios/icon.png" width="57" height="57" density="mdpi" />175 /* configParser returns icons that look like this :176 { src: 'res/ios/icon.png',177 target: undefined,178 density: 'mdpi',179 platform: null,180 width: 57,181 height: 57182 } ******/183 /* manifest expects them to be like this :184 { "src": "images/touch/icon-128x128.png",185 "type": "image/png",186 "sizes": "128x128"187 } ******/188 // ?Is it worth looking at file extentions?189 return {'src': icon.src,190 'type': 'image/png',191 'sizes': (icon.width + 'x' + icon.height)};192 });193 manifestJson.icons = manifestIcons;194 // orientation195 // <preference name="Orientation" value="landscape" />196 var oriPref = this.config.getGlobalPreference('Orientation');197 if (oriPref) {198 // if it's a supported value, use it199 if (['landscape', 'portrait'].indexOf(oriPref) > -1) {200 manifestJson.orientation = oriPref;201 } else { // anything else maps to 'any'202 manifestJson.orientation = 'any';203 }204 }205 // get start_url206 var contentNode = this.config.doc.find('content') || {'attrib': {'src': 'index.html'}}; // sensible default207 manifestJson.start_url = contentNode.attrib.src;208 // now we get some values from start_url page ...209 var startUrlPath = path.join(cordovaProject.locations.www, manifestJson.start_url);210 if (fs.existsSync(startUrlPath)) {211 var contents = fs.readFileSync(startUrlPath, 'utf-8');212 // matches <meta name="theme-color" content="#FF0044">213 var themeColorRegex = /<meta(?=[^>]*name="theme-color")\s[^>]*content="([^>]*)"/i;214 var result = themeColorRegex.exec(contents);215 var themeColor;216 if (result && result.length >= 2) {217 themeColor = result[1];218 } else { // see if there is a preference in config.xml219 // <preference name="StatusBarBackgroundColor" value="#000000" />220 themeColor = this.config.getGlobalPreference('StatusBarBackgroundColor');221 }222 if (themeColor) {223 manifestJson.theme_color = themeColor;224 }225 }226 }227 fs.writeFileSync(manifestPath, JSON.stringify(manifestJson, null, 2), 'utf8');228 }229 // update project according to config.xml changes.230 return this.parser.update_project(this.config, options);231};232Api.prototype.addPlugin = function (pluginInfo, installOptions) {233 // console.log(new Error().stack);234 if (!pluginInfo) {235 return Promise.reject(new Error('The parameter is incorrect. The first parameter ' +236 'should be valid PluginInfo instance'));237 }238 installOptions = installOptions || {};239 installOptions.variables = installOptions.variables || {};240 // CB-10108 platformVersion option is required for proper plugin installation241 installOptions.platformVersion = installOptions.platformVersion ||242 this.getPlatformInfo().version;243 var self = this;244 var actions = new ActionStack();245 var projectFile = this._handler.parseProjectFile && this._handler.parseProjectFile(this.root);246 // gather all files needs to be handled during install247 pluginInfo.getFilesAndFrameworks(this.platform)248 .concat(pluginInfo.getAssets(this.platform))249 .concat(pluginInfo.getJsModules(this.platform))250 .forEach(function (item) {251 actions.push(actions.createAction(252 self._getInstaller(item.itemType),253 [item, pluginInfo.dir, pluginInfo.id, installOptions, projectFile],254 self._getUninstaller(item.itemType),255 [item, pluginInfo.dir, pluginInfo.id, installOptions, projectFile]));256 });257 // run through the action stack258 return actions.process(this.platform, this.root)259 .then(function () {260 if (projectFile) {261 projectFile.write();262 }263 // Add PACKAGE_NAME variable into vars264 if (!installOptions.variables.PACKAGE_NAME) {265 installOptions.variables.PACKAGE_NAME = self._handler.package_name(self.root);266 }267 self._munger268 // Ignore passed `is_top_level` option since platform itself doesn't know269 // anything about managing dependencies - it's responsibility of caller.270 .add_plugin_changes(pluginInfo, installOptions.variables, /* is_top_level= */true, /* should_increment= */true)271 .save_all();272 var targetDir = installOptions.usePlatformWww ?273 self.getPlatformInfo().locations.platformWww :274 self.getPlatformInfo().locations.www;275 self._addModulesInfo(pluginInfo, targetDir);276 });277};278Api.prototype.removePlugin = function (plugin, uninstallOptions) {279 // console.log("NotImplemented :: browser-platform:Api:removePlugin ",plugin, uninstallOptions);280 uninstallOptions = uninstallOptions || {};281 // CB-10108 platformVersion option is required for proper plugin installation282 uninstallOptions.platformVersion = uninstallOptions.platformVersion ||283 this.getPlatformInfo().version;284 var self = this;285 var actions = new ActionStack();286 var projectFile = this._handler.parseProjectFile && this._handler.parseProjectFile(this.root);287 // queue up plugin files288 plugin.getFilesAndFrameworks(this.platform)289 .concat(plugin.getAssets(this.platform))290 .concat(plugin.getJsModules(this.platform))291 .forEach(function (item) {292 actions.push(actions.createAction(293 self._getUninstaller(item.itemType), [item, plugin.dir, plugin.id, uninstallOptions, projectFile],294 self._getInstaller(item.itemType), [item, plugin.dir, plugin.id, uninstallOptions, projectFile]));295 });296 // run through the action stack297 return actions.process(this.platform, this.root)298 .then(function () {299 if (projectFile) {300 projectFile.write();301 }302 self._munger303 // Ignore passed `is_top_level` option since platform itself doesn't know304 // anything about managing dependencies - it's responsibility of caller.305 .remove_plugin_changes(plugin, /* is_top_level= */true)306 .save_all();307 var targetDir = uninstallOptions.usePlatformWww ?308 self.getPlatformInfo().locations.platformWww :309 self.getPlatformInfo().locations.www;310 self._removeModulesInfo(plugin, targetDir);311 // Remove stale plugin directory312 // TODO: this should be done by plugin files uninstaller313 shell.rm('-rf', path.resolve(self.root, 'Plugins', plugin.id));314 });315};316Api.prototype._getInstaller = function (type) {317 var self = this;318 return function (item, plugin_dir, plugin_id, options, project) {319 var installer = self._handler[type];320 if (!installer) {321 console.log('unrecognized type ' + type);322 } else {323 var wwwDest = options.usePlatformWww ?324 self.getPlatformInfo().locations.platformWww :325 self._handler.www_dir(self.root);326 if (type === 'asset') {327 installer.install(item, plugin_dir, wwwDest);328 } else if (type === 'js-module') {329 installer.install(item, plugin_dir, plugin_id, wwwDest);330 } else {331 installer.install(item, plugin_dir, self.root, plugin_id, options, project);332 }333 }334 };335};336Api.prototype._getUninstaller = function (type) {337 var self = this;338 return function (item, plugin_dir, plugin_id, options, project) {339 var installer = self._handler[type];340 if (!installer) {341 console.log('browser plugin uninstall: unrecognized type, skipping : ' + type);342 } else {343 var wwwDest = options.usePlatformWww ?344 self.getPlatformInfo().locations.platformWww :345 self._handler.www_dir(self.root);346 if (['asset', 'js-module'].indexOf(type) > -1) {347 return installer.uninstall(item, wwwDest, plugin_id);348 } else {349 return installer.uninstall(item, self.root, plugin_id, options, project);350 }351 }352 };353};354/**355 * Removes the specified modules from list of installed modules and updates356 * platform_json and cordova_plugins.js on disk.357 *358 * @param {PluginInfo} plugin PluginInfo instance for plugin, which modules359 * needs to be added.360 * @param {String} targetDir The directory, where updated cordova_plugins.js361 * should be written to.362 */363Api.prototype._addModulesInfo = function (plugin, targetDir) {364 var installedModules = this._platformJson.root.modules || [];365 var installedPaths = installedModules.map(function (installedModule) {366 return installedModule.file;367 });368 var modulesToInstall = plugin.getJsModules(this.platform)369 .filter(function (moduleToInstall) {370 return installedPaths.indexOf(moduleToInstall.file) === -1;371 }).map(function (moduleToInstall) {372 var moduleName = plugin.id + '.' + (moduleToInstall.name || moduleToInstall.src.match(/([^\/]+)\.js/)[1]);373 var obj = {374 file: ['plugins', plugin.id, moduleToInstall.src].join('/'), /* eslint no-useless-escape : 0 */375 id: moduleName,376 pluginId: plugin.id377 };378 if (moduleToInstall.clobbers.length > 0) {379 obj.clobbers = moduleToInstall.clobbers.map(function (o) { return o.target; });380 }381 if (moduleToInstall.merges.length > 0) {382 obj.merges = moduleToInstall.merges.map(function (o) { return o.target; });383 }384 if (moduleToInstall.runs) {385 obj.runs = true;386 }387 return obj;388 });389 this._platformJson.root.modules = installedModules.concat(modulesToInstall);390 if (!this._platformJson.root.plugin_metadata) {391 this._platformJson.root.plugin_metadata = {};392 }393 this._platformJson.root.plugin_metadata[plugin.id] = plugin.version;394 this._writePluginModules(targetDir);395 this._platformJson.save();396};397/**398 * Fetches all installed modules, generates cordova_plugins contents and writes399 * it to file.400 *401 * @param {String} targetDir Directory, where write cordova_plugins.js to.402 * Ususally it is either <platform>/www or <platform>/platform_www403 * directories.404 */405Api.prototype._writePluginModules = function (targetDir) {406 // Write out moduleObjects as JSON wrapped in a cordova module to cordova_plugins.js407 var final_contents = 'cordova.define(\'cordova/plugin_list\', function(require, exports, module) {\n';408 final_contents += 'module.exports = ' + JSON.stringify(this._platformJson.root.modules, null, ' ') + ';\n';409 final_contents += 'module.exports.metadata = \n';410 final_contents += '// TOP OF METADATA\n';411 final_contents += JSON.stringify(this._platformJson.root.plugin_metadata || {}, null, ' ') + '\n';412 final_contents += '// BOTTOM OF METADATA\n';413 final_contents += '});'; // Close cordova.define.414 shell.mkdir('-p', targetDir);415 fs.writeFileSync(path.join(targetDir, 'cordova_plugins.js'), final_contents, 'utf-8');416};417/**418 * Removes the specified modules from list of installed modules and updates419 * platform_json and cordova_plugins.js on disk.420 *421 * @param {PluginInfo} plugin PluginInfo instance for plugin, which modules422 * needs to be removed.423 * @param {String} targetDir The directory, where updated cordova_plugins.js424 * should be written to.425 */426Api.prototype._removeModulesInfo = function (plugin, targetDir) {427 var installedModules = this._platformJson.root.modules || [];428 var modulesToRemove = plugin.getJsModules(this.platform)429 .map(function (jsModule) {430 return ['plugins', plugin.id, jsModule.src].join('/');431 });432 var updatedModules = installedModules433 .filter(function (installedModule) {434 return (modulesToRemove.indexOf(installedModule.file) === -1);435 });436 this._platformJson.root.modules = updatedModules;437 if (this._platformJson.root.plugin_metadata) {438 delete this._platformJson.root.plugin_metadata[plugin.id];439 }440 this._writePluginModules(targetDir);441 this._platformJson.save();442};443Api.prototype.build = function (buildOptions) {444 var self = this;445 return require('./lib/check_reqs').run()446 .then(function () {447 return require('./lib/build').run.call(self, buildOptions);448 });449};450Api.prototype.run = function (runOptions) {451 return require('./lib/run').run(runOptions);452};453Api.prototype.clean = function (cleanOptions) {454 return require('./lib/clean').run(cleanOptions);455};456Api.prototype.requirements = function () {457 return require('./lib/check_reqs').run();458};...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1import { connect } from 'dva';2import React, { Component } from 'react';3import { Card, Form, Modal, Input, Select, Button, Row, Col, Tooltip, Table, message, Tag, DatePicker, Popconfirm } from 'antd';4import moment from 'moment';5import DescriptionList from '@/components/DescriptionList';6import { formatMessage } from 'umi/locale';7import styles from './index.less';8const FormItem = Form.Item;9const { Option } = Select;10const { Description } = DescriptionList;11const { TextArea } = Input;12@connect(({ carrier, platform, loading }) => ({13 carrier,14 platform,15 loading: loading.effects['platform/fetchOrderItems'],16}))17@Form.create()18class OrderDetail extends Component {19 constructor(props) {20 super(props);21 this.state = {22 visible: false,23 submitLoading: false,24 carriers: [],25 editVisible: false,26 current: {},27 };28 }29 componentDidMount() {30 const { dispatch } = this.props;31 dispatch({32 type: 'carrier/fetchOption',33 payload: {},34 callback: carrier => this.setState({35 carriers: carrier,36 }),37 });38 this.initOneOrder();39 }40 initOneOrder = () => {41 const { dispatch, record } = this.props;42 dispatch({43 type: 'platform/fetchOneOrder',44 payload: {45 id: record.id,46 data: { with: ['platform', 'address', 'items.warehouseInventoryLock.warehouse'] },47 },48 });49 };50 handleModalVisible = flag => {51 this.setState({ visible: !!flag });52 };53 shipOrder = () => {54 const { record, form, dispatch, platform: { platformOrder = {} } } = this.props;55 form.validateFieldsAndScroll(['carrier_id', 'tracking_number', 'actual_ship_date'], (err, fieldValues) => {56 if (err) {57 return;58 }59 this.setState({ submitLoading: true });60 const { carrier_id, actual_ship_date } = fieldValues;61 if(platformOrder.local_status === 'Shipped') {62 dispatch({63 type: 'platform/editShipOrder',64 payload: {65 id: record.id,66 data: {67 ...fieldValues,68 'carrier_id': carrier_id.key,69 actual_ship_date: moment(actual_ship_date).format('YYYY-MM-DD HH:mm:ss'),70 },71 },72 callback: () => {73 message.success(formatMessage({ id: 'platform.detail.ship.edit.tips.success' }));74 this.setState({ visible: false, submitLoading: false }, () => this.initOneOrder());75 },76 });77 } else {78 dispatch({79 type: 'platform/shipOrder',80 payload: {81 id: record.id,82 data: {83 ...fieldValues,84 'carrier_id': carrier_id.key,85 actual_ship_date: moment(actual_ship_date).format('YYYY-MM-DD HH:mm:ss'),86 },87 },88 callback: res => {89 if(res.status === 'ok') {90 message.success(formatMessage({ id: 'platform.detail.tips.success' }));91 this.setState({ visible: false, submitLoading: false }, () => this.initOneOrder());92 } else {93 message.error(formatMessage({id: 'platform.detail.tips.failure'}));94 }95 },96 });97 }98 });99 };100 renderCarrier = id => {101 const { carriers } = this.state;102 const carrier = carriers.filter(item => item.value === id);103 if(carrier.length !== 0){104 return carrier[0].label;105 }106 return null;107 };108 handleEditRemark = (flag, record, refresh) => {109 this.setState({110 editVisible: !!flag,111 current: record,112 });113 if(refresh) {114 this.initOneOrder();115 }116 };117 handleSubmit = () => {118 const { form, dispatch } = this.props;119 const { current } = this.state;120 form.validateFieldsAndScroll(['remark'], (err, fieldValues) => {121 if (err) {122 return;123 }124 dispatch({125 type: 'platform/updateOrderProductItem',126 payload: {127 id: current.id,128 data: fieldValues,129 },130 callback: () => {131 message.success(formatMessage({ id: 'platform.detail.edit.tips.success' }));132 this.handleEditRemark(false, {}, true);133 },134 });135 });136 };137 138 renderInitialOption = id => {139 const { carriers } = this.state;140 const filter = carriers.filter(e => id === e.value);141 if(filter.length !== 0) {142 return { key: id, label: filter[0].label }143 }144 return undefined;145 };146 render() {147 const { form, platform: { platformOrder = {} } } = this.props;148 const { address = {}, items = [] } = platformOrder;149 const showAddress = address && Object.keys(address).length !== 0;150 const { visible, submitLoading, carriers, editVisible, current } = this.state;151 const columns = [152 {153 title: 'SKU',154 dataIndex: 'platform_sku',155 width: 300,156 },157 {158 title: formatMessage({ id: 'platform.detail.product.title' }),159 dataIndex: 'platform_title',160 width: 400,161 },162 { title: formatMessage({ id: 'platform.detail.product.quantity' }), dataIndex: 'quantity' },163 { title: formatMessage({ id: 'platform.detail.product.currency' }), dataIndex: 'currency_code' },164 { title: formatMessage({ id: 'platform.detail.product.amount' }), dataIndex: 'amount' },165 {166 title: formatMessage({ id: 'platform.detail.product.pick_info' }),167 dataIndex: 'pick_info',168 render: (text, item) => {169 if(platformOrder.fulfillment !== 'Platform') {170 const { warehouse_inventory_lock } = item;171 if (warehouse_inventory_lock) {172 const { warehouse } = warehouse_inventory_lock;173 return (174 <DescriptionList col={1} size="small">175 <Description176 term={formatMessage({ id: 'platform.detail.product.pick_info.warehouse' })}177 >178 {warehouse.name}179 </Description>180 <Description181 term={formatMessage({ id: 'platform.detail.product.pick_info.quantity' })}182 >183 {warehouse_inventory_lock.quantity}184 </Description>185 </DescriptionList>186 );187 }188 return <Tag color="red">CN</Tag>;189 }190 return formatMessage({ id: 'platform.detail.fulfillment.info' });191 },192 },193 {194 title: formatMessage({ id: 'platform.detail.product.remark' }),195 dataIndex: 'remark',196 width: 200,197 render: (text) => (198 <Tooltip title={text}>199 <div className={styles.white_space}>{text}</div>200 </Tooltip>201 ),202 },203 {204 title: formatMessage({ id: 'platform.detail.product.action' }),205 dataIndex: 'action',206 render: (text, record) => (207 (platformOrder.ignore_shipment !== true) && (platformOrder.platform_status !== 'Shipped') && platformOrder.local_status === 'Unshipped' && platformOrder.fulfillment === 'Merchant' ? (208 <Button209 type="primary"210 icon="edit"211 size="small"212 onClick={() => this.handleEditRemark(true, record)}213 />214 ) : null215 ),216 },217 ];218 return (219 <div>220 <div style={{ marginBottom: 20 }}>Order ID: # {platformOrder.platform_sn}</div>221 <Row gutter={24}>222 <Col span={16} style={{ paddingRight: 20 }}>223 <Card>224 <DescriptionList225 title={formatMessage({ id: 'platform.detail.subtitle.order' })}226 style={{ float: 'left' }}227 col="2"228 >229 <Description230 term={formatMessage({ id: 'platform.detail.order.created_at' })}231 >232 {platformOrder.order_date}233 </Description>234 <Description235 term={formatMessage({ id: 'platform.detail.order.price' })}236 >237 {`${platformOrder.currency_code} / ${platformOrder.amount}`}238 </Description>239 <Description240 term={formatMessage({ id: 'platform.detail.order.fulfillment' })}241 >242 {platformOrder.fulfillment}243 </Description>244 <Description245 term={formatMessage({ id: 'platform.detail.order.ship_level' })}246 >247 {platformOrder.ship_level}248 </Description>249 <Description250 term={formatMessage({ id: 'platform.detail.order.platform' })}251 >252 {platformOrder.platform && Object.keys(platformOrder.platform).length !== 0 ? platformOrder.platform.name : ''}253 </Description>254 <Description255 term={formatMessage({ id: 'platform.detail.order.platform_status' })}256 >257 {platformOrder.platform_status}258 </Description>259 <Description260 term={formatMessage({ id: 'platform.detail.order.local_status' })}261 >262 {platformOrder.local_status}263 </Description>264 {platformOrder.carrier_id !== null ?265 <Description266 term={formatMessage({ id: 'platform.detail.order.carrier' })}267 >268 {this.renderCarrier(platformOrder.carrier_id)}269 </Description> : null}270 {platformOrder.tracking_number !== null ?271 <Description272 term={formatMessage({ id: 'platform.detail.order.tracking_number' })}273 >274 {platformOrder.tracking_number}275 </Description> : null}276 {platformOrder.actual_ship_date !== null ?277 <Description278 term={formatMessage({ id: 'platform.detail.order.actual_ship_date' })}279 >280 {platformOrder.actual_ship_date}281 </Description> : null}282 </DescriptionList>283 </Card>284 </Col>285 <Col span={8} style={{ paddingLeft: 20 }}>286 <Card style={{ paddingBottom: 0 }}>287 <DescriptionList288 title={formatMessage({ id: 'platform.detail.subtitle.waybill' })}289 style={{ float: 'right' }}290 col="1"291 >292 <Description293 term={formatMessage({ id: 'platform.detail.waybill.name' })}294 >{showAddress ? address.name : ''}</Description>295 <Description296 term={formatMessage({ id: 'platform.detail.waybill.phone' })}297 >{showAddress ? address.phone : ''}</Description>298 <Description299 term={formatMessage({ id: 'platform.detail.waybill.address1' })}300 >{showAddress ? address.address1 : ''}</Description>301 <Description302 term={formatMessage({ id: 'platform.detail.waybill.address2' })}303 >{showAddress ? address.address2 : ''}</Description>304 <Description305 term={formatMessage({ id: 'platform.detail.waybill.address3' })}306 >{showAddress ? address.address3 : ''}</Description>307 <Description308 term={formatMessage({ id: 'platform.detail.waybill.city' })}309 >{showAddress ? address.city : ''}</Description>310 <Description311 term={formatMessage({ id: 'platform.detail.waybill.state' })}312 >{showAddress ? address.state : ''}</Description>313 <Description314 term={formatMessage({ id: 'platform.detail.waybill.postal_code' })}315 >{showAddress ? address.postal_code : ''}</Description>316 <Description317 term={formatMessage({ id: 'platform.detail.waybill.country' })}318 >{showAddress ? address.country_code : ''}</Description>319 </DescriptionList>320 </Card>321 </Col>322 </Row>323 <Card bordered={false}>324 <div className={styles.title}>325 {formatMessage({ id: 'platform.detail.subtitle.product' })}326 {327 (platformOrder.ignore_shipment !== true) && (platformOrder.platform_status !== 'Shipped') && platformOrder.local_status === 'Unshipped' && platformOrder.fulfillment === 'Merchant' ? (328 <Popconfirm329 title={formatMessage({ id: 'platform.detail.button.delivery.tips' })}330 onConfirm={() => this.handleModalVisible(true)}331 >332 <Button style={{ marginLeft: 20 }}>333 {formatMessage({ id: 'platform.detail.button.ship_conform' })}334 </Button>335 </Popconfirm>336 ) : null337 }338 {339 ((platformOrder.ignore_shipment !== true) && platformOrder.fulfillment === 'Merchant' && platformOrder.local_status === 'Shipped') ? (340 <Button style={{ marginLeft: 20 }} onClick={() => this.handleModalVisible(true)}>341 {formatMessage({ id: 'platform.detail.button.ship_edit' })}342 </Button>343 ) : null344 }345 </div>346 <Table347 rowKey='id'348 columns={columns}349 dataSource={items}350 pagination={false}351 />352 <Modal353 destroyOnClose354 confirmLoading={submitLoading}355 title={formatMessage({ id: 'platform.detail.delivery.title' })}356 width={720}357 visible={visible}358 onOk={this.shipOrder}359 onCancel={() => this.handleModalVisible(false)}360 >361 <Form>362 <FormItem363 label={formatMessage({ id: 'platform.detail.delivery.carrier' })}364 labelCol={{ span: 5 }}365 wrapperCol={{ span: 15 }}366 >367 {form.getFieldDecorator('carrier_id', {368 rules: [{369 required: true,370 message: formatMessage({ id: 'platform.detail.delivery.carrier.message' }),371 }],372 initialValue: this.renderInitialOption(platformOrder.carrier_id),373 })(374 <Select375 allowClear376 labelInValue377 placeholder={formatMessage({ id: 'platform.detail.delivery.carrier.placeholder' })}378 style={{ width: '100%' }}379 >380 {Object.keys(carriers).length !== 0 ? carriers.map(item =>381 <Option382 key={item.value}383 value={item.value}384 >385 {item.label}386 </Option>) : null}387 </Select>,388 )}389 </FormItem>390 <FormItem391 label={formatMessage({ id: 'platform.detail.delivery.tracking_number' })}392 labelCol={{ span: 5 }}393 wrapperCol={{ span: 15 }}394 >395 {form.getFieldDecorator('tracking_number', {396 rules: [{397 required: true,398 message: formatMessage({ id: 'platform.detail.delivery.tracking_number.message' }),399 }],400 initialValue: platformOrder.tracking_number,401 })(<Input402 placeholder={formatMessage({ id: 'platform.detail.delivery.tracking_number.placeholder' })}403 />)}404 </FormItem>405 <FormItem406 label={formatMessage({ id: 'platform.detail.delivery.actual_ship_date' })}407 labelCol={{ span: 5 }}408 wrapperCol={{ span: 15 }}409 >410 {form.getFieldDecorator('actual_ship_date', {411 initialValue: platformOrder.actual_ship_date ? moment(platformOrder.actual_ship_date) : null,412 })(413 <DatePicker414 showTime={{ defaultValue: moment('00:00:00', 'HH:mm:ss') }}415 format="YYYY-MM-DD HH:mm:ss"416 placeholder={formatMessage({ id: 'platform.detail.delivery.actual_ship_date.placeholder' })}417 style={{ width: '100%' }}418 />,419 )}420 </FormItem>421 </Form>422 </Modal>423 <Modal424 destroyOnClose425 title={formatMessage({ id: 'platform.detail.product.edit-remark' })}426 width={720}427 visible={editVisible}428 onOk={this.handleSubmit}429 onCancel={() => this.handleEditRemark(false, {})}430 >431 <Form>432 <FormItem433 label={formatMessage({ id: 'platform.detail.product.remark' })}434 labelCol={{ span: 7 }}435 wrapperCol={{ span: 13 }}436 >437 {form.getFieldDecorator('remark', {438 initialValue: current.remark ? current.remark : null,439 })(<TextArea />)}440 </FormItem>441 </Form>442 </Modal>443 </Card>444 </div>445 );446 }447}...

Full Screen

Full Screen

en-US.js

Source:en-US.js Github

copy

Full Screen

1export default {2 '3d': '3d', 3 'access-accessibility': 'access accessibility', 4 'access-ad': 'access ad', 5 'access-assist-listening': 'access assist listening', 6 'access-braille': 'access braille', 7 'access-sign': 'access sign', 8 'access-tty': 'access tty', 9 'access-volume-control': 'access volume control', 10 'access-wheelchair-active': 'access wheelchair active', 11 'access-wheelchair': 'access wheelchair', 12 'achievement': 'achievement', 13 'action': 'action', 14 'actions': 'actions', 15 'add-circle': 'add circle', 16 'add': 'add', 17 'aggregate': 'aggregate', 18 'aid': 'aid', 19 'alarm': 'alarm', 20 'alert': 'alert', 21 'analytics': 'analytics', 22 'announce': 'announce', 23 'apps': 'apps', 24 'archive': 'archive', 25 'article': 'article', 26 'ascend': 'ascend', 27 'attachment': 'attachment', 28 'back-ten': 'back ten', 29 'bar-chart': 'bar chart', 30 'basket': 'basket', 31 'blog': 'blog', 32 'book': 'book', 33 'bookmark': 'bookmark', 34 'bottom-corner': 'bottom corner', 35 'brand-apple-app-store': 'brand apple app store', 36 'brand-codepen-edit': 'brand codepen edit', 37 'brand-codepen-try': 'brand codepen try', 38 'brand-google-play': 'brand google play', 39 'brand-grommet-outline': 'brand grommet outline', 40 'brand-grommet-path': 'brand grommet path', 41 'brand-hpe-element-outline': 'brand hpe element outline', 42 'brand-hpe-element-path': 'brand hpe element path', 43 'brand-hpe-labs-insignia-outline': 'brand hpe labs insignia outline', 44 'brand-hpe-labs-insignia': 'brand hpe labs insignia', 45 'brand-hpe-stack-centered': 'brand hpe stack centered', 46 'brand-hpe-stack': 'brand hpe stack', 47 'briefcase': 'briefcase', 48 'brush': 'brush', 49 'bug': 'bug', 50 'bundle': 'bundle', 51 'business-service': 'business service', 52 'calculator': 'calculator', 53 'calendar': 'calendar', 54 'camera': 'camera', 55 'capacity': 'capacity', 56 'car': 'car', 57 'caret-down': 'caret down', 58 'caret-next': 'caret next', 59 'caret-previous': 'caret previous', 60 'caret-up': 'caret up', 61 'cart': 'cart', 62 'catalog': 'catalog', 63 'chapter-add': 'chapter add', 64 'chapter-next': 'chapter next', 65 'chapter-previous': 'chapter previous', 66 'chat': 'chat', 67 'checkbox-selected': 'checkbox selected', 68 'checkbox': 'checkbox', 69 'checkmark': 'checkmark', 70 'circle-information': 'circle information', 71 'circle-play': 'circle play', 72 'circle-question': 'circle question', 73 'clear-option': 'clear option', 74 'clear': 'clear', 75 'cli': 'cli', 76 'clipboard': 'clipboard', 77 'clock': 'clock', 78 'clone': 'clone', 79 'close': 'close', 80 'closed-caption': 'closed caption', 81 'cloud-computer': 'cloud computer', 82 'cloud-download': 'cloud download', 83 'cloud-software': 'cloud software', 84 'cloud-upload': 'cloud upload', 85 'cloud': 'cloud', 86 'cluster': 'cluster', 87 'code': 'code', 88 'columns': 'columns', 89 'compare': 'compare', 90 'compass': 'compass', 91 'compliance': 'compliance', 92 'configure': 'configure', 93 'connect': 'connect', 94 'contact-info': 'contact info', 95 'contact': 'contact', 96 'contract': 'contract', 97 'copy': 'copy', 98 'credit-card': 'credit card', 99 'cube': 'cube', 100 'cubes': 'cubes', 101 'currency': 'currency', 102 'cursor': 'cursor', 103 'cut': 'cut', 104 'cycle': 'cycle', 105 'dashboard': 'dashboard', 106 'database': 'database', 107 'deliver': 'deliver', 108 'deploy': 'deploy', 109 'descend': 'descend', 110 'desktop': 'desktop', 111 'detach': 'detach', 112 'diamond': 'diamond', 113 'directions': 'directions', 114 'dislike': 'dislike', 115 'document-cloud': 'document cloud', 116 'document-config': 'document config', 117 'document-csv': 'document csv', 118 'document-download': 'document download', 119 'document-excel': 'document excel', 120 'document-exe': 'document exe', 121 'document-image': 'document image', 122 'document-locked': 'document locked', 123 'document-missing': 'document missing', 124 'document-notes': 'document notes', 125 'document-outlook': 'document outlook', 126 'document-pdf': 'document pdf', 127 'document-performance': 'document performance', 128 'document-ppt': 'document ppt', 129 'document-rtf': 'document rtf', 130 'document-sound': 'document sound', 131 'document-store': 'document store', 132 'document-test': 'document test', 133 'document-threat': 'document threat', 134 'document-time': 'document time', 135 'document-transfer': 'document transfer', 136 'document-txt': 'document txt', 137 'document-update': 'document update', 138 'document-upload': 'document upload', 139 'document-user': 'document user', 140 'document-verified': 'document verified', 141 'document-video': 'document video', 142 'document-windows': 'document windows', 143 'document-word': 'document word', 144 'document-zip': 'document zip', 145 'document': 'document', 146 'domain': 'domain', 147 'down': 'down', 148 'download': 'download', 149 'drag': 'drag', 150 'drive-cage': 'drive cage', 151 'duplicate': 'duplicate', 152 'edit': 'edit', 153 'eject': 'eject', 154 'empty-circle': 'empty circle', 155 'expand': 'expand', 156 'fan': 'fan', 157 'fast-forward': 'fast forward', 158 'favorite': 'favorite', 159 'filter': 'filter', 160 'finger-print': 'finger print', 161 'flag': 'flag', 162 'folder-cycle': 'folder cycle', 163 'folder-open': 'folder open', 164 'folder': 'folder', 165 'forward-ten': 'forward ten', 166 'gallery': 'gallery', 167 'gamepad': 'gamepad', 168 'gift': 'gift', 169 'globe': 'globe', 170 'grid': 'grid', 171 'group': 'group', 172 'grow': 'grow', 173 'halt': 'halt', 174 'help': 'help', 175 'history': 'history', 176 'home': 'home', 177 'host-maintenance': 'host maintenance', 178 'host': 'host', 179 'image': 'image', 180 'impact': 'impact', 181 'in-progress': 'in progress', 182 'inbox': 'inbox', 183 'indicator': 'indicator', 184 'info': 'info', 185 'inherit': 'inherit', 186 'inspect': 'inspect', 187 'install': 'install', 188 'integration': 'integration', 189 'iteration': 'iteration', 190 'java': 'java', 191 'language': 'language', 192 'launch': 'launch', 193 'layer': 'layer', 194 'license': 'license', 195 'like': 'like', 196 'line-chart': 'line chart', 197 'link-bottom': 'link bottom', 198 'link-down': 'link down', 199 'link-next': 'link next', 200 'link-previous': 'link previous', 201 'link-top': 'link top', 202 'link-up': 'link up', 203 'link': 'link', 204 'local': 'local', 205 'location-pin': 'location pin', 206 'location': 'location', 207 'lock': 'lock', 208 'login': 'login', 209 'logout': 'logout', 210 'magic': 'magic', 211 'mail-option': 'mail option', 212 'mail': 'mail', 213 'manual': 'manual', 214 'map-location': 'map location', 215 'map': 'map', 216 'menu': 'menu', 217 'microphone': 'microphone', 218 'money': 'money', 219 'monitor': 'monitor', 220 'more': 'more', 221 'multiple': 'multiple', 222 'navigate': 'navigate', 223 'new-window': 'new window', 224 'new': 'new', 225 'next': 'next', 226 'nodes': 'nodes', 227 'note': 'note', 228 'notes': 'notes', 229 'notification': 'notification', 230 'object-group': 'object group', 231 'object-ungroup': 'object ungroup', 232 'optimize': 'optimize', 233 'organization': 'organization', 234 'overview': 'overview', 235 'pan': 'pan', 236 'pause-fill': 'pause fill', 237 'pause': 'pause', 238 'personal-computer': 'personal computer', 239 'pie-chart': 'pie chart', 240 'pin': 'pin', 241 'plan': 'plan', 242 'platform-amazon': 'platform amazon', 243 'platform-android': 'platform android', 244 'platform-apple': 'platform apple', 245 'platform-archlinux': 'platform archlinux', 246 'platform-aruba': 'platform aruba', 247 'platform-centos': 'platform centos', 248 'platform-chrome': 'platform chrome', 249 'platform-cloudlinux': 'platform cloudlinux', 250 'platform-debian': 'platform debian', 251 'platform-docker': 'platform docker', 252 'platform-dos': 'platform dos', 253 'platform-dropbox': 'platform dropbox', 254 'platform-edge': 'platform edge', 255 'platform-fedora': 'platform fedora', 256 'platform-firefox': 'platform firefox', 257 'platform-freebsd': 'platform freebsd', 258 'platform-google': 'platform google', 259 'platform-hadoop': 'platform hadoop', 260 'platform-heroku': 'platform heroku', 261 'platform-horton': 'platform horton', 262 'platform-hp': 'platform hp', 263 'platform-hpi': 'platform hpi', 264 'platform-internet-explorer': 'platform internet explorer', 265 'platform-java': 'platform java', 266 'platform-mandriva': 'platform mandriva', 267 'platform-mysql': 'platform mysql', 268 'platform-norton': 'platform norton', 269 'platform-onedrive': 'platform onedrive', 270 'platform-opera': 'platform opera', 271 'platform-oracle': 'platform oracle', 272 'platform-pied-piper': 'platform pied piper', 273 'platform-raspberry': 'platform raspberry', 274 'platform-reactjs': 'platform reactjs', 275 'platform-redhat': 'platform redhat', 276 'platform-safari-option': 'platform safari option', 277 'platform-safari': 'platform safari', 278 'platform-sco': 'platform sco', 279 'platform-solaris': 'platform solaris', 280 'platform-suse': 'platform suse', 281 'platform-swift': 'platform swift', 282 'platform-turbolinux': 'platform turbolinux', 283 'platform-ubuntu': 'platform ubuntu', 284 'platform-unixware': 'platform unixware', 285 'platform-vmware': 'platform vmware', 286 'platform-windows-legacy': 'platform windows legacy', 287 'platform-windows': 'platform windows', 288 'play-fill': 'play fill', 289 'play': 'play', 290 'power': 'power', 291 'previous': 'previous', 292 'print': 'print', 293 'radial-selected': 'radial selected', 294 'radial': 'radial', 295 'refresh': 'refresh', 296 'resources': 'resources', 297 'resume': 'resume', 298 'revert': 'revert', 299 'rewind': 'rewind', 300 'risk': 'risk', 301 'robot': 'robot', 302 'rss': 'rss', 303 'run': 'run', 304 'satellite': 'satellite', 305 'save': 'save', 306 'scan': 'scan', 307 'schedule-new': 'schedule new', 308 'schedule-play': 'schedule play', 309 'schedule': 'schedule', 310 'schedules': 'schedules', 311 'scorecard': 'scorecard', 312 'search-advanced': 'search advanced', 313 'search': 'search', 314 'secure': 'secure', 315 'select': 'select', 316 'selection': 'selection', 317 'send': 'send', 318 'server-cluster': 'server cluster', 319 'server': 'server', 320 'servers': 'servers', 321 'service-play': 'service play', 322 'services': 'services', 323 'settings-option': 'settings option', 324 'share': 'share', 325 'shield-security': 'shield security', 326 'shield': 'shield', 327 'shift': 'shift', 328 'sidebar': 'sidebar', 329 'social-amazon': 'social amazon', 330 'social-amex': 'social amex', 331 'social-bitcoin': 'social bitcoin', 332 'social-codepen': 'social codepen', 333 'social-creative-commons': 'social creative commons', 334 'social-dropbox': 'social dropbox', 335 'social-facebook-option': 'social facebook option', 336 'social-facebook': 'social facebook', 337 'social-github': 'social github', 338 'social-google-plus': 'social google plus', 339 'social-google-wallet': 'social google wallet', 340 'social-instagram': 'social instagram', 341 'social-linkedin-option': 'social linkedin option', 342 'social-linkedin': 'social linkedin', 343 'social-mail': 'social mail', 344 'social-mastercard': 'social mastercard', 345 'social-medium': 'social medium', 346 'social-paypal': 'social paypal', 347 'social-pinterest': 'social pinterest', 348 'social-product-hunt': 'social product hunt', 349 'social-reddit': 'social reddit', 350 'social-skype': 'social skype', 351 'social-slack': 'social slack', 352 'social-snapchat': 'social snapchat', 353 'social-square': 'social square', 354 'social-stack-overflow': 'social stack overflow', 355 'social-stripe': 'social stripe', 356 'social-tumblr': 'social tumblr', 357 'social-twitter': 'social twitter', 358 'social-vimeo': 'social vimeo', 359 'social-vine': 'social vine', 360 'social-visa': 'social visa', 361 'social-wordpress': 'social wordpress', 362 'social-youtube': 'social youtube', 363 'sort': 'sort', 364 'split': 'split', 365 'splits': 'splits', 366 'stakeholder': 'stakeholder', 367 'standards-3d-effects': 'standards 3d effects', 368 'standards-connectivity': 'standards connectivity', 369 'standards-css3': 'standards css3', 370 'standards-device': 'standards device', 371 'standards-fireball': 'standards fireball', 372 'standards-html5': 'standards html5', 373 'standards-multimedia': 'standards multimedia', 374 'standards-offline-storage': 'standards offline storage', 375 'standards-performance': 'standards performance', 376 'standards-sematics': 'standards sematics', 377 'star-half': 'star half', 378 'star': 'star', 379 'steps': 'steps', 380 'stop-fill': 'stop fill', 381 'stop': 'stop', 382 'storage': 'storage', 383 'street-view': 'street view', 384 'subtract-circle': 'subtract circle', 385 'subtract': 'subtract', 386 'support': 'support', 387 'sync': 'sync', 388 'system': 'system', 389 'table-add': 'table add', 390 'table': 'table', 391 'tag': 'tag', 392 'target': 'target', 393 'task': 'task', 394 'tasks': 'tasks', 395 'technology': 'technology', 396 'template': 'template', 397 'terminal': 'terminal', 398 'test-desktop': 'test desktop', 399 'test': 'test', 400 'text-wrap': 'text wrap', 401 'threats': 'threats', 402 'ticket': 'ticket', 403 'tools': 'tools', 404 'tooltip': 'tooltip', 405 'top-corner': 'top corner', 406 'transaction': 'transaction', 407 'trash': 'trash', 408 'tree': 'tree', 409 'trigger': 'trigger', 410 'trophy': 'trophy', 411 'troubleshoot': 'troubleshoot', 412 'unlink': 'unlink', 413 'unlock': 'unlock', 414 'up': 'up', 415 'update': 'update', 416 'upgrade': 'upgrade', 417 'upload': 'upload', 418 'user-add': 'user add', 419 'user-admin': 'user admin', 420 'user-expert': 'user expert', 421 'user-female': 'user female', 422 'user-manager': 'user manager', 423 'user-new': 'user new', 424 'user-police': 'user police', 425 'user-settings': 'user settings', 426 'user-worker': 'user worker', 427 'user': 'user', 428 'validate': 'validate', 429 'video': 'video', 430 'view': 'view', 431 'virtual-machine': 'virtual machine', 432 'vm-maintenance': 'vm maintenance', 433 'volume-low': 'volume low', 434 'volume-mute': 'volume mute', 435 'volume': 'volume', 436 'vulnerability': 'vulnerability', 437 'waypoint': 'waypoint', 438 'workshop': 'workshop', 439 'zoom-in': 'zoom in', 440 'zoom-out': 'zoom out', ...

Full Screen

Full Screen

amap-geolocation.js

Source:amap-geolocation.js Github

copy

Full Screen

1import { NativeModules, NativeEventEmitter, Platform } from "react-native";2const AMapGeolocation = NativeModules.BCMangoLocation;3const eventEmitter = new NativeEventEmitter(AMapGeolocation);4/**5 * 初始化 SDK6 *7 * @param key 高德开放平台应用 Key8 */9export function init(key) {10 return AMapGeolocation.init(Platform.select(key));11}12/**13 * 添加定位监听函数14 *15 * @param listener16 */17export function addLocationListener(listener) {18 return eventEmitter.addListener("AMapGeolocation", listener);19}20/**21 * 开始持续定位22 */23export function start() {24 AMapGeolocation.start();25}26/**27 * 停止持续定位28 */29export function stop() {30 AMapGeolocation.stop();31}32/**33 * 获取当前是否正在定位的状态34 *35 * @platform android36 */37export function isStarted() {38 return AMapGeolocation.isStarted();39}40/**41 * 设置发起定位请求的时间间隔(毫秒),默认 2000,最小值为 100042 *43 * @default 200044 * @platform android45 */46export function setInterval(interval) {47 if (Platform.OS === "android") {48 AMapGeolocation.setInterval(interval);49 }50}51/**52 * 设置是否单次定位53 *54 * @default false55 * @platform android56 */57export function setOnceLocation(isOnceLocation) {58 if (Platform.OS === "android") {59 AMapGeolocation.setOnceLocation(isOnceLocation);60 }61}62/**63 * 设置是否允许调用 WiFi 刷新64 *65 * 当设置为 `false` 时会停止主动调用 wifi 刷新,将会极大程度影响定位精度,66 * 但可以有效的降低定位耗电。67 *68 * @default true69 * @platform android70 */71export function setWifiScan(isWifiScan) {72 if (Platform.OS === "android") {73 AMapGeolocation.setWifiScan(isWifiScan);74 }75}76/**77 * 设置是否使用设备传感器78 *79 * @default false80 * @platform android81 */82export function setSensorEnable(enable) {83 if (Platform.OS === "android") {84 AMapGeolocation.setSensorEnable(enable);85 }86}87/**88 * 设置是否开启wifi始终扫描89 *90 * 只有设置了 `android.permission.WRITE_SECURE_SETTINGS` 权限后才会开启。91 * 开启后,即使关闭 wifi 开关的情况下也会扫描 wifi。92 * 此方法为静态方法,设置一次后其他定位 client 也会生效。93 *94 * @default true95 * @platform android96 */97export function setOpenAlwaysScanWifi(isOpen) {98 if (Platform.OS === "android") {99 AMapGeolocation.setOpenAlwaysScanWifi(isOpen);100 }101}102/**103 * 设置定位是否等待 WiFi 列表刷新104 *105 * 定位精度会更高,但是定位速度会变慢 1-3 秒,106 * 当设置为 `true` 时,连续定位会自动变为单次定位。107 *108 * @default false109 * @platform android110 */111export function setOnceLocationLatest(isOnceLocationLatest) {112 if (Platform.OS === "android") {113 AMapGeolocation.setOnceLocationLatest(isOnceLocationLatest);114 }115}116/**117 * 设置是否返回地址信息,默认返回地址信息118 *119 * GPS 定位时也可以返回地址信息,但需要网络通畅,第一次有可能没有地址信息返回。120 *121 * @default true122 * @platform android123 */124export function setNeedAddress(isNeedAddress) {125 if (Platform.OS === "android") {126 AMapGeolocation.setNeedAddress(isNeedAddress);127 }128}129/**130 * 设置是否允许模拟位置131 *132 * @default true133 * @platform android134 */135export function setMockEnable(enable) {136 if (Platform.OS === "android") {137 AMapGeolocation.setMockEnable(enable);138 }139}140/**141 * 设置是否使用缓存策略142 *143 * @default true144 * @platform android145 */146export function setLocationCacheEnable(enable) {147 if (Platform.OS === "android") {148 AMapGeolocation.setLocationCacheEnable(enable);149 }150}151/**152 * 设置联网超时时间(毫秒)153 *154 * @default 30000155 * @platform android156 */157export function setHttpTimeout(timeout) {158 if (Platform.OS === "android") {159 AMapGeolocation.setHttpTimeout(timeout);160 }161}162/**163 * 设置优先返回卫星定位信息时等待卫星定位结果的超时时间(毫秒)164 *165 * 只有在 `setGpsFirst(true)` 时才有效。166 *167 * @platform android168 */169export function setGpsFirstTimeout(timeout) {170 if (Platform.OS === "android") {171 AMapGeolocation.setGpsFirstTimeout(timeout);172 }173}174/**175 * 设置首次定位是否等待卫星定位结果176 *177 * 只有在单次定位高精度定位模式下有效,设置为 `true` 时,会等待卫星定位结果返回,178 * 最多等待 30 秒,若 30 秒后仍无卫星定位结果返回,返回网络定位结果。179 * 等待卫星定位结果返回的时间可以通过 [[setGpsFirstTimeout]] 进行设置。180 *181 * @default false182 * @platform android183 */184export function setGpsFirst(isGpsFirst) {185 if (Platform.OS === "android") {186 AMapGeolocation.setGpsFirst(isGpsFirst);187 }188}189/**190 * 设置定位模式191 *192 * @platform android193 */194export function setLocationMode(mode) {195 if (Platform.OS === "android") {196 AMapGeolocation.setLocationMode(mode);197 }198}199/**200 * 设置定位场景201 *202 * 根据场景快速修改 option,不支持动态改变,修改后需要调用 [[start]] 使其生效,当不需要场景时,可以设置为 `null`。203 *204 * 注意:不建议设置场景和自定义 option 混合使用。设置场景后,如果已经开始定位了,建议调用一次 [[stop]],然后主动调用一次 [[start]]205 * 以保证 option 正确生效。当主动设置的 option 和场景中的 option 有冲突时,以后设置的为准,比如:签到场景中默认的为单次定位,206 * 当主动设置 option 为连续定位时,如果先设置的场景,后改变的 option,这时如果不调用 [[start]] 不会变为连续定位,207 * 如果调用了 [[start]] 则会变为连续定位,如果先改变 option,后设置场景为签到场景,则会变为单次定位。208 *209 * @platform android210 */211export function setLocationPurpose(purpose) {212 if (Platform.OS === "android") {213 AMapGeolocation.setLocationPurpose(purpose);214 }215}216/**217 * 设置逆地理信息的语言,目前支持中文和英文218 *219 * @default GeoLanguage.DEFAULT220 */221export function setGeoLanguage(language) {222 AMapGeolocation.setGeoLanguage(language);223}224/**225 * 设定定位的最小更新距离(米)226 *227 * 默认为 `kCLDistanceFilterNone`,表示只要检测到设备位置发生变化就会更新位置信息。228 *229 * @platform ios230 */231export function setDistanceFilter(distance) {232 if (Platform.OS === "ios") {233 AMapGeolocation.setDistanceFilter(distance);234 }235}236/**237 * 设定期望的定位精度(米)238 *239 * 默认为 `kCLLocationAccuracyBest`。240 * 定位服务会尽可能去获取满足 `desiredAccuracy` 的定位结果,但不保证一定会得到满足期望的结果。241 *242 * 注意:设置为 `kCLLocationAccuracyBest` 或 `kCLLocationAccuracyBestForNavigation` 时,243 * 单次定位会在达到 `locationTimeout` 设定的时间后,将时间内获取到的最高精度的定位结果返回。244 *245 * @platform ios246 */247export function setDesiredAccuracy(desiredAccuracy) {248 if (Platform.OS === "ios") {249 AMapGeolocation.setDesiredAccuracy(desiredAccuracy);250 }251}252/**253 * 指定定位是否会被系统自动暂停254 *255 * @default false256 * @platform ios257 */258export function setPausesLocationUpdatesAutomatically(isPause) {259 if (Platform.OS === "ios") {260 AMapGeolocation.setPausesLocationUpdatesAutomatically(isPause);261 }262}263/**264 * 是否允许后台定位265 *266 * 只在iOS 9.0 及之后起作用。267 * 设置为YES的时候必须保证 `Background Modes` 中的 `Location updates` 处于选中状态,否则会抛出异常。268 * 由于iOS系统限制,需要在定位未开始之前或定位停止之后,修改该属性的值才会有效果。269 *270 * @default false271 * @platform ios272 */273export function setAllowsBackgroundLocationUpdates(isAllow) {274 if (Platform.OS === "ios") {275 AMapGeolocation.setAllowsBackgroundLocationUpdates(isAllow);276 }277}278/**279 * 指定单次定位超时时间(秒)280 *281 * 最小值是 2s。注意在单次定位请求前设置。282 *283 * 注意: 单次定位超时时间从确定了定位权限(非 `kCLAuthorizationStatusNotDetermined` 状态)后开始计算。284 *285 * @default 10286 * @platform ios287 */288export function setLocationTimeout(timeout) {289 if (Platform.OS === "ios") {290 AMapGeolocation.setLocationTimeout(timeout);291 }292}293/**294 * 指定单次定位逆地理超时时间(秒)295 *296 * 最小值是 2s。注意在单次定位请求前设置。297 *298 * @default 5299 * @platform ios300 */301export function setReGeocodeTimeout(timeout) {302 if (Platform.OS === "ios") {303 AMapGeolocation.setReGeocodeTimeout(timeout);304 }305}306export const _options = {};307/**308 * 连续定位是否返回逆地理编码309 *310 * @default false311 * @platform ios312 */313export function setLocatingWithReGeocode(withReGeocode) {314 _options.locatingWithReGeocode = withReGeocode;315 if (Platform.OS === "ios") {316 AMapGeolocation.setLocatingWithReGeocode(withReGeocode);317 }...

Full Screen

Full Screen

platformOrder.js

Source:platformOrder.js Github

copy

Full Screen

1export default {2 'platform.title.order-management': 'Order Management',3 'platform.search.classification': 'Classification',4 'platform.search-option.platform': 'Platform',5 'platform.search-option.platform.placeholder': 'Please choose platform',6 'platform.search-option.fulfillment': 'Fulfillment',7 'platform.search-option.fulfillment.placeholder': 'Please choose fulfillment',8 'platform.search-option.fulfillment.merchant': 'Merchant',9 'platform.search-option.fulfillment.platform': 'Platform',10 'platform.search-option.platform-status': 'Status',11 'platform.search-option.platform-status.placeholder': 'Please choose platform status',12 'platform.search-option.local-status': 'Status',13 'platform.search-option.local-status.placeholder': 'Please choose order status',14 'platform.search-option.pending': 'pending',15 'platform.search-option.unshipped': 'Unshipped',16 'platform.search-option.partially-shipped': 'Partially Shipped',17 'platform.search-option.shipped': 'Shipped',18 'platform.search-option.canceled': 'Canceled',19 'platform.search-option.refunded': 'Refunded',20 'platform.search-option.unfulfillable': 'Unfulfillable',21 'platform.search-option.unknown': 'Unknown',22 'platform.search.filter': 'Filter',23 'platform.search-option.platform-sn': 'SN',24 'platform.search-option.platform-sn.placeholder': 'Input',25 'platform.search-option.warehouse': 'Warehouse',26 'platform.search-option.warehouse.placeholder': 'Choose logistic warehouse',27 'platform.table.th.platform': 'Platform',28 'platform.table.th.sn': 'SN',29 'platform.table.th.fulfillment': 'Fulfillment',30 'platform.table.th.warehouse': 'Warehouse',31 'platform.table.th.ship-level': 'Ship Level',32 'platform.table.th.platform-status': 'Platform Status',33 'platform.table.th.local-status': 'System Status',34 'platform.table.th.customer': 'Customer',35 'platform.table.th.payment': 'Payment',36 'platform.table.th.price': 'Price',37 'platform.table.th.created_at': 'Created At',38 'platform.table.th.action': 'Action',39 'platform.table.platform-warehouse': 'Platform Warehouse',40 'platform.detail.title': 'Order Information',41 'platform.detail.subtitle.order': 'Order',42 'platform.detail.order.created_at': 'Purchase Date',43 'platform.detail.order.price': 'Price Amount',44 'platform.detail.order.fulfillment': 'Fulfillment',45 'platform.detail.order.ship_level': 'Ship Level',46 'platform.detail.order.platform': 'Platform',47 'platform.detail.order.platform_status': 'Platform Status',48 'platform.detail.order.local_status': 'System Status',49 'platform.detail.order.carrier': 'Carrier',50 'platform.detail.order.tracking_number': 'Tracking Number',51 'platform.detail.order.actual_ship_date': 'Actual Ship Date',52 'platform.detail.subtitle.waybill': 'Waybill',53 'platform.detail.waybill.name': 'Receiver',54 'platform.detail.waybill.phone': 'Phone',55 'platform.detail.waybill.address1': 'Address1',56 'platform.detail.waybill.address2': 'Address2',57 'platform.detail.waybill.address3': 'Address3',58 'platform.detail.waybill.city': 'City',59 'platform.detail.waybill.state': 'State',60 'platform.detail.waybill.postal_code': 'Postal Code',61 'platform.detail.waybill.country': 'Country',62 'platform.detail.subtitle.product': 'Product',63 'platform.detail.product.title': 'Title',64 'platform.detail.product.quantity': 'Quantity',65 'platform.detail.product.currency': 'Currency',66 'platform.detail.product.amount': 'Amount',67 'platform.detail.product.pick_info': 'Pick Information',68 'platform.detail.product.pick_info.warehouse': 'Warehouse',69 'platform.detail.product.pick_info.quantity': 'Quantity',70 'platform.detail.button.ship_conform': 'Confirm Delivery',71 'platform.detail.button.ship_edit': 'Shipping Information Edit',72 'platform.detail.product.remark': 'Remark',73 'platform.detail.product.action': 'Action',74 'platform.detail.product.edit-remark': 'Remark Edit',75 'platform.detail.edit.tips.success': 'success !',76 'platform.detail.delivery.title': 'Delivery',77 'platform.detail.delivery.carrier': 'Carrier',78 'platform.detail.delivery.carrier.message': 'Please choose carrier',79 'platform.detail.delivery.carrier.placeholder': 'Please choose',80 'platform.detail.delivery.tracking_number': 'Tracking Number',81 'platform.detail.delivery.tracking_number.message': 'Please input tracking number',82 'platform.detail.delivery.tracking_number.placeholder': 'Please input',83 'platform.detail.delivery.actual_ship_date': 'Ship Date',84 'platform.detail.delivery.actual_ship_date.placeholder': 'Please choose ship date',85 'platform.detail.tips.success': 'Success !',86 'platform.detail.tips.failure': 'Error !',87 'platform.detail.ship.edit.tips.success': 'Success !',88 'platform.detail.fulfillment.info': 'Platform Delivery ',89 'platform.table.ignore-shipment': 'Ignore Shipment',90 'platform.edit.whether-ignore-shipment': 'Ignore Shipment',91 'platform.edit.whether-ignore-shipment.yes': 'Yes',92 'platform.edit.whether-ignore-shipment.no': 'No',93 'platform.edit.tip.choose': 'Please Choose!',94 'platform.edit.form-title': 'Edit Merchant Order',95 'platform.detail.button.delivery.tips': 'Are you sure to delivery?',96 'platform.table.status.tips': 'The order platform status is inconsistent with the system status!',...

Full Screen

Full Screen

platform.js

Source:platform.js Github

copy

Full Screen

1(function(enyo, scope) {2 /**3 * Determines OS versions of platforms that need special treatment. Can have one of the following4 * properties:5 *6 * * android7 * * androidChrome (Chrome on Android, standard starting in 4.1)8 * * androidFirefox9 * * ie10 * * ios11 * * webos12 * * windowsPhone13 * * blackberry14 * * tizen15 * * safari (desktop version)16 * * chrome (desktop version)17 * * firefox (desktop version)18 * * firefoxOS19 *20 * If the property is defined, its value will be the major version number of the platform.21 *22 * Example:23 * ```javascript24 * // android 2 does not have 3d css25 * if (enyo.platform.android < 3) {26 * t = 'translate(30px, 50px)';27 * } else {28 * t = 'translate3d(30px, 50px, 0)';29 * }30 * this.applyStyle('-webkit-transform', t);31 * ```32 *33 * @name enyo.platform34 */35 enyo.platform = 36 /** @lends enyo.platform */ {37 //* `true` if the platform has native single-finger [events]{@glossary event}.38 touch: Boolean(('ontouchstart' in window) || window.navigator.msMaxTouchPoints),39 //* `true` if the platform has native double-finger [events]{@glossary event}.40 gesture: Boolean(('ongesturestart' in window) || window.navigator.msMaxTouchPoints)41 };42 /**43 * @private44 */45 var ua = navigator.userAgent;46 var ep = enyo.platform;47 var platforms = [48 // Android 4+ using Chrome49 {platform: 'androidChrome', regex: /Android .* Chrome\/(\d+)[.\d]+/},50 // Android 2 - 451 {platform: 'android', regex: /Android (\d+)/},52 // Kindle Fire53 // Force version to 2, (desktop mode does not list android version)54 {platform: 'android', regex: /Silk\/1./, forceVersion: 2, extra: {silk: 1}},55 // Kindle Fire HD (Silk versions 2 or 3)56 // Force version to 457 {platform: 'android', regex: /Silk\/2./, forceVersion: 4, extra: {silk: 2}},58 {platform: 'android', regex: /Silk\/3./, forceVersion: 4, extra: {silk: 3}},59 // Windows Phone 7 - 860 {platform: 'windowsPhone', regex: /Windows Phone (?:OS )?(\d+)[.\d]+/},61 // IE 8 - 1062 {platform: 'ie', regex: /MSIE (\d+)/},63 // IE 1164 {platform: 'ie', regex: /Trident\/.*; rv:(\d+)/},65 // iOS 3 - 566 // Apple likes to make this complicated67 {platform: 'ios', regex: /iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/},68 // webOS 1 - 369 {platform: 'webos', regex: /(?:web|hpw)OS\/(\d+)/},70 // webOS 4 / OpenWebOS71 {platform: "webos", regex: /WebAppManager|Isis|webOS\./, forceVersion: 4},72 // desktop Safari73 {platform: 'safari', regex: /Version\/(\d+)[.\d]+\s+Safari/},74 // desktop Chrome75 {platform: 'chrome', regex: /Chrome\/(\d+)[.\d]+/},76 // Firefox on Android77 {platform: 'androidFirefox', regex: /Android;.*Firefox\/(\d+)/},78 // FirefoxOS79 {platform: 'firefoxOS', regex: /Mobile;.*Firefox\/(\d+)/},80 // desktop Firefox81 {platform: 'firefox', regex: /Firefox\/(\d+)/},82 // Blackberry Playbook83 {platform: 'blackberry', regex: /PlayBook/i, forceVersion: 2},84 // Blackberry 10+85 {platform: 'blackberry', regex: /BB1\d;.*Version\/(\d+\.\d+)/},86 // Tizen87 {platform: 'tizen', regex: /Tizen (\d+)/}88 ];89 for (var i = 0, p, m, v; (p = platforms[i]); i++) {90 m = p.regex.exec(ua);91 if (m) {92 if (p.forceVersion) {93 v = p.forceVersion;94 } else {95 v = Number(m[1]);96 }97 ep[p.platform] = v;98 if (p.extra) {99 enyo.mixin(ep, p.extra);100 }101 ep.platformName = p.platform;102 break;103 }104 }105 106 /**107 * These platforms only allow one argument for [console.log()]{@glossary console.log}:108 *109 * * android110 * * ios111 * * webos112 *113 * @private114 */115 enyo.dumbConsole = Boolean(ep.android || ep.ios || ep.webos);...

Full Screen

Full Screen

image-tag.js

Source:image-tag.js Github

copy

Full Screen

1import { has, get, trimEnd, trimStart } from 'lodash-es';2import Platform from './platform';3class ImageTag {4 constructor(imageProperties) {5 const {6 repository = 'gableroux',7 name = 'unity3d',8 version = '2019.2.11f1',9 platform,10 } = imageProperties;11 if (!ImageTag.versionPattern.test(version)) {12 throw new Error(`Invalid version "${version}".`);13 }14 if (!has(ImageTag.targetPlatformToImageSuffixMap, platform)) {15 throw new Error(`Platform "${platform}" is currently not supported.`);16 }17 const builderPlatform = get(18 ImageTag.targetPlatformToImageSuffixMap,19 platform,20 ImageTag.imageSuffixes.generic,21 );22 Object.assign(this, { repository, name, version, platform, builderPlatform });23 }24 static get versionPattern() {25 return /^20\d{2}\.\d\.\w{3,4}|3$/;26 }27 static get imageSuffixes() {28 return {29 generic: '',30 webgl: 'webgl',31 mac: 'mac',32 windows: 'windows',33 android: 'android',34 ios: 'ios',35 facebook: 'facebook',36 };37 }38 static get targetPlatformToImageSuffixMap() {39 const { generic, webgl, mac, windows, android, ios, facebook } = ImageTag.imageSuffixes;40 // @see: https://docs.unity3d.com/ScriptReference/BuildTarget.html41 return {42 [Platform.types.StandaloneOSX]: mac,43 [Platform.types.StandaloneWindows]: windows,44 [Platform.types.StandaloneWindows64]: windows,45 [Platform.types.StandaloneLinux64]: windows,46 [Platform.types.iOS]: ios,47 [Platform.types.Android]: android,48 [Platform.types.WebGL]: webgl,49 [Platform.types.WSAPlayer]: windows,50 [Platform.types.PS4]: windows,51 [Platform.types.XboxOne]: windows,52 [Platform.types.tvOS]: windows,53 [Platform.types.Switch]: windows,54 // Unsupported55 [Platform.types.Lumin]: windows,56 [Platform.types.BJM]: windows,57 [Platform.types.Stadia]: windows,58 [Platform.types.Facebook]: facebook,59 [Platform.types.NoTarget]: generic,60 // Test specific61 [Platform.types.Test]: generic,62 };63 }64 get tag() {65 return trimEnd(`${this.version}-${this.builderPlatform}`, '-');66 }67 get image() {68 return trimStart(`${this.repository}/${this.name}`, '/');69 }70 toString() {71 const { image, tag } = this;72 return `${image}:${tag}`;73 }74}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { openBrowser, goto, closeBrowser } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await goto("google.com");6 } catch (e) {7 console.error(e);8 } finally {9 await closeBrowser();10 }11})();12const { openBrowser, goto, closeBrowser } = require('taiko');13const assert = require("assert");14describe('Google', () => {15 before(async () => {16 await openBrowser();17 });18 after(async () => {19 await closeBrowser();20 });21 it('should navigate to google', async () => {22 await goto("google.com");23 assert.ok(true);24 });25});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { openBrowser, goto, closeBrowser } = require('taiko');2(async () => {3 try {4 await openBrowser({headless:false});5 await goto("google.com");6 await closeBrowser();7 } catch (e) {8 console.error(e);9 } finally {10 }11})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { openBrowser, goto, closeBrowser } = require('taiko');2(async () => {3 try {4 await openBrowser({ headless: false });5 await goto('google.com');6 await closeBrowser();7 } catch (e) {8 console.error(e);9 } finally {10 }11})();12const puppeteer = require('puppeteer');13(async () => {14 const browser = await puppeteer.launch({ headless: false });15 const page = await browser.newPage();16 await browser.close();17})();18const { openBrowser, goto, closeBrowser, platform } = require('taiko');19(async () => {20 try {21 await openBrowser({ headless: false });22 await goto('google.com');23 console.log(platform.version);24 await closeBrowser();25 } catch (e) {26 console.error(e);27 } finally {28 }29})();30 at Object.<anonymous> (C:\Users\test\test.js:7:21)31 at Module._compile (internal/modules/cjs/loader.js:1137:30)32 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)33 at Module.load (internal/modules/cjs/loader.js:985:32)34 at Function.Module._load (internal/modules/cjs/loader.js:878:14)35 at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { openBrowser, goto, inputField, write, closeBrowser } = require('taiko');2(async () => {3 try {4 await openBrowser({ headless: false });5 await goto("google.com");6 await write("Taiko", into(inputField()));7 } catch (e) {8 console.error(e);9 } finally {10 await closeBrowser();11 }12})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { openBrowser, goto, closeBrowser, write, press, platform } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await write("Taiko", press('Enter'));6 await platform('darwin', async () => {7 await write("Taiko", press('Enter'));8 });9 await platform('linux', async () => {10 await write("Taiko", press('Enter'));11 });12 await platform('win32', async () => {13 await write("Taiko", press('Enter'));14 });15 } catch (e) {16 console.error(e);17 } finally {18 await closeBrowser();19 }20})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { openBrowser, goto, closeBrowser, text, $ } = require('taiko');2(async () => {3 try {4 await openBrowser();5 await text("Google Search").exists();6 await $("input[name='q']").exists();7 } catch (e) {8 console.error(e);9 } finally {10 await closeBrowser();11 }12})();13const { openBrowser, goto, closeBrowser, text, $ } = require('taiko');14(async () => {15 try {16 await openBrowser();17 await text("Google Search").exists();18 await $("input[name='q']").exists();19 } catch (e) {20 console.error(e);21 } finally {22 await closeBrowser();23 }24})();25const { openBrowser, goto, closeBrowser, text, $ } = require('taiko');26(async () => {27 try {28 await openBrowser();29 await text("Google Search").exists();30 await $("input[name='q']").exists();31 } catch (e) {32 console.error(e);33 } finally {34 await closeBrowser();35 }36})();37const { openBrowser, goto, closeBrowser, text, $ } = require('taiko');38(async () => {39 try {40 await openBrowser();41 await text("Google Search").exists();42 await $("input[name='q']").exists();43 } catch (e) {44 console.error(e);45 } finally {46 await closeBrowser();47 }48})();49const { openBrowser, goto, closeBrowser, text, $ } = require('taiko');50(async () => {51 try {52 await openBrowser();53 await text("Google Search").exists();54 await $("input[name='q']").exists();55 } catch (e) {56 console.error(e);57 } finally {58 await closeBrowser();59 }60})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const {openBrowser, goto, closeBrowser, platform} = require('taiko');2(async () => {3 try {4 await openBrowser();5 await goto("google.com");6 if(platform() === 'Mac') {7 console.log("Test is running on Mac");8 }9 } catch (e) {10 console.error(e);11 } finally {12 await closeBrowser();13 }14})();15platform()16const {openBrowser, goto, closeBrowser, platform} = require('taiko');17(async () => {18 try {19 await openBrowser();20 await goto("google.com");21 console.log(platform());22 } catch (e) {23 console.error(e);24 } finally {25 await closeBrowser();26 }27})();28setConfig()29setConfig(config)30const {openBrowser, goto, closeBrowser, setConfig} = require('taiko');31(async () => {32 try {33 setConfig({34 });35 await openBrowser();36 await goto("google.com");37 } catch (e) {38 console.error(e);39 } finally {40 await closeBrowser();41 }42})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { openBrowser, goto, closeBrowser, button, text, toRightOf, image, below, write, inputField, link, toLeftOf, textBox, dropDown, listItem, focus, radioButton, checkBox, click, attach, link, toLeftOf, textBox, dropDown, listItem, focus, radioButton, checkBox, click, attach, link, toLeftOf, textBox, dropDown, listItem, focus, radioButton, checkBox, click, attach } = require('taiko');2(async () => {3 try {4 await openBrowser({ headless: false });5 await click("Login");6 await focus(textBox(toLeftOf("Password")));7 await write("admin");8 await focus(textBox(toLeftOf("Password")));9 await write("admin");10 await click("Login");11 await click(link("New"));12 await focus(textBox(toLeftOf("Name")));13 await write("Test");14 await focus(textBox(toLeftOf("Name")));15 await write("Test");16 await focus(textBox(toLeftOf("Email")));17 await write("

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run taiko 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