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

Emmanuel Kasper e.kasper at proxmox.com
Wed Oct 12 12:03:51 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.

The double curly brace at the end is due to a double opening curly
brace when doing the declaration with Ext.define
Not sure if reindenting a 1200 lines object makes sense, so I left
it as it was.
---
 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 4ec7d5b..4cc5113 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
 
@@ -1343,6 +1343,12 @@ Ext.define('PVE.Utils', { statics: {
 	}
 
 	return title;
+    }},
+
+    singleton: true,
+    constructor: function() {
+	var me = this;
+	Ext.apply(me, me.utilities);
     }
-}});
+});
 
-- 
2.1.4





More information about the pve-devel mailing list