espiceland: branch 2.0 r5198 - in /branches/2.0/config: index.html js/astman.js

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Thu May 5 09:44:46 CDT 2011


Author: espiceland
Date: Thu May  5 09:44:43 2011
New Revision: 5198

URL: http://svnview.digium.com/svn/asterisk-gui?view=rev&rev=5198
Log:
Cache version calculations.  They are causing the same code to be executed many
times, and this slows down the responsiveness of the GUI.

Modified:
    branches/2.0/config/index.html
    branches/2.0/config/js/astman.js

Modified: branches/2.0/config/index.html
URL: http://svnview.digium.com/svn/asterisk-gui/branches/2.0/config/index.html?view=diff&rev=5198&r1=5197&r2=5198
==============================================================================
--- branches/2.0/config/index.html (original)
+++ branches/2.0/config/index.html Thu May  5 09:44:43 2011
@@ -282,6 +282,9 @@
 		},
 
 		AsteriskVersionString : '',
+		AsteriskVersion: '',
+		AsteriskBranch: '',
+		VersionCache: {},
 		httpConf: { // store any information from http.conf in this object
 			prefix: '',
 			postmappings_defined : false,

Modified: branches/2.0/config/js/astman.js
URL: http://svnview.digium.com/svn/asterisk-gui/branches/2.0/config/js/astman.js?view=diff&rev=5198&r1=5197&r2=5198
==============================================================================
--- branches/2.0/config/js/astman.js (original)
+++ branches/2.0/config/js/astman.js Thu May  5 09:44:43 2011
@@ -1362,30 +1362,41 @@
 		greater_than_equal_to: function (other) {
 			if (!top.sessionData.AsteriskVersion) { return false; }
 			if (top.sessionData.AsteriskBranch == 'trunk') { return true; }
+			if (top.sessionData.VersionCache[other] != undefined
+					&& (top.sessionData.VersionCache[other] == true
+					|| top.sessionData.VersionCache[other] == false
+					|| top.sessionData.VersionCache[other] == "equal")) {
+				return top.sessionData.VersionCache[other];
+			}
 			var thisversion = top.sessionData.AsteriskVersion || top.sessionData.AsteriskBranch;
 			var thispieces = thisversion.split('.');
 			var otherpieces = other.split('.');
 			for (var i = 0; i < ((thispieces.length < otherpieces.length) ? thispieces.length : otherpieces.length); i++) {
 				if (thispieces[i] > otherpieces[i]) {
+					top.sessionData.VersionCache[other] = true;
 					return true;
 				} else if (thispieces[i] < otherpieces[i]) {
+					top.sessionData.VersionCache[other] = false;
 					return false;
 				}
 			}
 			while (thispieces[i] || otherpieces[i] || i < 10) {
-					if (thispieces[i] == undefined) {
-						if (otherpieces[i] == undefined) {
-							return "equal";
-						} else {
-							return false;
-						}
+					if (thispieces[i] == otherpieces[i]) {
+						top.sessionData.VersionCache[other] = "equal";
+						return "equal";
+					} else if (thispieces[i] == undefined) {
+						top.sessionData.VersionCache[other] = false;
+						return false;
 					} else if (otherpieces[i] == undefined) {
+						top.sessionData.VersionCache[other] = true;
 						return true;
 					} else if (thispieces[i] > otherpieces[i]) {
+						top.sessionData.VersionCache[other] = true;
 						return true;
 					}
 				i++;
 			}
+			top.sessionData.VersionCache[other] = "equal";
 			return "equal";
 		}
 	},




More information about the asterisk-gui-commits mailing list