Patchwork [1,of,6] hgweb: showDiffstat javascript function accepts flag argument

login
register
mail settings
Submitter Alexander Plavin
Date July 12, 2013, 9:07 p.m.
Message ID <f639ae607bd76f71e3ae.1373663258@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/1846/
State Superseded, archived
Headers show

Comments

Alexander Plavin - July 12, 2013, 9:07 p.m.
# HG changeset patch
# User Alexander Plavin <me@aplavin.ru>
# Date 1373630471 -14400
#      Fri Jul 12 16:01:11 2013 +0400
# Node ID f639ae607bd76f71e3ae2e481edd09623324adc9
# Parent  9fb070f1aefb7b75994dad554ad32eb111417cea
hgweb: showDiffstat javascript function accepts flag argument

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

Patch

diff -r 9fb070f1aefb -r f639ae607bd7 mercurial/templates/paper/changeset.tmpl
--- a/mercurial/templates/paper/changeset.tmpl	Sat Jun 29 14:36:51 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 9fb070f1aefb -r f639ae607bd7 mercurial/templates/static/mercurial.js
--- a/mercurial/templates/static/mercurial.js	Sat Jun 29 14:36:51 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';
-}
diff -r 9fb070f1aefb -r f639ae607bd7 tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t	Sat Jun 29 14:36:51 2013 +0400
+++ b/tests/test-hgweb-commands.t	Fri Jul 12 16:01:11 2013 +0400
@@ -423,9 +423,9 @@ 
     <td class="diffstat">
        2 files changed, 2 insertions(+), 0 deletions(-)
   
-      <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>  <tr class="parity0">
       <td class="diffstat-file"><a href="#l1.1">da/foo</a></td>
diff -r 9fb070f1aefb -r f639ae607bd7 tests/test-hgweb-diffs.t
--- a/tests/test-hgweb-diffs.t	Sat Jun 29 14:36:51 2013 +0400
+++ b/tests/test-hgweb-diffs.t	Fri Jul 12 16:01:11 2013 +0400
@@ -115,9 +115,9 @@ 
     <td class="diffstat">
        2 files changed, 2 insertions(+), 0 deletions(-)
   
-      <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>  <tr class="parity0">
       <td class="diffstat-file"><a href="#l1.1">a</a></td>
@@ -376,9 +376,9 @@ 
     <td class="diffstat">
        2 files changed, 2 insertions(+), 0 deletions(-)
   
-      <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>  <tr class="parity0">
       <td class="diffstat-file"><a href="#l1.1">a</a></td>
diff -r 9fb070f1aefb -r f639ae607bd7 tests/test-hgweb-removed.t
--- a/tests/test-hgweb-removed.t	Sat Jun 29 14:36:51 2013 +0400
+++ b/tests/test-hgweb-removed.t	Fri Jul 12 16:01:11 2013 +0400
@@ -96,9 +96,9 @@ 
     <td class="diffstat">
        1 files changed, 0 insertions(+), 1 deletions(-)
   
-      <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>  <tr class="parity0">
       <td class="diffstat-file"><a href="#l1.1">a</a></td>