changeset 19834:80633eac7b9d

hgweb: eliminate extra complexity in process_dates definition There was an extra anonymous outer function, called immediately. It is removed in this patch.
author Alexander Plavin <alexander@plav.in>
date Fri, 06 Sep 2013 13:30:58 +0400
parents 1935e8383a9e
children 44d7bfe08c14
files mercurial/templates/static/mercurial.js
diffstat 1 files changed, 18 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templates/static/mercurial.js	Mon Sep 30 12:36:26 2013 -0700
+++ b/mercurial/templates/static/mercurial.js	Fri Sep 06 13:30:58 2013 +0400
@@ -176,7 +176,7 @@
 }
 
 
-process_dates = (function(document, RegExp, Math, isNaN, Date, _false, _true){
+function process_dates(){
 
 	// derived from code from mercurial/templatefilter.py
 
@@ -227,9 +227,9 @@
 
 		var delta = Math.floor((now.getTime() - once.getTime()) / 1000);
 
-		var future = _false;
+		var future = false;
 		if (delta < 0){
-			future = _true;
+			future = true;
 			delta = -delta;
 			if (delta > (30 * scales.year)){
 				return "in the distant future";
@@ -253,26 +253,24 @@
 		}
 	}
 
-	return function(){
-		var nodes = document.getElementsByTagName('*');
-		var ageclass = new RegExp('\\bage\\b');
-		var dateclass = new RegExp('\\bdate\\b');
-		for (var i=0; i<nodes.length; ++i){
-			var node = nodes[i];
-			var classes = node.className;
-			if (ageclass.test(classes)){
-				var agevalue = age(node.textContent);
-				if (dateclass.test(classes)){
-					// We want both: date + (age)
-					node.textContent += ' ('+agevalue+')';
-				} else {
-					node.title = node.textContent;
-					node.textContent = agevalue;
-				}
+	var nodes = document.getElementsByTagName('*');
+	var ageclass = new RegExp('\\bage\\b');
+	var dateclass = new RegExp('\\bdate\\b');
+	for (var i=0; i<nodes.length; ++i){
+		var node = nodes[i];
+		var classes = node.className;
+		if (ageclass.test(classes)){
+			var agevalue = age(node.textContent);
+			if (dateclass.test(classes)){
+				// We want both: date + (age)
+				node.textContent += ' ('+agevalue+')';
+			} else {
+				node.title = node.textContent;
+				node.textContent = agevalue;
 			}
 		}
 	}
-})(document, RegExp, Math, isNaN, Date, false, true)
+}
 
 function toggleDiffstat() {
     var curdetails = document.getElementById('diffstatdetails').style.display;