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 %}tag:{% endif %}{{ current | replace("~", "/") | 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" %}tag: {% endif %}{{ branch[0] }}</option>
6
{% endif %}
7
{% endfor %}
8
<!--<option value="new">[CREATE NEW BRANCH]</option>-->
9
</select>
10
<input id="repo-path-bar" value="{{ subpath }}">
11
<script>
12
branchSelect = document.getElementById("branch-selection");
13
14
branchSelect.addEventListener("change", function() {
15
if(branchSelect.value == "new") {
16
document.getElementById("new-branch").showModal();
17
} else {
18
const PREFIX = "ref-";
19
if(branchSelect.value.startsWith(PREFIX)) {
20
branch = branchSelect.value.slice(PREFIX.length);
21
}
22
var http = new XMLHttpRequest();
23
http.open("HEAD", "/{{ username }}/{{ repository }}/tree/" + branch + "/{{ subpath }}", false);
24
http.send();
25
if(http.status == 404) {
26
location.href = "/{{ username }}/{{ repository }}/tree/" + branch;
27
} else {
28
location.href = "/{{ username }}/{{ repository }}/tree/" + branch + "/{{ subpath }}";
29
}
30
}
31
});
32
33
path = document.getElementById("repo-path-bar");
34
35
path.addEventListener("change", function() {
36
location.href = "/{{ username }}/{{ repository }}/tree/{{ current }}" + path.value;
37
});
38
</script>