|
96 | 96 | <div class="pure-menu pure-menu-scrollable sub-menu"> |
97 | 97 | <ul class="pure-menu-list"> |
98 | 98 | {# Display all releases of this crate #} |
99 | | - {%- for release in details.releases -%} |
100 | | - <li class="pure-menu-item"> |
101 | | - {# If the release was yanked but built, show a warning #} |
102 | | - {%- if release.yanked and release.build_status -%} |
103 | | - <a href="/crate/{{ details.name }}/{{ release.version }}" class="pure-menu-link warn" |
104 | | - title="{{ details.name }}-{{ release.version }} is yanked"> |
105 | | - <i class="fa fa-fw fa-warning"></i> {{ release.version }} |
106 | | - </a> |
107 | | - |
108 | | - {# If the release was yanked and failed to build, show a warning #} |
109 | | - {%- elif release.yanked -%} |
110 | | - <a href="/crate/{{ details.name }}/{{ release.version }}" class="pure-menu-link warn" |
111 | | - title="{{ details.name }}-{{ release.version }} is yanked and docs.rs failed to build it"> |
112 | | - <i class="fa fa-fw fa-warning"></i> {{ release.version }} |
113 | | - </a> |
114 | | - |
115 | | - {# If the release wasn't yanked and built correctly, display it normally #} |
116 | | - {%- elif release.build_status -%} |
117 | | - <a href="/crate/{{ details.name }}/{{ release.version }}" class="pure-menu-link"> |
118 | | - {{ release.version }} |
119 | | - </a> |
120 | | - |
121 | | - {# If the release wasn't yanked but failed to build, show a warning #} |
122 | | - {%- else -%} |
123 | | - <a href="/crate/{{ details.name }}/{{ release.version }}" class="pure-menu-link warn" |
124 | | - title="docs.rs failed to build {{ details.name }}-{{ release.version }}"> |
125 | | - <i class="fa fa-fw fa-warning"></i> {{ release.version }} |
126 | | - </a> |
127 | | - {%- endif -%} |
128 | | - </li> |
129 | | - {%- endfor -%} |
| 99 | + {{ macros::releases_list(name=details.name, releases=details.releases) }} |
130 | 100 | </ul> |
131 | 101 | </div> |
132 | 102 | </li> |
|
204 | 174 | {%- block javascript -%} |
205 | 175 | {# Enable and load Rust and TOML syntax highlighting #} |
206 | 176 | {{ macros::highlight_js(languages=["rust", "ini"]) }} |
207 | | - |
208 | | - <script type="text/javascript" charset="utf-8"> |
209 | | - function getKey(ev) { |
210 | | - if ("key" in ev && typeof ev.key != "undefined") { |
211 | | - return ev.key; |
212 | | - } |
213 | | - |
214 | | - return String.fromCharCode(ev.charCode || ev.keyCode); |
215 | | - } |
216 | | - |
217 | | - document.getElementById("i-am-feeling-lucky-button").onclick = function () { |
218 | | - var form = document.getElementsByClassName("landing-search-form"); |
219 | | - var input = document.createElement('input'); |
220 | | - |
221 | | - input.type = 'hidden'; |
222 | | - input.name = 'i-am-feeling-lucky'; |
223 | | - input.value = 1; |
224 | | - document.getElementsByClassName("landing-search-form")[0].appendChild(input); |
225 | | - |
226 | | - return true; |
227 | | - }; |
228 | | - |
229 | | - function handleShortcut(ev) { |
230 | | - if (ev.ctrlKey || ev.altKey || ev.metaKey || document.activeElement.tagName === "INPUT") { |
231 | | - return; |
232 | | - } |
233 | | - |
234 | | - switch (getKey(ev)) { |
235 | | - case "s": |
236 | | - case "S": |
237 | | - ev.preventDefault(); |
238 | | - document.getElementById("search").focus(); |
239 | | - break; |
240 | | - } |
241 | | - } |
242 | | - |
243 | | - document.onkeypress = handleShortcut; |
244 | | - document.onkeydown = handleShortcut; |
245 | | - |
246 | | - var active = null; |
247 | | - |
248 | | - function handleKey(ev) { |
249 | | - if (ev.ctrlKey || ev.altKey || ev.metaKey || document.activeElement.tagName === "INPUT") { |
250 | | - return; |
251 | | - } |
252 | | - |
253 | | - if (ev.which === 40) { // Down arrow |
254 | | - ev.preventDefault(); |
255 | | - if (active === null) { |
256 | | - active = document.getElementsByClassName("recent-releases-container")[0].getElementsByTagName("li")[0]; |
257 | | - } else if (active.nextElementSibling) { |
258 | | - active.classList.remove("selected"); |
259 | | - active = active.nextElementSibling; |
260 | | - } |
261 | | - |
262 | | - active.classList.add("selected"); |
263 | | - } else if (ev.which === 38) { // Up arrow |
264 | | - ev.preventDefault(); |
265 | | - |
266 | | - if (active === null) { |
267 | | - active = document.getElementsByClassName("recent-releases-container")[0].getElementsByTagName("li")[0]; |
268 | | - } else if (active.previousElementSibling) { |
269 | | - active.classList.remove("selected"); |
270 | | - active = active.previousElementSibling; |
271 | | - } |
272 | | - |
273 | | - active.classList.add("selected"); |
274 | | - active.focus(); |
275 | | - } else if (ev.which === 13) { // Return |
276 | | - if (active !== null) { |
277 | | - document.location.href = active.getElementsByTagName("a")[0].href; |
278 | | - } |
279 | | - } else { |
280 | | - switch (getKey(ev)) { |
281 | | - case "s": |
282 | | - case "S": |
283 | | - ev.preventDefault(); |
284 | | - document.getElementsByClassName("search-input-nav")[0].focus(); |
285 | | - break; |
286 | | - } |
287 | | - } |
288 | | - } |
289 | | - |
290 | | - document.onkeypress = handleKey; |
291 | | - document.onkeydown = handleKey; |
292 | | - |
293 | | - var crates = |
294 | | - Array.prototype.slice.call(document.getElementsByClassName("recent-releases-container")[0].getElementsByTagName("li")); |
295 | | - |
296 | | - for (var i = 0; i < crates.length; ++i) { |
297 | | - crates[i].addEventListener("mouseover", function (event) { |
298 | | - this.classList.remove("selected"); active = null; |
299 | | - }); crates[i].addEventListener("mouseout", function (event) { |
300 | | - this.classList.remove("selected"); active = null; |
301 | | - }); |
302 | | - } |
303 | | - </script> |
304 | 177 | {% endblock javascript -%} |
0 commit comments