Best JavaScript code snippet using wpt
dc_motor.js
Source:dc_motor.js
1/**2 * @fileoverview FTC robot blocks related to DC motors.3 * @author lizlooney@google.com (Liz Looney)4 */56// The following are generated dynamically in HardwareUtil.fetchJavaScriptForHardware():7// createDcMotorDropdown8// The following are defined in vars.js:9// createNonEditableField10// functionColor11// getPropertyColor12// setPropertyColor1314Blockly.Blocks['dcMotor_setProperty'] = {15 init: function() {16 var PROPERTY_CHOICES = [17 ['Direction', 'Direction'],18 ['MaxSpeed', 'MaxSpeed'],19 ['Mode', 'Mode'],20 ['Power', 'Power'],21 ['TargetPosition', 'TargetPosition'],22 ['TargetPositionTolerance', 'TargetPositionTolerance'],23 ['Velocity', 'Velocity'],24 ['ZeroPowerBehavior', 'ZeroPowerBehavior'],25 ];26 this.appendValueInput('VALUE') // no type, for compatibility27 .appendField('set')28 .appendField(createDcMotorDropdown(), 'IDENTIFIER')29 .appendField('.')30 .appendField(new Blockly.FieldDropdown(PROPERTY_CHOICES), 'PROP')31 .appendField('to');32 this.setPreviousStatement(true);33 this.setNextStatement(true);34 this.setColour(setPropertyColor);35 // Assign 'this' to a variable for use in the tooltip closure below.36 var thisBlock = this;37 var TOOLTIPS = [38 ['Direction', 'Sets the Direction for the motor.'],39 ['MaxSpeed', 'This block does nothing. MaxSpeed is deprecated.'],40 ['Mode', 'Sets the RunMode for the motor.'],41 ['Power', 'Sets the power for the motor. Valid values are between -1.0 and 1.0.'],42 ['TargetPosition', 'Sets the target position for the motor.'],43 ['TargetPositionTolerance', 'Sets the target positioning tolerance for the motor. ' +44 'Not all DcMotors support this feature.'],45 ['Velocity', 'Sets the velocity for the motor in ticks per second. ' +46 'Not all DcMotors support this feature.'],47 ['ZeroPowerBehavior', 'Sets the ZeroPowerBehavior for the motor. Valid values are BRAKE or FLOAT.'],48 ];49 this.setTooltip(function() {50 var key = thisBlock.getFieldValue('PROP');51 for (var i = 0; i < TOOLTIPS.length; i++) {52 if (TOOLTIPS[i][0] == key) {53 return TOOLTIPS[i][1];54 }55 }56 return '';57 });58 }59};6061Blockly.JavaScript['dcMotor_setProperty'] = function(block) {62 var identifier = block.getFieldValue('IDENTIFIER');63 var property = block.getFieldValue('PROP');64 var value = Blockly.JavaScript.valueToCode(65 block, 'VALUE', Blockly.JavaScript.ORDER_NONE);66 return identifier + '.set' + property + '(' + value + ');\n';67};6869Blockly.FtcJava['dcMotor_setProperty'] = function(block) {70 var property = block.getFieldValue('PROP');71 if (property == 'MaxSpeed') {72 return '';73 }74 var identifier = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER', 'DcMotor');75 var value = Blockly.FtcJava.valueToCode(block, 'VALUE', Blockly.FtcJava.ORDER_NONE);76 if (property == 'TargetPositionTolerance' || property == 'Velocity') {77 // This java code will throw ClassCastException if the DcMotor is not a DcMotorEx.78 Blockly.FtcJava.generateImport_('DcMotorEx');79 return '((DcMotorEx) ' + identifier + ').set' + property + '(' + value + ');\n';80 } else {81 return identifier + '.set' + property + '(' + value + ');\n';82 }83};8485Blockly.Blocks['dcMotor_setProperty_Direction'] = {86 init: function() {87 var PROPERTY_CHOICES = [88 ['Direction', 'Direction'],89 ];90 this.appendValueInput('VALUE').setCheck('DcMotorSimple.Direction')91 .appendField('set')92 .appendField(createDcMotorDropdown(), 'IDENTIFIER')93 .appendField('.')94 .appendField(new Blockly.FieldDropdown(PROPERTY_CHOICES), 'PROP')95 .appendField('to');96 this.setPreviousStatement(true);97 this.setNextStatement(true);98 this.setColour(setPropertyColor);99 // Assign 'this' to a variable for use in the tooltip closure below.100 var thisBlock = this;101 var TOOLTIPS = [102 ['Direction', 'Sets the Direction for the motor.'],103 ];104 this.setTooltip(function() {105 var key = thisBlock.getFieldValue('PROP');106 for (var i = 0; i < TOOLTIPS.length; i++) {107 if (TOOLTIPS[i][0] == key) {108 return TOOLTIPS[i][1];109 }110 }111 return '';112 });113 }114};115116Blockly.JavaScript['dcMotor_setProperty_Direction'] =117 Blockly.JavaScript['dcMotor_setProperty'];118119Blockly.FtcJava['dcMotor_setProperty_Direction'] =120 Blockly.FtcJava['dcMotor_setProperty'];121122Blockly.Blocks['dcMotor_setProperty_Number'] = {123 init: function() {124 var PROPERTY_CHOICES = [125 ['MaxSpeed', 'MaxSpeed'],126 ['Power', 'Power'],127 ['TargetPosition', 'TargetPosition'],128 ['TargetPositionTolerance', 'TargetPositionTolerance'],129 ['Velocity', 'Velocity'],130 ];131 this.appendValueInput('VALUE').setCheck('Number')132 .appendField('set')133 .appendField(createDcMotorDropdown(), 'IDENTIFIER')134 .appendField('.')135 .appendField(new Blockly.FieldDropdown(PROPERTY_CHOICES), 'PROP')136 .appendField('to');137 this.setPreviousStatement(true);138 this.setNextStatement(true);139 this.setColour(setPropertyColor);140 // Assign 'this' to a variable for use in the closures below.141 var thisBlock = this;142 var TOOLTIPS = [143 ['MaxSpeed', 'This block does nothing. MaxSpeed is deprecated.'],144 ['Power', 'Sets the power for the motor. Valid values are between -1.0 and 1.0.'],145 ['TargetPosition', 'Sets the target position for the motor.'],146 ['TargetPositionTolerance', 'Sets the target positioning tolerance for the motor. ' +147 'Not all DcMotors support this feature.'],148 ['Velocity', 'Sets the velocity for the motor in ticks per second. ' +149 'Not all DcMotors support this feature.'],150 ];151 this.setTooltip(function() {152 var key = thisBlock.getFieldValue('PROP');153 for (var i = 0; i < TOOLTIPS.length; i++) {154 if (TOOLTIPS[i][0] == key) {155 return TOOLTIPS[i][1];156 }157 }158 return '';159 });160 this.getFtcJavaInputType = function(inputName) {161 if (inputName == 'VALUE') {162 var property = thisBlock.getFieldValue('PROP');163 switch (property) {164 case 'MaxSpeed':165 case 'Power':166 case 'Velocity':167 return 'double';168 case 'TargetPosition':169 case 'TargetPositionTolerance':170 return 'int';171 default:172 throw 'Unexpected property ' + property + ' (dcMotor_setProperty_Number getArgumentType).';173 }174 }175 return '';176 };177 }178};179180Blockly.JavaScript['dcMotor_setProperty_Number'] =181 Blockly.JavaScript['dcMotor_setProperty'];182183Blockly.FtcJava['dcMotor_setProperty_Number'] =184 Blockly.FtcJava['dcMotor_setProperty'];185186Blockly.Blocks['dcMotor_setProperty_RunMode'] = {187 init: function() {188 var PROPERTY_CHOICES = [189 ['Mode', 'Mode'],190 ];191 this.appendValueInput('VALUE').setCheck('DcMotor.RunMode')192 .appendField('set')193 .appendField(createDcMotorDropdown(), 'IDENTIFIER')194 .appendField('.')195 .appendField(new Blockly.FieldDropdown(PROPERTY_CHOICES), 'PROP')196 .appendField('to');197 this.setPreviousStatement(true);198 this.setNextStatement(true);199 this.setColour(setPropertyColor);200 // Assign 'this' to a variable for use in the tooltip closure below.201 var thisBlock = this;202 var TOOLTIPS = [203 ['Mode', 'Sets the RunMode for the motor.'],204 ];205 this.setTooltip(function() {206 var key = thisBlock.getFieldValue('PROP');207 for (var i = 0; i < TOOLTIPS.length; i++) {208 if (TOOLTIPS[i][0] == key) {209 return TOOLTIPS[i][1];210 }211 }212 return '';213 });214 }215};216217Blockly.JavaScript['dcMotor_setProperty_RunMode'] =218 Blockly.JavaScript['dcMotor_setProperty'];219220Blockly.FtcJava['dcMotor_setProperty_RunMode'] =221 Blockly.FtcJava['dcMotor_setProperty'];222223Blockly.Blocks['dcMotor_setProperty_ZeroPowerBehavior'] = {224 init: function() {225 var PROPERTY_CHOICES = [226 ['ZeroPowerBehavior', 'ZeroPowerBehavior'],227 ];228 this.appendValueInput('VALUE').setCheck('DcMotor.ZeroPowerBehavior')229 .appendField('set')230 .appendField(createDcMotorDropdown(), 'IDENTIFIER')231 .appendField('.')232 .appendField(new Blockly.FieldDropdown(PROPERTY_CHOICES), 'PROP')233 .appendField('to');234 this.setPreviousStatement(true);235 this.setNextStatement(true);236 this.setColour(setPropertyColor);237 // Assign 'this' to a variable for use in the tooltip closure below.238 var thisBlock = this;239 var TOOLTIPS = [240 ['ZeroPowerBehavior', 'Sets the ZeroPowerBehavior for the motor. Valid values are BRAKE or FLOAT.'],241 ];242 this.setTooltip(function() {243 var key = thisBlock.getFieldValue('PROP');244 for (var i = 0; i < TOOLTIPS.length; i++) {245 if (TOOLTIPS[i][0] == key) {246 return TOOLTIPS[i][1];247 }248 }249 return '';250 });251 }252};253254Blockly.JavaScript['dcMotor_setProperty_ZeroPowerBehavior'] =255 Blockly.JavaScript['dcMotor_setProperty'];256257Blockly.FtcJava['dcMotor_setProperty_ZeroPowerBehavior'] =258 Blockly.FtcJava['dcMotor_setProperty'];259260Blockly.Blocks['dcMotor_getProperty'] = {261 init: function() {262 var PROPERTY_CHOICES = [263 ['CurrentPosition', 'CurrentPosition'],264 ['Direction', 'Direction'],265 ['MaxSpeed', 'MaxSpeed'],266 ['Mode', 'Mode'],267 ['Power', 'Power'],268 ['PowerFloat', 'PowerFloat'],269 ['TargetPosition', 'TargetPosition'],270 ['TargetPositionTolerance', 'TargetPositionTolerance'],271 ['Velocity', 'Velocity'],272 ['ZeroPowerBehavior', 'ZeroPowerBehavior'],273 ];274 this.setOutput(true); // no type, for compatibility275 this.appendDummyInput()276 .appendField(createDcMotorDropdown(), 'IDENTIFIER')277 .appendField('.')278 .appendField(new Blockly.FieldDropdown(PROPERTY_CHOICES), 'PROP');279 this.setColour(getPropertyColor);280 // Assign 'this' to a variable for use in the tooltip closure below.281 var thisBlock = this;282 var TOOLTIPS = [283 ['CurrentPosition', 'Returns the current position of the motor.'],284 ['Direction', 'Returns the Direction of the motor.'],285 ['MaxSpeed', 'This block always returns 0. MaxSpeed is deprecated.'],286 ['Mode', 'Returns the RunMode of the motor.'],287 ['Power', 'Returns the power of the motor.'],288 ['PowerFloat', 'Returns true if the motor is currently in a float power level.'],289 ['TargetPosition', 'Returns the target position of the motor.'],290 ['TargetPositionTolerance', 'Returns the current target positioning tolerance of the motor. ' +291 'Not all DcMotors support this feature.'],292 ['Velocity', 'Returns the current velocity of the motor, in ticks per second. ' +293 'Not all DcMotors support this feature.'],294 ['ZeroPowerBehavior', 'Returns the current ZeroPowerBehavior of the motor: BRAKE or FLOAT.'],295 ];296 this.setTooltip(function() {297 var key = thisBlock.getFieldValue('PROP');298 for (var i = 0; i < TOOLTIPS.length; i++) {299 if (TOOLTIPS[i][0] == key) {300 return TOOLTIPS[i][1];301 }302 }303 return '';304 });305 }306};307308Blockly.JavaScript['dcMotor_getProperty'] = function(block) {309 var identifier = block.getFieldValue('IDENTIFIER');310 var property = block.getFieldValue('PROP');311 var code = identifier + '.get' + property + '()';312 return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];313};314315Blockly.FtcJava['dcMotor_getProperty'] = function(block) {316 var property = block.getFieldValue('PROP');317 if (property == 'MaxSpeed') {318 return ['0', Blockly.FtcJava.ORDER_ATOMIC];319 }320 var identifier = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER', 'DcMotor');321 var code;322 if (property == 'TargetPositionTolerance' || property == 'Velocity') {323 // This java code will throw ClassCastException if the DcMotor is not a DcMotorEx.324 Blockly.FtcJava.generateImport_('DcMotorEx');325 code = '((DcMotorEx) ' + identifier + ').get' + property + '()';326 } else {327 code = identifier + '.get' + property + '()';328 }329 return [code, Blockly.FtcJava.ORDER_FUNCTION_CALL];330};331332Blockly.Blocks['dcMotor_getProperty_Direction'] = {333 init: function() {334 var PROPERTY_CHOICES = [335 ['Direction', 'Direction'],336 ];337 this.setOutput(true, 'DcMotorSimple.Direction');338 this.appendDummyInput()339 .appendField(createDcMotorDropdown(), 'IDENTIFIER')340 .appendField('.')341 .appendField(new Blockly.FieldDropdown(PROPERTY_CHOICES), 'PROP');342 this.setColour(getPropertyColor);343 // Assign 'this' to a variable for use in the tooltip closure below.344 var thisBlock = this;345 var TOOLTIPS = [346 ['Direction', 'Returns the Direction of the motor.'],347 ];348 this.setTooltip(function() {349 var key = thisBlock.getFieldValue('PROP');350 for (var i = 0; i < TOOLTIPS.length; i++) {351 if (TOOLTIPS[i][0] == key) {352 return TOOLTIPS[i][1];353 }354 }355 return '';356 });357 }358};359360Blockly.JavaScript['dcMotor_getProperty_Direction'] =361 Blockly.JavaScript['dcMotor_getProperty'];362363Blockly.FtcJava['dcMotor_getProperty_Direction'] =364 Blockly.FtcJava['dcMotor_getProperty'];365366Blockly.Blocks['dcMotor_getProperty_Boolean'] = {367 init: function() {368 var PROPERTY_CHOICES = [369 ['PowerFloat', 'PowerFloat'],370 ];371 this.setOutput(true, 'Boolean');372 this.appendDummyInput()373 .appendField(createDcMotorDropdown(), 'IDENTIFIER')374 .appendField('.')375 .appendField(new Blockly.FieldDropdown(PROPERTY_CHOICES), 'PROP');376 this.setColour(getPropertyColor);377 // Assign 'this' to a variable for use in the tooltip closure below.378 var thisBlock = this;379 var TOOLTIPS = [380 ['PowerFloat', 'Returns true if the motor is currently in a float power level.'],381 ];382 this.setTooltip(function() {383 var key = thisBlock.getFieldValue('PROP');384 for (var i = 0; i < TOOLTIPS.length; i++) {385 if (TOOLTIPS[i][0] == key) {386 return TOOLTIPS[i][1];387 }388 }389 return '';390 });391 }392};393394Blockly.JavaScript['dcMotor_getProperty_Boolean'] =395 Blockly.JavaScript['dcMotor_getProperty'];396397Blockly.FtcJava['dcMotor_getProperty_Boolean'] =398 Blockly.FtcJava['dcMotor_getProperty'];399400Blockly.Blocks['dcMotor_getProperty_Number'] = {401 init: function() {402 var PROPERTY_CHOICES = [403 ['CurrentPosition', 'CurrentPosition'],404 ['MaxSpeed', 'MaxSpeed'],405 ['Power', 'Power'],406 ['TargetPosition', 'TargetPosition'],407 ['TargetPositionTolerance', 'TargetPositionTolerance'],408 ['Velocity', 'Velocity'],409 ];410 this.setOutput(true, 'Number');411 this.appendDummyInput()412 .appendField(createDcMotorDropdown(), 'IDENTIFIER')413 .appendField('.')414 .appendField(new Blockly.FieldDropdown(PROPERTY_CHOICES), 'PROP');415 this.setColour(getPropertyColor);416 // Assign 'this' to a variable for use in the closures below.417 var thisBlock = this;418 var TOOLTIPS = [419 ['CurrentPosition', 'Returns the current position of the motor.'],420 ['MaxSpeed', 'This block always returns 0. MaxSpeed is deprecated.'],421 ['Power', 'Returns the power of the motor.'],422 ['TargetPosition', 'Returns the target position of the motor.'],423 ['TargetPositionTolerance', 'Returns the current target positioning tolerance of the motor. ' +424 'Not all DcMotors support this feature.'],425 ['Velocity', 'Returns the current velocity of the motor, in ticks per second. ' +426 'Not all DcMotors support this feature.'],427 ];428 this.setTooltip(function() {429 var key = thisBlock.getFieldValue('PROP');430 for (var i = 0; i < TOOLTIPS.length; i++) {431 if (TOOLTIPS[i][0] == key) {432 return TOOLTIPS[i][1];433 }434 }435 return '';436 });437 this.getFtcJavaOutputType = function() {438 var property = thisBlock.getFieldValue('PROP');439 switch (property) {440 case 'MaxSpeed':441 case 'Power':442 case 'Velocity':443 return 'double';444 case 'CurrentPosition':445 case 'TargetPosition':446 case 'TargetPositionTolerance':447 return 'int';448 default:449 throw 'Unexpected property ' + property + ' (dcMotor_getProperty_Number getOutputType).';450 }451 };452 }453};454455Blockly.JavaScript['dcMotor_getProperty_Number'] =456 Blockly.JavaScript['dcMotor_getProperty'];457458Blockly.FtcJava['dcMotor_getProperty_Number'] =459 Blockly.FtcJava['dcMotor_getProperty'];460461Blockly.Blocks['dcMotor_getProperty_RunMode'] = {462 init: function() {463 var PROPERTY_CHOICES = [464 ['Mode', 'Mode'],465 ];466 this.setOutput(true, 'DcMotor.RunMode');467 this.appendDummyInput()468 .appendField(createDcMotorDropdown(), 'IDENTIFIER')469 .appendField('.')470 .appendField(new Blockly.FieldDropdown(PROPERTY_CHOICES), 'PROP');471 this.setColour(getPropertyColor);472 // Assign 'this' to a variable for use in the tooltip closure below.473 var thisBlock = this;474 var TOOLTIPS = [475 ['Mode', 'Returns the RunMode of the motor.'],476 ];477 this.setTooltip(function() {478 var key = thisBlock.getFieldValue('PROP');479 for (var i = 0; i < TOOLTIPS.length; i++) {480 if (TOOLTIPS[i][0] == key) {481 return TOOLTIPS[i][1];482 }483 }484 return '';485 });486 }487};488489Blockly.JavaScript['dcMotor_getProperty_RunMode'] =490 Blockly.JavaScript['dcMotor_getProperty'];491492Blockly.FtcJava['dcMotor_getProperty_RunMode'] =493 Blockly.FtcJava['dcMotor_getProperty'];494495Blockly.Blocks['dcMotor_getProperty_ZeroPowerBehavior'] = {496 init: function() {497 var PROPERTY_CHOICES = [498 ['ZeroPowerBehavior', 'ZeroPowerBehavior'],499 ];500 this.setOutput(true, 'DcMotor.ZeroPowerBehavior');501 this.appendDummyInput()502 .appendField(createDcMotorDropdown(), 'IDENTIFIER')503 .appendField('.')504 .appendField(new Blockly.FieldDropdown(PROPERTY_CHOICES), 'PROP');505 this.setColour(getPropertyColor);506 // Assign 'this' to a variable for use in the tooltip closure below.507 var thisBlock = this;508 var TOOLTIPS = [509 ['ZeroPowerBehavior', 'Returns the current ZeroPowerBehavior of the motor: BRAKE or FLOAT.'],510 ];511 this.setTooltip(function() {512 var key = thisBlock.getFieldValue('PROP');513 for (var i = 0; i < TOOLTIPS.length; i++) {514 if (TOOLTIPS[i][0] == key) {515 return TOOLTIPS[i][1];516 }517 }518 return '';519 });520 }521};522523Blockly.JavaScript['dcMotor_getProperty_ZeroPowerBehavior'] =524 Blockly.JavaScript['dcMotor_getProperty'];525526Blockly.FtcJava['dcMotor_getProperty_ZeroPowerBehavior'] =527 Blockly.FtcJava['dcMotor_getProperty'];528529// Dual property setters530531Blockly.Blocks['dcMotor_setDualProperty'] = {532 init: function() {533 var PROPERTY_CHOICES = [534 ['MaxSpeed', 'MaxSpeed'],535 ['Mode', 'Mode'],536 ['Power', 'Power'],537 ['TargetPosition', 'TargetPosition'],538 ['TargetPositionTolerance', 'TargetPositionTolerance'],539 ['Velocity', 'Velocity'],540 ['ZeroPowerBehavior', 'ZeroPowerBehavior'],541 ];542 this.appendDummyInput()543 .appendField('set')544 .appendField(new Blockly.FieldDropdown(PROPERTY_CHOICES), 'PROP')545 this.appendValueInput('VALUE1') // no type, for compatibility546 .appendField(createDcMotorDropdown(), 'IDENTIFIER1')547 .appendField('to')548 .setAlign(Blockly.ALIGN_RIGHT);549 this.appendValueInput('VALUE2') // no type, for compatibility550 .appendField(createDcMotorDropdown(), 'IDENTIFIER2')551 .appendField('to')552 .setAlign(Blockly.ALIGN_RIGHT);553 this.setPreviousStatement(true);554 this.setNextStatement(true);555 this.setColour(setPropertyColor);556 // Assign 'this' to a variable for use in the tooltip closure below.557 var thisBlock = this;558 var TOOLTIPS = [559 ['MaxSpeed', 'This block does nothing. MaxSpeed is deprecated.'],560 ['Mode', 'Sets the RunMode for two motors.'],561 ['Power', 'Sets the power for two motors. Valid values are between -1.0 and 1.0.'],562 ['TargetPosition', 'Sets the target position for two motors.'],563 ['TargetPositionTolerance', 'Sets the target positioning tolerance for two motors. ' +564 'Not all DcMotors support this feature.'],565 ['Velocity', 'Sets the velocity for two motors in ticks per second. ' +566 'Not all DcMotors support this feature.'],567 ['ZeroPowerBehavior', 'Sets the ZeroPowerBehavior for two motors. Valid values are BRAKE or FLOAT.'],568 ];569 this.setTooltip(function() {570 var key = thisBlock.getFieldValue('PROP');571 for (var i = 0; i < TOOLTIPS.length; i++) {572 if (TOOLTIPS[i][0] == key) {573 return TOOLTIPS[i][1];574 }575 }576 return '';577 });578 }579};580581Blockly.JavaScript['dcMotor_setDualProperty'] = function(block) {582 var identifier1 = block.getFieldValue('IDENTIFIER1');583 var identifier2 = block.getFieldValue('IDENTIFIER2');584 var property = block.getFieldValue('PROP');585 var value1 = Blockly.JavaScript.valueToCode(586 block, 'VALUE1', Blockly.JavaScript.ORDER_COMMA);587 var value2 = Blockly.JavaScript.valueToCode(588 block, 'VALUE2', Blockly.JavaScript.ORDER_COMMA);589 return identifier1 + '.setDual' + property + '(' + value1 + ', ' +590 identifier2 + ', ' + value2 + ');\n';591};592593Blockly.FtcJava['dcMotor_setDualProperty'] = function(block) {594 var property = block.getFieldValue('PROP');595 if (property == 'MaxSpeed') {596 return '';597 }598 var identifier1 = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER1', 'DcMotor');599 var identifier2 = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER2', 'DcMotor');600 var value1 = Blockly.FtcJava.valueToCode(601 block, 'VALUE1', Blockly.FtcJava.ORDER_COMMA);602 var value2 = Blockly.FtcJava.valueToCode(603 block, 'VALUE2', Blockly.FtcJava.ORDER_COMMA);604 if (property == 'TargetPositionTolerance' || property == 'Velocity') {605 // This java code will throw ClassCastException if the DcMotor is not a DcMotorEx.606 Blockly.FtcJava.generateImport_('DcMotorEx');607 return '((DcMotorEx) ' + identifier1 + ').set' + property + '(' + value1 + ');\n' +608 '((DcMotorEx) ' + identifier2 + ').set' + property + '(' + value2 + ');\n';609 } else {610 return identifier1 + '.set' + property + '(' + value1 + ');\n' +611 identifier2 + '.set' + property + '(' + value2 + ');\n';612 }613};614615Blockly.Blocks['dcMotor_setDualProperty_Number'] = {616 init: function() {617 var PROPERTY_CHOICES = [618 ['MaxSpeed', 'MaxSpeed'],619 ['Power', 'Power'],620 ['TargetPosition', 'TargetPosition'],621 ['TargetPositionTolerance', 'TargetPositionTolerance'],622 ['Velocity', 'Velocity'],623 ];624 this.appendDummyInput()625 .appendField('set')626 .appendField(new Blockly.FieldDropdown(PROPERTY_CHOICES), 'PROP')627 this.appendValueInput('VALUE1').setCheck('Number')628 .appendField(createDcMotorDropdown(), 'IDENTIFIER1')629 .appendField('to')630 .setAlign(Blockly.ALIGN_RIGHT);631 this.appendValueInput('VALUE2').setCheck('Number')632 .appendField(createDcMotorDropdown(), 'IDENTIFIER2')633 .appendField('to')634 .setAlign(Blockly.ALIGN_RIGHT);635 this.setPreviousStatement(true);636 this.setNextStatement(true);637 this.setColour(setPropertyColor);638 // Assign 'this' to a variable for use in the closures below.639 var thisBlock = this;640 var TOOLTIPS = [641 ['MaxSpeed', 'This block does nothing. MaxSpeed is deprecated.'],642 ['Power', 'Sets the power for two motors. Valid values are between -1.0 and 1.0.'],643 ['TargetPosition', 'Sets the target position for two motors.'],644 ['TargetPositionTolerance', 'Sets the target positioning tolerance for two motors. ' +645 'Not all DcMotors support this feature.'],646 ['Velocity', 'Sets the velocity for two motors in ticks per second. ' +647 'Not all DcMotors support this feature.'],648 ];649 this.setTooltip(function() {650 var key = thisBlock.getFieldValue('PROP');651 for (var i = 0; i < TOOLTIPS.length; i++) {652 if (TOOLTIPS[i][0] == key) {653 return TOOLTIPS[i][1];654 }655 }656 return '';657 });658 this.getFtcJavaInputType = function(inputName) {659 if (inputName == 'VALUE1' || inputName == 'VALUE2') {660 var property = thisBlock.getFieldValue('PROP');661 switch (property) {662 case 'MaxSpeed':663 case 'Power':664 case 'Velocity':665 return 'double';666 case 'TargetPosition':667 case 'TargetPositionTolerance':668 return 'int';669 default:670 throw 'Unexpected property ' + property + ' (dcMotor_setDualProperty_Number getArgumentType).';671 }672 }673 return '';674 };675 }676};677678Blockly.JavaScript['dcMotor_setDualProperty_Number'] =679 Blockly.JavaScript['dcMotor_setDualProperty'];680681Blockly.FtcJava['dcMotor_setDualProperty_Number'] =682 Blockly.FtcJava['dcMotor_setDualProperty'];683684685Blockly.Blocks['dcMotor_setDualProperty_RunMode'] = {686 init: function() {687 var PROPERTY_CHOICES = [688 ['Mode', 'Mode'],689 ];690 this.appendDummyInput()691 .appendField('set')692 .appendField(new Blockly.FieldDropdown(PROPERTY_CHOICES), 'PROP')693 this.appendValueInput('VALUE1').setCheck('DcMotor.RunMode')694 .appendField(createDcMotorDropdown(), 'IDENTIFIER1')695 .appendField('to')696 .setAlign(Blockly.ALIGN_RIGHT);697 this.appendValueInput('VALUE2').setCheck('DcMotor.RunMode')698 .appendField(createDcMotorDropdown(), 'IDENTIFIER2')699 .appendField('to')700 .setAlign(Blockly.ALIGN_RIGHT);701 this.setPreviousStatement(true);702 this.setNextStatement(true);703 this.setColour(setPropertyColor);704 // Assign 'this' to a variable for use in the tooltip closure below.705 var thisBlock = this;706 var TOOLTIPS = [707 ['Mode', 'Sets the RunMode for two motors.'],708 ];709 this.setTooltip(function() {710 var key = thisBlock.getFieldValue('PROP');711 for (var i = 0; i < TOOLTIPS.length; i++) {712 if (TOOLTIPS[i][0] == key) {713 return TOOLTIPS[i][1];714 }715 }716 return '';717 });718 }719};720721Blockly.JavaScript['dcMotor_setDualProperty_RunMode'] =722 Blockly.JavaScript['dcMotor_setDualProperty'];723724Blockly.FtcJava['dcMotor_setDualProperty_RunMode'] =725 Blockly.FtcJava['dcMotor_setDualProperty'];726727Blockly.Blocks['dcMotor_setDualProperty_ZeroPowerBehavior'] = {728 init: function() {729 var PROPERTY_CHOICES = [730 ['ZeroPowerBehavior', 'ZeroPowerBehavior'],731 ];732 this.appendDummyInput()733 .appendField('set')734 .appendField(new Blockly.FieldDropdown(PROPERTY_CHOICES), 'PROP')735 this.appendValueInput('VALUE1').setCheck('DcMotor.ZeroPowerBehavior')736 .appendField(createDcMotorDropdown(), 'IDENTIFIER1')737 .appendField('to')738 .setAlign(Blockly.ALIGN_RIGHT);739 this.appendValueInput('VALUE2').setCheck('DcMotor.ZeroPowerBehavior')740 .appendField(createDcMotorDropdown(), 'IDENTIFIER2')741 .appendField('to')742 .setAlign(Blockly.ALIGN_RIGHT);743 this.setPreviousStatement(true);744 this.setNextStatement(true);745 this.setColour(setPropertyColor);746 // Assign 'this' to a variable for use in the tooltip closure below.747 var thisBlock = this;748 var TOOLTIPS = [749 ['ZeroPowerBehavior', 'Sets the ZeroPowerBehavior for two motors. Valid values are BRAKE or FLOAT.'],750 ];751 this.setTooltip(function() {752 var key = thisBlock.getFieldValue('PROP');753 for (var i = 0; i < TOOLTIPS.length; i++) {754 if (TOOLTIPS[i][0] == key) {755 return TOOLTIPS[i][1];756 }757 }758 return '';759 });760 }761};762763Blockly.JavaScript['dcMotor_setDualProperty_ZeroPowerBehavior'] =764 Blockly.JavaScript['dcMotor_setDualProperty'];765766Blockly.FtcJava['dcMotor_setDualProperty_ZeroPowerBehavior'] =767 Blockly.FtcJava['dcMotor_setDualProperty'];768769// Enums770771Blockly.Blocks['dcMotor_enum_runMode'] = {772 init: function() {773 var RUN_MODE_CHOICES = [774 ['RUN_WITHOUT_ENCODER', 'RUN_WITHOUT_ENCODER'],775 ['RUN_USING_ENCODER', 'RUN_USING_ENCODER'],776 ['RUN_TO_POSITION', 'RUN_TO_POSITION'],777 ['STOP_AND_RESET_ENCODER', 'STOP_AND_RESET_ENCODER'],778 ];779 this.setOutput(true); // no type, for compatibility780 this.appendDummyInput()781 .appendField(createNonEditableField('RunMode'))782 .appendField('.')783 .appendField(new Blockly.FieldDropdown(RUN_MODE_CHOICES), 'RUN_MODE');784 this.setColour(getPropertyColor);785 // Assign 'this' to a variable for use in the tooltip closure below.786 var thisBlock = this;787 var TOOLTIPS = [788 ['RUN_WITHOUT_ENCODER', 'The DcMotor RunMode value RUN_WITHOUT_ENCODER.'],789 ['RUN_USING_ENCODER', 'The DcMotor RunMode value RUN_USING_ENCODER.'],790 ['RUN_TO_POSITION', 'The DcMotor RunMode value RUN_TO_POSITION.'],791 ['STOP_AND_RESET_ENCODER', 'The DcMotor RunMode value STOP_AND_RESET_ENCODER.'],792 ];793 this.setTooltip(function() {794 var key = thisBlock.getFieldValue('RUN_MODE');795 for (var i = 0; i < TOOLTIPS.length; i++) {796 if (TOOLTIPS[i][0] == key) {797 return TOOLTIPS[i][1];798 }799 }800 return '';801 });802 }803};804805Blockly.JavaScript['dcMotor_enum_runMode'] = function(block) {806 var code = '"' + block.getFieldValue('RUN_MODE') + '"';807 return [code, Blockly.JavaScript.ORDER_ATOMIC];808};809810Blockly.FtcJava['dcMotor_enum_runMode'] = function(block) {811 var code = 'DcMotor.RunMode.' + block.getFieldValue('RUN_MODE');812 Blockly.FtcJava.generateImport_('DcMotor');813 return [code, Blockly.FtcJava.ORDER_MEMBER];814};815816Blockly.Blocks['dcMotor_typedEnum_runMode'] = {817 init: function() {818 var RUN_MODE_CHOICES = [819 ['RUN_WITHOUT_ENCODER', 'RUN_WITHOUT_ENCODER'],820 ['RUN_USING_ENCODER', 'RUN_USING_ENCODER'],821 ['RUN_TO_POSITION', 'RUN_TO_POSITION'],822 ['STOP_AND_RESET_ENCODER', 'STOP_AND_RESET_ENCODER'],823 ];824 this.setOutput(true, 'DcMotor.RunMode');825 this.appendDummyInput()826 .appendField(createNonEditableField('RunMode'))827 .appendField('.')828 .appendField(new Blockly.FieldDropdown(RUN_MODE_CHOICES), 'RUN_MODE');829 this.setColour(getPropertyColor);830 // Assign 'this' to a variable for use in the tooltip closure below.831 var thisBlock = this;832 var TOOLTIPS = [833 ['RUN_WITHOUT_ENCODER', 'The DcMotor RunMode value RUN_WITHOUT_ENCODER.'],834 ['RUN_USING_ENCODER', 'The DcMotor RunMode value RUN_USING_ENCODER.'],835 ['RUN_TO_POSITION', 'The DcMotor RunMode value RUN_TO_POSITION.'],836 ['STOP_AND_RESET_ENCODER', 'The DcMotor RunMode value STOP_AND_RESET_ENCODER.'],837 ];838 this.setTooltip(function() {839 var key = thisBlock.getFieldValue('RUN_MODE');840 for (var i = 0; i < TOOLTIPS.length; i++) {841 if (TOOLTIPS[i][0] == key) {842 return TOOLTIPS[i][1];843 }844 }845 return '';846 });847 }848};849850Blockly.JavaScript['dcMotor_typedEnum_runMode'] =851 Blockly.JavaScript['dcMotor_enum_runMode'];852853Blockly.FtcJava['dcMotor_typedEnum_runMode'] =854 Blockly.FtcJava['dcMotor_enum_runMode'];855856Blockly.Blocks['dcMotor_enum_direction'] = {857 init: function() {858 var DIRECTION_CHOICES = [859 ['REVERSE', 'REVERSE'],860 ['FORWARD', 'FORWARD'],861 ];862 this.setOutput(true); // no type, for compatibility863 this.appendDummyInput()864 .appendField(createNonEditableField('Direction'))865 .appendField('.')866 .appendField(new Blockly.FieldDropdown(DIRECTION_CHOICES), 'DIRECTION');867 this.setColour(getPropertyColor);868 // Assign 'this' to a variable for use in the tooltip closure below.869 var thisBlock = this;870 var TOOLTIPS = [871 ['REVERSE', 'The Direction value REVERSE.'],872 ['FORWARD', 'The Direction value FORWARD.'],873 ];874 this.setTooltip(function() {875 var key = thisBlock.getFieldValue('DIRECTION');876 for (var i = 0; i < TOOLTIPS.length; i++) {877 if (TOOLTIPS[i][0] == key) {878 return TOOLTIPS[i][1];879 }880 }881 return '';882 });883 }884};885886Blockly.JavaScript['dcMotor_enum_direction'] = function(block) {887 var code = '"' + block.getFieldValue('DIRECTION') + '"';888 return [code, Blockly.JavaScript.ORDER_ATOMIC];889};890891Blockly.FtcJava['dcMotor_enum_direction'] = function(block) {892 var code = 'DcMotorSimple.Direction.' + block.getFieldValue('DIRECTION');893 Blockly.FtcJava.generateImport_('DcMotorSimple');894 return [code, Blockly.FtcJava.ORDER_MEMBER];895};896897Blockly.Blocks['dcMotor_typedEnum_direction'] = {898 init: function() {899 var DIRECTION_CHOICES = [900 ['REVERSE', 'REVERSE'],901 ['FORWARD', 'FORWARD'],902 ];903 this.setOutput(true, 'DcMotorSimple.Direction');904 this.appendDummyInput()905 .appendField(createNonEditableField('Direction'))906 .appendField('.')907 .appendField(new Blockly.FieldDropdown(DIRECTION_CHOICES), 'DIRECTION');908 this.setColour(getPropertyColor);909 // Assign 'this' to a variable for use in the tooltip closure below.910 var thisBlock = this;911 var TOOLTIPS = [912 ['REVERSE', 'The Direction value REVERSE.'],913 ['FORWARD', 'The Direction value FORWARD.'],914 ];915 this.setTooltip(function() {916 var key = thisBlock.getFieldValue('DIRECTION');917 for (var i = 0; i < TOOLTIPS.length; i++) {918 if (TOOLTIPS[i][0] == key) {919 return TOOLTIPS[i][1];920 }921 }922 return '';923 });924 }925};926927Blockly.JavaScript['dcMotor_typedEnum_direction'] =928 Blockly.JavaScript['dcMotor_enum_direction'];929930Blockly.FtcJava['dcMotor_typedEnum_direction'] =931 Blockly.FtcJava['dcMotor_enum_direction'];932933Blockly.Blocks['dcMotor_enum_zeroPowerBehavior'] = {934 init: function() {935 var ZERO_POWER_BEHAVIOR_CHOICES = [936 ['BRAKE', 'BRAKE'],937 ['FLOAT', 'FLOAT'],938 ];939 this.setOutput(true); // no type, for compatibility940 this.appendDummyInput()941 .appendField(createNonEditableField('ZeroPowerBehavior'))942 .appendField('.')943 .appendField(new Blockly.FieldDropdown(ZERO_POWER_BEHAVIOR_CHOICES), 'ZERO_POWER_BEHAVIOR');944 this.setColour(getPropertyColor);945 // Assign 'this' to a variable for use in the tooltip closure below.946 var thisBlock = this;947 var TOOLTIPS = [948 ['BRAKE', 'The ZeroPowerBehavior value BRAKE.'],949 ['FLOAT', 'The ZeroPowerBehavior value FLOAT.'],950 ];951 this.setTooltip(function() {952 var key = thisBlock.getFieldValue('ZERO_POWER_BEHAVIOR');953 for (var i = 0; i < TOOLTIPS.length; i++) {954 if (TOOLTIPS[i][0] == key) {955 return TOOLTIPS[i][1];956 }957 }958 return '';959 });960 }961};962963Blockly.JavaScript['dcMotor_enum_zeroPowerBehavior'] = function(block) {964 var code = '"' + block.getFieldValue('ZERO_POWER_BEHAVIOR') + '"';965 return [code, Blockly.JavaScript.ORDER_ATOMIC];966};967968Blockly.FtcJava['dcMotor_enum_zeroPowerBehavior'] = function(block) {969 var code = 'DcMotor.ZeroPowerBehavior.' + block.getFieldValue('ZERO_POWER_BEHAVIOR');970 Blockly.FtcJava.generateImport_('DcMotor');971 return [code, Blockly.FtcJava.ORDER_MEMBER];972};973974Blockly.Blocks['dcMotor_typedEnum_zeroPowerBehavior'] = {975 init: function() {976 var ZERO_POWER_BEHAVIOR_CHOICES = [977 ['BRAKE', 'BRAKE'],978 ['FLOAT', 'FLOAT'],979 ];980 this.setOutput(true, 'DcMotor.ZeroPowerBehavior');981 this.appendDummyInput()982 .appendField(createNonEditableField('ZeroPowerBehavior'))983 .appendField('.')984 .appendField(new Blockly.FieldDropdown(ZERO_POWER_BEHAVIOR_CHOICES), 'ZERO_POWER_BEHAVIOR');985 this.setColour(getPropertyColor);986 // Assign 'this' to a variable for use in the tooltip closure below.987 var thisBlock = this;988 var TOOLTIPS = [989 ['BRAKE', 'The ZeroPowerBehavior value BRAKE.'],990 ['FLOAT', 'The ZeroPowerBehavior value FLOAT.'],991 ];992 this.setTooltip(function() {993 var key = thisBlock.getFieldValue('ZERO_POWER_BEHAVIOR');994 for (var i = 0; i < TOOLTIPS.length; i++) {995 if (TOOLTIPS[i][0] == key) {996 return TOOLTIPS[i][1];997 }998 }999 return '';1000 });1001 }1002};10031004Blockly.JavaScript['dcMotor_typedEnum_zeroPowerBehavior'] =1005 Blockly.JavaScript['dcMotor_enum_zeroPowerBehavior'];10061007Blockly.FtcJava['dcMotor_typedEnum_zeroPowerBehavior'] =1008 Blockly.FtcJava['dcMotor_enum_zeroPowerBehavior'];10091010// Functions10111012Blockly.Blocks['dcMotor_isBusy'] = {1013 init: function() {1014 this.setOutput(true, 'Boolean');1015 this.appendDummyInput()1016 .appendField('call')1017 .appendField(createDcMotorDropdown(), 'IDENTIFIER')1018 .appendField('.')1019 .appendField(createNonEditableField('isBusy'));1020 this.setColour(functionColor);1021 this.setTooltip('Returns true if the motor is currently advancing or retreating to a target position.');1022 }1023};10241025Blockly.JavaScript['dcMotor_isBusy'] = function(block) {1026 var identifier = block.getFieldValue('IDENTIFIER');1027 var code = identifier + '.isBusy()';1028 return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];1029};10301031Blockly.FtcJava['dcMotor_isBusy'] = function(block) {1032 var identifier = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER', 'DcMotor');1033 var code = identifier + '.isBusy()';1034 return [code, Blockly.FtcJava.ORDER_FUNCTION_CALL];1035};10361037Blockly.Blocks['dcMotor_setMotorEnable'] = {1038 init: function() {1039 this.appendDummyInput()1040 .appendField('call')1041 .appendField(createDcMotorExDropdown(), 'IDENTIFIER')1042 .appendField('.')1043 .appendField(createNonEditableField('setMotorEnable'));1044 this.setPreviousStatement(true);1045 this.setNextStatement(true);1046 this.setColour(functionColor);1047 this.setTooltip('Individually energizes this particular motor. ' +1048 'Not all DcMotors support this feature.');1049 }1050};10511052Blockly.JavaScript['dcMotor_setMotorEnable'] = function(block) {1053 var identifier = block.getFieldValue('IDENTIFIER');1054 return identifier + '.setMotorEnable();\n';1055};10561057Blockly.FtcJava['dcMotor_setMotorEnable'] = function(block) {1058 var identifier = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER', 'DcMotor');1059 // This java code will throw ClassCastException if the DcMotor is not a DcMotorEx.1060 Blockly.FtcJava.generateImport_('DcMotorEx');1061 return '((DcMotorEx) ' + identifier + ').setMotorEnable();\n';1062};10631064Blockly.Blocks['dcMotor_setMotorDisable'] = {1065 init: function() {1066 this.appendDummyInput()1067 .appendField('call')1068 .appendField(createDcMotorExDropdown(), 'IDENTIFIER')1069 .appendField('.')1070 .appendField(createNonEditableField('setMotorDisable'));1071 this.setPreviousStatement(true);1072 this.setNextStatement(true);1073 this.setColour(functionColor);1074 this.setTooltip('Individually de-energizes this particular motor. ' +1075 'Not all DcMotors support this feature.');1076 }1077};10781079Blockly.JavaScript['dcMotor_setMotorDisable'] = function(block) {1080 var identifier = block.getFieldValue('IDENTIFIER');1081 return identifier + '.setMotorDisable();\n';1082};10831084Blockly.FtcJava['dcMotor_setMotorDisable'] = function(block) {1085 var identifier = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER', 'DcMotor');1086 // This java code will throw ClassCastException if the DcMotor is not a DcMotorEx.1087 Blockly.FtcJava.generateImport_('DcMotorEx');1088 return '((DcMotorEx) ' + identifier + ').setMotorDisable();\n';1089};10901091Blockly.Blocks['dcMotor_isMotorEnabled'] = {1092 init: function() {1093 this.setOutput(true, 'Boolean');1094 this.appendDummyInput()1095 .appendField('call')1096 .appendField(createDcMotorExDropdown(), 'IDENTIFIER')1097 .appendField('.')1098 .appendField(createNonEditableField('isMotorEnabled'));1099 this.setColour(functionColor);1100 this.setTooltip('Returns true if the motor is energized. ' +1101 'Not all DcMotors support this feature.');1102 }1103};11041105Blockly.JavaScript['dcMotor_isMotorEnabled'] = function(block) {1106 var identifier = block.getFieldValue('IDENTIFIER');1107 var code = identifier + '.isMotorEnabled()';1108 return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];1109};11101111Blockly.FtcJava['dcMotor_isMotorEnabled'] = function(block) {1112 var identifier = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER', 'DcMotor');1113 // This java code will throw ClassCastException if the DcMotor is not a DcMotorEx.1114 Blockly.FtcJava.generateImport_('DcMotorEx');1115 var code = '((DcMotorEx) ' + identifier + ').isMotorEnabled()';1116 return [code, Blockly.FtcJava.ORDER_FUNCTION_CALL];1117};11181119Blockly.Blocks['dcMotor_setVelocity_withAngleUnit'] = {1120 init: function() {1121 this.appendDummyInput()1122 .appendField('call')1123 .appendField(createDcMotorExDropdown(), 'IDENTIFIER')1124 .appendField('.')1125 .appendField(createNonEditableField('setVelocity'));1126 this.appendValueInput('ANGULAR_RATE').setCheck('Number')1127 .appendField('angularRate')1128 .setAlign(Blockly.ALIGN_RIGHT);1129 this.appendValueInput('ANGLE_UNIT').setCheck('AngleUnit')1130 .appendField('angleUnit')1131 .setAlign(Blockly.ALIGN_RIGHT);1132 this.setPreviousStatement(true);1133 this.setNextStatement(true);1134 this.setColour(functionColor);1135 this.setTooltip('Sets the velocity of the motor. ' +1136 'Not all DcMotors support this feature.');1137 this.getFtcJavaInputType = function(inputName) {1138 switch (inputName) {1139 case 'ANGULAR_RATE':1140 return 'double';1141 }1142 return '';1143 };1144 }1145};11461147Blockly.JavaScript['dcMotor_setVelocity_withAngleUnit'] = function(block) {1148 var identifier = block.getFieldValue('IDENTIFIER');1149 var angularRate = Blockly.JavaScript.valueToCode(1150 block, 'ANGULAR_RATE', Blockly.JavaScript.ORDER_COMMA);1151 var angleUnit = Blockly.JavaScript.valueToCode(1152 block, 'ANGLE_UNIT', Blockly.JavaScript.ORDER_COMMA);1153 return identifier + '.setVelocity_withAngleUnit(' + angularRate + ', ' + angleUnit + ');\n';1154};11551156Blockly.FtcJava['dcMotor_setVelocity_withAngleUnit'] = function(block) {1157 var identifier = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER', 'DcMotor');1158 var angularRate = Blockly.FtcJava.valueToCode(1159 block, 'ANGULAR_RATE', Blockly.FtcJava.ORDER_COMMA);1160 var angleUnit = Blockly.FtcJava.valueToCode(1161 block, 'ANGLE_UNIT', Blockly.FtcJava.ORDER_COMMA);1162 // This java code will throw ClassCastException if the DcMotor is not a DcMotorEx.1163 Blockly.FtcJava.generateImport_('DcMotorEx');1164 return '((DcMotorEx) ' + identifier + ').setVelocity(' + angularRate + ', ' + angleUnit + ');\n';1165};11661167Blockly.Blocks['dcMotor_getVelocity_withAngleUnit'] = {1168 init: function() {1169 this.setOutput(true, 'Number');1170 this.appendDummyInput()1171 .appendField('call')1172 .appendField(createDcMotorExDropdown(), 'IDENTIFIER')1173 .appendField('.')1174 .appendField(createNonEditableField('getVelocity'));1175 this.appendValueInput('ANGLE_UNIT').setCheck('AngleUnit')1176 .appendField('angleUnit')1177 .setAlign(Blockly.ALIGN_RIGHT);1178 this.setColour(functionColor);1179 this.setTooltip('Returns the current velocity of the motor, in angular units per second. ' +1180 'Not all DcMotors support this feature.');1181 this.getFtcJavaOutputType = function() {1182 return 'double';1183 };1184 }1185};11861187Blockly.JavaScript['dcMotor_getVelocity_withAngleUnit'] = function(block) {1188 var identifier = block.getFieldValue('IDENTIFIER');1189 var angleUnit = Blockly.JavaScript.valueToCode(1190 block, 'ANGLE_UNIT', Blockly.JavaScript.ORDER_NONE);1191 var code = identifier + '.getVelocity_withAngleUnit(' + angleUnit + ')';1192 return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];1193};11941195Blockly.FtcJava['dcMotor_getVelocity_withAngleUnit'] = function(block) {1196 var identifier = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER', 'DcMotor');1197 var angleUnit = Blockly.FtcJava.valueToCode(1198 block, 'ANGLE_UNIT', Blockly.FtcJava.ORDER_NONE);1199 // This java code will throw ClassCastException if the DcMotor is not a DcMotorEx.1200 Blockly.FtcJava.generateImport_('DcMotorEx');1201 var code = '((DcMotorEx) ' + identifier + ').getVelocity(' + angleUnit + ')';1202 return [code, Blockly.FtcJava.ORDER_FUNCTION_CALL];1203};12041205Blockly.Blocks['dcMotor_setPIDFCoefficients'] = {1206 init: function() {1207 this.appendDummyInput()1208 .appendField('call')1209 .appendField(createDcMotorExDropdown(), 'IDENTIFIER')1210 .appendField('.')1211 .appendField(createNonEditableField('setPIDFCoefficients'));1212 this.appendValueInput('RUN_MODE').setCheck('DcMotor.RunMode')1213 .appendField('runMode')1214 .setAlign(Blockly.ALIGN_RIGHT);1215 this.appendValueInput('PIDF_COEFFICIENTS').setCheck('PIDFCoefficients')1216 .appendField('pidfCoefficients')1217 .setAlign(Blockly.ALIGN_RIGHT);1218 this.setPreviousStatement(true);1219 this.setNextStatement(true);1220 this.setColour(functionColor);1221 this.setTooltip('Sets the PIDF control coefficients for one of the PIDF modes of this motor. ' +1222 'Note that in some controller implementations, setting the PIDF coefficients for one ' +1223 'mode on a motor might affect other modes on that motor, or might affect the PIDF ' +1224 'coefficients used by other motors on the same controller. ' +1225 'The runMode value can be either RUN_USING_ENCODER or RUN_TO_POSITION. ' +1226 'Not all DcMotors support this feature.');1227 }1228};12291230Blockly.JavaScript['dcMotor_setPIDFCoefficients'] = function(block) {1231 var identifier = block.getFieldValue('IDENTIFIER');1232 var runMode = Blockly.JavaScript.valueToCode(1233 block, 'RUN_MODE', Blockly.JavaScript.ORDER_COMMA);1234 var pidfCoefficients = Blockly.JavaScript.valueToCode(1235 block, 'PIDF_COEFFICIENTS', Blockly.JavaScript.ORDER_COMMA);1236 return identifier + '.setPIDFCoefficients(' + runMode + ', ' + pidfCoefficients + ');\n';1237};12381239Blockly.FtcJava['dcMotor_setPIDFCoefficients'] = function(block) {1240 var identifier = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER', 'DcMotor');1241 var runMode = Blockly.FtcJava.valueToCode(1242 block, 'RUN_MODE', Blockly.FtcJava.ORDER_COMMA);1243 var pidfCoefficients = Blockly.FtcJava.valueToCode(1244 block, 'PIDF_COEFFICIENTS', Blockly.FtcJava.ORDER_COMMA);1245 // This java code will throw ClassCastException if the DcMotor is not a DcMotorEx.1246 Blockly.FtcJava.generateImport_('DcMotorEx');1247 return '((DcMotorEx) ' + identifier + ').setPIDFCoefficients(' + runMode + ', ' +1248 pidfCoefficients + ');\n';1249};12501251Blockly.Blocks['dcMotor_getPIDFCoefficients'] = {1252 init: function() {1253 this.setOutput(true, 'PIDFCoefficients');1254 this.appendDummyInput()1255 .appendField('call')1256 .appendField(createDcMotorExDropdown(), 'IDENTIFIER')1257 .appendField('.')1258 .appendField(createNonEditableField('getPIDFCoefficients'));1259 this.appendValueInput('RUN_MODE').setCheck('DcMotor.RunMode')1260 .appendField('runMode')1261 .setAlign(Blockly.ALIGN_RIGHT);1262 this.setColour(functionColor);1263 this.setTooltip('Returns the PIDF control coefficients used when running in the indicated mode ' +1264 'on this motor. The runMode value can be either RUN_USING_ENCODER or RUN_TO_POSITION. ' +1265 'Not all DcMotors support this feature.');1266 }1267};12681269Blockly.JavaScript['dcMotor_getPIDFCoefficients'] = function(block) {1270 var identifier = block.getFieldValue('IDENTIFIER');1271 var runMode = Blockly.JavaScript.valueToCode(1272 block, 'RUN_MODE', Blockly.JavaScript.ORDER_NONE);1273 var code = identifier + '.getPIDFCoefficients(' + runMode + ')';1274 return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];1275};12761277Blockly.FtcJava['dcMotor_getPIDFCoefficients'] = function(block) {1278 var identifier = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER', 'DcMotor');1279 var runMode = Blockly.FtcJava.valueToCode(1280 block, 'RUN_MODE', Blockly.FtcJava.ORDER_NONE);1281 // This java code will throw ClassCastException if the DcMotor is not a DcMotorEx.1282 Blockly.FtcJava.generateImport_('DcMotorEx');1283 var code = '((DcMotorEx) ' + identifier + ').getPIDFCoefficients(' + runMode + ')';1284 return [code, Blockly.FtcJava.ORDER_FUNCTION_CALL];1285};12861287Blockly.Blocks['dcMotor_setVelocityPIDFCoefficients'] = {1288 init: function() {1289 this.appendDummyInput()1290 .appendField('call')1291 .appendField(createDcMotorExDropdown(), 'IDENTIFIER')1292 .appendField('.')1293 .appendField(createNonEditableField('setVelocityPIDFCoefficients'));1294 this.appendValueInput('P').setCheck('Number')1295 .appendField('p')1296 .setAlign(Blockly.ALIGN_RIGHT);1297 this.appendValueInput('I').setCheck('Number')1298 .appendField('i')1299 .setAlign(Blockly.ALIGN_RIGHT);1300 this.appendValueInput('D').setCheck('Number')1301 .appendField('d')1302 .setAlign(Blockly.ALIGN_RIGHT);1303 this.appendValueInput('F').setCheck('Number')1304 .appendField('f')1305 .setAlign(Blockly.ALIGN_RIGHT);1306 this.setPreviousStatement(true);1307 this.setNextStatement(true);1308 this.setColour(functionColor);1309 this.setTooltip('A shorthand for setting the PIDF coefficients for the RUN_USING_ENCODER mode. ' +1310 'Not all DcMotors support this feature.');1311 this.getFtcJavaInputType = function(inputName) {1312 switch (inputName) {1313 case 'P':1314 case 'I':1315 case 'D':1316 case 'F':1317 return 'double';1318 }1319 return '';1320 };1321 }1322};13231324Blockly.JavaScript['dcMotor_setVelocityPIDFCoefficients'] = function(block) {1325 var identifier = block.getFieldValue('IDENTIFIER');1326 var p = Blockly.JavaScript.valueToCode(1327 block, 'P', Blockly.JavaScript.ORDER_COMMA);1328 var i = Blockly.JavaScript.valueToCode(1329 block, 'I', Blockly.JavaScript.ORDER_COMMA);1330 var d = Blockly.JavaScript.valueToCode(1331 block, 'D', Blockly.JavaScript.ORDER_COMMA);1332 var f = Blockly.JavaScript.valueToCode(1333 block, 'F', Blockly.JavaScript.ORDER_COMMA);1334 return identifier + '.setVelocityPIDFCoefficients(' + p + ', ' + i + ', ' + d + ', ' + f + ');\n';1335};13361337Blockly.FtcJava['dcMotor_setVelocityPIDFCoefficients'] = function(block) {1338 var identifier = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER', 'DcMotor');1339 var p = Blockly.FtcJava.valueToCode(1340 block, 'P', Blockly.FtcJava.ORDER_COMMA);1341 var i = Blockly.FtcJava.valueToCode(1342 block, 'I', Blockly.FtcJava.ORDER_COMMA);1343 var d = Blockly.FtcJava.valueToCode(1344 block, 'D', Blockly.FtcJava.ORDER_COMMA);1345 var f = Blockly.FtcJava.valueToCode(1346 block, 'F', Blockly.FtcJava.ORDER_COMMA);1347 // This java code will throw ClassCastException if the DcMotor is not a DcMotorEx.1348 Blockly.FtcJava.generateImport_('DcMotorEx');1349 return '((DcMotorEx) ' + identifier + ').setVelocityPIDFCoefficients(' + p + ', ' + i + ', ' + d + ', ' + f + ');\n';1350};13511352Blockly.Blocks['dcMotor_setPositionPIDFCoefficients'] = {1353 init: function() {1354 this.appendDummyInput()1355 .appendField('call')1356 .appendField(createDcMotorExDropdown(), 'IDENTIFIER')1357 .appendField('.')1358 .appendField(createNonEditableField('setPositionPIDFCoefficients'));1359 this.appendValueInput('P').setCheck('Number')1360 .appendField('p')1361 .setAlign(Blockly.ALIGN_RIGHT);1362 this.setPreviousStatement(true);1363 this.setNextStatement(true);1364 this.setColour(functionColor);1365 this.setTooltip('A shorthand for setting the PIDF coefficients for the RUN_TO_POSITION mode. ' +1366 'Not all DcMotors support this feature.');1367 this.getFtcJavaInputType = function(inputName) {1368 switch (inputName) {1369 case 'P':1370 return 'double';1371 }1372 return '';1373 };1374 }1375};13761377Blockly.JavaScript['dcMotor_setPositionPIDFCoefficients'] = function(block) {1378 var identifier = block.getFieldValue('IDENTIFIER');1379 var p = Blockly.JavaScript.valueToCode(1380 block, 'P', Blockly.JavaScript.ORDER_NONE);1381 return identifier + '.setPositionPIDFCoefficients(' + p + ');\n';1382};13831384Blockly.FtcJava['dcMotor_setPositionPIDFCoefficients'] = function(block) {1385 var identifier = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER', 'DcMotor');1386 var p = Blockly.FtcJava.valueToCode(1387 block, 'P', Blockly.FtcJava.ORDER_NONE);1388 // This java code will throw ClassCastException if the DcMotor is not a DcMotorEx.1389 Blockly.FtcJava.generateImport_('DcMotorEx');1390 return '((DcMotorEx) ' + identifier + ').setPositionPIDFCoefficients(' + p + ');\n';1391};13921393Blockly.Blocks['dcMotor_getCurrent'] = {1394 init: function() {1395 this.setOutput(true, 'Number');1396 this.appendDummyInput()1397 .appendField('call')1398 .appendField(createDcMotorExDropdown(), 'IDENTIFIER')1399 .appendField('.')1400 .appendField(createNonEditableField('getCurrent'));1401 this.appendValueInput('CURRENT_UNIT').setCheck('CurrentUnit')1402 .appendField('currentUnit')1403 .setAlign(Blockly.ALIGN_RIGHT);1404 this.setColour(functionColor);1405 this.setTooltip('Returns the current consumed by this motor. ' +1406 'Not all DcMotors support this feature.');1407 this.getFtcJavaOutputType = function() {1408 return 'double';1409 };1410 }1411};14121413Blockly.JavaScript['dcMotor_getCurrent'] = function(block) {1414 var identifier = block.getFieldValue('IDENTIFIER');1415 var currentUnit = Blockly.JavaScript.valueToCode(1416 block, 'CURRENT_UNIT', Blockly.JavaScript.ORDER_NONE);1417 var code = identifier + '.getCurrent(' + currentUnit + ')';1418 return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];1419};14201421Blockly.FtcJava['dcMotor_getCurrent'] = function(block) {1422 var identifier = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER', 'DcMotor');1423 var currentUnit = Blockly.FtcJava.valueToCode(1424 block, 'CURRENT_UNIT', Blockly.FtcJava.ORDER_NONE);1425 // This java code will throw ClassCastException if the DcMotor is not a DcMotorEx.1426 Blockly.FtcJava.generateImport_('DcMotorEx');1427 var code = '((DcMotorEx) ' + identifier + ').getCurrent(' + currentUnit + ')';1428 return [code, Blockly.FtcJava.ORDER_FUNCTION_CALL];1429};14301431Blockly.Blocks['dcMotor_getCurrentAlert'] = {1432 init: function() {1433 this.setOutput(true, 'Number');1434 this.appendDummyInput()1435 .appendField('call')1436 .appendField(createDcMotorExDropdown(), 'IDENTIFIER')1437 .appendField('.')1438 .appendField(createNonEditableField('getCurrentAlert'));1439 this.appendValueInput('CURRENT_UNIT').setCheck('CurrentUnit')1440 .appendField('currentUnit')1441 .setAlign(Blockly.ALIGN_RIGHT);1442 this.setColour(functionColor);1443 this.setTooltip('Returns the current alert for this motor. ' +1444 'Not all DcMotors support this feature.');1445 this.getFtcJavaOutputType = function() {1446 return 'double';1447 };1448 }1449};14501451Blockly.JavaScript['dcMotor_getCurrentAlert'] = function(block) {1452 var identifier = block.getFieldValue('IDENTIFIER');1453 var currentUnit = Blockly.JavaScript.valueToCode(1454 block, 'CURRENT_UNIT', Blockly.JavaScript.ORDER_NONE);1455 var code = identifier + '.getCurrentAlert(' + currentUnit + ')';1456 return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];1457};14581459Blockly.FtcJava['dcMotor_getCurrentAlert'] = function(block) {1460 var identifier = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER', 'DcMotor');1461 var currentUnit = Blockly.FtcJava.valueToCode(1462 block, 'CURRENT_UNIT', Blockly.FtcJava.ORDER_NONE);1463 // This java code will throw ClassCastException if the DcMotor is not a DcMotorEx.1464 Blockly.FtcJava.generateImport_('DcMotorEx');1465 var code = '((DcMotorEx) ' + identifier + ').getCurrentAlert(' + currentUnit + ')';1466 return [code, Blockly.FtcJava.ORDER_FUNCTION_CALL];1467};14681469Blockly.Blocks['dcMotor_setCurrentAlert'] = {1470 init: function() {1471 this.appendDummyInput()1472 .appendField('call')1473 .appendField(createDcMotorExDropdown(), 'IDENTIFIER')1474 .appendField('.')1475 .appendField(createNonEditableField('setCurrentAlert'));1476 this.appendValueInput('CURRENT').setCheck('Number')1477 .appendField('current')1478 .setAlign(Blockly.ALIGN_RIGHT);1479 this.appendValueInput('CURRENT_UNIT').setCheck('CurrentUnit')1480 .appendField('currentUnit')1481 .setAlign(Blockly.ALIGN_RIGHT);1482 this.setPreviousStatement(true);1483 this.setNextStatement(true);1484 this.setColour(functionColor);1485 this.setTooltip('Sets the current alert for this motor. ' +1486 'Not all DcMotors support this feature.');1487 this.getFtcJavaInputType = function(inputName) {1488 switch (inputName) {1489 case 'CURRENT':1490 return 'double';1491 }1492 return '';1493 };1494 }1495};14961497Blockly.JavaScript['dcMotor_setCurrentAlert'] = function(block) {1498 var identifier = block.getFieldValue('IDENTIFIER');1499 var current = Blockly.JavaScript.valueToCode(1500 block, 'CURRENT', Blockly.JavaScript.ORDER_COMMA);1501 var currentUnit = Blockly.JavaScript.valueToCode(1502 block, 'CURRENT_UNIT', Blockly.JavaScript.ORDER_COMMA);1503 return identifier + '.setCurrentAlert(' + current + ', ' + currentUnit + ');\n';1504};15051506Blockly.FtcJava['dcMotor_setCurrentAlert'] = function(block) {1507 var identifier = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER', 'DcMotor');1508 var current = Blockly.FtcJava.valueToCode(1509 block, 'CURRENT', Blockly.FtcJava.ORDER_COMMA);1510 var currentUnit = Blockly.FtcJava.valueToCode(1511 block, 'CURRENT_UNIT', Blockly.FtcJava.ORDER_COMMA);1512 // This java code will throw ClassCastException if the DcMotor is not a DcMotorEx.1513 Blockly.FtcJava.generateImport_('DcMotorEx');1514 return '((DcMotorEx) ' + identifier + ').setCurrentAlert(' + current + ', ' + currentUnit + ');\n';1515};15161517Blockly.Blocks['dcMotor_isOverCurrent'] = {1518 init: function() {1519 this.setOutput(true, 'Boolean');1520 this.appendDummyInput()1521 .appendField('call')1522 .appendField(createDcMotorExDropdown(), 'IDENTIFIER')1523 .appendField('.')1524 .appendField(createNonEditableField('isOverCurrent'));1525 this.setColour(functionColor);1526 this.setTooltip('Returns true if the current consumption of this motor exceeds the alert threshold. ' +1527 'Not all DcMotors support this feature.');1528 }1529};15301531Blockly.JavaScript['dcMotor_isOverCurrent'] = function(block) {1532 var identifier = block.getFieldValue('IDENTIFIER');1533 var code = identifier + '.isOverCurrent()';1534 return [code, Blockly.JavaScript.ORDER_FUNCTION_CALL];1535};15361537Blockly.FtcJava['dcMotor_isOverCurrent'] = function(block) {1538 var identifier = Blockly.FtcJava.importDeclareAssign_(block, 'IDENTIFIER', 'DcMotor');1539 // This java code will throw ClassCastException if the DcMotor is not a DcMotorEx.1540 Blockly.FtcJava.generateImport_('DcMotorEx');1541 var code = '((DcMotorEx) ' + identifier + ').isOverCurrent()';1542 return [code, Blockly.FtcJava.ORDER_FUNCTION_CALL];
...
getBankNameByCard.js
Source:getBankNameByCard.js
1/**2 * Created by liswn on 2018/7/1.3 */4function bankCardAttribution (bankCard) {5 var cardTypeMap = {6 DC: 'å¨èå¡',7 CC: 'ä¿¡ç¨å¡',8 SCC: 'åè´·è®°å¡',9 PC: 'é¢ä»è´¹å¡'10 }11 function extend (target, source) {12 var result = {}13 var key14 target = target || {}15 source = source || {}16 for (key in target) {17 if (target.hasOwnProperty(key)) {18 result[key] = target[key]19 }20 }21 for (key in source) {22 if (source.hasOwnProperty(key)) {23 result[key] = source[key]24 }25 }26 return result27 }28 function getCardTypeName (cardType) {29 if (cardTypeMap[cardType]) {30 return cardTypeMap[cardType]31 }32 return undefined33 }34 var bankcardList = [{35 bankName: 'ä¸å½é®æ¿å¨èé¶è¡',36 bankCode: 'PSBC',37 patterns: [{38 reg: /^(621096|621098|622150|622151|622181|622188|622199|955100|621095|620062|621285|621798|621799|621797|620529|621622|621599|621674|623218|623219)\d{13}$/g,39 cardType: 'DC'40 }, {41 reg: /^(62215049|62215050|62215051|62218850|62218851|62218849)\d{11}$/g,42 cardType: 'DC'43 }, {44 reg: /^(622812|622810|622811|628310|625919)\d{10}$/g,45 cardType: 'CC'46 }]47 }, {48 bankName: 'ä¸å½å·¥åé¶è¡',49 bankCode: 'ICBC',50 patterns: [{51 reg: /^(620200|620302|620402|620403|620404|620406|620407|620409|620410|620411|620412|620502|620503|620405|620408|620512|620602|620604|620607|620611|620612|620704|620706|620707|620708|620709|620710|620609|620712|620713|620714|620802|620711|620904|620905|621001|620902|621103|621105|621106|621107|621102|621203|621204|621205|621206|621207|621208|621209|621210|621302|621303|621202|621305|621306|621307|621309|621311|621313|621211|621315|621304|621402|621404|621405|621406|621407|621408|621409|621410|621502|621317|621511|621602|621603|621604|621605|621608|621609|621610|621611|621612|621613|621614|621615|621616|621617|621607|621606|621804|621807|621813|621814|621817|621901|621904|621905|621906|621907|621908|621909|621910|621911|621912|621913|621915|622002|621903|622004|622005|622006|622007|622008|622010|622011|622012|621914|622015|622016|622003|622018|622019|622020|622102|622103|622104|622105|622013|622111|622114|622017|622110|622303|622304|622305|622306|622307|622308|622309|622314|622315|622317|622302|622402|622403|622404|622313|622504|622505|622509|622513|622517|622502|622604|622605|622606|622510|622703|622715|622806|622902|622903|622706|623002|623006|623008|623011|623012|622904|623015|623100|623202|623301|623400|623500|623602|623803|623901|623014|624100|624200|624301|624402|623700|624000)\d{12}$/g,52 cardType: 'DC'53 }, {54 reg: /^(622200|622202|622203|622208|621225|620058|621281|900000|621558|621559|621722|621723|620086|621226|621618|620516|621227|621288|621721|900010|623062|621670|621720|621379|621240|621724|621762|621414|621375|622926|622927|622928|622929|622930|622931|621733|621732|621372|621369|621763)\d{13}$/g,55 cardType: 'DC'56 }, {57 reg: /^(402791|427028|427038|548259|621376|621423|621428|621434|621761|621749|621300|621378|622944|622949|621371|621730|621734|621433|621370|621764|621464|621765|621750|621377|621367|621374|621731|621781)\d{10}$/g,58 cardType: 'DC'59 }, {60 reg: /^(9558)\d{15}$/g,61 cardType: 'DC'62 }, {63 reg: /^(370246|370248|370249|370247|370267|374738|374739)\d{9}$/g,64 cardType: 'CC'65 }, {66 reg: /^(427010|427018|427019|427020|427029|427030|427039|438125|438126|451804|451810|451811|458071|489734|489735|489736|510529|427062|524091|427064|530970|530990|558360|524047|525498|622230|622231|622232|622233|622234|622235|622237|622239|622240|622245|622238|451804|451810|451811|458071|628288|628286|622206|526836|513685|543098|458441|622246|544210|548943|356879|356880|356881|356882|528856|625330|625331|625332|622236|524374|550213|625929|625927|625939|625987|625930|625114|622159|625021|625022|625932|622889|625900|625915|625916|622171|625931|625113|625928|625914|625986|625925|625921|625926|625942|622158|625917|625922|625934|625933|625920|625924|625017|625018|625019)\d{10}$/g,67 cardType: 'CC'68 }, {69 reg: /^(45806|53098|45806|53098)\d{11}$/g,70 cardType: 'CC'71 }, {72 reg: /^(622210|622211|622212|622213|622214|622220|622223|622225|622229|622215|622224)\d{10}$/g,73 cardType: 'SCC'74 }, {75 reg: /^(620054|620142|620184|620030|620050|620143|620149|620124|620183|620094|620186|620148|620185)\d{10}$/g,76 cardType: 'PC'77 }, {78 reg: /^(620114|620187|620046)\d{13}$/g,79 cardType: 'PC'80 }]81 }, {82 bankName: 'ä¸å½åä¸é¶è¡',83 bankCode: 'ABC',84 patterns: [{85 reg: /^(622841|622824|622826|622848|620059|621282|622828|622823|621336|621619|622821|622822|622825|622827|622845|622849|623018|623206|621671|622840|622843|622844|622846|622847|620501)\d{13}$/g,86 cardType: 'DC'87 }, {88 reg: /^(95595|95596|95597|95598|95599)\d{14}$/g,89 cardType: 'DC'90 }, {91 reg: /^(103)\d{16}$/g,92 cardType: 'DC'93 }, {94 reg: /^(403361|404117|404118|404119|404120|404121|463758|519412|519413|520082|520083|552599|558730|514027|622836|622837|628268|625996|625998|625997|622838|625336|625826|625827|544243|548478|628269)\d{10}$/g,95 cardType: 'CC'96 }, {97 reg: /^(622820|622830)\d{10}$/g,98 cardType: 'SCC'99 }]100 }, {101 bankName: 'ä¸å½é¶è¡',102 bankCode: 'BOC',103 patterns: [{104 reg: /^(621660|621661|621662|621663|621665|621667|621668|621669|621666|456351|601382|621256|621212|621283|620061|621725|621330|621331|621332|621333|621297|621568|621569|621672|623208|621620|621756|621757|621758|621759|621785|621786|621787|621788|621789|621790|622273|622274|622771|622772|622770|621741|621041)\d{13}$/g,105 cardType: 'DC'106 }, {107 reg: /^(621293|621294|621342|621343|621364|621394|621648|621248|621215|621249|621231|621638|621334|621395|623040|622348)\d{10}$/g,108 cardType: 'DC'109 }, {110 reg: /^(625908|625910|625909|356833|356835|409665|409666|409668|409669|409670|409671|409672|512315|512316|512411|512412|514957|409667|438088|552742|553131|514958|622760|628388|518377|622788|628313|628312|622750|622751|625145|622479|622480|622789|625140|622346|622347)\d{10}$/g,111 cardType: 'CC'112 }, {113 reg: /^(518378|518379|518474|518475|518476|524865|525745|525746|547766|558868|622752|622753|622755|524864|622757|622758|622759|622761|622762|622763|622756|622754|622764|622765|558869|625905|625906|625907|625333)\d{10}$/g,114 cardType: 'SCC'115 }, {116 reg: /^(53591|49102|377677)\d{11}$/g,117 cardType: 'SCC'118 }, {119 reg: /^(620514|620025|620026|620210|620211|620019|620035|620202|620203|620048|620515|920000)\d{10}$/g,120 cardType: 'PC'121 }, {122 reg: /^(620040|620531|620513|921000|620038)\d{13}$/g,123 cardType: 'PC'124 }]125 }, {126 bankName: 'ä¸å½å»ºè®¾é¶è¡',127 bankCode: 'CCB',128 patterns: [{129 reg: /^(621284|436742|589970|620060|621081|621467|621598|621621|621700|622280|622700|623211|623668)\d{13}$/g,130 cardType: 'DC'131 }, {132 reg: /^(421349|434061|434062|524094|526410|552245|621080|621082|621466|621488|621499|622966|622988|622382|621487|621083|621084|620107)\d{10}$/g,133 cardType: 'DC'134 }, {135 reg: /^(436742193|622280193)\d{10}$/g,136 cardType: 'DC'137 }, {138 reg: /^(553242)\d{12}$/g,139 cardType: 'CC'140 }, {141 reg: /^(625362|625363|628316|628317|356896|356899|356895|436718|436738|436745|436748|489592|531693|532450|532458|544887|552801|557080|558895|559051|622166|622168|622708|625964|625965|625966|628266|628366|622381|622675|622676|622677)\d{10}$/g,142 cardType: 'CC'143 }, {144 reg: /^(5453242|5491031|5544033)\d{11}$/g,145 cardType: 'CC'146 }, {147 reg: /^(622725|622728|436728|453242|491031|544033|622707|625955|625956)\d{10}$/g,148 cardType: 'SCC'149 }, {150 reg: /^(53242|53243)\d{11}$/g,151 cardType: 'SCC'152 }]153 }, {154 bankName: 'ä¸å½äº¤éé¶è¡',155 bankCode: 'COMM',156 patterns: [{157 reg: /^(622261|622260|622262|621002|621069|621436|621335)\d{13}$/g,158 cardType: 'DC'159 }, {160 reg: /^(620013)\d{10}$/g,161 cardType: 'DC'162 }, {163 reg: /^(405512|601428|405512|601428|622258|622259|405512|601428)\d{11}$/g,164 cardType: 'DC'165 }, {166 reg: /^(49104|53783)\d{11}$/g,167 cardType: 'CC'168 }, {169 reg: /^(434910|458123|458124|520169|522964|552853|622250|622251|521899|622253|622656|628216|622252|955590|955591|955592|955593|628218|625028|625029)\d{10}$/g,170 cardType: 'CC'171 }, {172 reg: /^(622254|622255|622256|622257|622284)\d{10}$/g,173 cardType: 'SCC'174 }, {175 reg: /^(620021|620521)\d{13}$/g,176 cardType: 'PC'177 }]178 }, {179 bankName: 'æåé¶è¡',180 bankCode: 'CMB',181 patterns: [{182 reg: /^(402658|410062|468203|512425|524011|622580|622588|622598|622609|95555|621286|621483|621485|621486|621299)\d{10}$/g,183 cardType: 'DC'184 }, {185 reg: /^(690755)\d{9}$/g,186 cardType: 'DC'187 }, {188 reg: /^(690755)\d{12}$/g,189 cardType: 'DC'190 }, {191 reg: /^(356885|356886|356887|356888|356890|439188|439227|479228|479229|521302|356889|545620|545621|545947|545948|552534|552587|622575|622576|622577|622578|622579|545619|622581|622582|545623|628290|439225|518710|518718|628362|439226|628262|625802|625803)\d{10}$/g,192 cardType: 'CC'193 }, {194 reg: /^(370285|370286|370287|370289)\d{9}$/g,195 cardType: 'CC'196 }, {197 reg: /^(620520)\d{13}$/g,198 cardType: 'PC'199 }]200 }, {201 bankName: 'ä¸å½æ°çé¶è¡',202 bankCode: 'CMBC',203 patterns: [{204 reg: /^(622615|622616|622618|622622|622617|622619|415599|421393|421865|427570|427571|472067|472068|622620)\d{10}$/g,205 cardType: 'DC'206 }, {207 reg: /^(545392|545393|545431|545447|356859|356857|407405|421869|421870|421871|512466|356856|528948|552288|622600|622601|622602|517636|622621|628258|556610|622603|464580|464581|523952|545217|553161|356858|622623|625912|625913|625911)\d{10}$/g,208 cardType: 'CC'209 }, {210 reg: /^(377155|377152|377153|377158)\d{9}$/g,211 cardType: 'CC'212 }]213 }, {214 bankName: 'ä¸å½å
大é¶è¡',215 bankCode: 'CEB',216 patterns: [{217 reg: /^(303)\d{13}$/g,218 cardType: 'DC'219 }, {220 reg: /^(90030)\d{11}$/g,221 cardType: 'DC'222 }, {223 reg: /^(620535)\d{13}$/g,224 cardType: 'DC'225 }, {226 reg: /^(620085|622660|622662|622663|622664|622665|622666|622667|622669|622670|622671|622672|622668|622661|622674|622673|620518|621489|621492)\d{10}$/g,227 cardType: 'DC'228 }, {229 reg: /^(356837|356838|486497|622657|622685|622659|622687|625978|625980|625981|625979|356839|356840|406252|406254|425862|481699|524090|543159|622161|622570|622650|622655|622658|625975|625977|628201|628202|625339|625976)\d{10}$/g,230 cardType: 'CC'231 }]232 }, {233 bankName: 'ä¸ä¿¡é¶è¡',234 bankCode: 'CITIC',235 patterns: [{236 reg: /^(433670|433680|442729|442730|620082|622690|622691|622692|622696|622698|622998|622999|433671|968807|968808|968809|621771|621767|621768|621770|621772|621773|622453|622456)\d{10}$/g,237 cardType: 'DC'238 }, {239 reg: /^(622459)\d{11}$/g,240 cardType: 'DC'241 }, {242 reg: /^(376968|376969|376966)\d{9}$/g,243 cardType: 'CC'244 }, {245 reg: /^(400360|403391|403392|404158|404159|404171|404172|404173|404174|404157|433667|433668|433669|514906|403393|520108|433666|558916|622678|622679|622680|622688|622689|628206|556617|628209|518212|628208|356390|356391|356392|622916|622918|622919)\d{10}$/g,246 cardType: 'CC'247 }]248 }, {249 bankName: 'åå¤é¶è¡',250 bankCode: 'HXBANK',251 patterns: [{252 reg: /^(622630|622631|622632|622633|999999|621222|623020|623021|623022|623023)\d{10}$/g,253 cardType: 'DC'254 }, {255 reg: /^(523959|528709|539867|539868|622637|622638|628318|528708|622636|625967|625968|625969)\d{10}$/g,256 cardType: 'CC'257 }]258 }, {259 bankName: 'æ·±å/å¹³å®é¶è¡',260 bankCode: 'SPABANK',261 patterns: [{262 reg: /^(621626|623058)\d{13}$/g,263 cardType: 'DC'264 }, {265 reg: /^(602907|622986|622989|622298|627069|627068|627066|627067|412963|415752|415753|622535|622536|622538|622539|998800|412962|622983)\d{10}$/g,266 cardType: 'DC'267 }, {268 reg: /^(531659|622157|528020|622155|622156|526855|356869|356868|625360|625361|628296|435744|435745|483536|622525|622526|998801|998802)\d{10}$/g,269 cardType: 'CC'270 }, {271 reg: /^(620010)\d{10}$/g,272 cardType: 'PC'273 }]274 }, {275 bankName: 'å
´ä¸é¶è¡',276 bankCode: 'CIB',277 patterns: [{278 reg: /^(438589)\d{12}$/g,279 cardType: 'DC'280 }, {281 reg: /^(90592)\d{11}$/g,282 cardType: 'DC'283 }, {284 reg: /^(966666|622909|438588|622908)\d{12}$/g,285 cardType: 'DC'286 }, {287 reg: /^(461982|486493|486494|486861|523036|451289|527414|528057|622901|622902|622922|628212|451290|524070|625084|625085|625086|625087|548738|549633|552398|625082|625083|625960|625961|625962|625963)\d{10}$/g,288 cardType: 'CC'289 }, {290 reg: /^(620010)\d{10}$/g,291 cardType: 'PC'292 }]293 }, {294 bankName: 'ä¸æµ·é¶è¡',295 bankCode: 'SHBANK',296 patterns: [{297 reg: /^(621050|622172|622985|622987|620522|622267|622278|622279|622468|622892|940021)\d{12}$/g,298 cardType: 'DC'299 }, {300 reg: /^(438600)\d{10}$/g,301 cardType: 'DC'302 }, {303 reg: /^(356827|356828|356830|402673|402674|486466|519498|520131|524031|548838|622148|622149|622268|356829|622300|628230|622269|625099|625953)\d{10}$/g,304 cardType: 'CC'305 }]306 }, {307 bankName: '浦ä¸åå±é¶è¡',308 bankCode: 'SPDB',309 patterns: [{310 reg: /^(622516|622517|622518|622521|622522|622523|984301|984303|621352|621793|621795|621796|621351|621390|621792|621791)\d{10}$/g,311 cardType: 'DC'312 }, {313 reg: /^(84301|84336|84373|84385|84390|87000|87010|87030|87040|84380|84361|87050|84342)\d{11}$/g,314 cardType: 'DC'315 }, {316 reg: /^(356851|356852|404738|404739|456418|498451|515672|356850|517650|525998|622177|622277|628222|622500|628221|622176|622276|622228|625957|625958|625993|625831)\d{10}$/g,317 cardType: 'CC'318 }, {319 reg: /^(622520|622519)\d{10}$/g,320 cardType: 'SCC'321 }, {322 reg: /^(620530)\d{13}$/g,323 cardType: 'PC'324 }]325 }, {326 bankName: '广åé¶è¡',327 bankCode: 'GDB',328 patterns: [{329 reg: /^(622516|622517|622518|622521|622522|622523|984301|984303|621352|621793|621795|621796|621351|621390|621792|621791)\d{10}$/g,330 cardType: 'DC'331 }, {332 reg: /^(622568|6858001|6858009|621462)\d{13}$/g,333 cardType: 'DC'334 }, {335 reg: /^(9111)\d{15}$/g,336 cardType: 'DC'337 }, {338 reg: /^(406365|406366|428911|436768|436769|436770|487013|491032|491033|491034|491035|491036|491037|491038|436771|518364|520152|520382|541709|541710|548844|552794|493427|622555|622556|622557|622558|622559|622560|528931|558894|625072|625071|628260|628259|625805|625806|625807|625808|625809|625810)\d{10}$/g,339 cardType: 'CC'340 }, {341 reg: /^(685800|6858000)\d{13}$/g,342 cardType: 'CC'343 }]344 }, {345 bankName: '渤海é¶è¡',346 bankCode: 'BOHAIB',347 patterns: [{348 reg: /^(621268|622684|622884|621453)\d{10}$/g,349 cardType: 'DC'350 }]351 }, {352 bankName: '广å·é¶è¡',353 bankCode: 'GCB',354 patterns: [{355 reg: /^(603445|622467|940016|621463)\d{13}$/g,356 cardType: 'DC'357 }]358 }, {359 bankName: 'éåé¶è¡',360 bankCode: 'JHBANK',361 patterns: [{362 reg: /^(622449|940051)\d{10}$/g,363 cardType: 'DC'364 }, {365 reg: /^(622450|628204)\d{10}$/g,366 cardType: 'CC'367 }]368 }, {369 bankName: '温å·é¶è¡',370 bankCode: 'WZCB',371 patterns: [{372 reg: /^(621977)\d{10}$/g,373 cardType: 'DC'374 }, {375 reg: /^(622868|622899|628255)\d{10}$/g,376 cardType: 'CC'377 }]378 }, {379 bankName: 'å¾½åé¶è¡',380 bankCode: 'HSBANK',381 patterns: [{382 reg: /^(622877|622879|621775|623203)\d{13}$/g,383 cardType: 'DC'384 }, {385 reg: /^(603601|622137|622327|622340|622366)\d{11}$/g,386 cardType: 'DC'387 }, {388 reg: /^(628251|622651|625828)\d{10}$/g,389 cardType: 'CC'390 }]391 }, {392 bankName: 'æ±èé¶è¡',393 bankCode: 'JSBANK',394 patterns: [{395 reg: /^(621076|622173|622131|621579|622876)\d{13}$/g,396 cardType: 'DC'397 }, {398 reg: /^(504923|622422|622447|940076)\d{10}$/g,399 cardType: 'DC'400 }, {401 reg: /^(628210|622283|625902)\d{10}$/g,402 cardType: 'CC'403 }]404 }, {405 bankName: 'å京é¶è¡',406 bankCode: 'NJCB',407 patterns: [{408 reg: /^(621777|622305|621259)\d{10}$/g,409 cardType: 'DC'410 }, {411 reg: /^(622303|628242|622595|622596)\d{10}$/g,412 cardType: 'CC'413 }]414 }, {415 bankName: 'å®æ³¢é¶è¡',416 bankCode: 'NBBANK',417 patterns: [{418 reg: /^(621279|622281|622316|940022)\d{10}$/g,419 cardType: 'DC'420 }, {421 reg: /^(621418)\d{13}$/g,422 cardType: 'DC'423 }, {424 reg: /^(625903|622778|628207|512431|520194|622282|622318)\d{10}$/g,425 cardType: 'CC'426 }]427 }, {428 bankName: 'å京é¶è¡',429 bankCode: 'BJBANK',430 patterns: [{431 reg: /^(623111|421317|422161|602969|422160|621030|621420|621468)\d{10}$/g,432 cardType: 'DC'433 }, {434 reg: /^(522001|622163|622853|628203|622851|622852)\d{10}$/g,435 cardType: 'CC'436 }]437 }, {438 bankName: 'å京åæåä¸é¶è¡',439 bankCode: 'BJRCB',440 patterns: [{441 reg: /^(620088|621068|622138|621066|621560)\d{13}$/g,442 cardType: 'DC'443 }, {444 reg: /^(625526|625186|628336)\d{10}$/g,445 cardType: 'CC'446 }]447 }, {448 bankName: 'æ±ä¸°é¶è¡',449 bankCode: 'HSBC',450 patterns: [{451 reg: /^(622946)\d{10}$/g,452 cardType: 'DC'453 }, {454 reg: /^(622406|621442)\d{11}$/g,455 cardType: 'DC'456 }, {457 reg: /^(622407|621443)\d{13}$/g,458 cardType: 'DC'459 }, {460 reg: /^(622360|622361|625034|625096|625098)\d{10}$/g,461 cardType: 'CC'462 }]463 }, {464 bankName: '渣æé¶è¡',465 bankCode: 'SCB',466 patterns: [{467 reg: /^(622948|621740|622942|622994)\d{10}$/g,468 cardType: 'DC'469 }, {470 reg: /^(622482|622483|622484)\d{10}$/g,471 cardType: 'CC'472 }]473 }, {474 bankName: 'è±æé¶è¡',475 bankCode: 'CITI',476 patterns: [{477 reg: /^(621062|621063)\d{10}$/g,478 cardType: 'DC'479 }, {480 reg: /^(625076|625077|625074|625075|622371|625091)\d{10}$/g,481 cardType: 'CC'482 }]483 }, {484 bankName: 'ä¸äºé¶è¡',485 bankCode: 'HKBEA',486 patterns: [{487 reg: /^(622933|622938|623031|622943|621411)\d{13}$/g,488 cardType: 'DC'489 }, {490 reg: /^(622372|622471|622472|622265|622266|625972|625973)\d{10}$/g,491 cardType: 'CC'492 }, {493 reg: /^(622365)\d{11}$/g,494 cardType: 'CC'495 }]496 }, {497 bankName: '广ä¸åå
´é¶è¡',498 bankCode: 'GHB',499 patterns: [{500 reg: /^(621469|621625)\d{13}$/g,501 cardType: 'DC'502 }]503 }, {504 bankName: 'æ·±å³åæåä¸é¶è¡',505 bankCode: 'SRCB',506 patterns: [{507 reg: /^(622128|622129|623035)\d{10}$/g,508 cardType: 'DC'509 }]510 }, {511 bankName: '广å·åæåä¸é¶è¡è¡ä»½æéå
¬å¸',512 bankCode: 'GZRCU',513 patterns: [{514 reg: /^(909810|940035|621522|622439)\d{12}$/g,515 cardType: 'DC'516 }]517 }, {518 bankName: 'ä¸èåæåä¸é¶è¡',519 bankCode: 'DRCBCL',520 patterns: [{521 reg: /^(622328|940062|623038)\d{13}$/g,522 cardType: 'DC'523 }, {524 reg: /^(625288|625888)\d{10}$/g,525 cardType: 'CC'526 }]527 }, {528 bankName: 'ä¸èå¸åä¸é¶è¡',529 bankCode: 'BOD',530 patterns: [{531 reg: /^(622333|940050)\d{10}$/g,532 cardType: 'DC'533 }, {534 reg: /^(621439|623010)\d{13}$/g,535 cardType: 'DC'536 }, {537 reg: /^(622888)\d{10}$/g,538 cardType: 'CC'539 }]540 }, {541 bankName: '广ä¸çåæä¿¡ç¨ç¤¾èå社',542 bankCode: 'GDRCC',543 patterns: [{544 reg: /^(622302)\d{10}$/g,545 cardType: 'DC'546 }, {547 reg: /^(622477|622509|622510|622362|621018|621518)\d{13}$/g,548 cardType: 'DC'549 }]550 }, {551 bankName: '大æ°é¶è¡',552 bankCode: 'DSB',553 patterns: [{554 reg: /^(622297|621277)\d{10}$/g,555 cardType: 'DC'556 }, {557 reg: /^(622375|622489)\d{11}$/g,558 cardType: 'DC'559 }, {560 reg: /^(622293|622295|622296|622373|622451|622294|625940)\d{10}$/g,561 cardType: 'CC'562 }]563 }, {564 bankName: '永亨é¶è¡',565 bankCode: 'WHB',566 patterns: [{567 reg: /^(622871|622958|622963|622957|622861|622932|622862|621298)\d{10}$/g,568 cardType: 'DC'569 }, {570 reg: /^(622798|625010|622775|622785)\d{10}$/g,571 cardType: 'CC'572 }]573 }, {574 bankName: 'æå±é¶è¡é¦æ¸¯æéå
¬å¸',575 bankCode: 'DBS',576 patterns: [{577 reg: /^(621016|621015)\d{13}$/g,578 cardType: 'DC'579 }, {580 reg: /^(622487|622490|622491|622492)\d{10}$/g,581 cardType: 'DC'582 }, {583 reg: /^(622487|622490|622491|622492|621744|621745|621746|621747)\d{11}$/g,584 cardType: 'DC'585 }]586 }, {587 bankName: 'æ丰é¶è¡',588 bankCode: 'EGBANK',589 patterns: [{590 reg: /^(623078)\d{13}$/g,591 cardType: 'DC'592 }, {593 reg: /^(622384|940034)\d{11}$/g,594 cardType: 'DC'595 }]596 }, {597 bankName: '天津å¸åä¸é¶è¡',598 bankCode: 'TCCB',599 patterns: [{600 reg: /^(940015|622331)\d{12}$/g,601 cardType: 'DC'602 }, {603 reg: /^(6091201)\d{11}$/g,604 cardType: 'DC'605 }, {606 reg: /^(622426|628205)\d{10}$/g,607 cardType: 'CC'608 }]609 }, {610 bankName: 'æµåé¶è¡',611 bankCode: 'CZBANK',612 patterns: [{613 reg: /^(621019|622309|621019)\d{13}$/g,614 cardType: 'DC'615 }, {616 reg: /^(6223091100|6223092900|6223093310|6223093320|6223093330|6223093370|6223093380|6223096510|6223097910)\d{9}$/g,617 cardType: 'DC'618 }]619 }, {620 bankName: 'åæ´åä¸é¶è¡',621 bankCode: 'NCB',622 patterns: [{623 reg: /^(621213|621289|621290|621291|621292|621042|621743)\d{13}$/g,624 cardType: 'DC'625 }, {626 reg: /^(623041|622351)\d{10}$/g,627 cardType: 'DC'628 }, {629 reg: /^(625046|625044|625058|622349|622350)\d{10}$/g,630 cardType: 'CC'631 }, {632 reg: /^(620208|620209|625093|625095)\d{10}$/g,633 cardType: 'PC'634 }]635 }, {636 bankName: 'å¦é¨é¶è¡',637 bankCode: 'XMBANK',638 patterns: [{639 reg: /^(622393|940023)\d{10}$/g,640 cardType: 'DC'641 }, {642 reg: /^(6886592)\d{11}$/g,643 cardType: 'DC'644 }, {645 reg: /^(623019|621600|)\d{13}$/g,646 cardType: 'DC'647 }]648 }, {649 bankName: 'ç¦å»ºæµ·å³¡é¶è¡',650 bankCode: 'FJHXBC',651 patterns: [{652 reg: /^(622388)\d{10}$/g,653 cardType: 'DC'654 }, {655 reg: /^(621267|623063)\d{12}$/g,656 cardType: 'DC'657 }, {658 reg: /^(620043|)\d{12}$/g,659 cardType: 'PC'660 }]661 }, {662 bankName: 'åæé¶è¡',663 bankCode: 'JLBANK',664 patterns: [{665 reg: /^(622865|623131)\d{13}$/g,666 cardType: 'DC'667 }, {668 reg: /^(940012)\d{10}$/g,669 cardType: 'DC'670 }, {671 reg: /^(622178|622179|628358)\d{10}$/g,672 cardType: 'CC'673 }]674 }, {675 bankName: 'æ±å£é¶è¡',676 bankCode: 'HKB',677 patterns: [{678 reg: /^(990027)\d{12}$/g,679 cardType: 'DC'680 }, {681 reg: /^(622325|623105|623029)\d{10}$/g,682 cardType: 'DC'683 }]684 }, {685 bankName: 'ç京é¶è¡',686 bankCode: 'SJBANK',687 patterns: [{688 reg: /^(566666)\d{12}$/g,689 cardType: 'DC'690 }, {691 reg: /^(622455|940039)\d{13}$/g,692 cardType: 'DC'693 }, {694 reg: /^(623108|623081)\d{10}$/g,695 cardType: 'DC'696 }, {697 reg: /^(622466|628285)\d{10}$/g,698 cardType: 'CC'699 }]700 }, {701 bankName: '大è¿é¶è¡',702 bankCode: 'DLB',703 patterns: [{704 reg: /^(603708)\d{11}$/g,705 cardType: 'DC'706 }, {707 reg: /^(622993|623069|623070|623172|623173)\d{13}$/g,708 cardType: 'DC'709 }, {710 reg: /^(622383|622385|628299)\d{10}$/g,711 cardType: 'CC'712 }]713 }, {714 bankName: 'æ²³åé¶è¡',715 bankCode: 'BHB',716 patterns: [{717 reg: /^(622498|622499|623000|940046)\d{13}$/g,718 cardType: 'DC'719 }, {720 reg: /^(622921|628321)\d{10}$/g,721 cardType: 'CC'722 }]723 }, {724 bankName: 'ä¹é²æ¨é½å¸åä¸é¶è¡',725 bankCode: 'URMQCCB',726 patterns: [{727 reg: /^(621751|622143|940001|621754)\d{13}$/g,728 cardType: 'DC'729 }, {730 reg: /^(622476|628278)\d{10}$/g,731 cardType: 'CC'732 }]733 }, {734 bankName: 'ç»å
´é¶è¡',735 bankCode: 'SXCB',736 patterns: [{737 reg: /^(622486)\d{10}$/g,738 cardType: 'DC'739 }, {740 reg: /^(603602|623026|623086)\d{12}$/g,741 cardType: 'DC'742 }, {743 reg: /^(628291)\d{10}$/g,744 cardType: 'CC'745 }]746 }, {747 bankName: 'æé½åä¸é¶è¡',748 bankCode: 'CDCB',749 patterns: [{750 reg: /^(622152|622154|622996|622997|940027|622153|622135|621482|621532)\d{13}$/g,751 cardType: 'DC'752 }]753 }, {754 bankName: 'æ顺é¶è¡',755 bankCode: 'FSCB',756 patterns: [{757 reg: /^(622442)\d{11}$/g,758 cardType: 'DC'759 }, {760 reg: /^(940053)\d{12}$/g,761 cardType: 'DC'762 }, {763 reg: /^(622442|623099)\d{13}$/g,764 cardType: 'DC'765 }]766 }, {767 bankName: 'éå·é¶è¡',768 bankCode: 'ZZBANK',769 patterns: [{770 reg: /^(622421)\d{13}$/g,771 cardType: 'DC'772 }, {773 reg: /^(940056)\d{11}$/g,774 cardType: 'DC'775 }, {776 reg: /^(96828)\d{11}$/g,777 cardType: 'DC'778 }]779 }, {780 bankName: 'å®å¤é¶è¡',781 bankCode: 'NXBANK',782 patterns: [{783 reg: /^(621529|622429|621417|623089|623200)\d{13}$/g,784 cardType: 'DC'785 }, {786 reg: /^(628214|625529|622428)\d{10}$/g,787 cardType: 'CC'788 }]789 }, {790 bankName: 'éåºé¶è¡',791 bankCode: 'CQBANK',792 patterns: [{793 reg: /^(9896)\d{12}$/g,794 cardType: 'DC'795 }, {796 reg: /^(622134|940018|623016)\d{10}$/g,797 cardType: 'DC'798 }]799 }, {800 bankName: 'åå°æ»¨é¶è¡',801 bankCode: 'HRBANK',802 patterns: [{803 reg: /^(621577|622425)\d{13}$/g,804 cardType: 'DC'805 }, {806 reg: /^(940049)\d{12}$/g,807 cardType: 'DC'808 }, {809 reg: /^(622425)\d{11}$/g,810 cardType: 'DC'811 }]812 }, {813 bankName: 'å
°å·é¶è¡',814 bankCode: 'LZYH',815 patterns: [{816 reg: /^(622139|940040|628263)\d{10}$/g,817 cardType: 'DC'818 }, {819 reg: /^(621242|621538|621496)\d{13}$/g,820 cardType: 'DC'821 }]822 }, {823 bankName: 'éå²é¶è¡',824 bankCode: 'QDCCB',825 patterns: [{826 reg: /^(621252|622146|940061|628239)\d{10}$/g,827 cardType: 'DC'828 }, {829 reg: /^(621419|623170)\d{13}$/g,830 cardType: 'DC'831 }]832 }, {833 bankName: '秦çå²å¸åä¸é¶è¡',834 bankCode: 'QHDCCB',835 patterns: [{836 reg: /^(62249802|94004602)\d{11}$/g,837 cardType: 'DC'838 }, {839 reg: /^(621237|623003)\d{13}$/g,840 cardType: 'DC'841 }]842 }, {843 bankName: 'éæµ·é¶è¡',844 bankCode: 'BOQH',845 patterns: [{846 reg: /^(622310|940068)\d{11}$/g,847 cardType: 'DC'848 }, {849 reg: /^(622817|628287|625959)\d{10}$/g,850 cardType: 'CC'851 }, {852 reg: /^(62536601)\d{8}$/g,853 cardType: 'CC'854 }]855 }, {856 bankName: 'å°å·é¶è¡',857 bankCode: 'TZCB',858 patterns: [{859 reg: /^(622427)\d{10}$/g,860 cardType: 'DC'861 }, {862 reg: /^(940069)\d{11}$/g,863 cardType: 'DC'864 }, {865 reg: /^(623039)\d{13}$/g,866 cardType: 'DC'867 }, {868 reg: /^(622321|628273)\d{10}$/g,869 cardType: 'CC'870 }, {871 reg: /^(625001)\d{10}$/g,872 cardType: 'SCC'873 }]874 }, {875 bankName: 'é¿æ²é¶è¡',876 bankCode: 'CSCB',877 patterns: [{878 reg: /^(694301)\d{12}$/g,879 cardType: 'DC'880 }, {881 reg: /^(940071|622368|621446)\d{13}$/g,882 cardType: 'DC'883 }, {884 reg: /^(625901|622898|622900|628281|628282|622806|628283)\d{10}$/g,885 cardType: 'CC'886 }, {887 reg: /^(620519)\d{13}$/g,888 cardType: 'PC'889 }]890 }, {891 bankName: 'æ³å·é¶è¡',892 bankCode: 'BOQZ',893 patterns: [{894 reg: /^(683970|940074)\d{12}$/g,895 cardType: 'DC'896 }, {897 reg: /^(622370)\d{13}$/g,898 cardType: 'DC'899 }, {900 reg: /^(621437)\d{13}$/g,901 cardType: 'DC'902 }, {903 reg: /^(628319)\d{10}$/g,904 cardType: 'CC'905 }]906 }, {907 bankName: 'å
åé¶è¡',908 bankCode: 'BSB',909 patterns: [{910 reg: /^(622336|621760)\d{11}$/g,911 cardType: 'DC'912 }, {913 reg: /^(622165)\d{10}$/g,914 cardType: 'DC'915 }, {916 reg: /^(622315|625950|628295)\d{10}$/g,917 cardType: 'CC'918 }]919 }, {920 bankName: 'é¾æ±é¶è¡',921 bankCode: 'DAQINGB',922 patterns: [{923 reg: /^(621037|621097|621588|622977)\d{13}$/g,924 cardType: 'DC'925 }, {926 reg: /^(62321601)\d{11}$/g,927 cardType: 'DC'928 }, {929 reg: /^(622860)\d{10}$/g,930 cardType: 'DC'931 }, {932 reg: /^(622644|628333)\d{10}$/g,933 cardType: 'CC'934 }]935 }, {936 bankName: 'ä¸æµ·ååé¶è¡',937 bankCode: 'SHRCB',938 patterns: [{939 reg: /^(622478|940013|621495)\d{10}$/g,940 cardType: 'DC'941 }, {942 reg: /^(625500)\d{10}$/g,943 cardType: 'SCC'944 }, {945 reg: /^(622611|622722|628211|625989)\d{10}$/g,946 cardType: 'CC'947 }]948 }, {949 bankName: 'æµæ±æ³°éåä¸é¶è¡',950 bankCode: 'ZJQL',951 patterns: [{952 reg: /^(622717)\d{10}$/g,953 cardType: 'SCC'954 }, {955 reg: /^(628275|622565|622287)\d{10}$/g,956 cardType: 'CC'957 }]958 }, {959 bankName: 'å
èå¤é¶è¡',960 bankCode: 'H3CB',961 patterns: [{962 reg: /^(622147|621633)\d{13}$/g,963 cardType: 'DC'964 }, {965 reg: /^(628252)\d{10}$/g,966 cardType: 'CC'967 }]968 }, {969 bankName: '广西åé¨æ¹¾é¶è¡',970 bankCode: 'BGB',971 patterns: [{972 reg: /^(623001)\d{10}$/g,973 cardType: 'DC'974 }, {975 reg: /^(628227)\d{10}$/g,976 cardType: 'CC'977 }]978 }, {979 bankName: 'æ¡æé¶è¡',980 bankCode: 'GLBANK',981 patterns: [{982 reg: /^(621456)\d{11}$/g,983 cardType: 'DC'984 }, {985 reg: /^(621562)\d{13}$/g,986 cardType: 'DC'987 }, {988 reg: /^(628219)\d{10}$/g,989 cardType: 'CC'990 }]991 }, {992 bankName: 'é¾æ±é¶è¡',993 bankCode: 'DAQINGB',994 patterns: [{995 reg: /^(621037|621097|621588|622977)\d{13}$/g,996 cardType: 'DC'997 }, {998 reg: /^(62321601)\d{11}$/g,999 cardType: 'DC'1000 }, {1001 reg: /^(622475|622860)\d{10}$/g,1002 cardType: 'DC'1003 }, {1004 reg: /^(625588)\d{10}$/g,1005 cardType: 'SCC'1006 }, {1007 reg: /^(622270|628368|625090|622644|628333)\d{10}$/g,1008 cardType: 'CC'1009 }]1010 }, {1011 bankName: 'æé½åæåä¸é¶è¡',1012 bankCode: 'CDRCB',1013 patterns: [{1014 reg: /^(623088)\d{13}$/g,1015 cardType: 'DC'1016 }, {1017 reg: /^(622829|628301|622808|628308)\d{10}$/g,1018 cardType: 'CC'1019 }]1020 }, {1021 bankName: 'ç¦å»ºçåæä¿¡ç¨ç¤¾èå社',1022 bankCode: 'FJNX',1023 patterns: [{1024 reg: /^(622127|622184|621701|621251|621589|623036)\d{13}$/g,1025 cardType: 'DC'1026 }, {1027 reg: /^(628232|622802|622290)\d{10}$/g,1028 cardType: 'CC'1029 }]1030 }, {1031 bankName: '天津åæåä¸é¶è¡',1032 bankCode: 'TRCB',1033 patterns: [{1034 reg: /^(622531|622329)\d{13}$/g,1035 cardType: 'DC'1036 }, {1037 reg: /^(622829|628301)\d{10}$/g,1038 cardType: 'CC'1039 }]1040 }, {1041 bankName: 'æ±èçåæä¿¡ç¨ç¤¾èå社',1042 bankCode: 'JSRCU',1043 patterns: [{1044 reg: /^(621578|623066|622452|622324)\d{13}$/g,1045 cardType: 'DC'1046 }, {1047 reg: /^(622815|622816|628226)\d{10}$/g,1048 cardType: 'CC'1049 }]1050 }, {1051 bankName: 'æ¹ååæä¿¡ç¨ç¤¾èå社',1052 bankCode: 'SLH',1053 patterns: [{1054 reg: /^(622906|628386|625519|625506)\d{10}$/g,1055 cardType: 'CC'1056 }]1057 }, {1058 bankName: 'æ±è¥¿çåæä¿¡ç¨ç¤¾èå社',1059 bankCode: 'JXNCX',1060 patterns: [{1061 reg: /^(621592)\d{10}$/g,1062 cardType: 'DC'1063 }, {1064 reg: /^(628392)\d{10}$/g,1065 cardType: 'CC'1066 }]1067 }, {1068 bankName: 'åä¸å¸åä¸é¶è¡',1069 bankCode: 'SCBBANK',1070 patterns: [{1071 reg: /^(621748)\d{13}$/g,1072 cardType: 'DC'1073 }, {1074 reg: /^(628271)\d{10}$/g,1075 cardType: 'CC'1076 }]1077 }, {1078 bankName: 'åèæ¹æ±é¶è¡',1079 bankCode: 'HRXJB',1080 patterns: [{1081 reg: /^(621366|621388)\d{13}$/g,1082 cardType: 'DC'1083 }, {1084 reg: /^(628328)\d{10}$/g,1085 cardType: 'CC'1086 }]1087 }, {1088 bankName: 'è¡¡æ°´å¸åä¸é¶è¡',1089 bankCode: 'HSBK',1090 patterns: [{1091 reg: /^(621239|623068)\d{13}$/g,1092 cardType: 'DC'1093 }]1094 }, {1095 bankName: 'éåºåå·ç³é¶æéé¶è¡',1096 bankCode: 'CQNCSYCZ',1097 patterns: [{1098 reg: /^(621653004)\d{10}$/g,1099 cardType: 'DC'1100 }]1101 }, {1102 bankName: 'æ¹åçåæä¿¡ç¨ç¤¾èå社',1103 bankCode: 'HNRCC',1104 patterns: [{1105 reg: /^(622169|621519|621539|623090)\d{13}$/g,1106 cardType: 'DC'1107 }]1108 }, {1109 bankName: 'é¢å°é¶è¡',1110 bankCode: 'XTB',1111 patterns: [{1112 reg: /^(621238|620528)\d{13}$/g,1113 cardType: 'DC'1114 }]1115 }, {1116 bankName: '临汾å¸å°§é½åºåæä¿¡ç¨åä½è社',1117 bankCode: 'LPRDNCXYS',1118 patterns: [{1119 reg: /^(628382|625158)\d{10}$/g,1120 cardType: 'CC'1121 }]1122 }, {1123 bankName: 'ä¸è¥é¶è¡',1124 bankCode: 'DYCCB',1125 patterns: [{1126 reg: /^(621004)\d{12}$/g,1127 cardType: 'DC'1128 }, {1129 reg: /^(628217)\d{10}$/g,1130 cardType: 'CC'1131 }]1132 }, {1133 bankName: 'ä¸é¥¶é¶è¡',1134 bankCode: 'SRBANK',1135 patterns: [{1136 reg: /^(621416)\d{10}$/g,1137 cardType: 'DC'1138 }, {1139 reg: /^(628217)\d{10}$/g,1140 cardType: 'CC'1141 }]1142 }, {1143 bankName: 'å¾·å·é¶è¡',1144 bankCode: 'DZBANK',1145 patterns: [{1146 reg: /^(622937)\d{13}$/g,1147 cardType: 'DC'1148 }, {1149 reg: /^(628397)\d{10}$/g,1150 cardType: 'CC'1151 }]1152 }, {1153 bankName: 'æ¿å¾·é¶è¡',1154 bankCode: 'CDB',1155 patterns: [{1156 reg: /^(628229)\d{10}$/g,1157 cardType: 'CC'1158 }]1159 }, {1160 bankName: 'äºåçåæä¿¡ç¨ç¤¾',1161 bankCode: 'YNRCC',1162 patterns: [{1163 reg: /^(622469|628307)\d{10}$/g,1164 cardType: 'CC'1165 }]1166 }, {1167 bankName: 'æ³å·é¶è¡',1168 bankCode: 'LZCCB',1169 patterns: [{1170 reg: /^(622292|622291|621412)\d{12}$/g,1171 cardType: 'DC'1172 }, {1173 reg: /^(622880|622881)\d{10}$/g,1174 cardType: 'DC'1175 }, {1176 reg: /^(62829)\d{10}$/g,1177 cardType: 'CC'1178 }]1179 }, {1180 bankName: 'å¨æµ·å¸åä¸é¶è¡',1181 bankCode: 'WHSYBANK',1182 patterns: [{1183 reg: /^(623102)\d{10}$/g,1184 cardType: 'DC'1185 }, {1186 reg: /^(628234)\d{10}$/g,1187 cardType: 'CC'1188 }]1189 }, {1190 bankName: 'æ¹å·é¶è¡',1191 bankCode: 'HZBANK',1192 patterns: [{1193 reg: /^(628306)\d{10}$/g,1194 cardType: 'CC'1195 }]1196 }, {1197 bankName: 'æ½åé¶è¡',1198 bankCode: 'BANKWF',1199 patterns: [{1200 reg: /^(622391|940072)\d{10}$/g,1201 cardType: 'DC'1202 }, {1203 reg: /^(628391)\d{10}$/g,1204 cardType: 'CC'1205 }]1206 }, {1207 bankName: 'èµ£å·é¶è¡',1208 bankCode: 'GZB',1209 patterns: [{1210 reg: /^(622967|940073)\d{13}$/g,1211 cardType: 'DC'1212 }, {1213 reg: /^(628233)\d{10}$/g,1214 cardType: 'CC'1215 }]1216 }, {1217 bankName: 'æ¥ç
§é¶è¡',1218 bankCode: 'RZGWYBANK',1219 patterns: [{1220 reg: /^(628257)\d{10}$/g,1221 cardType: 'CC'1222 }]1223 }, {1224 bankName: 'åæé¶è¡',1225 bankCode: 'NCB',1226 patterns: [{1227 reg: /^(621269|622275)\d{10}$/g,1228 cardType: 'DC'1229 }, {1230 reg: /^(940006)\d{11}$/g,1231 cardType: 'DC'1232 }, {1233 reg: /^(628305)\d{11}$/g,1234 cardType: 'CC'1235 }]1236 }, {1237 bankName: 'è´µé³é¶è¡',1238 bankCode: 'GYCB',1239 patterns: [{1240 reg: /^(622133|621735)\d{13}$/g,1241 cardType: 'DC'1242 }, {1243 reg: /^(888)\d{13}$/g,1244 cardType: 'DC'1245 }, {1246 reg: /^(628213)\d{10}$/g,1247 cardType: 'CC'1248 }]1249 }, {1250 bankName: 'é¦å·é¶è¡',1251 bankCode: 'BOJZ',1252 patterns: [{1253 reg: /^(622990|940003)\d{11}$/g,1254 cardType: 'DC'1255 }, {1256 reg: /^(628261)\d{10}$/g,1257 cardType: 'CC'1258 }]1259 }, {1260 bankName: 'é½åé¶è¡',1261 bankCode: 'QSBANK',1262 patterns: [{1263 reg: /^(622311|940057)\d{11}$/g,1264 cardType: 'DC'1265 }, {1266 reg: /^(628311)\d{10}$/g,1267 cardType: 'CC'1268 }]1269 }, {1270 bankName: 'ç æµ·å润é¶è¡',1271 bankCode: 'RBOZ',1272 patterns: [{1273 reg: /^(622363|940048)\d{13}$/g,1274 cardType: 'DC'1275 }, {1276 reg: /^(628270)\d{10}$/g,1277 cardType: 'CC'1278 }]1279 }, {1280 bankName: 'è«è¦å²å¸åä¸é¶è¡',1281 bankCode: 'HLDCCB',1282 patterns: [{1283 reg: /^(622398|940054)\d{10}$/g,1284 cardType: 'DC'1285 }]1286 }, {1287 bankName: 'å®æå¸åä¸é¶è¡',1288 bankCode: 'HBC',1289 patterns: [{1290 reg: /^(940055)\d{11}$/g,1291 cardType: 'DC'1292 }, {1293 reg: /^(622397)\d{11}$/g,1294 cardType: 'CC'1295 }]1296 }, {1297 bankName: 'æå·åä¸é¶è¡',1298 bankCode: 'HZCB',1299 patterns: [{1300 reg: /^(603367|622878)\d{12}$/g,1301 cardType: 'DC'1302 }, {1303 reg: /^(622397)\d{11}$/g,1304 cardType: 'CC'1305 }]1306 }, {1307 bankName: 'èå·å¸åä¸é¶è¡',1308 bankCode: 'JSBANK',1309 patterns: [{1310 reg: /^(603506)\d{13}$/g,1311 cardType: 'DC'1312 }]1313 }, {1314 bankName: 'è¾½é³é¶è¡',1315 bankCode: 'LYCB',1316 patterns: [{1317 reg: /^(622399|940043)\d{11}$/g,1318 cardType: 'DC'1319 }]1320 }, {1321 bankName: 'æ´é³é¶è¡',1322 bankCode: 'LYB',1323 patterns: [{1324 reg: /^(622420|940041)\d{11}$/g,1325 cardType: 'DC'1326 }]1327 }, {1328 bankName: 'ç¦ä½å¸åä¸é¶è¡',1329 bankCode: 'JZCBANK',1330 patterns: [{1331 reg: /^(622338)\d{13}$/g,1332 cardType: 'DC'1333 }, {1334 reg: /^(940032)\d{10}$/g,1335 cardType: 'DC'1336 }]1337 }, {1338 bankName: 'éæ±å¸åä¸é¶è¡',1339 bankCode: 'ZJCCB',1340 patterns: [{1341 reg: /^(622394|940025)\d{10}$/g,1342 cardType: 'DC'1343 }]1344 }, {1345 bankName: 'æ³å½å
´ä¸é¶è¡',1346 bankCode: 'FGXYBANK',1347 patterns: [{1348 reg: /^(621245)\d{10}$/g,1349 cardType: 'DC'1350 }]1351 }, {1352 bankName: '大åé¶è¡',1353 bankCode: 'DYBANK',1354 patterns: [{1355 reg: /^(621328)\d{13}$/g,1356 cardType: 'DC'1357 }]1358 }, {1359 bankName: 'ä¼ä¸é¶è¡',1360 bankCode: 'DIYEBANK',1361 patterns: [{1362 reg: /^(621651)\d{13}$/g,1363 cardType: 'DC'1364 }]1365 }, {1366 bankName: 'å侨é¶è¡',1367 bankCode: 'HQBANK',1368 patterns: [{1369 reg: /^(621077)\d{10}$/g,1370 cardType: 'DC'1371 }]1372 }, {1373 bankName: 'æçé¶è¡',1374 bankCode: 'HSB',1375 patterns: [{1376 reg: /^(622409|621441)\d{13}$/g,1377 cardType: 'DC'1378 }, {1379 reg: /^(622410|621440)\d{11}$/g,1380 cardType: 'DC'1381 }, {1382 reg: /^(622950|622951)\d{10}$/g,1383 cardType: 'DC'1384 }, {1385 reg: /^(625026|625024|622376|622378|622377|625092)\d{10}$/g,1386 cardType: 'CC'1387 }]1388 }, {1389 bankName: '临æ²åä¸é¶è¡',1390 bankCode: 'LSB',1391 patterns: [{1392 reg: /^(622359|940066)\d{13}$/g,1393 cardType: 'DC'1394 }]1395 }, {1396 bankName: 'çå°åä¸é¶è¡',1397 bankCode: 'YTCB',1398 patterns: [{1399 reg: /^(622886)\d{10}$/g,1400 cardType: 'DC'1401 }]1402 }, {1403 bankName: 'é½é²é¶è¡',1404 bankCode: 'QLB',1405 patterns: [{1406 reg: /^(940008|622379)\d{13}$/g,1407 cardType: 'DC'1408 }, {1409 reg: /^(628379)\d{10}$/g,1410 cardType: 'CC'1411 }]1412 }, {1413 bankName: 'BCå¡å
¬å¸',1414 bankCode: 'BCCC',1415 patterns: [{1416 reg: /^(620011|620027|620031|620039|620103|620106|620120|620123|620125|620220|620278|620812|621006|621011|621012|621020|621023|621025|621027|621031|620132|621039|621078|621220|621003)\d{10}$/g,1417 cardType: 'DC'1418 }, {1419 reg: /^(625003|625011|625012|625020|625023|625025|625027|625031|621032|625039|625078|625079|625103|625106|625006|625112|625120|625123|625125|625127|625131|625032|625139|625178|625179|625220|625320|625111|625132|625244)\d{10}$/g,1420 cardType: 'CC'1421 }]1422 }, {1423 bankName: 'éåé¶è¡',1424 bankCode: 'CYB',1425 patterns: [{1426 reg: /^(622355|623042)\d{10}$/g,1427 cardType: 'DC'1428 }, {1429 reg: /^(621043|621742)\d{13}$/g,1430 cardType: 'DC'1431 }, {1432 reg: /^(622352|622353|625048|625053|625060)\d{10}$/g,1433 cardType: 'CC'1434 }, {1435 reg: /^(620206|620207)\d{10}$/g,1436 cardType: 'PC'1437 }]1438 }, {1439 bankName: '大丰é¶è¡',1440 bankCode: 'TFB',1441 patterns: [{1442 reg: /^(622547|622548|622546)\d{13}$/g,1443 cardType: 'DC'1444 }, {1445 reg: /^(625198|625196|625147)\d{10}$/g,1446 cardType: 'CC'1447 }, {1448 reg: /^(620072)\d{13}$/g,1449 cardType: 'PC'1450 }, {1451 reg: /^(620204|620205)\d{10}$/g,1452 cardType: 'PC'1453 }]1454 }, {1455 bankName: 'AEONä¿¡è´·è´¢å¡äºæ´²æéå
¬å¸',1456 bankCode: 'AEON',1457 patterns: [{1458 reg: /^(621064|622941|622974)\d{10}$/g,1459 cardType: 'DC'1460 }, {1461 reg: /^(622493)\d{10}$/g,1462 cardType: 'CC'1463 }]1464 }, {1465 bankName: 'æ¾³é¨BDA',1466 bankCode: 'MABDA',1467 patterns: [{1468 reg: /^(621274|621324)\d{13}$/g,1469 cardType: 'DC'1470 }]1471 }]1472 // function getBankNameByBankCode (bankcode) {1473 // for (var i = 0, len = bankcardList.length; i < len; i++) {1474 // var bankcard = bankcardList[i]1475 // if (bankcode === bankcard.bankCode) {1476 // return bankcard.bankName1477 // }1478 // }1479 // return ''1480 // }1481 function _getBankInfoByCardNo (cardNo) {1482 for (var i = 0, len = bankcardList.length; i < len; i++) {1483 var bankcard = bankcardList[i]1484 var patterns = bankcard.patterns1485 for (var j = 0, jLen = patterns.length; j < jLen; j++) {1486 var pattern = patterns[j]1487 if ((new RegExp(pattern.reg)).test(cardNo)) {1488 var info = extend(bankcard, pattern)1489 delete info.patterns1490 delete info.reg1491 info['cardTypeName'] = getCardTypeName(info['cardType'])1492 return info // è¿åé¶è¡å¡ç»æ1493 }1494 }1495 }1496 return 'error'1497 }1498 return _getBankInfoByCardNo(bankCard)1499}...
Drawer.js
Source:Drawer.js
1function Drawer(){this.initialize.apply(this, arguments)};2(function(_class){3 4 _class.prototype.initialize = function(canvasCtx) {5 this.dc = canvasCtx;6 }7 _class.prototype.close = function() {8 // nop.9 }10 11 _class.prototype.beginItem = function(item) {12 this.dc.save();13 }14 _class.prototype.endItem = function() {15 this.dc.restore();16 }17 18 _class.prototype.clipStart = function(x1,y1,w,h) {19 var dc = this.dc;20 dc.rect(x1-1,y1-1,w+2,h+2);21 dc.clip();22 }23 _class.prototype.clipEnd = function(x1,y1,w,h) {24 var dc = this.dc;25 dc.rect(0,0,10000,10000);26 dc.clip();27 }28 29 _class.prototype.textSize = function(font, str, minLine) {30 return _class.textSize(this.dc, font, str, minLine);31 }32 _class.textSize = function(dc, font, str, minLine) {33 minLine = minLine ? minLine : 0;34 dc.font = font.name;35 var h = font.height;36 if (str == null || str == "") {37 return {w:0, h:h*minLine};38 }39 var m = dc.measureText(str);40 var lines = str.split("\n");41 var width = 1;42 for (var i=0; i<lines.length; i++) {43 width = Math.max(width, dc.measureText(lines[i]).width);44 }45 return {w:width, h: h*lines.length};46 }47 48 _class.prototype.drawText = function(font, str, xx, yy) {49 var dc = this.dc;50 var isUnderLine = (font.decoration == "underline");51 dc.fillStyle = "black";52 dc.font = font.name;53 dc.textBaseline = "alphabetic";54 55 var h = font.height;56 var lines = str.split("\n");57 for (var i=0; i<lines.length; i++) {58 dc.fillText(lines[i], xx, yy+font.acender);59 if (isUnderLine) {60 var m = dc.measureText(lines[i]);61 this.drawHLine(xx, yy+font.acender, m.width);62 }63 yy += h;64 }65 }66 _class.prototype.drawTextLine = function(font, str, xx, yy) {67 var dc = this.dc;68 dc.strokeStyle = "white";69 dc.lineWidth = 2;70 dc.fillStyle = "black";71 dc.font = font;72 dc.textBaseline = "alphabetic";73 dc.strokeText(str, xx, yy+font.acender);74 dc.fillText(str, xx, yy+font.acender);75 }76 _class.prototype.drawHLine = function(xx,yy,ww, lw) {77 yy = Math.floor(yy)+0.5;78 var dc = this.dc;79 dc.strokeStyle = "black";80 dc.lineWidth = lw?lw:1;81 dc.beginPath();82 dc.moveTo(xx, yy);83 dc.lineTo(xx+ww, yy);84 dc.stroke();85 }86 _class.prototype.drawVLine = function(xx,yy,hh, lw) {87 xx = Math.floor(xx)+0.5;88 var dc = this.dc;89 dc.strokeStyle = "black";90 dc.lineWidth = lw?lw:1;91 dc.beginPath();92 dc.moveTo(xx, yy);93 dc.lineTo(xx, yy+hh);94 dc.stroke();95 }96 _class.prototype.whiteBox = function(xx,yy,ww,hh) {97 var dc = this.dc;98 dc.fillStyle= "white";99 dc.fillRect(xx,yy,ww,hh);100 }101 _class.prototype.ellipse = function(x,y,width,height) {102 var dc = this.dc;103 var radW = width/2;104 var radH = height/2;105 x = x + radW;106 y = y + radH;107 dc.lineWidth = 2;108 dc.strokeStyle = "black";109 dc.fillStyle = "white";110 dc.beginPath();111 dc.bezierCurveTo(x, y - radH, x + radW , y - radH, x + radW, y);112 dc.bezierCurveTo(x + radW, y, x + radW, y + radH, x, y + radH);113 dc.bezierCurveTo(x, y + radH, x - radW, y + radH, x - radW, y);114 dc.bezierCurveTo(x - radW, y, x - radW, y - radH, x, y - radH);115 //dc.closePath();116 dc.fill();117 dc.stroke();118 };119 _class.prototype.drawMarker = function(image, xx, yy) {120 this.dc.drawImage(image, xx, yy);121 }122 _class.prototype.drawBox = function(x,y,w,h) {123 var dc = this.dc;124 dc.fillStyle = "white";125 dc.strokeStyle = "black";126 dc.fillRect(x, y, w, h);127 dc.lineWidth = 2;128 dc.strokeRect(x, y, w, h);129 }130 131 _class.prototype.drawPoly = function(points) {132 var dc = this.dc;133 dc.fillStyle = "white";134 dc.strokeStyle = "black";135 drawPoly(dc, points);136 }137 _class.prototype.drawPolyGuide = function(points) {138 var dc = this.dc;139 dc.fillStyle = "transparent";140 dc.strokeStyle = Color.GUIDE;141 dc.lineWidth = 0.25;142 drawPoly(dc, points);143 }144 function drawPoly(dc, points) {145 dc.beginPath();146 147 dc.moveTo(points[0].x-0.5, points[0].y-0.5);148 for (var i=1; i<points.length; i++) {149 dc.lineTo(points[i].x-0.5, points[i].y-0.5);150 }151 dc.closePath();152 dc.fill();153 dc.stroke();154 }155 156 function setLineStyle(dc, style) {157 if (style == null) style = "normal-2";158 159 var parts = style.split("-");160 var patt = null;161 if (parts[0] == "dotted") {162 patt = [4,4];163 164 if (dc.setLineDash) {165 dc.setLineDash(patt);166 } else if ($.browser.mozilla) {167 dc.mozDash = patt;168 } else { // for IE9169 //dc.strokeStyle = "#888888";170 dc.strokeStyle = dc.createPattern($("#meshImg")[0], 'repeat');171 }172 } else {173 if (dc.setLineDash) dc.setLineDash(null);174 dc.mozDash = null;175 dc.strokeStyle = "black";176 }177 178 dc.lineWidth = 2;179 if (parts.length>=2) {180 dc.lineWidth = parseInt(parts[1]);181 }182 }183 184 _class.prototype.drawLines = function(lines, style) {185 var dc = this.dc;186 dc.fillStyle = "transparent";187 dc.strokeStyle = "black";188 setLineStyle(dc, style);189 dc.beginPath();190 191 //dc.moveTo(lines[0].x1, lines[0].y1);192 for (var i=0; i<lines.length; i++) {193 dc.moveTo(lines[i].x1, lines[i].y1);194 dc.lineTo(lines[i].x2, lines[i].y2);195 }196 dc.stroke();197 dc.closePath();198 }199 _class.prototype.drawLinesS = function(lines, style) {200 var dc = this.dc;201 dc.fillStyle = "transparent";202 dc.lineWidth = 0.1;203 dc.strokeStyle = Color.GUIDE;204 dc.beginPath();205 206 var centers = [];207 for (var i=0; i<lines.length; i++) {208 centers.push(Util.getCenter(lines[i]));209 // Guid line210 dc.moveTo(lines[i].x1, lines[i].y1);211 dc.lineTo(lines[i].x2, lines[i].y2);212 }213 dc.stroke();214 215 216 dc.strokeStyle = "black";217 setLineStyle(dc, style);218 dc.beginPath();219 dc.moveTo(lines[0].x1, lines[0].y1);220 dc.lineTo(centers[0].x, centers[0].y);221 for (var i=0; i<lines.length-1; i++) {222 dc.moveTo(centers[i].x, centers[i].y);223 dc.quadraticCurveTo(lines[i].x2, lines[i].y2, 224 centers[i+1].x, centers[i+1].y);225 }226 var i = lines.length-1;227 dc.moveTo(centers[i].x, centers[i].y);228 dc.lineTo(lines[i].x2, lines[i].y2);229 dc.stroke();230 dc.closePath();231 }232 233 234 _class.prototype.drawLine = function(x1,y1,x2,y2, style) {235 var dc = this.dc;236 dc.strokeStyle = "black";237 setLineStyle(dc, style);238 dc.beginPath();239 dc.moveTo(x1, y1);240 dc.lineTo(x2, y2);241 dc.stroke();242 dc.closePath();243 }244 245 var NONE = "none";246 var ARROW = "arrow"; // â247 var TRIANGLE = "triangle"; // â³248 var RHOMBI = "rhombi"; // â249 _class.NONE = NONE;250 _class.ARROW = ARROW;251 _class.TRIANGLE = TRIANGLE;252 _class.RHOMBI = RHOMBI;253 254 255 _class.prototype.drawArrow = function(shape, x1,y1,x2,y2) {256 var dc = this.dc;257 if (shape == NONE) return;258 setLineStyle(dc, null);259 260 var isFill = shape.match(/-B$/);261 shape = shape.replace(/-B$/,"");262 var len = 10;263 var angle = 30 * (Math.PI / 180); // toRadian264 var theta = Math.atan2(y2 - y1, x2 - x1);265 if (shape == RHOMBI) {266 len = 7;267 }268 var x3 = x2 + len*Math.cos(theta+Math.PI-angle);269 var y3 = y2 + len*Math.sin(theta+Math.PI-angle);270 var x4 = x2 + len*Math.cos(theta+Math.PI+angle);271 var y4 = y2 + len*Math.sin(theta+Math.PI+angle);272 var x5 = x2 + len*(1.73)*Math.cos(theta+Math.PI);273 var y5 = y2 + len*(1.73)*Math.sin(theta+Math.PI);274 dc.beginPath();275 dc.lineWidth = (shape == ARROW)?2:1;276 dc.moveTo(x3, y3);277 dc.lineTo(x2, y2);278 dc.lineTo(x4, y4); // â§279 280 if (shape == TRIANGLE) { // â³281 dc.closePath();282 } else if (shape == RHOMBI) { // â283 dc.lineTo(x5, y5);284 dc.closePath();285 }286 dc.strokeStyle = "black";287 if (shape == ARROW) {288 dc.stroke();289 } else {290 dc.fillStyle = isFill ? "black" : "white";291 dc.fill();292 dc.stroke();293 }294 }295})(Drawer);...
Using AI Code Generation
1var page = require('webpage').create();2page.onConsoleMessage = function(msg) {3 console.log(msg);4};5 if (status === "success") {6 page.evaluate(function() {7 window.callPhantom('Page loaded');8 window.callPhantom('Page title is ' + document.title);9 });10 } else {11 window.callPhantom('Page failed to load.');12 }13 phantom.exit();14});15var page = require('webpage').create();16var system = require('system');17var url = system.args[1];18var key = system.args[2];19var dc = system.args[3];20var wpt = require('webpagetest');21var wptServer = 'www.webpagetest.org';22var wptKey = key;23var wptClient = wpt(wptServer, wptKey);24page.open(url, function(status) {25 if (status === "success") {26 wptClient.runTest(url, {27 }, function(err, data) {28 if (err) {29 console.log("There was an error running the test: " + err);30 } else {31 console.log("Test started: " + data.data.testId);32 }33 phantom.exit();34 });35 } else {36 console.log("Page failed to load.");37 phantom.exit();38 }39});40var page = require('webpage').create();41var system = require('system');42var url = system.args[1];43var key = system.args[2];44var dc = system.args[3];45var wpt = require('webpagetest');
Using AI Code Generation
1var wpt = require('webpagetest');2var options = {3};4wpt.runTest(options, function(err, data) {5 if (err) {6 console.log(err);7 } else {8 wpt.getTestResults(data.data.testId, function(err, data) {9 if (err) {10 console.log(err);11 } else {12 console.log(data.data.average.firstView);13 console.log(data.data.median.firstView);14 }15 });16 }17});18The wpt.getTestResults() method returns a JSON object with the results of the test. The JSON object can be used to get the test results. For example, the following code prints out the firstView and repeatView median run results for the test:19{ data: { testId: '170405_2E_2e2f',
Using AI Code Generation
1var wpt = require('wpt');2var dc = new wpt.dc();3 if(err) return console.log(err);4 console.log(data);5});6var wpt = require('wpt');7var dc = new wpt.dc();8 if(err) return console.log(err);9 console.log(data);10});11var wpt = require('wpt');12var dc = new wpt.dc();13 if(err) return console.log(err);14 console.log(data);15});16var wpt = require('wpt');17var dc = new wpt.dc();18 if(err) return console.log(err);19 console.log(data);20});21var wpt = require('wpt');22var dc = new wpt.dc();23 if(err) return console.log(err);24 console.log(data);25});26var wpt = require('wpt');27var dc = new wpt.dc();28 if(err) return console.log(err);29 console.log(data);30});31var wpt = require('wpt');32var dc = new wpt.dc();33 if(err) return console.log(err);34 console.log(data);35});36var wpt = require('wpt');37var dc = new wpt.dc();
Using AI Code Generation
1var wpt = require('wpt');2var dc = new wpt.dc();3 if (err) {4 console.log('Error: ' + err);5 } else {6 console.log(data);7 }8});9var wpt = require('wpt');10var dc = new wpt.dc();11 if (err) {12 console.log('Error: ' + err);13 } else {14 console.log(data);15 }16});17var wpt = require('wpt');18var dc = new wpt.dc();19 if (err) {20 console.log('Error: ' + err);21 } else {22 console.log(data);23 }24});25var wpt = require('wpt');26var dc = new wpt.dc();27 if (err) {28 console.log('Error: ' + err);29 } else {30 console.log(data);31 }32});33var wpt = require('wpt');34var dc = new wpt.dc();35 if (err) {36 console.log('Error: ' + err);37 } else {38 console.log(data);39 }40});41var wpt = require('wpt');42var dc = new wpt.dc();43 if (err) {44 console.log('Error: ' + err);45 } else {46 console.log(data);47 }48});49var wpt = require('wpt');50var dc = new wpt.dc();
Using AI Code Generation
1var wpt = require('webpagetest');2var dc = wpt.dc;3 console.log(data);4});5var wpt = require('webpagetest');6 console.log(data);7});8var wpt = require('webpagetest');9var dc = wpt.dc;10 console.log(data);11});12var wpt = require('webpagetest');13 console.log(data);14});15var wpt = require('webpagetest');16var dc = wpt.dc;17 console.log(data);18});19var wpt = require('webpagetest');20 console.log(data);21});22var wpt = require('webpagetest');23var dc = wpt.dc;24 console.log(data);25});26var wpt = require('webpagetest');27 console.log(data);28});29var wpt = require('webpagetest');30var dc = wpt.dc;31 console.log(data);32});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!