]>
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)' ,
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 bond_mode_gettext_map
: {
103 '802.3ad' : 'LACP (802.3ad)' ,
104 'lacp-balance-slb' : 'LACP (balance-slb)' ,
105 'lacp-balance-tcp' : 'LACP (balance-tcp)' ,
108 render_bond_mode
: value
=> Proxmox
. Utils
. bond_mode_gettext_map
[ value
] || value
|| '' ,
110 bond_mode_array : function ( modes
) {
111 return modes
. map ( mode
=> [ mode
, Proxmox
. Utils
. render_bond_mode ( mode
)]);
114 getNoSubKeyHtml : function ( url
) {
115 // url http://www.proxmox.com/products/proxmox-ve/subscription-service-plans
116 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' );
119 format_boolean_with_default : function ( value
) {
120 if ( Ext
. isDefined ( value
) && value
!== '__default__' ) {
121 return value
? Proxmox
. Utils
. yesText
: Proxmox
. Utils
. noText
;
123 return Proxmox
. Utils
. defaultText
;
126 format_boolean : function ( value
) {
127 return value
? Proxmox
. Utils
. yesText
: Proxmox
. Utils
. noText
;
130 format_neg_boolean : function ( value
) {
131 return ! value
? Proxmox
. Utils
. yesText
: Proxmox
. Utils
. noText
;
134 format_enabled_toggle : function ( value
) {
135 return value
? Proxmox
. Utils
. enabledText
: Proxmox
. Utils
. disabledText
;
138 format_expire : function ( date
) {
140 return Proxmox
. Utils
. neverText
;
142 return Ext
. Date
. format ( date
, "Y-m-d" );
145 format_duration_long : function ( ut
) {
147 var days
= Math
. floor ( ut
/ 86400 );
149 var hours
= Math
. floor ( ut
/ 3600 );
151 var mins
= Math
. floor ( ut
/ 60 );
154 var hours_str
= '00' + hours
. toString ();
155 hours_str
= hours_str
. substr ( hours_str
. length
- 2 );
156 var mins_str
= "00" + mins
. toString ();
157 mins_str
= mins_str
. substr ( mins_str
. length
- 2 );
158 var ut_str
= "00" + ut
. toString ();
159 ut_str
= ut_str
. substr ( ut_str
. length
- 2 );
162 var ds
= days
> 1 ? Proxmox
. Utils
. daysText
: Proxmox
. Utils
. dayText
;
163 return days
. toString () + ' ' + ds
+ ' ' +
164 hours_str
+ ':' + mins_str
+ ':' + ut_str
;
166 return hours_str
+ ':' + mins_str
+ ':' + ut_str
;
170 format_subscription_level : function ( level
) {
173 } else if ( level
=== 'b' ) {
175 } else if ( level
=== 's' ) {
177 } else if ( level
=== 'p' ) {
180 return Proxmox
. Utils
. noneText
;
184 compute_min_label_width : function ( text
, width
) {
186 if ( width
=== undefined ) { width
= 100 ; }
188 var tm
= new Ext
. util
. TextMetrics ();
189 var min
= tm
. getWidth ( text
+ ':' );
191 return min
< width
? width
: min
;
194 setAuthData : function ( data
) {
195 Proxmox
. CSRFPreventionToken
= data
. CSRFPreventionToken
;
196 Proxmox
. UserName
= data
. username
;
197 Proxmox
. LoggedOut
= data
. LoggedOut
;
198 // creates a session cookie (expire = null)
199 // that way the cookie gets deleted after the browser window is closed
200 Ext
. util
. Cookies
. set ( Proxmox
. Setup
. auth_cookie_name
, data
. ticket
, null , '/' , null , true );
204 if ( Proxmox
. LoggedOut
) {
207 return ( Proxmox
. UserName
!== '' ) && Ext
. util
. Cookies
. get ( Proxmox
. Setup
. auth_cookie_name
);
210 authClear : function () {
211 if ( Proxmox
. LoggedOut
) {
214 Ext
. util
. Cookies
. clear ( Proxmox
. Setup
. auth_cookie_name
);
217 // comp.setLoading() is buggy in ExtJS 4.0.7, so we
218 // use el.mask() instead
219 setErrorMask : function ( comp
, msg
) {
228 el
. mask ( gettext ( "Loading..." ));
235 monStoreErrors : function ( me
, store
, clearMaskBeforeLoad
) {
236 if ( clearMaskBeforeLoad
) {
237 me
. mon ( store
, 'beforeload' , function ( s
, operation
, eOpts
) {
238 Proxmox
. Utils
. setErrorMask ( me
, false );
241 me
. mon ( store
, 'beforeload' , function ( s
, operation
, eOpts
) {
243 me
. loadCount
= 0 ; // make sure it is numeric
244 Proxmox
. Utils
. setErrorMask ( me
, true );
249 // only works with 'proxmox' proxy
250 me
. mon ( store
. proxy
, 'afterload' , function ( proxy
, request
, success
) {
254 Proxmox
. Utils
. setErrorMask ( me
, false );
259 /*jslint nomen: true */
260 var operation
= request
. _operation
;
261 var error
= operation
. getError ();
262 if ( error
. statusText
) {
263 msg
= error
. statusText
+ ' (' + error
. status
+ ')' ;
265 msg
= gettext ( 'Connection error' );
267 Proxmox
. Utils
. setErrorMask ( me
, msg
);
271 extractRequestError : function ( result
, verbose
) {
272 var msg
= gettext ( 'Successful' );
274 if (! result
. success
) {
275 msg
= gettext ( "Unknown error" );
276 if ( result
. message
) {
277 msg
= result
. message
;
279 msg
+= ' (' + result
. status
+ ')' ;
282 if ( verbose
&& Ext
. isObject ( result
. errors
)) {
284 Ext
. Object
. each ( result
. errors
, function ( prop
, desc
) {
285 msg
+= "<br><b>" + Ext
. htmlEncode ( prop
) + "</b>: " +
286 Ext
. htmlEncode ( desc
);
295 API2Request : function ( reqOpts
) {
297 var newopts
= Ext
. apply ({
298 waitMsg
: gettext ( 'Please wait...' )
301 if (! newopts
. url
. match ( /^\/api2/ )) {
302 newopts
. url
= '/api2/extjs' + newopts
. url
;
304 delete newopts
. callback
;
306 var createWrapper = function ( successFn
, callbackFn
, failureFn
) {
308 success : function ( response
, options
) {
309 if ( options
. waitMsgTarget
) {
310 if ( Proxmox
. Utils
. toolkit
=== 'touch' ) {
311 options
. waitMsgTarget
. setMasked ( false );
313 options
. waitMsgTarget
. setLoading ( false );
316 var result
= Ext
. decode ( response
. responseText
);
317 response
. result
= result
;
318 if (! result
. success
) {
319 response
. htmlStatus
= Proxmox
. Utils
. extractRequestError ( result
, true );
320 Ext
. callback ( callbackFn
, options
. scope
, [ options
, false , response
]);
321 Ext
. callback ( failureFn
, options
. scope
, [ response
, options
]);
324 Ext
. callback ( callbackFn
, options
. scope
, [ options
, true , response
]);
325 Ext
. callback ( successFn
, options
. scope
, [ response
, options
]);
327 failure : function ( response
, options
) {
328 if ( options
. waitMsgTarget
) {
329 if ( Proxmox
. Utils
. toolkit
=== 'touch' ) {
330 options
. waitMsgTarget
. setMasked ( false );
332 options
. waitMsgTarget
. setLoading ( false );
335 response
. result
= {};
337 response
. result
= Ext
. decode ( response
. responseText
);
339 var msg
= gettext ( 'Connection error' ) + ' - server offline?' ;
340 if ( response
. aborted
) {
341 msg
= gettext ( 'Connection error' ) + ' - aborted.' ;
342 } else if ( response
. timedout
) {
343 msg
= gettext ( 'Connection error' ) + ' - Timeout.' ;
344 } else if ( response
. status
&& response
. statusText
) {
345 msg
= gettext ( 'Connection error' ) + ' ' + response
. status
+ ': ' + response
. statusText
;
347 response
. htmlStatus
= msg
;
348 Ext
. callback ( callbackFn
, options
. scope
, [ options
, false , response
]);
349 Ext
. callback ( failureFn
, options
. scope
, [ response
, options
]);
354 createWrapper ( reqOpts
. success
, reqOpts
. callback
, reqOpts
. failure
);
356 var target
= newopts
. waitMsgTarget
;
358 if ( Proxmox
. Utils
. toolkit
=== 'touch' ) {
359 target
. setMasked ({ xtype
: 'loadmask' , message
: newopts
. waitMsg
} );
361 // Note: ExtJS bug - this does not work when component is not rendered
362 target
. setLoading ( newopts
. waitMsg
);
365 Ext
. Ajax
. request ( newopts
);
368 checked_command : function ( orig_cmd
) {
369 Proxmox
. Utils
. API2Request ({
370 url
: '/nodes/localhost/subscription' ,
373 failure : function ( response
, opts
) {
374 Ext
. Msg
. alert ( gettext ( 'Error' ), response
. htmlStatus
);
376 success : function ( response
, opts
) {
377 var data
= response
. result
. data
;
379 if ( data
. status
!== 'Active' ) {
381 title
: gettext ( 'No valid subscription' ),
382 icon
: Ext
. Msg
. WARNING
,
383 msg
: Proxmox
. Utils
. getNoSubKeyHtml ( data
. url
),
385 callback : function ( btn
) {
399 assemble_field_data : function ( values
, data
) {
400 if ( Ext
. isObject ( data
)) {
401 Ext
. Object
. each ( data
, function ( name
, val
) {
402 if ( values
. hasOwnProperty ( name
)) {
403 var bucket
= values
[ name
];
404 if (! Ext
. isArray ( bucket
)) {
405 bucket
= values
[ name
] = [ bucket
];
407 if ( Ext
. isArray ( val
)) {
408 values
[ name
] = bucket
. concat ( val
);
419 dialog_title : function ( subject
, create
, isAdd
) {
422 return gettext ( 'Add' ) + ': ' + subject
;
424 return gettext ( 'Create' ) + ': ' + subject
;
427 return gettext ( 'Edit' ) + ': ' + subject
;
431 network_iface_types
: {
432 eth
: gettext ( "Network Device" ),
433 bridge
: 'Linux Bridge' ,
436 OVSBridge
: 'OVS Bridge' ,
439 OVSIntPort
: 'OVS IntPort'
442 render_network_iface_type : function ( value
) {
443 return Proxmox
. Utils
. network_iface_types
[ value
] ||
444 Proxmox
. Utils
. unknownText
;
448 acmenewcert
: [ 'SRV' , gettext ( 'Order Certificate' ) ],
449 acmeregister
: [ 'ACME Account' , gettext ( 'Register' ) ],
450 acmedeactivate
: [ 'ACME Account' , gettext ( 'Deactivate' ) ],
451 acmeupdate
: [ 'ACME Account' , gettext ( 'Update' ) ],
452 acmerefresh
: [ 'ACME Account' , gettext ( 'Refresh' ) ],
453 acmerenew
: [ 'SRV' , gettext ( 'Renew Certificate' ) ],
454 acmerevoke
: [ 'SRV' , gettext ( 'Revoke Certificate' ) ],
455 'move_volume' : [ 'CT' , gettext ( 'Move Volume' ) ],
456 clustercreate
: [ '' , gettext ( 'Create Cluster' ) ],
457 clusterjoin
: [ '' , gettext ( 'Join Cluster' ) ],
458 diskinit
: [ 'Disk' , gettext ( 'Initialize Disk with GPT' ) ],
459 vncproxy
: [ 'VM/CT' , gettext ( 'Console' ) ],
460 spiceproxy
: [ 'VM/CT' , gettext ( 'Console' ) + ' (Spice)' ],
461 vncshell
: [ '' , gettext ( 'Shell' ) ],
462 spiceshell
: [ '' , gettext ( 'Shell' ) + ' (Spice)' ],
463 qmsnapshot
: [ 'VM' , gettext ( 'Snapshot' ) ],
464 qmrollback
: [ 'VM' , gettext ( 'Rollback' ) ],
465 qmdelsnapshot
: [ 'VM' , gettext ( 'Delete Snapshot' ) ],
466 qmcreate
: [ 'VM' , gettext ( 'Create' ) ],
467 qmrestore
: [ 'VM' , gettext ( 'Restore' ) ],
468 qmdestroy
: [ 'VM' , gettext ( 'Destroy' ) ],
469 qmigrate
: [ 'VM' , gettext ( 'Migrate' ) ],
470 qmclone
: [ 'VM' , gettext ( 'Clone' ) ],
471 qmmove
: [ 'VM' , gettext ( 'Move disk' ) ],
472 qmtemplate
: [ 'VM' , gettext ( 'Convert to template' ) ],
473 qmstart
: [ 'VM' , gettext ( 'Start' ) ],
474 qmstop
: [ 'VM' , gettext ( 'Stop' ) ],
475 qmreset
: [ 'VM' , gettext ( 'Reset' ) ],
476 qmshutdown
: [ 'VM' , gettext ( 'Shutdown' ) ],
477 qmsuspend
: [ 'VM' , gettext ( 'Hibernate' ) ],
478 qmpause
: [ 'VM' , gettext ( 'Pause' ) ],
479 qmresume
: [ 'VM' , gettext ( 'Resume' ) ],
480 qmconfig
: [ 'VM' , gettext ( 'Configure' ) ],
481 vzsnapshot
: [ 'CT' , gettext ( 'Snapshot' ) ],
482 vzrollback
: [ 'CT' , gettext ( 'Rollback' ) ],
483 vzdelsnapshot
: [ 'CT' , gettext ( 'Delete Snapshot' ) ],
484 vzcreate
: [ 'CT' , gettext ( 'Create' ) ],
485 vzrestore
: [ 'CT' , gettext ( 'Restore' ) ],
486 vzdestroy
: [ 'CT' , gettext ( 'Destroy' ) ],
487 vzmigrate
: [ 'CT' , gettext ( 'Migrate' ) ],
488 vzclone
: [ 'CT' , gettext ( 'Clone' ) ],
489 vztemplate
: [ 'CT' , gettext ( 'Convert to template' ) ],
490 vzstart
: [ 'CT' , gettext ( 'Start' ) ],
491 vzstop
: [ 'CT' , gettext ( 'Stop' ) ],
492 vzmount
: [ 'CT' , gettext ( 'Mount' ) ],
493 vzumount
: [ 'CT' , gettext ( 'Unmount' ) ],
494 vzshutdown
: [ 'CT' , gettext ( 'Shutdown' ) ],
495 vzsuspend
: [ 'CT' , gettext ( 'Suspend' ) ],
496 vzresume
: [ 'CT' , gettext ( 'Resume' ) ],
497 hamigrate
: [ 'HA' , gettext ( 'Migrate' ) ],
498 hastart
: [ 'HA' , gettext ( 'Start' ) ],
499 hastop
: [ 'HA' , gettext ( 'Stop' ) ],
500 srvstart
: [ 'SRV' , gettext ( 'Start' ) ],
501 srvstop
: [ 'SRV' , gettext ( 'Stop' ) ],
502 srvrestart
: [ 'SRV' , gettext ( 'Restart' ) ],
503 srvreload
: [ 'SRV' , gettext ( 'Reload' ) ],
504 cephcreatemgr
: [ 'Ceph Manager' , gettext ( 'Create' ) ],
505 cephdestroymgr
: [ 'Ceph Manager' , gettext ( 'Destroy' ) ],
506 cephcreatemon
: [ 'Ceph Monitor' , gettext ( 'Create' ) ],
507 cephdestroymon
: [ 'Ceph Monitor' , gettext ( 'Destroy' ) ],
508 cephcreateosd
: [ 'Ceph OSD' , gettext ( 'Create' ) ],
509 cephdestroyosd
: [ 'Ceph OSD' , gettext ( 'Destroy' ) ],
510 cephcreatepool
: [ 'Ceph Pool' , gettext ( 'Create' ) ],
511 cephdestroypool
: [ 'Ceph Pool' , gettext ( 'Destroy' ) ],
512 cephfscreate
: [ 'CephFS' , gettext ( 'Create' ) ],
513 cephcreatemds
: [ 'Ceph Metadata Server' , gettext ( 'Create' ) ],
514 cephdestroymds
: [ 'Ceph Metadata Server' , gettext ( 'Destroy' ) ],
515 imgcopy
: [ '' , gettext ( 'Copy data' ) ],
516 imgdel
: [ '' , gettext ( 'Erase data' ) ],
517 unknownimgdel
: [ '' , gettext ( 'Destroy image from unknown guest' ) ],
518 download
: [ '' , gettext ( 'Download' ) ],
519 vzdump
: [ 'VM/CT' , gettext ( 'Backup' ) ],
520 aptupdate
: [ '' , gettext ( 'Update package database' ) ],
521 startall
: [ '' , gettext ( 'Start all VMs and Containers' ) ],
522 stopall
: [ '' , gettext ( 'Stop all VMs and Containers' ) ],
523 migrateall
: [ '' , gettext ( 'Migrate all VMs and Containers' ) ],
524 dircreate
: [ gettext ( 'Directory Storage' ), gettext ( 'Create' ) ],
525 lvmcreate
: [ gettext ( 'LVM Storage' ), gettext ( 'Create' ) ],
526 lvmthincreate
: [ gettext ( 'LVM-Thin Storage' ), gettext ( 'Create' ) ],
527 zfscreate
: [ gettext ( 'ZFS Storage' ), gettext ( 'Create' ) ]
530 format_task_description : function ( type
, id
) {
531 var farray
= Proxmox
. Utils
. task_desc_table
[ type
];
540 var prefix
= farray
[ 0 ];
543 return prefix
+ ' ' + id
+ ' - ' + text
;
548 format_size : function ( size
) {
549 /*jslint confusion: true */
551 var units
= [ '' , 'Ki' , 'Mi' , 'Gi' , 'Ti' , 'Pi' , 'Ei' , 'Zi' , 'Yi' ];
554 while ( size
>= 1024 && (( num
++)+ 1 ) < units
. length
) {
558 return size
. toFixed (( num
> 0 )? 2 : 0 ) + " " + units
[ num
] + "B" ;
561 render_upid : function ( value
, metaData
, record
) {
562 var type
= record
. data
. type
;
563 var id
= record
. data
. id
;
565 return Proxmox
. Utils
. format_task_description ( type
, id
);
568 render_uptime : function ( value
) {
572 if ( uptime
=== undefined ) {
580 return Proxmox
. Utils
. format_duration_long ( uptime
);
583 parse_task_upid : function ( upid
) {
586 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]+):$/ );
588 throw "unable to parse upid '" + upid
+ "'" ;
591 task
. pid
= parseInt ( res
[ 2 ], 16 );
592 task
. pstart
= parseInt ( res
[ 3 ], 16 );
593 task
. starttime
= parseInt ( res
[ 4 ], 16 );
598 task
. desc
= Proxmox
. Utils
. format_task_description ( task
. type
, task
. id
);
603 render_timestamp : function ( value
, metaData
, record
, rowIndex
, colIndex
, store
) {
604 var servertime
= new Date ( value
* 1000 );
605 return Ext
. Date
. format ( servertime
, 'Y-m-d H:i:s' );
608 get_help_info : function ( section
) {
610 if ( typeof proxmoxOnlineHelpInfo
!== 'undefined' ) {
611 helpMap
= proxmoxOnlineHelpInfo
;
612 } else if ( typeof pveOnlineHelpInfo
!== 'undefined' ) {
613 // be backward compatible with older pve-doc-generators
614 helpMap
= pveOnlineHelpInfo
;
616 throw "no global OnlineHelpInfo map declared" ;
619 return helpMap
[ section
];
622 get_help_link : function ( section
) {
623 var info
= Proxmox
. Utils
. get_help_info ( section
);
628 return window
. location
. origin
+ info
. link
;
631 openXtermJsViewer : function ( vmtype
, vmid
, nodename
, vmname
, cmd
) {
632 var url
= Ext
. Object
. toQueryString ({
633 console
: vmtype
, // kvm, lxc, upgrade or shell
641 var nw
= window
. open ( "?" + url
, '_blank' , 'toolbar=no,location=no,status=no,menubar=no,resizable=yes,width=800,height=420' );
650 constructor : function () {
652 Ext
. apply ( me
, me
. utilities
);
654 var IPV4_OCTET
= "(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])" ;
655 var IPV4_REGEXP
= "(?:(?:" + IPV4_OCTET
+ " \\ .){3}" + IPV4_OCTET
+ ")" ;
656 var IPV6_H16
= "(?:[0-9a-fA-F]{1,4})" ;
657 var IPV6_LS32
= "(?:(?:" + IPV6_H16
+ ":" + IPV6_H16
+ ")|" + IPV4_REGEXP
+ ")" ;
658 var IPV4_CIDR_MASK
= "([0-9]{1,2})" ;
659 var IPV6_CIDR_MASK
= "([0-9]{1,3})" ;
662 me
. IP4_match
= new RegExp ( "^(?:" + IPV4_REGEXP
+ ")$" );
663 me
. IP4_cidr_match
= new RegExp ( "^(?:" + IPV4_REGEXP
+ ")\/" + IPV4_CIDR_MASK
+ "$" );
665 var IPV6_REGEXP
= "(?:" +
666 "(?:(?:" + "(?:" + IPV6_H16
+ ":){6})" + IPV6_LS32
+ ")|" +
667 "(?:(?:" + "::" + "(?:" + IPV6_H16
+ ":){5})" + IPV6_LS32
+ ")|" +
668 "(?:(?:(?:" + IPV6_H16
+ ")?::" + "(?:" + IPV6_H16
+ ":){4})" + IPV6_LS32
+ ")|" +
669 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,1}" + IPV6_H16
+ ")?::" + "(?:" + IPV6_H16
+ ":){3})" + IPV6_LS32
+ ")|" +
670 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,2}" + IPV6_H16
+ ")?::" + "(?:" + IPV6_H16
+ ":){2})" + IPV6_LS32
+ ")|" +
671 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,3}" + IPV6_H16
+ ")?::" + "(?:" + IPV6_H16
+ ":){1})" + IPV6_LS32
+ ")|" +
672 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,4}" + IPV6_H16
+ ")?::" + ")" + IPV6_LS32
+ ")|" +
673 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,5}" + IPV6_H16
+ ")?::" + ")" + IPV6_H16
+ ")|" +
674 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,7}" + IPV6_H16
+ ")?::" + ")" + ")" +
677 me
. IP6_match
= new RegExp ( "^(?:" + IPV6_REGEXP
+ ")$" );
678 me
. IP6_cidr_match
= new RegExp ( "^(?:" + IPV6_REGEXP
+ ")\/" + IPV6_CIDR_MASK
+ "$" );
679 me
. IP6_bracket_match
= new RegExp ( "^ \\ [(" + IPV6_REGEXP
+ ") \\ ]" );
681 me
. IP64_match
= new RegExp ( "^(?:" + IPV6_REGEXP
+ "|" + IPV4_REGEXP
+ ")$" );
682 me
. IP64_cidr_match
= new RegExp ( "^(?:" + IPV6_REGEXP
+ "\/" + IPV6_CIDR_MASK
+ ")|(?:" + IPV4_REGEXP
+ "\/" + IPV4_CIDR_MASK
+ ")$" );
684 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])?))" ;
685 me
. DnsName_match
= new RegExp ( "^" + DnsName_REGEXP
+ "$" );
687 me
. HostPort_match
= new RegExp ( "^(" + IPV4_REGEXP
+ "|" + DnsName_REGEXP
+ ")(: \\ d+)?$" );
688 me
. HostPortBrackets_match
= new RegExp ( "^ \\ [(?:" + IPV6_REGEXP
+ "|" + IPV4_REGEXP
+ "|" + DnsName_REGEXP
+ ") \\ ](: \\ d+)?$" );
689 me
. IP6_dotnotation_match
= new RegExp ( "^" + IPV6_REGEXP
+ "( \\ . \\ d+)?$" );