[PATCH] hgweb: showDiffstat javascript function accepts flag argument

Alexander Plavin me at aplavin.ru
Fri Jul 12 07:07:27 CDT 2013


# HG changeset patch
# User Alexander Plavin <me at aplavin.ru>
# Date 1373630471 -14400
#      Fri Jul 12 16:01:11 2013 +0400
# Node ID 6187d6255fd2a14d7d21e27cd0d86ce6f282a86c
# Parent  965d2ac231bc500fabbdd21bd11b0333098511a1
hgweb: showDiffstat javascript function accepts flag argument

This eliminates the need of another almost equal function hideDiffstat
and makes the code cleaner.

diff -r 965d2ac231bc -r 6187d6255fd2 mercurial/templates/paper/changeset.tmpl
--- a/mercurial/templates/paper/changeset.tmpl	Thu Jul 04 14:19:43 2013 +0400
+++ b/mercurial/templates/paper/changeset.tmpl	Fri Jul 12 16:01:11 2013 +0400
@@ -66,9 +66,9 @@
   <th class="diffstat">diffstat</th>
   <td class="diffstat">
     {diffsummary}
-    <a id="diffstatexpand" href="javascript:showDiffstat()"/>[<tt>+</tt>]</a>
+    <a id="diffstatexpand" href="javascript:showDiffstat(true)"/>[<tt>+</tt>]</a>
     <div id="diffstatdetails" style="display:none;">
-      <a href="javascript:hideDiffstat()"/>[<tt>-</tt>]</a>
+      <a href="javascript:showDiffstat(false)"/>[<tt>-</tt>]</a>
       <p>
       <table>{diffstat}</table>
     </div>
diff -r 965d2ac231bc -r 6187d6255fd2 mercurial/templates/static/mercurial.js
--- a/mercurial/templates/static/mercurial.js	Thu Jul 04 14:19:43 2013 +0400
+++ b/mercurial/templates/static/mercurial.js	Fri Jul 12 16:01:11 2013 +0400
@@ -265,12 +265,7 @@
 	}
 })(document, RegExp, Math, isNaN, Date, false, true)
 
-function showDiffstat() {
-	document.getElementById('diffstatdetails').style.display = 'inline';
-	document.getElementById('diffstatexpand').style.display = 'none';
+function showDiffstat(flag) {
+	document.getElementById('diffstatdetails').style.display = flag ? 'inline' : 'none';
+	document.getElementById('diffstatexpand').style.display = flag ? 'none' : 'inline';
 }
-
-function hideDiffstat() {
-	document.getElementById('diffstatdetails').style.display = 'none';
-	document.getElementById('diffstatexpand').style.display = 'inline';
-}


More information about the Mercurial-devel mailing list