diff --git a/src/main/twirl/gitbucket/core/helper/diff.scala.html b/src/main/twirl/gitbucket/core/helper/diff.scala.html index 0222d22..2dbe74c 100644 --- a/src/main/twirl/gitbucket/core/helper/diff.scala.html +++ b/src/main/twirl/gitbucket/core/helper/diff.scala.html @@ -16,9 +16,9 @@ @if(oldCommitId.isDefined && newCommitId.isDefined) { Patch } -
- - +
+ Unified + Split
Showing @diffs.size changed @helpers.plural(diffs.size, "file") @@ -151,29 +151,22 @@ }); } + window.params = {}; + // Render diffs as unified mode initially if(("&" + location.search.substring(1)).indexOf("&w=1") != -1){ - $('.ignore-whitespace').prop('checked',true); + $('.ignore-whitespace').prop('checked', true); + window.params['w'] = 1; } - window.viewType = 1; if(("&" + location.search.substring(1)).indexOf("&diff=split") != -1){ window.viewType = 0; - } - renderDiffs(); - - $('#btn-unified').click(function(){ + $('#btn-split').addClass('active'); + window.params['diff'] = 'split'; + } else { window.viewType = 1; $('#btn-unified').addClass('active'); - $('#btn-split').removeClass('active'); - renderDiffs(); - }); - - $('#btn-split').click(function(){ - window.viewType = 0; - $('#btn-unified').removeClass('active'); - $('#btn-split').addClass('active'); - renderDiffs(); - }); + } + renderDiffs(); $('.toggle-notes').change(function() { if (!$(this).prop('checked')) { @@ -188,7 +181,6 @@ function getInlineContainer(where) { if (window.viewType == 0) { - console.log(where); if (where === 'new') { return $(''); } else { @@ -410,4 +402,19 @@ render(); } }); + +function changeDisplaySetting(key, value){ + var url = ''; + window.params[key] = value; + for(key in window.params){ + if(window.params[key] != ''){ + if(url != ''){ + url = url + '&' + key + '=' + window.params[key]; + } else { + url = url + '?' + key + '=' + window.params[key]; + } + } + } + location.href = url; +}