diff --git a/seahub/templates/file_revisions.html b/seahub/templates/file_revisions.html
index 33252d75aa..da2012efbc 100644
--- a/seahub/templates/file_revisions.html
+++ b/seahub/templates/file_revisions.html
@@ -124,13 +124,6 @@ $('.text-diff').each(function() {
$(this).attr('href', $(this).attr('href') + '&referer=' + encodeURIComponent(location.href));
});
-$('.go-back').click(function() {
- var referer = '{{referer|escapejs}}';
- var str = location.protocol + '//' + location.host;
- if (referer.indexOf(str) == 0) {
- location.href = referer;
- }
- return false;
-});
+{% include 'snippets/go_back_js.html' %}
{% endblock %}
diff --git a/seahub/templates/repo_dir_recycle_view.html b/seahub/templates/repo_dir_recycle_view.html
index e5ad65922b..6185a01176 100644
--- a/seahub/templates/repo_dir_recycle_view.html
+++ b/seahub/templates/repo_dir_recycle_view.html
@@ -12,7 +12,7 @@
{% block wide_page_content %}
{% blocktrans %}{{repo_dir_name}} Trash{% endblocktrans %}
{% if referer %}
-
+
{% endif %}
@@ -179,5 +179,7 @@ $('table').on("click", ".restore-file, .restore-dir", function() {
return false;
});
{% endif %}
+
+{% include 'snippets/go_back_js.html' %}
{% endblock %}
diff --git a/seahub/templates/repo_history.html b/seahub/templates/repo_history.html
index 93e3e82653..a0ace827d2 100644
--- a/seahub/templates/repo_history.html
+++ b/seahub/templates/repo_history.html
@@ -14,7 +14,7 @@
{% blocktrans with repo_name=repo.props.name %}{{repo_name}} Modification History{% endblocktrans %}
{% if referer %}
-
+
{% endif %}
@@ -81,5 +81,7 @@
$('.view-snapshot').each(function() {
$(this).attr('href', $(this).attr('href') + '&referer=' + encodeURIComponent(location.href));
});
+
+{% include 'snippets/go_back_js.html' %}
{% endblock %}
diff --git a/seahub/templates/repo_history_view.html b/seahub/templates/repo_history_view.html
index 898c1ed3a0..18e72db613 100644
--- a/seahub/templates/repo_history_view.html
+++ b/seahub/templates/repo_history_view.html
@@ -13,7 +13,7 @@
{% blocktrans with repo_name=repo.props.name %}{{repo_name}} Snapshot{% endblocktrans %} ({{ current_commit.props.ctime|tsstr_sec }})
{% if referer %}
-
+
{% endif %}
@@ -122,5 +122,7 @@ $('.restore-file, .restore-dir').click(function() {
$('.repo-history-view-link').each(function() {
$(this).attr('href', $(this).attr('href') + '&referer=' + encodeURIComponent(location.href));
});
+
+{% include 'snippets/go_back_js.html' %}
{% endblock %}
diff --git a/seahub/templates/snippets/go_back_js.html b/seahub/templates/snippets/go_back_js.html
new file mode 100644
index 0000000000..459370967f
--- /dev/null
+++ b/seahub/templates/snippets/go_back_js.html
@@ -0,0 +1,8 @@
+$('.go-back').click(function() {
+ var referer = '{{referer|escapejs}}';
+ var str = location.protocol + '//' + location.host;
+ if (referer.indexOf(str) == 0) { // check referer
+ location.href = referer;
+ }
+ return false;
+});
diff --git a/seahub/templates/text_diff.html b/seahub/templates/text_diff.html
index afb525ebee..5001416cc3 100644
--- a/seahub/templates/text_diff.html
+++ b/seahub/templates/text_diff.html
@@ -12,7 +12,7 @@
{{ u_filename }} {% trans "modification details" %} {% avatar current_commit.creator_name 16 %}{{ current_commit.creator_name|email2nickname }}{{ current_commit.ctime|translate_seahub_time }}
{% if referer %}
-
+
{% endif %}
@@ -49,5 +49,6 @@
{% block extra_script %}
{% endblock %}