]>
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 NoneText
: gettext ( 'None' ),
46 errorText
: gettext ( 'Error' ),
47 unknownText
: gettext ( 'Unknown' ),
48 defaultText
: gettext ( 'Default' ),
49 daysText
: gettext ( 'days' ),
50 dayText
: gettext ( 'day' ),
51 runningText
: gettext ( 'running' ),
52 stoppedText
: gettext ( 'stopped' ),
53 neverText
: gettext ( 'never' ),
54 totalText
: gettext ( 'Total' ),
55 usedText
: gettext ( 'Used' ),
56 directoryText
: gettext ( 'Directory' ),
57 stateText
: gettext ( 'State' ),
58 groupText
: gettext ( 'Group' ),
67 eu
: 'Euskera (Basque)' ,
68 fa
: 'Persian (Farsi)' ,
73 nb
: 'Norwegian (Bokmal)' ,
74 nn
: 'Norwegian (Nynorsk)' ,
76 pt_BR
: 'Portuguese (Brazil)' ,
81 zh_CN
: 'Chinese (Simplified)' ,
82 zh_TW
: 'Chinese (Traditional)' ,
85 render_language : function ( value
) {
87 return Proxmox
. Utils
. defaultText
+ ' (English)' ;
89 var text
= Proxmox
. Utils
. language_map
[ value
];
91 return text
+ ' (' + value
+ ')' ;
96 language_array : function () {
97 var data
= [[ '__default__' , Proxmox
. Utils
. render_language ( '' )]];
98 Ext
. Object
. each ( Proxmox
. Utils
. language_map
, function ( key
, value
) {
99 data
. push ([ key
, Proxmox
. Utils
. render_language ( value
)]);
105 bond_mode_gettext_map
: {
106 '802.3ad' : 'LACP (802.3ad)' ,
107 'lacp-balance-slb' : 'LACP (balance-slb)' ,
108 'lacp-balance-tcp' : 'LACP (balance-tcp)' ,
111 render_bond_mode
: value
=> Proxmox
. Utils
. bond_mode_gettext_map
[ value
] || value
|| '' ,
113 bond_mode_array : function ( modes
) {
114 return modes
. map ( mode
=> [ mode
, Proxmox
. Utils
. render_bond_mode ( mode
)]);
117 getNoSubKeyHtml : function ( url
) {
118 // url http://www.proxmox.com/products/proxmox-ve/subscription-service-plans
119 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' );
122 format_boolean_with_default : function ( value
) {
123 if ( Ext
. isDefined ( value
) && value
!== '__default__' ) {
124 return value
? Proxmox
. Utils
. yesText
: Proxmox
. Utils
. noText
;
126 return Proxmox
. Utils
. defaultText
;
129 format_boolean : function ( value
) {
130 return value
? Proxmox
. Utils
. yesText
: Proxmox
. Utils
. noText
;
133 format_neg_boolean : function ( value
) {
134 return ! value
? Proxmox
. Utils
. yesText
: Proxmox
. Utils
. noText
;
137 format_enabled_toggle : function ( value
) {
138 return value
? Proxmox
. Utils
. enabledText
: Proxmox
. Utils
. disabledText
;
141 format_expire : function ( date
) {
143 return Proxmox
. Utils
. neverText
;
145 return Ext
. Date
. format ( date
, "Y-m-d" );
148 format_duration_long : function ( ut
) {
150 var days
= Math
. floor ( ut
/ 86400 );
152 var hours
= Math
. floor ( ut
/ 3600 );
154 var mins
= Math
. floor ( ut
/ 60 );
157 var hours_str
= '00' + hours
. toString ();
158 hours_str
= hours_str
. substr ( hours_str
. length
- 2 );
159 var mins_str
= "00" + mins
. toString ();
160 mins_str
= mins_str
. substr ( mins_str
. length
- 2 );
161 var ut_str
= "00" + ut
. toString ();
162 ut_str
= ut_str
. substr ( ut_str
. length
- 2 );
165 var ds
= days
> 1 ? Proxmox
. Utils
. daysText
: Proxmox
. Utils
. dayText
;
166 return days
. toString () + ' ' + ds
+ ' ' +
167 hours_str
+ ':' + mins_str
+ ':' + ut_str
;
169 return hours_str
+ ':' + mins_str
+ ':' + ut_str
;
173 format_subscription_level : function ( level
) {
176 } else if ( level
=== 'b' ) {
178 } else if ( level
=== 's' ) {
180 } else if ( level
=== 'p' ) {
183 return Proxmox
. Utils
. noneText
;
187 compute_min_label_width : function ( text
, width
) {
189 if ( width
=== undefined ) { width
= 100 ; }
191 var tm
= new Ext
. util
. TextMetrics ();
192 var min
= tm
. getWidth ( text
+ ':' );
194 return min
< width
? width
: min
;
197 setAuthData : function ( data
) {
198 Proxmox
. CSRFPreventionToken
= data
. CSRFPreventionToken
;
199 Proxmox
. UserName
= data
. username
;
200 Proxmox
. LoggedOut
= data
. LoggedOut
;
201 // creates a session cookie (expire = null)
202 // that way the cookie gets deleted after the browser window is closed
203 Ext
. util
. Cookies
. set ( Proxmox
. Setup
. auth_cookie_name
, data
. ticket
, null , '/' , null , true );
207 if ( Proxmox
. LoggedOut
) {
210 return ( Proxmox
. UserName
!== '' ) && Ext
. util
. Cookies
. get ( Proxmox
. Setup
. auth_cookie_name
);
213 authClear : function () {
214 if ( Proxmox
. LoggedOut
) {
217 Ext
. util
. Cookies
. clear ( Proxmox
. Setup
. auth_cookie_name
);
220 // comp.setLoading() is buggy in ExtJS 4.0.7, so we
221 // use el.mask() instead
222 setErrorMask : function ( comp
, msg
) {
231 el
. mask ( gettext ( "Loading..." ));
238 getResponseErrorMessage
: ( err
) => {
239 if (! err
. statusText
) {
240 return gettext ( 'Connection error' );
242 let msg
= ` ${err.statusText} ( ${err.status} )` ;
243 if ( err
. response
&& err
. response
. responseText
) {
244 let txt
= err
. response
. responseText
;
246 let res
= JSON
. parse ( txt
)
247 for ( let [ key
, value
] of Object
. entries ( res
. errors
)) {
248 msg
+= `<br> ${key} : ${value} ` ;
250 } catch ( e
) { /* TODO? */ }
255 monStoreErrors : function ( me
, store
, clearMaskBeforeLoad
) {
256 if ( clearMaskBeforeLoad
) {
257 me
. mon ( store
, 'beforeload' , function ( s
, operation
, eOpts
) {
258 Proxmox
. Utils
. setErrorMask ( me
, false );
261 me
. mon ( store
, 'beforeload' , function ( s
, operation
, eOpts
) {
263 me
. loadCount
= 0 ; // make sure it is numeric
264 Proxmox
. Utils
. setErrorMask ( me
, true );
269 // only works with 'proxmox' proxy
270 me
. mon ( store
. proxy
, 'afterload' , function ( proxy
, request
, success
) {
274 Proxmox
. Utils
. setErrorMask ( me
, false );
278 let error
= request
. _operation
. getError ();
279 let msg
= Proxmox
. Utils
. getResponseErrorMessage ( error
);
280 Proxmox
. Utils
. setErrorMask ( me
, msg
);
284 extractRequestError : function ( result
, verbose
) {
285 var msg
= gettext ( 'Successful' );
287 if (! result
. success
) {
288 msg
= gettext ( "Unknown error" );
289 if ( result
. message
) {
290 msg
= result
. message
;
292 msg
+= ' (' + result
. status
+ ')' ;
295 if ( verbose
&& Ext
. isObject ( result
. errors
)) {
297 Ext
. Object
. each ( result
. errors
, function ( prop
, desc
) {
298 msg
+= "<br><b>" + Ext
. htmlEncode ( prop
) + "</b>: " +
299 Ext
. htmlEncode ( desc
);
308 API2Request : function ( reqOpts
) {
310 var newopts
= Ext
. apply ({
311 waitMsg
: gettext ( 'Please wait...' )
314 if (! newopts
. url
. match ( /^\/api2/ )) {
315 newopts
. url
= '/api2/extjs' + newopts
. url
;
317 delete newopts
. callback
;
319 var createWrapper = function ( successFn
, callbackFn
, failureFn
) {
321 success : function ( response
, options
) {
322 if ( options
. waitMsgTarget
) {
323 if ( Proxmox
. Utils
. toolkit
=== 'touch' ) {
324 options
. waitMsgTarget
. setMasked ( false );
326 options
. waitMsgTarget
. setLoading ( false );
329 var result
= Ext
. decode ( response
. responseText
);
330 response
. result
= result
;
331 if (! result
. success
) {
332 response
. htmlStatus
= Proxmox
. Utils
. extractRequestError ( result
, true );
333 Ext
. callback ( callbackFn
, options
. scope
, [ options
, false , response
]);
334 Ext
. callback ( failureFn
, options
. scope
, [ response
, options
]);
337 Ext
. callback ( callbackFn
, options
. scope
, [ options
, true , response
]);
338 Ext
. callback ( successFn
, options
. scope
, [ response
, options
]);
340 failure : function ( response
, options
) {
341 if ( options
. waitMsgTarget
) {
342 if ( Proxmox
. Utils
. toolkit
=== 'touch' ) {
343 options
. waitMsgTarget
. setMasked ( false );
345 options
. waitMsgTarget
. setLoading ( false );
348 response
. result
= {};
350 response
. result
= Ext
. decode ( response
. responseText
);
352 var msg
= gettext ( 'Connection error' ) + ' - server offline?' ;
353 if ( response
. aborted
) {
354 msg
= gettext ( 'Connection error' ) + ' - aborted.' ;
355 } else if ( response
. timedout
) {
356 msg
= gettext ( 'Connection error' ) + ' - Timeout.' ;
357 } else if ( response
. status
&& response
. statusText
) {
358 msg
= gettext ( 'Connection error' ) + ' ' + response
. status
+ ': ' + response
. statusText
;
360 response
. htmlStatus
= msg
;
361 Ext
. callback ( callbackFn
, options
. scope
, [ options
, false , response
]);
362 Ext
. callback ( failureFn
, options
. scope
, [ response
, options
]);
367 createWrapper ( reqOpts
. success
, reqOpts
. callback
, reqOpts
. failure
);
369 var target
= newopts
. waitMsgTarget
;
371 if ( Proxmox
. Utils
. toolkit
=== 'touch' ) {
372 target
. setMasked ({ xtype
: 'loadmask' , message
: newopts
. waitMsg
} );
374 // Note: ExtJS bug - this does not work when component is not rendered
375 target
. setLoading ( newopts
. waitMsg
);
378 Ext
. Ajax
. request ( newopts
);
381 checked_command : function ( orig_cmd
) {
382 Proxmox
. Utils
. API2Request ({
383 url
: '/nodes/localhost/subscription' ,
386 failure : function ( response
, opts
) {
387 Ext
. Msg
. alert ( gettext ( 'Error' ), response
. htmlStatus
);
389 success : function ( response
, opts
) {
390 var data
= response
. result
. data
;
392 if ( data
. status
!== 'Active' ) {
394 title
: gettext ( 'No valid subscription' ),
395 icon
: Ext
. Msg
. WARNING
,
396 message
: Proxmox
. Utils
. getNoSubKeyHtml ( data
. url
),
398 callback : function ( btn
) {
412 assemble_field_data : function ( values
, data
) {
413 if ( Ext
. isObject ( data
)) {
414 Ext
. Object
. each ( data
, function ( name
, val
) {
415 if ( values
. hasOwnProperty ( name
)) {
416 var bucket
= values
[ name
];
417 if (! Ext
. isArray ( bucket
)) {
418 bucket
= values
[ name
] = [ bucket
];
420 if ( Ext
. isArray ( val
)) {
421 values
[ name
] = bucket
. concat ( val
);
432 dialog_title : function ( subject
, create
, isAdd
) {
435 return gettext ( 'Add' ) + ': ' + subject
;
437 return gettext ( 'Create' ) + ': ' + subject
;
440 return gettext ( 'Edit' ) + ': ' + subject
;
444 network_iface_types
: {
445 eth
: gettext ( "Network Device" ),
446 bridge
: 'Linux Bridge' ,
449 OVSBridge
: 'OVS Bridge' ,
452 OVSIntPort
: 'OVS IntPort'
455 render_network_iface_type : function ( value
) {
456 return Proxmox
. Utils
. network_iface_types
[ value
] ||
457 Proxmox
. Utils
. unknownText
;
461 acmenewcert
: [ 'SRV' , gettext ( 'Order Certificate' ) ],
462 acmeregister
: [ 'ACME Account' , gettext ( 'Register' ) ],
463 acmedeactivate
: [ 'ACME Account' , gettext ( 'Deactivate' ) ],
464 acmeupdate
: [ 'ACME Account' , gettext ( 'Update' ) ],
465 acmerefresh
: [ 'ACME Account' , gettext ( 'Refresh' ) ],
466 acmerenew
: [ 'SRV' , gettext ( 'Renew Certificate' ) ],
467 acmerevoke
: [ 'SRV' , gettext ( 'Revoke Certificate' ) ],
468 'auth-realm-sync' : [ gettext ( 'Realm' ), gettext ( 'Sync' ) ],
469 'auth-realm-sync-test' : [ gettext ( 'Realm' ), gettext ( 'Sync Preview' )],
470 'move_volume' : [ 'CT' , gettext ( 'Move Volume' ) ],
471 clustercreate
: [ '' , gettext ( 'Create Cluster' ) ],
472 clusterjoin
: [ '' , gettext ( 'Join Cluster' ) ],
473 diskinit
: [ 'Disk' , gettext ( 'Initialize Disk with GPT' ) ],
474 vncproxy
: [ 'VM/CT' , gettext ( 'Console' ) ],
475 spiceproxy
: [ 'VM/CT' , gettext ( 'Console' ) + ' (Spice)' ],
476 vncshell
: [ '' , gettext ( 'Shell' ) ],
477 spiceshell
: [ '' , gettext ( 'Shell' ) + ' (Spice)' ],
478 qmsnapshot
: [ 'VM' , gettext ( 'Snapshot' ) ],
479 qmrollback
: [ 'VM' , gettext ( 'Rollback' ) ],
480 qmdelsnapshot
: [ 'VM' , gettext ( 'Delete Snapshot' ) ],
481 qmcreate
: [ 'VM' , gettext ( 'Create' ) ],
482 qmrestore
: [ 'VM' , gettext ( 'Restore' ) ],
483 qmdestroy
: [ 'VM' , gettext ( 'Destroy' ) ],
484 qmigrate
: [ 'VM' , gettext ( 'Migrate' ) ],
485 qmclone
: [ 'VM' , gettext ( 'Clone' ) ],
486 qmmove
: [ 'VM' , gettext ( 'Move disk' ) ],
487 qmtemplate
: [ 'VM' , gettext ( 'Convert to template' ) ],
488 qmstart
: [ 'VM' , gettext ( 'Start' ) ],
489 qmstop
: [ 'VM' , gettext ( 'Stop' ) ],
490 qmreset
: [ 'VM' , gettext ( 'Reset' ) ],
491 qmshutdown
: [ 'VM' , gettext ( 'Shutdown' ) ],
492 qmreboot
: [ 'VM' , gettext ( 'Reboot' ) ],
493 qmsuspend
: [ 'VM' , gettext ( 'Hibernate' ) ],
494 qmpause
: [ 'VM' , gettext ( 'Pause' ) ],
495 qmresume
: [ 'VM' , gettext ( 'Resume' ) ],
496 qmconfig
: [ 'VM' , gettext ( 'Configure' ) ],
497 vzsnapshot
: [ 'CT' , gettext ( 'Snapshot' ) ],
498 vzrollback
: [ 'CT' , gettext ( 'Rollback' ) ],
499 vzdelsnapshot
: [ 'CT' , gettext ( 'Delete Snapshot' ) ],
500 vzcreate
: [ 'CT' , gettext ( 'Create' ) ],
501 vzrestore
: [ 'CT' , gettext ( 'Restore' ) ],
502 vzdestroy
: [ 'CT' , gettext ( 'Destroy' ) ],
503 vzmigrate
: [ 'CT' , gettext ( 'Migrate' ) ],
504 vzclone
: [ 'CT' , gettext ( 'Clone' ) ],
505 vztemplate
: [ 'CT' , gettext ( 'Convert to template' ) ],
506 vzstart
: [ 'CT' , gettext ( 'Start' ) ],
507 vzstop
: [ 'CT' , gettext ( 'Stop' ) ],
508 vzmount
: [ 'CT' , gettext ( 'Mount' ) ],
509 vzumount
: [ 'CT' , gettext ( 'Unmount' ) ],
510 vzshutdown
: [ 'CT' , gettext ( 'Shutdown' ) ],
511 vzreboot
: [ 'CT' , gettext ( 'Reboot' ) ],
512 vzsuspend
: [ 'CT' , gettext ( 'Suspend' ) ],
513 vzresume
: [ 'CT' , gettext ( 'Resume' ) ],
514 push_file
: [ 'CT' , gettext ( 'Push file' )],
515 pull_file
: [ 'CT' , gettext ( 'Pull file' )],
516 hamigrate
: [ 'HA' , gettext ( 'Migrate' ) ],
517 hastart
: [ 'HA' , gettext ( 'Start' ) ],
518 hastop
: [ 'HA' , gettext ( 'Stop' ) ],
519 hashutdown
: [ 'HA' , gettext ( 'Shutdown' ) ],
520 srvstart
: [ 'SRV' , gettext ( 'Start' ) ],
521 srvstop
: [ 'SRV' , gettext ( 'Stop' ) ],
522 srvrestart
: [ 'SRV' , gettext ( 'Restart' ) ],
523 srvreload
: [ 'SRV' , gettext ( 'Reload' ) ],
524 cephcreatemgr
: [ 'Ceph Manager' , gettext ( 'Create' ) ],
525 cephdestroymgr
: [ 'Ceph Manager' , gettext ( 'Destroy' ) ],
526 cephcreatemon
: [ 'Ceph Monitor' , gettext ( 'Create' ) ],
527 cephdestroymon
: [ 'Ceph Monitor' , gettext ( 'Destroy' ) ],
528 cephcreateosd
: [ 'Ceph OSD' , gettext ( 'Create' ) ],
529 cephdestroyosd
: [ 'Ceph OSD' , gettext ( 'Destroy' ) ],
530 cephcreatepool
: [ 'Ceph Pool' , gettext ( 'Create' ) ],
531 cephdestroypool
: [ 'Ceph Pool' , gettext ( 'Destroy' ) ],
532 cephfscreate
: [ 'CephFS' , gettext ( 'Create' ) ],
533 cephcreatemds
: [ 'Ceph Metadata Server' , gettext ( 'Create' ) ],
534 cephdestroymds
: [ 'Ceph Metadata Server' , gettext ( 'Destroy' ) ],
535 imgcopy
: [ '' , gettext ( 'Copy data' ) ],
536 imgdel
: [ '' , gettext ( 'Erase data' ) ],
537 unknownimgdel
: [ '' , gettext ( 'Destroy image from unknown guest' ) ],
538 download
: [ '' , gettext ( 'Download' ) ],
539 vzdump
: [ 'VM/CT' , gettext ( 'Backup' ) ],
540 aptupdate
: [ '' , gettext ( 'Update package database' ) ],
541 startall
: [ '' , gettext ( 'Start all VMs and Containers' ) ],
542 stopall
: [ '' , gettext ( 'Stop all VMs and Containers' ) ],
543 migrateall
: [ '' , gettext ( 'Migrate all VMs and Containers' ) ],
544 dircreate
: [ gettext ( 'Directory Storage' ), gettext ( 'Create' ) ],
545 lvmcreate
: [ gettext ( 'LVM Storage' ), gettext ( 'Create' ) ],
546 lvmthincreate
: [ gettext ( 'LVM-Thin Storage' ), gettext ( 'Create' ) ],
547 zfscreate
: [ gettext ( 'ZFS Storage' ), gettext ( 'Create' ) ]
550 format_task_description : function ( type
, id
) {
551 var farray
= Proxmox
. Utils
. task_desc_table
[ type
];
560 var prefix
= farray
[ 0 ];
563 return prefix
+ ' ' + id
+ ' - ' + text
;
568 format_size : function ( size
) {
569 /*jslint confusion: true */
571 var units
= [ '' , 'Ki' , 'Mi' , 'Gi' , 'Ti' , 'Pi' , 'Ei' , 'Zi' , 'Yi' ];
574 while ( size
>= 1024 && (( num
++)+ 1 ) < units
. length
) {
578 return size
. toFixed (( num
> 0 )? 2 : 0 ) + " " + units
[ num
] + "B" ;
581 render_upid : function ( value
, metaData
, record
) {
582 var type
= record
. data
. type
;
583 var id
= record
. data
. id
;
585 return Proxmox
. Utils
. format_task_description ( type
, id
);
588 render_uptime : function ( value
) {
592 if ( uptime
=== undefined ) {
600 return Proxmox
. Utils
. format_duration_long ( uptime
);
603 parse_task_upid : function ( upid
) {
606 var res
= upid
. match ( /^UPID:([^\s:]+):([0-9A-Fa-f]{8}):([0-9A-Fa-f]{8,9}):(([0-9A-Fa-f]{8,16}):)?([0-9A-Fa-f]{8}):([^:\s]+):([^:\s]*):([^:\s]+):$/ );
608 throw "unable to parse upid '" + upid
+ "'" ;
611 task
. pid
= parseInt ( res
[ 2 ], 16 );
612 task
. pstart
= parseInt ( res
[ 3 ], 16 );
613 if ( res
[ 5 ] !== undefined ) {
614 task
. task_id
= parseInt ( res
[ 5 ], 16 );
616 task
. starttime
= parseInt ( res
[ 6 ], 16 );
621 task
. desc
= Proxmox
. Utils
. format_task_description ( task
. type
, task
. id
);
626 render_timestamp : function ( value
, metaData
, record
, rowIndex
, colIndex
, store
) {
627 var servertime
= new Date ( value
* 1000 );
628 return Ext
. Date
. format ( servertime
, 'Y-m-d H:i:s' );
631 get_help_info : function ( section
) {
633 if ( typeof proxmoxOnlineHelpInfo
!== 'undefined' ) {
634 helpMap
= proxmoxOnlineHelpInfo
;
635 } else if ( typeof pveOnlineHelpInfo
!== 'undefined' ) {
636 // be backward compatible with older pve-doc-generators
637 helpMap
= pveOnlineHelpInfo
;
639 throw "no global OnlineHelpInfo map declared" ;
642 return helpMap
[ section
];
645 get_help_link : function ( section
) {
646 var info
= Proxmox
. Utils
. get_help_info ( section
);
651 return window
. location
. origin
+ info
. link
;
654 openXtermJsViewer : function ( vmtype
, vmid
, nodename
, vmname
, cmd
) {
655 var url
= Ext
. Object
. toQueryString ({
656 console
: vmtype
, // kvm, lxc, upgrade or shell
664 var nw
= window
. open ( "?" + url
, '_blank' , 'toolbar=no,location=no,status=no,menubar=no,resizable=yes,width=800,height=420' );
673 constructor : function () {
675 Ext
. apply ( me
, me
. utilities
);
677 var IPV4_OCTET
= "(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])" ;
678 var IPV4_REGEXP
= "(?:(?:" + IPV4_OCTET
+ " \\ .){3}" + IPV4_OCTET
+ ")" ;
679 var IPV6_H16
= "(?:[0-9a-fA-F]{1,4})" ;
680 var IPV6_LS32
= "(?:(?:" + IPV6_H16
+ ":" + IPV6_H16
+ ")|" + IPV4_REGEXP
+ ")" ;
681 var IPV4_CIDR_MASK
= "([0-9]{1,2})" ;
682 var IPV6_CIDR_MASK
= "([0-9]{1,3})" ;
685 me
. IP4_match
= new RegExp ( "^(?:" + IPV4_REGEXP
+ ")$" );
686 me
. IP4_cidr_match
= new RegExp ( "^(?:" + IPV4_REGEXP
+ ")\/" + IPV4_CIDR_MASK
+ "$" );
688 var IPV6_REGEXP
= "(?:" +
689 "(?:(?:" + "(?:" + IPV6_H16
+ ":){6})" + IPV6_LS32
+ ")|" +
690 "(?:(?:" + "::" + "(?:" + IPV6_H16
+ ":){5})" + IPV6_LS32
+ ")|" +
691 "(?:(?:(?:" + IPV6_H16
+ ")?::" + "(?:" + IPV6_H16
+ ":){4})" + IPV6_LS32
+ ")|" +
692 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,1}" + IPV6_H16
+ ")?::" + "(?:" + IPV6_H16
+ ":){3})" + IPV6_LS32
+ ")|" +
693 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,2}" + IPV6_H16
+ ")?::" + "(?:" + IPV6_H16
+ ":){2})" + IPV6_LS32
+ ")|" +
694 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,3}" + IPV6_H16
+ ")?::" + "(?:" + IPV6_H16
+ ":){1})" + IPV6_LS32
+ ")|" +
695 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,4}" + IPV6_H16
+ ")?::" + ")" + IPV6_LS32
+ ")|" +
696 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,5}" + IPV6_H16
+ ")?::" + ")" + IPV6_H16
+ ")|" +
697 "(?:(?:(?:(?:" + IPV6_H16
+ ":){0,7}" + IPV6_H16
+ ")?::" + ")" + ")" +
700 me
. IP6_match
= new RegExp ( "^(?:" + IPV6_REGEXP
+ ")$" );
701 me
. IP6_cidr_match
= new RegExp ( "^(?:" + IPV6_REGEXP
+ ")\/" + IPV6_CIDR_MASK
+ "$" );
702 me
. IP6_bracket_match
= new RegExp ( "^ \\ [(" + IPV6_REGEXP
+ ") \\ ]" );
704 me
. IP64_match
= new RegExp ( "^(?:" + IPV6_REGEXP
+ "|" + IPV4_REGEXP
+ ")$" );
705 me
. IP64_cidr_match
= new RegExp ( "^(?:" + IPV6_REGEXP
+ "\/" + IPV6_CIDR_MASK
+ ")|(?:" + IPV4_REGEXP
+ "\/" + IPV4_CIDR_MASK
+ ")$" );
707 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])?))" ;
708 me
. DnsName_match
= new RegExp ( "^" + DnsName_REGEXP
+ "$" );
710 me
. HostPort_match
= new RegExp ( "^(" + IPV4_REGEXP
+ "|" + DnsName_REGEXP
+ ")(: \\ d+)?$" );
711 me
. HostPortBrackets_match
= new RegExp ( "^ \\ [(?:" + IPV6_REGEXP
+ "|" + IPV4_REGEXP
+ "|" + DnsName_REGEXP
+ ") \\ ](: \\ d+)?$" );
712 me
. IP6_dotnotation_match
= new RegExp ( "^" + IPV6_REGEXP
+ "( \\ . \\ d+)?$" );
713 me
. Vlan_match
= new RegExp ( '^vlan( \\ d+)' );
714 me
. VlanInterface_match
= new RegExp ( '( \\ w+) \\ .( \\ d+)' );