mirror of
https://github.com/tuna/mirror-web.git
synced 2025-12-25 20:32:46 +00:00
remove unavailable help items
This commit is contained in:
parent
ade7c1803a
commit
030554281d
|
|
@ -19,7 +19,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 +30,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,13 @@ $(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));
|
||||
$('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