-
- StorageId: function(v) {
- return (/^[a-z][a-z0-9\-\_\.]*[a-z0-9]$/i).test(v);
- },
- StorageIdText: gettext("Allowed characters") + ": 'A-Z', 'a-z', '0-9', '-', '_', '.'" + "<br />" +
- gettext("Minimum characters") + ": 2" + "<br />" +
- gettext("Must start with") + ": 'A-Z', 'a-z'<br />" +
- gettext("Must end with") + ": 'A-Z', 'a-z', '0-9'<br />",
-
- ConfigId: function(v) {
- return (/^[a-z][a-z0-9\_]+$/i).test(v);
- },
- ConfigIdText: gettext("Allowed characters") + ": 'A-Z', 'a-z', '0-9', '_'" + "<br />" +
- gettext("Minimum characters") + ": 2" + "<br />" +
- gettext("Must start with") + ": " + gettext("letter"),
-
- HttpProxy: function(v) {
- return (/^http:\/\/.*$/).test(v);
- },
- HttpProxyText: gettext('Example') + ": http://username:password@host:port/",
-
- DnsName: function(v) {
- return PVE.Utils.DnsName_match.test(v);
- },
- DnsNameText: gettext('This is not a valid DNS name'),
-
- // workaround for https://www.sencha.com/forum/showthread.php?302150
- pveMail: function(v) {
- return (/^(\w+)([\-+.][\w]+)*@(\w[\-\w]*\.){1,5}([A-Za-z]){2,63}$/).test(v);
- },
- pveMailText: gettext('Example') + ": user@example.com",
-
- HostList: function(v) {
- var list = v.split(/[\ \,\;]+/);
- var i;
- for (i = 0; i < list.length; i++) {
- if (list[i] == "") {
- continue;
- }
-
- if (!PVE.Utils.HostPort_match.test(list[i]) &&
- !PVE.Utils.HostPortBrackets_match.test(list[i]) &&
- !PVE.Utils.IP6_dotnotation_match.test(list[i])) {
- return false;
- }
- }
-
- return true;
- },
- HostListText: gettext('Not a valid list of hosts')
-});
-
-// since we always want the number in
-// x.y format and never in e.g. x,y
-Ext.define('PVE.form.field.Number', {
- override: 'Ext.form.field.Number',
- submitLocaleSeparator: false
-});
-
-// ExtJs 5-6 has an issue with caching
-// see https://www.sencha.com/forum/showthread.php?308989
-Ext.define('PVE.UnderlayPool', {
- override: 'Ext.dom.UnderlayPool',
-
- checkOut: function () {
- var cache = this.cache,
- len = cache.length,
- el;
-
- // do cleanup because some of the objects might have been destroyed
- while (len--) {
- if (cache[len].destroyed) {
- cache.splice(len, 1);
- }
- }
- // end do cleanup
-
- el = cache.shift();
-
- if (!el) {
- el = Ext.Element.create(this.elementConfig);
- el.setVisibilityMode(2);
- //<debug>
- // tell the spec runner to ignore this element when checking if the dom is clean
- el.dom.setAttribute('data-sticky', true);
- //</debug>
- }
-
- return el;
- }
-});
-
-// if the order of the values are not the same in originalValue and value
-// extjs will not overwrite value, but marks the field dirty and thus
-// the reset button will be enabled (but clicking it changes nothing)
-// so if the arrays are not the same after resetting, we
-// clear and set it
-Ext.define('PVE.form.ComboBox', {
- override: 'Ext.form.field.ComboBox',
-
- reset: function() {
- // copied from combobox
- var me = this;
- me.callParent();
-
- // clear and set when not the same
- var value = me.getValue();
- if (Ext.isArray(me.originalValue) && Ext.isArray(value) && !Ext.Array.equals(value, me.originalValue)) {
- me.clearValue();
- me.setValue(me.originalValue);
- }
- }
-});
-
-// should be fixed with ExtJS 6.0.2, see:
-// https://www.sencha.com/forum/showthread.php?307244-Bug-with-datefield-in-window-with-scroll
-Ext.define('PVE.Datepicker', {
- override: 'Ext.picker.Date',
- hideMode: 'visibility'