]>
git.proxmox.com Git - proxmox-widget-toolkit.git/blob - Utils.js
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)' ,
83 render_language : function ( value
) {
85 return Proxmox
. Utils
. defaultText
+ ' (English)' ;
87 var text
= Proxmox
. Utils
. language_map
[ value
];
89 return text
+ ' (' + value
+ ')' ;
94 language_array : function () {
95 var data
= [[ '__default__' , Proxmox
. Utils
. render_language ( '' )]];
96 Ext
. Object
. each ( Proxmox
. Utils
. language_map
, function ( key
, value
) {
97 data
. push ([ key
, Proxmox
. Utils
. render_language ( value
)]);
103 bond_mode_gettext_map
: {
104 '802.3ad' : 'LACP (802.3ad)' ,
105 'lacp-balance-slb' : 'LACP (balance-slb)' ,
106 'lacp-balance-tcp' : 'LACP (balance-tcp)' ,
109 render_bond_mode
: value
=> Proxmox
. Utils
. bond_mode_gettext_map
[ value
] || value
|| '' ,
111 bond_mode_array : function ( modes
) {
112 return modes
. map ( mode
=> [ mode
, Proxmox
. Utils
. render_bond_mode ( mode
)]);
115 getNoSubKeyHtml : function ( url
) {
116 // url http://www.proxmox.com/products/proxmox-ve/subscription-service-plans
117 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
|| 'https://www.proxmox.com' );
120 format_boolean_with_default : function ( value
) {
121 if ( Ext
. isDefined ( value
) && value
!== '__default__' ) {
122 return value
? Proxmox
. Utils
. yesText
: Proxmox
. Utils
. noText
;
124 return Proxmox
. Utils
. defaultText
;
127 format_boolean : function ( value
) {
128 return value
? Proxmox
. Utils
. yesText
: Proxmox
. Utils
. noText
;
131 format_neg_boolean : function ( value
) {
132 return ! value
? Proxmox
. Utils
. yesText
: Proxmox
. Utils
. noText
;
135 format_enabled_toggle : function ( value
) {
136 return value
? Proxmox
. Utils
. enabledText
: Proxmox
. Utils
. disabledText
;
139 format_expire : function ( date
) {
141 return Proxmox
. Utils
. neverText
;
143 return Ext
. Date
. format ( date
, "Y-m-d" );
146 format_duration_long : function ( ut
) {
148 var days
= Math
. floor ( ut
/ 86400 );
150 var hours
= Math
. floor ( ut
/ 3600 );
152 var mins
= Math
. floor ( ut
/ 60 );
155 var hours_str
= '00' + hours
. toString ();
156 hours_str
= hours_str
. substr ( hours_str
. length
- 2 );
157 var mins_str
= "00" + mins
. toString ();
158 mins_str
= mins_str
. substr ( mins_str
. length
- 2 );
159 var ut_str
= "00" + ut
. toString ();
160 ut_str
= ut_str
. substr ( ut_str
. length
- 2 );
163 var ds
= days
> 1 ? Proxmox
. Utils
. daysText
: Proxmox
. Utils
. dayText
;
164 return days
. toString () + ' ' + ds
+ ' ' +
165 hours_str
+ ':' + mins_str
+ ':' + ut_str
;
167 return hours_str
+ ':' + mins_str
+ ':' + ut_str
;
171 format_subscription_level : function ( level
) {
174 } else if ( level
=== 'b' ) {
176 } else if ( level
=== 's' ) {
178 } else if ( level
=== 'p' ) {
181 return Proxmox
. Utils
. noneText
;
185 compute_min_label_width : function ( text
, width
) {
187 if ( width
=== undefined ) { width
= 100 ; }
189 var tm
= new Ext
. util
. TextMetrics ();
190 var min
= tm
. getWidth ( text
+ ':' );
192 return min
< width
? width
: min
;
195 setAuthData : function ( data
) {
196 Proxmox
. CSRFPreventionToken
= data
. CSRFPreventionToken
;
197 Proxmox
. UserName
= data
. username
;
198 Proxmox
. LoggedOut
= data
. LoggedOut
;
199 // creates a session cookie (expire = null)
200 // that way the cookie gets deleted after the browser window is closed
201 Ext
. util
. Cookies
. set ( Proxmox
. Setup
. auth_cookie_name
, data
. ticket
, null , '/' , null , true );
205 if ( Proxmox
. LoggedOut
) {
208 return ( Proxmox
. UserName
!== '' ) && Ext
. util
. Cookies
. get ( Proxmox
. Setup
. auth_cookie_name
);
211 authClear : function () {
212 if ( Proxmox
. LoggedOut
) {
215 Ext
. util
. Cookies
. clear ( Proxmox
. Setup
. auth_cookie_name
);
218 // comp.setLoading() is buggy in ExtJS 4.0.7, so we
219 // use el.mask() instead
220 setErrorMask : function ( comp
, msg
) {
229 el
. mask ( gettext ( "Loading..." ));
236 monStoreErrors : function ( me
, store
, clearMaskBeforeLoad
) {
237 if ( clearMaskBeforeLoad
) {
238 me
. mon ( store
, 'beforeload' , function ( s
, operation
, eOpts
) {
239 Proxmox
. Utils
. setErrorMask ( me
, false );
242 me
. mon ( store
, 'beforeload' , function ( s
, operation
, eOpts
) {
244 me
. loadCount
= 0 ; // make sure it is numeric
245 Proxmox
. Utils
. setErrorMask ( me
, true );
250 // only works with 'proxmox' proxy
251 me
. mon ( store
. proxy
, 'afterload' , function ( proxy
, request
, success
) {
255 Proxmox
. Utils
. setErrorMask ( me
, false );
260 /*jslint nomen: true */
261 var operation
= request
. _operation
;
262 var error
= operation
. getError ();
263 if ( error
. statusText
) {
264 msg
= error
. statusText
+ ' (' + error
. status
+ ')' ;
266 msg
= gettext ( 'Connection error' );
268 Proxmox
. Utils
. setErrorMask ( me
, msg
);
272 extractRequestError : function ( result
, verbose
) {
273 var msg
= gettext ( 'Successful' );
275 if (! result
. success
) {
276 msg
= gettext ( "Unknown error" );
277 if ( result
. message
) {
278 msg
= result
. message
;
280 msg
+= ' (' + result
. status
+ ')' ;
283 if ( verbose
&& Ext
. isObject ( result
. errors
)) {
285 Ext
. Object
. each ( result
. errors
, function ( prop
, desc
) {
286 msg
+= "<br><b>" + Ext
. htmlEncode ( prop
) + "</b>: " +
287 Ext
. htmlEncode ( desc
);
296 API2Request : function ( reqOpts
) {
298 var newopts
= Ext
. apply ({
299 waitMsg
: gettext ( 'Please wait...' )
302 if (! newopts
. url
. match ( /^\/api2/ )) {
303 newopts
. url
= '/api2/extjs' + newopts
. url
;
305 delete newopts
. callback
;
307 var createWrapper = function ( successFn
, callbackFn
, failureFn
) {
309 success : function ( response
, options
) {
310 if ( options
. waitMsgTarget
) {
311 if ( Proxmox
. Utils
. toolkit
=== 'touch' ) {
312 options
. waitMsgTarget
. setMasked ( false );
314 options
. waitMsgTarget
. setLoading ( false );
317 var result
= Ext
. decode ( response
. responseText
);
318 response
. result
= result
;
319 if (! result
. success
) {
320 response
. htmlStatus
= Proxmox
. Utils
. extractRequestError ( result
, true );
321 Ext
. callback ( callbackFn
, options
. scope
, [ options
, false , response
]);
322 Ext
. callback ( failureFn
, options
. scope
, [ response
, options
]);
325 Ext
. callback ( callbackFn
, options
. scope
, [ options
, true , response
]);
326 Ext
. callback ( successFn
, options
. scope
, [ response
, options
]);
328 failure : function ( response
, options
) {
329 if ( options
. waitMsgTarget
) {
330 if ( Proxmox
. Utils
. toolkit
=== 'touch' ) {
331 options
. waitMsgTarget
. setMasked ( false );
333 options
. waitMsgTarget
. setLoading ( false );
336 response
. result
= {};
338 response
. result
= Ext
. decode ( response
. responseText
);
340 var msg
= gettext ( 'Connection error' ) + ' - server offline?' ;
341 if ( response
. aborted
) {
342 msg
= gettext ( 'Connection error' ) + ' - aborted.' ;
343 } else if ( response
. timedout
) {
344 msg
= gettext ( 'Connection error' ) + ' - Timeout.' ;
345 } else if ( response
. status
&& response
. statusText
) {
346 msg
= gettext ( 'Connection error' ) + ' ' + response
. status
+ ': ' + response
. statusText
;
348 response
. htmlStatus
= msg
;
349 Ext
. callback ( callbackFn
, options
. scope
, [ options
, false , response
]);
350 Ext
. callback ( failureFn
, options
. scope
, [ response
, options
]);
355 createWrapper ( reqOpts
. success
, reqOpts
. callback
, reqOpts
. failure
);
357 var target
= newopts
. waitMsgTarget
;
359 if ( Proxmox
. Utils
. toolkit
=== 'touch' ) {
360 target
. setMasked ({ xtype
: 'loadmask' , message
: newopts
. waitMsg
} );
362 // Note: ExtJS bug - this does not work when component is not rendered
363 target
. setLoading ( newopts
. waitMsg
);
366 Ext
. Ajax
. request ( newopts
);
369 checked_command : function ( orig_cmd
) {
370 Proxmox
. Utils
. API2Request ({
371 url
: '/nodes/localhost/subscription' ,
374 failure : function ( response
, opts
) {
375 Ext
. Msg
. alert ( gettext ( 'Error' ), response
. htmlStatus
);
377 success : function ( response
, opts
) {
378 var data
= response
. result
. data
;
380 if ( data
. status
!== 'Active' ) {
382 title
: gettext ( 'No valid subscription' ),
383 icon
: Ext
. Msg
. WARNING
,
384 msg
: Proxmox
. Utils
. getNoSubKeyHtml ( data
. url
),
386 callback : function ( btn
) {
400 assemble_field_data : function ( values
, data
) {
401 if ( Ext
. isObject ( data
)) {
402 Ext
. Object
. each ( data
, function ( name
, val
) {
403 if ( values
. hasOwnProperty ( name
)) {
404 var bucket
= values
[ name
];
405 if (! Ext
. isArray ( bucket
)) {
406 bucket
= values
[ name
] = [ bucket
];
408 if ( Ext
. isArray ( val
)) {
409 values
[ name
] = bucket
. concat ( val
);
420 dialog_title : function ( subject
, create
, isAdd
) {
423 return gettext ( 'Add' ) + ': ' + subject
;
425 return gettext ( 'Create' ) + ': ' + subject
;
428 return gettext ( 'Edit' ) + ': ' + subject
;
432 network_iface_types
: {
433 eth
: gettext ( "Network Device" ),
434 bridge
: 'Linux Bridge' ,
437 OVSBridge
: 'OVS Bridge' ,
440 OVSIntPort
: 'OVS IntPort'
443 render_network_iface_type : function ( value
) {
444 return Proxmox
. Utils
. network_iface_types
[ value
] ||
445 Proxmox
. Utils
. unknownText
;
449 acmenewcert
: [ 'SRV' , gettext ( 'Order Certificate' ) ],
450 acmeregister
: [ 'ACME Account' , gettext ( 'Register' ) ],
451 acmedeactivate
: [ 'ACME Account' , gettext ( 'Deactivate' ) ],
452 acmeupdate
: [ 'ACME Account' , gettext ( 'Update' ) ],
453 acmerefresh
: [ 'ACME Account' , gettext ( 'Refresh' ) ],
454 acmerenew
: [ 'SRV' , gettext ( 'Renew Certificate' ) ],
455 acmerevoke
: [ 'SRV' , gettext ( 'Revoke Certificate' ) ],
456 'move_volume' : [ 'CT' , gettext ( 'Move Volume' ) ],
457 clustercreate
: [ '' , gettext ( 'Create Cluster' ) ],
458 clusterjoin
: [ '' , gettext ( 'Join Cluster' ) ],
459 diskinit
: [ 'Disk' , gettext ( 'Initialize Disk with GPT' ) ],
460 vncproxy
: [ 'VM/CT' , gettext ( 'Console' ) ],
461 spiceproxy
: [ 'VM/CT' , gettext ( 'Console' ) + ' (Spice)' ],
462 vncshell
: [ '' , gettext ( 'Shell' ) ],
463 spiceshell
: [ '' , gettext ( 'Shell' ) + ' (Spice)' ],
464 qmsnapshot
: [ 'VM' , gettext ( 'Snapshot' ) ],
465 qmrollback
: [ 'VM' , gettext ( 'Rollback' ) ],
466 qmdelsnapshot
: [ 'VM' , gettext ( 'Delete Snapshot' ) ],
467 qmcreate
: [ 'VM' , gettext ( 'Create' ) ],
468 qmrestore
: [ 'VM' , gettext ( 'Restore' ) ],
469 qmdestroy
: [ 'VM' , gettext ( 'Destroy' ) ],
470 qmigrate
: [ 'VM' , gettext ( 'Migrate' ) ],
471 qmclone
: [ 'VM' , gettext ( 'Clone' ) ],
472 qmmove
: [ 'VM' , gettext ( 'Move disk' ) ],
473 qmtemplate
: [ 'VM' , gettext ( 'Convert to template' ) ],
474 qmstart
: [ 'VM' , gettext ( 'Start' ) ],
475 qmstop
: [ 'VM' , gettext ( 'Stop' ) ],
476 qmreset
: [ 'VM' , gettext ( 'Reset' ) ],
477 qmshutdown
: [ 'VM' , gettext ( 'Shutdown' ) ],
478 qmreboot
: [ 'VM' , gettext ( 'Reboot' ) ],
479 qmsuspend
: [ 'VM' , gettext ( 'Hibernate' ) ],
480 qmpause
: [ 'VM' , gettext ( 'Pause' ) ],
481 qmresume
: [ 'VM' , gettext ( 'Resume' ) ],
482 qmconfig
: [ 'VM' , gettext ( 'Configure' ) ],
483 vzsnapshot
: [ 'CT' , gettext ( 'Snapshot' ) ],
484 vzrollback
: [ 'CT' , gettext ( 'Rollback' ) ],
485 vzdelsnapshot
: [ 'CT' , gettext ( 'Delete Snapshot' ) ],
486 vzcreate
: [ 'CT' , gettext ( 'Create' ) ],
487 vzrestore
: [ 'CT' , gettext ( 'Restore' ) ],
488 vzdestroy
: [ 'CT' , gettext ( 'Destroy' ) ],
489 vzmigrate
: [ 'CT' , gettext ( 'Migrate' ) ],
490 vzclone
: [ 'CT' , gettext ( 'Clone' ) ],
491 vztemplate
: [ 'CT' , gettext ( 'Convert to template' ) ],
492 vzstart
: [ 'CT' , gettext ( 'Start' ) ],
493 vzstop
: [ 'CT' , gettext ( 'Stop' ) ],
494 vzmount
: [ 'CT' , gettext ( 'Mount' ) ],
495 vzumount
: [ 'CT' , gettext ( 'Unmount' ) ],
496 vzshutdown
: [ 'CT' , gettext ( 'Shutdown' ) ],
497 vzsuspend
: [ 'CT' , gettext ( 'Suspend' ) ],
498 vzresume
: [ 'CT' , gettext ( 'Resume' ) ],
499 hamigrate
: [ 'HA' , gettext ( 'Migrate' ) ],
500 hastart
: [ 'HA' , gettext ( 'Start' ) ],
501 hastop
: [ 'HA' , gettext ( 'Stop' ) ],
502 srvstart
: [ 'SRV' , gettext ( 'Start' ) ],
503 srvstop
: [ 'SRV' , gettext ( 'Stop' ) ],
504 srvrestart
: [ 'SRV' , gettext ( 'Restart' ) ],
505 srvreload
: [ 'SRV' , gettext ( 'Reload' ) ],
506 cephcreatemgr
: [ 'Ceph Manager' , gettext ( 'Create' ) ],
507 cephdestroymgr
: [ 'Ceph Manager' , gettext ( 'Destroy' ) ],
508 cephcreatemon
: [ 'Ceph Monitor' , gettext ( 'Create' ) ],
509 cephdestroymon
: [ 'Ceph Monitor' , gettext ( 'Destroy' ) ],
510 cephcreateosd
: [ 'Ceph OSD' , gettext ( 'Create' ) ],
511 cephdestroyosd
: [ 'Ceph OSD' , gettext ( 'Destroy' ) ],
512 cephcreatepool
: [ 'Ceph Pool' , gettext ( 'Create' ) ],
513 cephdestroypool
: [ 'Ceph Pool' , gettext ( 'Destroy' ) ],
514 cephfscreate
: [ 'CephFS' , gettext ( 'Create' ) ],
515 cephcreatemds
: [ 'Ceph Metadata Server' , gettext ( 'Create' ) ],
516 cephdestroymds
: [ 'Ceph Metadata Server' , gettext ( 'Destroy' ) ],
517 imgcopy
: [ '' , gettext ( 'Copy data' ) ],
518 imgdel
: [ '' , gettext ( 'Erase data' ) ],
519 unknownimgdel
: [ '' , gettext ( 'Destroy image from unknown guest' ) ],
520 download
: [ '' , gettext ( 'Download' ) ],
521 vzdump
: [ 'VM/CT' , gettext ( 'Backup' ) ],
522 aptupdate
: [ '' , gettext ( 'Update package database' ) ],
523 startall
: [ '' , gettext ( 'Start all VMs and Containers' ) ],
524 stopall
: [ '' , gettext ( 'Stop all VMs and Containers' ) ],
525 migrateall
: [ '' , gettext ( 'Migrate all VMs and Containers' ) ],
526 dircreate
: [ gettext ( 'Directory Storage' ), gettext ( 'Create' ) ],
527 lvmcreate
: [ gettext ( 'LVM Storage' ), gettext ( 'Create' ) ],
528 lvmthincreate
: [ gettext ( 'LVM-Thin Storage' ), gettext ( 'Create' ) ],
529 zfscreate
: [ gettext ( 'ZFS Storage' ), gettext ( 'Create' ) ]
532 format_task_description : function ( type
, id
) {
533 var farray
= Proxmox
. Utils
. task_desc_table
[ type
];
542 var prefix
= farray
[ 0 ];
545 return prefix
+ ' ' + id
+ ' - ' + text
;
550 format_size : function ( size
) {
551 /*jslint confusion: true */
553 var units
= [ '' , 'Ki' , 'Mi' , 'Gi' , 'Ti' , 'Pi' , 'Ei' , 'Zi' , 'Yi' ];
556 while ( size
>= 1024 && (( num
++)+ 1 ) < units
. length
) {
560 return size
. toFixed (( num
> 0 )? 2 : 0 ) + " " + units
[ num
] + "B" ;
563 render_upid : function ( value
, metaData
, record
) {
564 var type
= record
. data
. type
;
565 var id
= record
. data
. id
;
567 return Proxmox
. Utils
. format_task_description ( type
, id
);
570 render_uptime : function ( value
) {
574 if ( uptime
=== undefined ) {
582 return Proxmox
. Utils
. format_duration_long ( uptime
);
585 parse_task_upid : function ( upid
) {
588 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]+):$/ );
590 throw "unable to parse upid '" + upid
+ "'" ;
593 task
. pid
= parseInt ( res
[ 2 ], 16 );
594 task
. pstart
= parseInt ( res
[ 3 ], 16 );
595 task
. starttime
= parseInt ( res
[ 4 ], 16 );
600 task
. desc
= Proxmox
. Utils
. format_task_description ( task
. type
, task
. id
);
605 render_timestamp : function ( value
, metaData
, record
, rowIndex
, colIndex
, store
) {
606 var servertime
= new Date ( value
* 1000 );
607 return Ext
. Date
. format ( servertime
, 'Y-m-d H:i:s' );
610 get_help_info : function ( section
) {
612 if ( typeof proxmoxOnlineHelpInfo
!== 'undefined' ) {
613 helpMap
= proxmoxOnlineHelpInfo
;
614 } else if ( typeof pveOnlineHelpInfo
!== 'undefined' ) {
615 // be backward compatible with older pve-doc-generators
616 helpMap
= pveOnlineHelpInfo
;
618 throw "no global OnlineHelpInfo map declared" ;
621 return helpMap
[ section
];
624 get_help_link : function ( section
) {
625 var info
= Proxmox
. Utils
. get_help_info ( section
);
630 return window
. location
. origin
+ info
. link
;
633 openXtermJsViewer : function ( vmtype
, vmid
, nodename
, vmname
, cmd
) {
634 var url
= Ext
. Object
. toQueryString ({
635 console
: vmtype
, // kvm, lxc, upgrade or shell
643 var nw
= window
. open ( "?" + url
, '_blank' , 'toolbar=no,location=no,status=no,menubar=no,resizable=yes,width=800,height=420' );
652 constructor : function () {
654 Ext
. apply ( me
, me
. utilities
);
656 var IPV4_OCTET
= "(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])" ;
657 var IPV4_REGEXP
= "(?:(?:" + IPV4_OCTET
+ " \\ .){3}" + IPV4_OCTET
+ ")" ;
658 var IPV6_H16
= "(?:[0-9a-fA-F]{1,4})" ;
659 var IPV6_LS32
= "(?:(?:" + IPV6_H16
+ ":" + IPV6_H16
+ ")|" + IPV4_REGEXP
+ ")" ;
660 var IPV4_CIDR_MASK
= "([0-9]{1,2})" ;
661 var IPV6_CIDR_MASK
= "([0-9]{1,3})" ;
664 me
. IP4_match
= new RegExp ( "^(?:" + IPV4_REGEXP
+ ")$" );
665 me
. IP4_cidr_match
= new RegExp ( "^(?:" + IPV4_REGEXP
+ ")\/" + IPV4_CIDR_MASK
+ "$" );
667 var IPV6_REGEXP
= "(?:" +
668 "(?:(?:" + "(?:" + IPV6_H16
+ ":){6})" + IPV6_LS32
+ ")|" +
669 "(?:(?:" + "::" + "(?:" + IPV6_H16
+ ":){5})" + IPV6_LS32
+ ")|" +
670 "(?:(?:(?:" + IPV6_H16
+ ")?::" + "(?:" + IPV6_H16
+ ":){4})" + IPV6_LS32
+ ")|" +
671 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,1}" + IPV6_H16
+ ")?::" + "(?:" + IPV6_H16
+ ":){3})" + IPV6_LS32
+ ")|" +
672 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,2}" + IPV6_H16
+ ")?::" + "(?:" + IPV6_H16
+ ":){2})" + IPV6_LS32
+ ")|" +
673 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,3}" + IPV6_H16
+ ")?::" + "(?:" + IPV6_H16
+ ":){1})" + IPV6_LS32
+ ")|" +
674 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,4}" + IPV6_H16
+ ")?::" + ")" + IPV6_LS32
+ ")|" +
675 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,5}" + IPV6_H16
+ ")?::" + ")" + IPV6_H16
+ ")|" +
676 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,7}" + IPV6_H16
+ ")?::" + ")" + ")" +
679 me
. IP6_match
= new RegExp ( "^(?:" + IPV6_REGEXP
+ ")$" );
680 me
. IP6_cidr_match
= new RegExp ( "^(?:" + IPV6_REGEXP
+ ")\/" + IPV6_CIDR_MASK
+ "$" );
681 me
. IP6_bracket_match
= new RegExp ( "^ \\ [(" + IPV6_REGEXP
+ ") \\ ]" );
683 me
. IP64_match
= new RegExp ( "^(?:" + IPV6_REGEXP
+ "|" + IPV4_REGEXP
+ ")$" );
684 me
. IP64_cidr_match
= new RegExp ( "^(?:" + IPV6_REGEXP
+ "\/" + IPV6_CIDR_MASK
+ ")|(?:" + IPV4_REGEXP
+ "\/" + IPV4_CIDR_MASK
+ ")$" );
686 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])?))" ;
687 me
. DnsName_match
= new RegExp ( "^" + DnsName_REGEXP
+ "$" );
689 me
. HostPort_match
= new RegExp ( "^(" + IPV4_REGEXP
+ "|" + DnsName_REGEXP
+ ")(: \\ d+)?$" );
690 me
. HostPortBrackets_match
= new RegExp ( "^ \\ [(?:" + IPV6_REGEXP
+ "|" + IPV4_REGEXP
+ "|" + DnsName_REGEXP
+ ") \\ ](: \\ d+)?$" );
691 me
. IP6_dotnotation_match
= new RegExp ( "^" + IPV6_REGEXP
+ "( \\ . \\ d+)?$" );