[pve-devel] [PATCH manager v2 1/2] Turn PVE.Utils into a singleton

Emmanuel Kasper e.kasper at proxmox.com
Tue Oct 18 12:13:55 CEST 2016


This will allow us to add contructed values ( regexp a = stringA + stringB )
into the constructor.
Access to the PVE.Utils properties and methods stays the same.
---
 www/manager6/Utils.js | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 011308a..eb98084 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -63,9 +63,9 @@ var HostPort_match = new RegExp("^(" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")(:
 var HostPortBrackets_match = new RegExp("^\\[(?:" + IPV6_REGEXP + "|" + IPV4_REGEXP + "|" + DnsName_REGEXP + ")\\](:\\d+)?$");
 var IP6_dotnotation_match = new RegExp("^" + IPV6_REGEXP + "(\\.\\d+)?$");
 
-Ext.define('PVE.Utils', { statics: {
+Ext.define('PVE.Utils', { utilities: {
 
-    // this class only contains static functions
+    // this singleton contains miscellaneous utilities
 
     toolkit: undefined, // (extjs|touch), set inside Toolkit.js
 
@@ -1277,6 +1277,12 @@ Ext.define('PVE.Utils', { statics: {
 	}
 
 	menu.showAt(event.getXY());
+    }},
+
+    singleton: true,
+    constructor: function() {
+	var me = this;
+	Ext.apply(me, me.utilities);
     }
-}});
+});
 
-- 
2.1.4





More information about the pve-devel mailing list