Patchwork [1,of,4] hgweb: eliminate extra complexity in process_dates definition

login
register
mail settings
Submitter Alexander Plavin
Date Sept. 24, 2013, 7:39 p.m.
Message ID <c3e2dd350a17ce393b36.1380051554@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2627/
State Deferred
Commit 80633eac7b9d061d91bc0efc9fd789bc5d35946f
Headers show

Comments

Alexander Plavin - Sept. 24, 2013, 7:39 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1378459858 -14400
#      Fri Sep 06 13:30:58 2013 +0400
# Node ID c3e2dd350a17ce393b36fbfb546a2d7707f2b5d7
# Parent  8c01d533c6f20a0883c22a14b324c90cde9efdaf
hgweb: eliminate extra complexity in process_dates definition

There was an extra anonymous outer function, called immediately. It is removed
in this patch.

Patch

diff -r 8c01d533c6f2 -r c3e2dd350a17 mercurial/templates/static/mercurial.js
--- a/mercurial/templates/static/mercurial.js	Sun Sep 22 14:19:57 2013 +0400
+++ 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;
-				}
-			}
-		}
-	}
-})(document, RegExp, Math, isNaN, Date, false, true)
+    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;
+            }
+        }
+    }
+}
 
 function toggleDiffstat() {
     var curdetails = document.getElementById('diffstatdetails').style.display;