From 8c9bd180540470d4abe229ec294a3ef563090758 Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Thu, 24 Sep 2020 14:35:05 +0800 Subject: [PATCH] * Finish task #7915. --- module/repo/control.php | 22 ++++++++++++++++++++-- module/repo/js/diff.js | 6 ++++++ module/repo/view/ajaxsidecommits.html.php | 2 +- module/repo/view/log.html.php | 2 +- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/module/repo/control.php b/module/repo/control.php index 937af61f02..5dbb0a8a18 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -287,6 +287,14 @@ class repo extends control $this->app->loadClass('pager', $static = true); $pager = new pager(0, 8, 1); + if($_POST) + { + $oldRevision = isset($this->post->revision[1]) ? $this->post->revision[1] : ''; + $newRevision = isset($this->post->revision[0]) ? $this->post->revision[0] : ''; + + $this->locate( $this->repo->createLink('diff', "repoID=$repoID&entry=" . $this->repo->encodePath(urldecode($path)) . "&oldrevision=$oldRevision&newRevision=$newRevision")); + } + /* Cache infos. */ if($refresh or !$cacheFile or !file_exists($cacheFile) or (time() - filemtime($cacheFile)) / 60 > $this->config->repo->cacheTime) { @@ -371,6 +379,14 @@ class repo extends control $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); + if($_POST) + { + $oldRevision = isset($this->post->revision[1]) ? $this->post->revision[1] : ''; + $newRevision = isset($this->post->revision[0]) ? $this->post->revision[0] : ''; + + $this->locate( $this->repo->createLink('diff', "repoID=$repoID&entry=" . $this->repo->encodePath(urldecode($path)) . "&oldrevision=$oldRevision&newRevision=$newRevision")); + } + $this->scm->setEngine($repo); $info = $this->scm->info($entry, $revision); @@ -558,14 +574,16 @@ class repo extends control $arrange = $this->cookie->arrange ? $this->cookie->arrange : 'inline'; if($this->server->request_method == 'POST') { - $oldRevision = isset($this->post->revision[1]) ?$this->post->revision[1] : ''; - $newRevision = isset($this->post->revision[0]) ?$this->post->revision[0] : ''; + $oldRevision = isset($this->post->revision[1]) ? $this->post->revision[1] : ''; + $newRevision = isset($this->post->revision[0]) ? $this->post->revision[0] : ''; if($this->post->arrange) { $arrange = $this->post->arrange; setcookie('arrange', $arrange); } if($this->post->encoding) $encoding = $this->post->encoding; + + $this->locate( $this->repo->createLink('diff', "repoID=$repoID&entry=$entry&oldrevision=$oldRevision&newRevision=$newRevision&showBug=&encoding=$encoding")); } $this->scm->setEngine($repo); diff --git a/module/repo/js/diff.js b/module/repo/js/diff.js index e2caeb5a9e..b95eb6e738 100644 --- a/module/repo/js/diff.js +++ b/module/repo/js/diff.js @@ -1,3 +1,9 @@ +$(document).ready(function() +{ + $("#inline").click(function(){$('#arrange').val('inline');this.form.submit();}); + $("#appose").click(function(){$('#arrange').val('appose');this.form.submit();}); + $(".label-exchange").click(function(){ $('#exchange').submit();}); +}); function changeEncoding(encoding) { $('#encoding').val(encoding); diff --git a/module/repo/view/ajaxsidecommits.html.php b/module/repo/view/ajaxsidecommits.html.php index 5157efda55..71df22223c 100644 --- a/module/repo/view/ajaxsidecommits.html.php +++ b/module/repo/view/ajaxsidecommits.html.php @@ -14,7 +14,7 @@ $pathInfo = '&root=' . $this->repo->encodePath(empty($path) ? '/' : $path); if(isset($entry)) $pathInfo .= '&type=file'; ?> -