]>
git.proxmox.com Git - proxmox-widget-toolkit.git/blob - Utils.js
37eba47b2c3b2a610b8cfd257498a5258f710ab5
2 Ext
. ns ( 'Proxmox.Setup' );
4 if (! Ext
. isDefined ( Proxmox
. Setup
. auth_cookie_name
)) {
5 throw "Proxmox library not initialized" ;
8 // avoid errors related to Accessible Rich Internet Applications
9 // (access for people with disabilities)
10 // TODO reenable after all components are upgraded
11 Ext
. enableAria
= false ;
12 Ext
. enableAriaButtons
= false ;
13 Ext
. enableAriaPanels
= false ;
15 // avoid errors when running without development tools
16 if (! Ext
. isDefined ( Ext
. global
. console
)) {
23 Ext
. Ajax
. defaultHeaders
= {
24 'Accept' : 'application/json'
27 Ext
. Ajax
. on ( 'beforerequest' , function ( conn
, options
) {
28 if ( Proxmox
. CSRFPreventionToken
) {
29 if (! options
. headers
) {
32 options
. headers
. CSRFPreventionToken
= Proxmox
. CSRFPreventionToken
;
36 Ext
. define ( 'Proxmox.Utils' , { utilities
: {
38 // this singleton contains miscellaneous utilities
40 yesText
: gettext ( 'Yes' ),
41 noText
: gettext ( 'No' ),
42 enabledText
: gettext ( 'Enabled' ),
43 disabledText
: gettext ( 'Disabled' ),
44 noneText
: gettext ( 'none' ),
45 errorText
: gettext ( 'Error' ),
46 unknownText
: gettext ( 'Unknown' ),
47 defaultText
: gettext ( 'Default' ),
48 daysText
: gettext ( 'days' ),
49 dayText
: gettext ( 'day' ),
50 runningText
: gettext ( 'running' ),
51 stoppedText
: gettext ( 'stopped' ),
52 neverText
: gettext ( 'never' ),
53 totalText
: gettext ( 'Total' ),
54 usedText
: gettext ( 'Used' ),
55 directoryText
: gettext ( 'Directory' ),
56 stateText
: gettext ( 'State' ),
57 groupText
: gettext ( 'Group' ),
60 zh_CN
: 'Chinese (Simplified)' ,
61 zh_TW
: 'Chinese (Traditional)' ,
65 eu
: 'Euskera (Basque)' ,
71 nb
: 'Norwegian (Bokmal)' ,
72 nn
: 'Norwegian (Nynorsk)' ,
73 fa
: 'Persian (Farsi)' ,
75 pt_BR
: 'Portuguese (Brazil)' ,
82 render_language : function ( value
) {
84 return Proxmox
. Utils
. defaultText
+ ' (English)' ;
86 var text
= Proxmox
. Utils
. language_map
[ value
];
88 return text
+ ' (' + value
+ ')' ;
93 language_array : function () {
94 var data
= [[ '__default__' , Proxmox
. Utils
. render_language ( '' )]];
95 Ext
. Object
. each ( Proxmox
. Utils
. language_map
, function ( key
, value
) {
96 data
. push ([ key
, Proxmox
. Utils
. render_language ( value
)]);
102 getNoSubKeyHtml : function ( url
) {
103 // url http://www.proxmox.com/products/proxmox-ve/subscription-service-plans
104 return Ext
. String
. format ( 'You do not have a valid subscription for this server. Please visit <a target="_blank" href="{0}">www.proxmox.com</a> to get a list of available options.' , url
|| 'http://www.proxmox.com' );
107 format_boolean_with_default : function ( value
) {
108 if ( Ext
. isDefined ( value
) && value
!== '__default__' ) {
109 return value
? Proxmox
. Utils
. yesText
: Proxmox
. Utils
. noText
;
111 return Proxmox
. Utils
. defaultText
;
114 format_boolean : function ( value
) {
115 return value
? Proxmox
. Utils
. yesText
: Proxmox
. Utils
. noText
;
118 format_neg_boolean : function ( value
) {
119 return ! value
? Proxmox
. Utils
. yesText
: Proxmox
. Utils
. noText
;
122 format_enabled_toggle : function ( value
) {
123 return value
? Proxmox
. Utils
. enabledText
: Proxmox
. Utils
. disabledText
;
126 format_expire : function ( date
) {
128 return Proxmox
. Utils
. neverText
;
130 return Ext
. Date
. format ( date
, "Y-m-d" );
133 format_duration_long : function ( ut
) {
135 var days
= Math
. floor ( ut
/ 86400 );
137 var hours
= Math
. floor ( ut
/ 3600 );
139 var mins
= Math
. floor ( ut
/ 60 );
142 var hours_str
= '00' + hours
. toString ();
143 hours_str
= hours_str
. substr ( hours_str
. length
- 2 );
144 var mins_str
= "00" + mins
. toString ();
145 mins_str
= mins_str
. substr ( mins_str
. length
- 2 );
146 var ut_str
= "00" + ut
. toString ();
147 ut_str
= ut_str
. substr ( ut_str
. length
- 2 );
150 var ds
= days
> 1 ? Proxmox
. Utils
. daysText
: Proxmox
. Utils
. dayText
;
151 return days
. toString () + ' ' + ds
+ ' ' +
152 hours_str
+ ':' + mins_str
+ ':' + ut_str
;
154 return hours_str
+ ':' + mins_str
+ ':' + ut_str
;
158 format_subscription_level : function ( level
) {
161 } else if ( level
=== 'b' ) {
163 } else if ( level
=== 's' ) {
165 } else if ( level
=== 'p' ) {
168 return Proxmox
. Utils
. noneText
;
172 compute_min_label_width : function ( text
, width
) {
174 if ( width
=== undefined ) { width
= 100 ; }
176 var tm
= new Ext
. util
. TextMetrics ();
177 var min
= tm
. getWidth ( text
+ ':' );
179 return min
< width
? width
: min
;
183 return ( Proxmox
. UserName
!== '' ) && Ext
. util
. Cookies
. get ( Proxmox
. Setup
. auth_cookie_name
);
186 authClear : function () {
187 Ext
. util
. Cookies
. clear ( Proxmox
. Setup
. auth_cookie_name
);
190 // comp.setLoading() is buggy in ExtJS 4.0.7, so we
191 // use el.mask() instead
192 setErrorMask : function ( comp
, msg
) {
201 el
. mask ( gettext ( "Loading..." ));
208 monStoreErrors : function ( me
, store
, clearMaskBeforeLoad
) {
209 if ( clearMaskBeforeLoad
) {
210 me
. mon ( store
, 'beforeload' , function ( s
, operation
, eOpts
) {
211 Proxmox
. Utils
. setErrorMask ( me
, false );
214 me
. mon ( store
, 'beforeload' , function ( s
, operation
, eOpts
) {
216 me
. loadCount
= 0 ; // make sure it is numeric
217 Proxmox
. Utils
. setErrorMask ( me
, true );
222 // only works with 'proxmox' proxy
223 me
. mon ( store
. proxy
, 'afterload' , function ( proxy
, request
, success
) {
227 Proxmox
. Utils
. setErrorMask ( me
, false );
232 /*jslint nomen: true */
233 var operation
= request
. _operation
;
234 var error
= operation
. getError ();
235 if ( error
. statusText
) {
236 msg
= error
. statusText
+ ' (' + error
. status
+ ')' ;
238 msg
= gettext ( 'Connection error' );
240 Proxmox
. Utils
. setErrorMask ( me
, msg
);
244 extractRequestError : function ( result
, verbose
) {
245 var msg
= gettext ( 'Successful' );
247 if (! result
. success
) {
248 msg
= gettext ( "Unknown error" );
249 if ( result
. message
) {
250 msg
= result
. message
;
252 msg
+= ' (' + result
. status
+ ')' ;
255 if ( verbose
&& Ext
. isObject ( result
. errors
)) {
257 Ext
. Object
. each ( result
. errors
, function ( prop
, desc
) {
258 msg
+= "<br><b>" + Ext
. htmlEncode ( prop
) + "</b>: " +
259 Ext
. htmlEncode ( desc
);
268 API2Request : function ( reqOpts
) {
270 var newopts
= Ext
. apply ({
271 waitMsg
: gettext ( 'Please wait...' )
274 if (! newopts
. url
. match ( /^\/api2/ )) {
275 newopts
. url
= '/api2/extjs' + newopts
. url
;
277 delete newopts
. callback
;
279 var createWrapper = function ( successFn
, callbackFn
, failureFn
) {
281 success : function ( response
, options
) {
282 if ( options
. waitMsgTarget
) {
283 if ( Proxmox
. Utils
. toolkit
=== 'touch' ) {
284 options
. waitMsgTarget
. setMasked ( false );
286 options
. waitMsgTarget
. setLoading ( false );
289 var result
= Ext
. decode ( response
. responseText
);
290 response
. result
= result
;
291 if (! result
. success
) {
292 response
. htmlStatus
= Proxmox
. Utils
. extractRequestError ( result
, true );
293 Ext
. callback ( callbackFn
, options
. scope
, [ options
, false , response
]);
294 Ext
. callback ( failureFn
, options
. scope
, [ response
, options
]);
297 Ext
. callback ( callbackFn
, options
. scope
, [ options
, true , response
]);
298 Ext
. callback ( successFn
, options
. scope
, [ response
, options
]);
300 failure : function ( response
, options
) {
301 if ( options
. waitMsgTarget
) {
302 if ( Proxmox
. Utils
. toolkit
=== 'touch' ) {
303 options
. waitMsgTarget
. setMasked ( false );
305 options
. waitMsgTarget
. setLoading ( false );
308 response
. result
= {};
310 response
. result
= Ext
. decode ( response
. responseText
);
312 var msg
= gettext ( 'Connection error' ) + ' - server offline?' ;
313 if ( response
. aborted
) {
314 msg
= gettext ( 'Connection error' ) + ' - aborted.' ;
315 } else if ( response
. timedout
) {
316 msg
= gettext ( 'Connection error' ) + ' - Timeout.' ;
317 } else if ( response
. status
&& response
. statusText
) {
318 msg
= gettext ( 'Connection error' ) + ' ' + response
. status
+ ': ' + response
. statusText
;
320 response
. htmlStatus
= msg
;
321 Ext
. callback ( callbackFn
, options
. scope
, [ options
, false , response
]);
322 Ext
. callback ( failureFn
, options
. scope
, [ response
, options
]);
327 createWrapper ( reqOpts
. success
, reqOpts
. callback
, reqOpts
. failure
);
329 var target
= newopts
. waitMsgTarget
;
331 if ( Proxmox
. Utils
. toolkit
=== 'touch' ) {
332 target
. setMasked ({ xtype
: 'loadmask' , message
: newopts
. waitMsg
} );
334 // Note: ExtJS bug - this does not work when component is not rendered
335 target
. setLoading ( newopts
. waitMsg
);
338 Ext
. Ajax
. request ( newopts
);
341 checked_command : function ( orig_cmd
) {
342 Proxmox
. Utils
. API2Request ({
343 url
: '/nodes/localhost/subscription' ,
346 failure : function ( response
, opts
) {
347 Ext
. Msg
. alert ( gettext ( 'Error' ), response
. htmlStatus
);
349 success : function ( response
, opts
) {
350 var data
= response
. result
. data
;
352 if ( data
. status
!== 'Active' ) {
354 title
: gettext ( 'No valid subscription' ),
355 icon
: Ext
. Msg
. WARNING
,
356 msg
: Proxmox
. Utils
. getNoSubKeyHtml ( data
. url
),
358 callback : function ( btn
) {
372 assemble_field_data : function ( values
, data
) {
373 if ( Ext
. isObject ( data
)) {
374 Ext
. Object
. each ( data
, function ( name
, val
) {
375 if ( values
. hasOwnProperty ( name
)) {
376 var bucket
= values
[ name
];
377 if (! Ext
. isArray ( bucket
)) {
378 bucket
= values
[ name
] = [ bucket
];
380 if ( Ext
. isArray ( val
)) {
381 values
[ name
] = bucket
. concat ( val
);
392 dialog_title : function ( subject
, create
, isAdd
) {
395 return gettext ( 'Add' ) + ': ' + subject
;
397 return gettext ( 'Create' ) + ': ' + subject
;
400 return gettext ( 'Edit' ) + ': ' + subject
;
404 network_iface_types
: {
405 eth
: gettext ( "Network Device" ),
406 bridge
: 'Linux Bridge' ,
409 OVSBridge
: 'OVS Bridge' ,
412 OVSIntPort
: 'OVS IntPort'
415 render_network_iface_type : function ( value
) {
416 return Proxmox
. Utils
. network_iface_types
[ value
] ||
417 Proxmox
. Utils
. unknownText
;
421 acmenewcert
: [ 'SRV' , gettext ( 'Order Certificate' ) ],
422 acmeregister
: [ 'ACME Account' , gettext ( 'Register' ) ],
423 acmedeactivate
: [ 'ACME Account' , gettext ( 'Deactivate' ) ],
424 acmeupdate
: [ 'ACME Account' , gettext ( 'Update' ) ],
425 acmerefresh
: [ 'ACME Account' , gettext ( 'Refresh' ) ],
426 acmerenew
: [ 'SRV' , gettext ( 'Renew Certificate' ) ],
427 acmerevoke
: [ 'SRV' , gettext ( 'Revoke Certificate' ) ],
428 'move_volume' : [ 'CT' , gettext ( 'Move Volume' ) ],
429 clustercreate
: [ '' , gettext ( 'Create Cluster' ) ],
430 clusterjoin
: [ '' , gettext ( 'Join Cluster' ) ],
431 diskinit
: [ 'Disk' , gettext ( 'Initialize Disk with GPT' ) ],
432 vncproxy
: [ 'VM/CT' , gettext ( 'Console' ) ],
433 spiceproxy
: [ 'VM/CT' , gettext ( 'Console' ) + ' (Spice)' ],
434 vncshell
: [ '' , gettext ( 'Shell' ) ],
435 spiceshell
: [ '' , gettext ( 'Shell' ) + ' (Spice)' ],
436 qmsnapshot
: [ 'VM' , gettext ( 'Snapshot' ) ],
437 qmrollback
: [ 'VM' , gettext ( 'Rollback' ) ],
438 qmdelsnapshot
: [ 'VM' , gettext ( 'Delete Snapshot' ) ],
439 qmcreate
: [ 'VM' , gettext ( 'Create' ) ],
440 qmrestore
: [ 'VM' , gettext ( 'Restore' ) ],
441 qmdestroy
: [ 'VM' , gettext ( 'Destroy' ) ],
442 qmigrate
: [ 'VM' , gettext ( 'Migrate' ) ],
443 qmclone
: [ 'VM' , gettext ( 'Clone' ) ],
444 qmmove
: [ 'VM' , gettext ( 'Move disk' ) ],
445 qmtemplate
: [ 'VM' , gettext ( 'Convert to template' ) ],
446 qmstart
: [ 'VM' , gettext ( 'Start' ) ],
447 qmstop
: [ 'VM' , gettext ( 'Stop' ) ],
448 qmreset
: [ 'VM' , gettext ( 'Reset' ) ],
449 qmshutdown
: [ 'VM' , gettext ( 'Shutdown' ) ],
450 qmsuspend
: [ 'VM' , gettext ( 'Suspend' ) ],
451 qmresume
: [ 'VM' , gettext ( 'Resume' ) ],
452 qmconfig
: [ 'VM' , gettext ( 'Configure' ) ],
453 vzsnapshot
: [ 'CT' , gettext ( 'Snapshot' ) ],
454 vzrollback
: [ 'CT' , gettext ( 'Rollback' ) ],
455 vzdelsnapshot
: [ 'CT' , gettext ( 'Delete Snapshot' ) ],
456 vzcreate
: [ 'CT' , gettext ( 'Create' ) ],
457 vzrestore
: [ 'CT' , gettext ( 'Restore' ) ],
458 vzdestroy
: [ 'CT' , gettext ( 'Destroy' ) ],
459 vzmigrate
: [ 'CT' , gettext ( 'Migrate' ) ],
460 vzclone
: [ 'CT' , gettext ( 'Clone' ) ],
461 vztemplate
: [ 'CT' , gettext ( 'Convert to template' ) ],
462 vzstart
: [ 'CT' , gettext ( 'Start' ) ],
463 vzstop
: [ 'CT' , gettext ( 'Stop' ) ],
464 vzmount
: [ 'CT' , gettext ( 'Mount' ) ],
465 vzumount
: [ 'CT' , gettext ( 'Unmount' ) ],
466 vzshutdown
: [ 'CT' , gettext ( 'Shutdown' ) ],
467 vzsuspend
: [ 'CT' , gettext ( 'Suspend' ) ],
468 vzresume
: [ 'CT' , gettext ( 'Resume' ) ],
469 hamigrate
: [ 'HA' , gettext ( 'Migrate' ) ],
470 hastart
: [ 'HA' , gettext ( 'Start' ) ],
471 hastop
: [ 'HA' , gettext ( 'Stop' ) ],
472 srvstart
: [ 'SRV' , gettext ( 'Start' ) ],
473 srvstop
: [ 'SRV' , gettext ( 'Stop' ) ],
474 srvrestart
: [ 'SRV' , gettext ( 'Restart' ) ],
475 srvreload
: [ 'SRV' , gettext ( 'Reload' ) ],
476 cephcreatemgr
: [ 'Ceph Manager' , gettext ( 'Create' ) ],
477 cephdestroymgr
: [ 'Ceph Manager' , gettext ( 'Destroy' ) ],
478 cephcreatemon
: [ 'Ceph Monitor' , gettext ( 'Create' ) ],
479 cephdestroymon
: [ 'Ceph Monitor' , gettext ( 'Destroy' ) ],
480 cephcreateosd
: [ 'Ceph OSD' , gettext ( 'Create' ) ],
481 cephdestroyosd
: [ 'Ceph OSD' , gettext ( 'Destroy' ) ],
482 cephcreatepool
: [ 'Ceph Pool' , gettext ( 'Create' ) ],
483 cephdestroypool
: [ 'Ceph Pool' , gettext ( 'Destroy' ) ],
484 cephfscreate
: [ 'CephFS' , gettext ( 'Create' ) ],
485 cephcreatemds
: [ 'Ceph Metadata Server' , gettext ( 'Create' ) ],
486 cephdestroymds
: [ 'Ceph Metadata Server' , gettext ( 'Destroy' ) ],
487 imgcopy
: [ '' , gettext ( 'Copy data' ) ],
488 imgdel
: [ '' , gettext ( 'Erase data' ) ],
489 unknownimgdel
: [ '' , gettext ( 'Destroy image from unkown guest' ) ],
490 download
: [ '' , gettext ( 'Download' ) ],
491 vzdump
: [ '' , gettext ( 'Backup' ) ],
492 aptupdate
: [ '' , gettext ( 'Update package database' ) ],
493 startall
: [ '' , gettext ( 'Start all VMs and Containers' ) ],
494 stopall
: [ '' , gettext ( 'Stop all VMs and Containers' ) ],
495 migrateall
: [ '' , gettext ( 'Migrate all VMs and Containers' ) ],
496 dircreate
: [ gettext ( 'Directory Storage' ), gettext ( 'Create' ) ],
497 lvmcreate
: [ gettext ( 'LVM Storage' ), gettext ( 'Create' ) ],
498 lvmthincreate
: [ gettext ( 'LVM-Thin Storage' ), gettext ( 'Create' ) ],
499 zfscreate
: [ gettext ( 'ZFS Storage' ), gettext ( 'Create' ) ]
502 format_task_description : function ( type
, id
) {
503 var farray
= Proxmox
. Utils
. task_desc_table
[ type
];
512 var prefix
= farray
[ 0 ];
515 return prefix
+ ' ' + id
+ ' - ' + text
;
520 format_size : function ( size
) {
521 /*jslint confusion: true */
523 var units
= [ '' , 'Ki' , 'Mi' , 'Gi' , 'Ti' , 'Pi' , 'Ei' , 'Zi' , 'Yi' ];
526 while ( size
>= 1024 && (( num
++)+ 1 ) < units
. length
) {
530 return size
. toFixed (( num
> 0 )? 2 : 0 ) + " " + units
[ num
] + "B" ;
533 render_upid : function ( value
, metaData
, record
) {
534 var type
= record
. data
. type
;
535 var id
= record
. data
. id
;
537 return Proxmox
. Utils
. format_task_description ( type
, id
);
540 render_uptime : function ( value
) {
544 if ( uptime
=== undefined ) {
552 return Proxmox
. Utils
. format_duration_long ( uptime
);
555 parse_task_upid : function ( upid
) {
558 var res
= upid
. match ( /^UPID:(\S+):([0-9A-Fa-f]{8}):([0-9A-Fa-f]{8,9}):([0-9A-Fa-f]{8}):([^:\s]+):([^:\s]*):([^:\s]+):$/ );
560 throw "unable to parse upid '" + upid
+ "'" ;
563 task
. pid
= parseInt ( res
[ 2 ], 16 );
564 task
. pstart
= parseInt ( res
[ 3 ], 16 );
565 task
. starttime
= parseInt ( res
[ 4 ], 16 );
570 task
. desc
= Proxmox
. Utils
. format_task_description ( task
. type
, task
. id
);
575 render_timestamp : function ( value
, metaData
, record
, rowIndex
, colIndex
, store
) {
576 var servertime
= new Date ( value
* 1000 );
577 return Ext
. Date
. format ( servertime
, 'Y-m-d H:i:s' );
580 openXtermJsViewer : function ( vmtype
, vmid
, nodename
, vmname
) {
581 var url
= Ext
. urlEncode ({
582 console
: vmtype
, // kvm, lxc, upgrade or shell
588 var nw
= window
. open ( "?" + url
, '_blank' , 'toolbar=no,location=no,status=no,menubar=no,resizable=yes,width=800,height=420' );
595 constructor : function () {
597 Ext
. apply ( me
, me
. utilities
);
599 var IPV4_OCTET
= "(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])" ;
600 var IPV4_REGEXP
= "(?:(?:" + IPV4_OCTET
+ " \\ .){3}" + IPV4_OCTET
+ ")" ;
601 var IPV6_H16
= "(?:[0-9a-fA-F]{1,4})" ;
602 var IPV6_LS32
= "(?:(?:" + IPV6_H16
+ ":" + IPV6_H16
+ ")|" + IPV4_REGEXP
+ ")" ;
605 me
. IP4_match
= new RegExp ( "^(?:" + IPV4_REGEXP
+ ")$" );
606 me
. IP4_cidr_match
= new RegExp ( "^(?:" + IPV4_REGEXP
+ ")\/([0-9]{1,2})$" );
608 var IPV6_REGEXP
= "(?:" +
609 "(?:(?:" + "(?:" + IPV6_H16
+ ":){6})" + IPV6_LS32
+ ")|" +
610 "(?:(?:" + "::" + "(?:" + IPV6_H16
+ ":){5})" + IPV6_LS32
+ ")|" +
611 "(?:(?:(?:" + IPV6_H16
+ ")?::" + "(?:" + IPV6_H16
+ ":){4})" + IPV6_LS32
+ ")|" +
612 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,1}" + IPV6_H16
+ ")?::" + "(?:" + IPV6_H16
+ ":){3})" + IPV6_LS32
+ ")|" +
613 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,2}" + IPV6_H16
+ ")?::" + "(?:" + IPV6_H16
+ ":){2})" + IPV6_LS32
+ ")|" +
614 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,3}" + IPV6_H16
+ ")?::" + "(?:" + IPV6_H16
+ ":){1})" + IPV6_LS32
+ ")|" +
615 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,4}" + IPV6_H16
+ ")?::" + ")" + IPV6_LS32
+ ")|" +
616 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,5}" + IPV6_H16
+ ")?::" + ")" + IPV6_H16
+ ")|" +
617 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,7}" + IPV6_H16
+ ")?::" + ")" + ")" +
620 me
. IP6_match
= new RegExp ( "^(?:" + IPV6_REGEXP
+ ")$" );
621 me
. IP6_cidr_match
= new RegExp ( "^(?:" + IPV6_REGEXP
+ ")\/([0-9]{1,3})$" );
622 me
. IP6_bracket_match
= new RegExp ( "^ \\ [(" + IPV6_REGEXP
+ ") \\ ]" );
624 me
. IP64_match
= new RegExp ( "^(?:" + IPV6_REGEXP
+ "|" + IPV4_REGEXP
+ ")$" );
626 var DnsName_REGEXP
= "(?:(([a-zA-Z0-9]([a-zA-Z0-9 \\ -]*[a-zA-Z0-9])?) \\ .)*([A-Za-z0-9]([A-Za-z0-9 \\ -]*[A-Za-z0-9])?))" ;
627 me
. DnsName_match
= new RegExp ( "^" + DnsName_REGEXP
+ "$" );
629 me
. HostPort_match
= new RegExp ( "^(" + IPV4_REGEXP
+ "|" + DnsName_REGEXP
+ ")(: \\ d+)?$" );
630 me
. HostPortBrackets_match
= new RegExp ( "^ \\ [(?:" + IPV6_REGEXP
+ "|" + IPV4_REGEXP
+ "|" + DnsName_REGEXP
+ ") \\ ](: \\ d+)?$" );
631 me
. IP6_dotnotation_match
= new RegExp ( "^" + IPV6_REGEXP
+ "( \\ . \\ d+)?$" );