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

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 8, 2013, 1:16 p.m.
Message ID <d2e91a2d576deff3bb97.1375967816@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2095/
State Superseded
Headers show

Comments

Alexander Plavin - Aug. 8, 2013, 1:16 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1374677635 -14400
#      Wed Jul 24 18:53:55 2013 +0400
# Node ID d2e91a2d576deff3bb97fefc1fe71c2a64d64bb6
# Parent  f0f7f831444ba82f8547dabd4a47bb502232b4d2
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 f0f7f831444b -r d2e91a2d576d mercurial/templates/static/mercurial.js
--- a/mercurial/templates/static/mercurial.js	Wed Jul 24 03:20:26 2013 +0400
+++ b/mercurial/templates/static/mercurial.js	Wed Jul 24 18:53:55 2013 +0400
@@ -168,7 +168,7 @@ 
 }
 
 
-process_dates = (function(document, RegExp, Math, isNaN, Date, _false, _true){
+function process_dates(){
 
 	// derived from code from mercurial/templatefilter.py
 
@@ -219,9 +219,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";
@@ -245,26 +245,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;