mirror of
https://github.com/tuna/mirror-web.git
synced 2025-12-26 05:02:48 +00:00
commit
e97a910cd9
|
|
@ -12,6 +12,10 @@
|
|||
</script>
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
window.mirrorId = "{{page.mirrorid}}";
|
||||
</script>
|
||||
|
||||
{% assign help_pages = site.categories["help"] | sort: 'mirrorid' %}
|
||||
<div id="help-page">
|
||||
<div class="container">
|
||||
|
|
@ -19,7 +23,7 @@
|
|||
<div class="col-sm-2 hidden-xs">
|
||||
<ul class="nav nav-pills nav-stacked" id="help-nav">
|
||||
{% for h in help_pages %}
|
||||
<li{% if h.mirrorid == page.mirrorid or h.redirect_help_id == page.mirrorid %} class="active"{%endif%}><a href="{{h.url}}">{{h.mirrorid}}</a></li>
|
||||
<li{% if h.mirrorid == page.mirrorid or h.redirect_help_id == page.mirrorid %} class="active"{%endif%} id="toc-{{h.mirrorid}}"><a href="{{h.url}}">{{h.mirrorid}}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div><!-- sidenave -->
|
||||
|
|
@ -30,7 +34,7 @@
|
|||
<label>选择帮助条目: </label>
|
||||
<select class="form-control" id="help-select">
|
||||
{% for h in help_pages %}
|
||||
<option data-help-url="{{h.url}}"{% if h.mirrorid == page.mirrorid%} selected{%endif%}>{{h.mirrorid}}</option>
|
||||
<option data-help-url="{{h.url}}"{% if h.mirrorid == page.mirrorid%} selected{%endif%} id="toc-{{h.mirrorid}}">{{h.mirrorid}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -35,6 +35,18 @@ $(document).ready(() => {
|
|||
let help_url = $(ev.target).find("option:selected").data('help-url');
|
||||
window.location = `${window.location.protocol}//${window.location.host}${help_url}`;
|
||||
});
|
||||
|
||||
$.getJSON("/static/tunasync.json", (statusData) => {
|
||||
// remove help items for disabled/removed mirrors
|
||||
let availableMirrorIds = new Set(statusData.map(x => x.name));
|
||||
console.log(window.mirrorId);
|
||||
if (!availableMirrorIds.has(window.mirrorId)) {
|
||||
location.href = "/404.html"; // this will break 404 issue submission
|
||||
}
|
||||
|
||||
$('li').filter((_, node) => node.id && node.id.startsWith("toc-") && !availableMirrorIds.has(node.id.slice(4))).remove();
|
||||
$('option').filter((_, node) => node.id && node.id.startsWith("toc-") && !availableMirrorIds.has(node.id.slice(4))).remove();
|
||||
});
|
||||
});
|
||||
|
||||
// vim: ts=2 sts=2 sw=2 noexpandtab
|
||||
|
|
|
|||
Loading…
Reference in New Issue