diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index e4107dfa9..e1c5d5d86 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -208,6 +208,9 @@ func NewFuncMap() []template.FuncMap {
}
return path
},
+ "DiffStatsWidth": func(adds int, dels int) string {
+ return fmt.Sprintf("%f", float64(adds)/(float64(adds)+float64(dels))*100)
+ },
"Json": func(in interface{}) string {
out, err := json.Marshal(in)
if err != nil {
diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl
index 05f056feb..d34d9b8fd 100644
--- a/templates/repo/diff/box.tmpl
+++ b/templates/repo/diff/box.tmpl
@@ -38,12 +38,7 @@
{{if not .IsBin}}
-
+{{.Addition}}
-
-
-
-
-
-{{.Deletion}}
+ {{template "repo/diff/stats" .}}
{{else}}
{{$.i18n.Tr "repo.diff.bin"}}
{{end}}
@@ -60,12 +55,7 @@
{{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}{{if .IsLFSFile}} ({{$.i18n.Tr "repo.stored_lfs"}}){{end}}
diff --git a/templates/repo/diff/stats.tmpl b/templates/repo/diff/stats.tmpl
new file mode 100644
index 000000000..7e5d34c3d
--- /dev/null
+++ b/templates/repo/diff/stats.tmpl
@@ -0,0 +1,6 @@
++ {{.Addition}}
+
+
+
+
+- {{.Deletion}}
diff --git a/web_src/js/index.js b/web_src/js/index.js
index 1d36dcf6b..1f4c9a509 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -1134,17 +1134,6 @@ async function initRepository() {
initReactionSelector();
}
- // Diff
- if ($('.repository.diff').length > 0) {
- $('.diff-counter').each(function () {
- const $item = $(this);
- const addLine = $item.find('span[data-line].add').data('line');
- const delLine = $item.find('span[data-line].del').data('line');
- const addPercent = parseFloat(addLine) / (parseFloat(addLine) + parseFloat(delLine)) * 100;
- $item.find('.bar .add').css('width', `${addPercent}%`);
- });
- }
-
// Quick start and repository home
$('#repo-clone-ssh').on('click', function () {
$('.clone-url').text($(this).data('link'));