By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

 path-bar.html

View raw Download
text/html • 1.71 kiB
HTML document, ASCII text
        
            
1
<select id="branch-selection" style="flex: 0 1 auto;">
2
<option value="ref-{{ current }}" selected>{% if "tag:" in current %}{% trans %}tag:{% endtrans %} {% endif %}{{ current | replace("~", "/") | lstrip("/") | replace("tag:", " ") }}</option>
3
{% for branch in branches %}
4
{% if branch[0] != current | replace("~", "/") | replace("tag:", " ") %}
5
<option value="ref-{% if branch[1] == 'tag' %}tag:{% endif %}{{ branch[0] | replace('/', '~') }}">{% if branch[1] == "tag" %}{% trans %}tag:{% endtrans %} {% endif %}{{ branch[0] }}</option>
6
{% endif %}
7
{% endfor %}
8
</select>
9
<input id="repo-path-bar" value="{{ subpath }}">
10
<script>
11
branchSelect = document.getElementById("branch-selection");
12
13
branchSelect.addEventListener("change", function() {
14
if(branchSelect.value == "new") {
15
document.getElementById("new-branch").showModal();
16
} else {
17
const PREFIX = "ref-";
18
if(branchSelect.value.startsWith(PREFIX)) {
19
branch = branchSelect.value.slice(PREFIX.length);
20
}
21
var http = new XMLHttpRequest();
22
http.open("HEAD", "/{{ username }}/{{ repository }}/tree/" + branch + "/{{ subpath }}", false);
23
http.send();
24
if(http.status == 404) {
25
location.href = "/{{ username }}/{{ repository }}/tree/" + branch;
26
} else {
27
location.href = "/{{ username }}/{{ repository }}/tree/" + branch + "/{{ subpath }}";
28
}
29
}
30
});
31
32
path = document.getElementById("repo-path-bar");
33
34
path.addEventListener("change", function() {
35
location.href = "/{{ username }}/{{ repository }}/tree/{{ current }}" + path.value;
36
});
37
</script>
38